marko 6.0.130 → 6.0.132
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/accessor.d.ts +1 -1
- package/dist/common/accessor.debug.d.ts +1 -1
- package/dist/debug/dom.js +5 -4
- package/dist/debug/dom.mjs +5 -4
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/dom.d.ts +2 -2
- package/dist/dom.js +3 -3
- package/dist/dom.mjs +3 -3
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/core/lifecycle.d.ts +0 -7
- package/dist/translator/index.js +848 -551
- package/dist/translator/util/binding-has-prop.d.ts +3 -0
- package/dist/translator/util/binding-prop-tree.d.ts +4 -3
- package/dist/translator/util/nested-attribute-tags.d.ts +3 -2
- package/dist/translator/util/references.d.ts +6 -5
- package/dist/translator/util/sections.d.ts +6 -3
- package/dist/translator/util/set-tag-sections-downstream.d.ts +1 -1
- package/dist/translator/util/translate-attrs.d.ts +3 -4
- package/package.json +1 -1
- package/dist/translator/util/binding-has-downstream-expressions.d.ts +0 -2
package/dist/translator/index.js
CHANGED
|
@@ -128,7 +128,7 @@ var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
|
128
128
|
AccessorPrefix4["DynamicHTMLLastChild"] = "DynamicHTMLLastChild:";
|
|
129
129
|
AccessorPrefix4["EventAttributes"] = "EventAttributes:";
|
|
130
130
|
AccessorPrefix4["Getter"] = "Getter:";
|
|
131
|
-
AccessorPrefix4["
|
|
131
|
+
AccessorPrefix4["Lifecycle"] = "Lifecycle:";
|
|
132
132
|
AccessorPrefix4["Promise"] = "Promise:";
|
|
133
133
|
AccessorPrefix4["TagVariableChange"] = "TagVariableChange:";
|
|
134
134
|
return AccessorPrefix4;
|
|
@@ -1118,6 +1118,15 @@ function fromIter(data) {
|
|
|
1118
1118
|
}
|
|
1119
1119
|
return many || one;
|
|
1120
1120
|
}
|
|
1121
|
+
function* toIter(data) {
|
|
1122
|
+
if (data !== void 0) {
|
|
1123
|
+
if (Array.isArray(data)) {
|
|
1124
|
+
yield* data;
|
|
1125
|
+
} else {
|
|
1126
|
+
yield data;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1121
1130
|
function includes(data, item) {
|
|
1122
1131
|
return data !== void 0 ? Array.isArray(data) ? data.includes(item) : data === item : false;
|
|
1123
1132
|
}
|
|
@@ -1284,7 +1293,7 @@ var AccessorPrefix2 = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
|
1284
1293
|
AccessorPrefix4["DynamicHTMLLastChild"] = "H";
|
|
1285
1294
|
AccessorPrefix4["EventAttributes"] = "I";
|
|
1286
1295
|
AccessorPrefix4["Getter"] = "J";
|
|
1287
|
-
AccessorPrefix4["
|
|
1296
|
+
AccessorPrefix4["Lifecycle"] = "K";
|
|
1288
1297
|
AccessorPrefix4["Promise"] = "L";
|
|
1289
1298
|
AccessorPrefix4["TagVariableChange"] = "M";
|
|
1290
1299
|
return AccessorPrefix4;
|
|
@@ -1886,7 +1895,10 @@ function getSectionRegisterReasons(section) {
|
|
|
1886
1895
|
if (section.isBranch) return false;
|
|
1887
1896
|
const { downstreamBinding } = section;
|
|
1888
1897
|
if (downstreamBinding) {
|
|
1889
|
-
return getAllSerializeReasonsForBinding(
|
|
1898
|
+
return getAllSerializeReasonsForBinding(
|
|
1899
|
+
downstreamBinding.binding,
|
|
1900
|
+
downstreamBinding.properties
|
|
1901
|
+
);
|
|
1890
1902
|
} else if (downstreamBinding === false) {
|
|
1891
1903
|
return false;
|
|
1892
1904
|
}
|
|
@@ -1963,7 +1975,10 @@ function finalizeParamSerializeReasonGroups(section) {
|
|
|
1963
1975
|
}
|
|
1964
1976
|
function ensureParamReasonGroup(section, reason) {
|
|
1965
1977
|
const { paramReasonGroups } = section;
|
|
1966
|
-
const group = {
|
|
1978
|
+
const group = {
|
|
1979
|
+
id: Symbol(getDebugNames(reason)),
|
|
1980
|
+
reason
|
|
1981
|
+
};
|
|
1967
1982
|
if (paramReasonGroups) {
|
|
1968
1983
|
const found = findSorted(compareParamGroups, paramReasonGroups, group);
|
|
1969
1984
|
if (found) return found;
|
|
@@ -2061,7 +2076,7 @@ function canIgnoreRegister(markoRoot, exprRoot) {
|
|
|
2061
2076
|
markoRoot.isMarkoPlaceholder() || // bail within a server only statement
|
|
2062
2077
|
markoRoot.isMarkoScriptlet() && (!markoRoot.node.static || markoRoot.node.target === "server") || // bail within the tag name
|
|
2063
2078
|
markoRoot.isMarkoTag() && markoRoot.node.name == exprRoot.node || isMarkoAttribute(markoRoot) && (analyzeTagNameType(markoRoot.parentPath) === 0 /* NativeTag */ && // TODO: all native tag functions should avoid registration but right now change handlers require it.
|
|
2064
|
-
/^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
|
|
2079
|
+
/^on[A-Z-]/.test(markoRoot.node.name) && !hasSpreadAttributeAfter(markoRoot) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))
|
|
2065
2080
|
);
|
|
2066
2081
|
}
|
|
2067
2082
|
function getStaticDeclRefs(fnExtra, path7, refs = /* @__PURE__ */ new Set()) {
|
|
@@ -2110,6 +2125,13 @@ function shouldAlwaysRegister(markoRoot) {
|
|
|
2110
2125
|
}
|
|
2111
2126
|
return false;
|
|
2112
2127
|
}
|
|
2128
|
+
function hasSpreadAttributeAfter(attr) {
|
|
2129
|
+
const attrs = attr.parent.attributes;
|
|
2130
|
+
for (let i = attr.key + 1; i < attrs.length; i++) {
|
|
2131
|
+
if (attrs[i].type === "MarkoSpreadAttribute") return true;
|
|
2132
|
+
}
|
|
2133
|
+
return false;
|
|
2134
|
+
}
|
|
2113
2135
|
function getTagFromMarkoRoot(markoRoot) {
|
|
2114
2136
|
let cur = markoRoot;
|
|
2115
2137
|
do {
|
|
@@ -2233,26 +2255,17 @@ var import_compiler27 = require("@marko/compiler");
|
|
|
2233
2255
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
2234
2256
|
var import_path2 = __toESM(require("path"));
|
|
2235
2257
|
|
|
2236
|
-
// src/translator/util/binding-has-downstream-expressions.ts
|
|
2237
|
-
function bindingHasDownstreamExpressions(binding) {
|
|
2238
|
-
if (binding.downstreamExpressions.size) return true;
|
|
2239
|
-
for (const alias of binding.aliases) {
|
|
2240
|
-
if (bindingHasDownstreamExpressions(alias)) return true;
|
|
2241
|
-
}
|
|
2242
|
-
for (const alias of binding.propertyAliases.values()) {
|
|
2243
|
-
if (bindingHasDownstreamExpressions(alias)) return true;
|
|
2244
|
-
}
|
|
2245
|
-
return false;
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
2258
|
// src/translator/util/binding-prop-tree.ts
|
|
2249
2259
|
function getBindingPropTree(binding) {
|
|
2260
|
+
if (pruneBinding(binding)) {
|
|
2261
|
+
return void 0;
|
|
2262
|
+
}
|
|
2250
2263
|
const props = {
|
|
2251
2264
|
binding,
|
|
2252
2265
|
props: void 0,
|
|
2253
2266
|
rest: void 0
|
|
2254
2267
|
};
|
|
2255
|
-
if (!binding.
|
|
2268
|
+
if (!binding.reads.size) {
|
|
2256
2269
|
if (!binding.aliases.size) {
|
|
2257
2270
|
props.props = {};
|
|
2258
2271
|
for (const [property, alias] of binding.propertyAliases) {
|
|
@@ -2291,12 +2304,20 @@ function hasSupersetExcludeProperties(binding, excludeProperties) {
|
|
|
2291
2304
|
}
|
|
2292
2305
|
return true;
|
|
2293
2306
|
}
|
|
2294
|
-
function
|
|
2295
|
-
return propTree.props
|
|
2307
|
+
function getKnownFromPropTree(propTree, name2) {
|
|
2308
|
+
return propTree === true ? true : propTree.props ? propTree.props[name2] || (propTree.rest ? getKnownFromPropTree(propTree.rest, name2) : void 0) : includes(propTree.binding.excludeProperties, name2) ? void 0 : true;
|
|
2296
2309
|
}
|
|
2297
|
-
function
|
|
2310
|
+
function getAllKnownPropNames(propTree) {
|
|
2298
2311
|
const keys = propTree.props ? Object.keys(propTree.props) : [];
|
|
2299
|
-
|
|
2312
|
+
if (propTree.rest?.props) {
|
|
2313
|
+
for (const key of Object.keys(propTree.rest.props)) {
|
|
2314
|
+
keys.push(key);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
return keys;
|
|
2318
|
+
}
|
|
2319
|
+
function hasAllKnownProps(propTree) {
|
|
2320
|
+
return propTree.props && (!propTree.rest || !!propTree.rest.props);
|
|
2300
2321
|
}
|
|
2301
2322
|
|
|
2302
2323
|
// src/translator/util/entry-builder.ts
|
|
@@ -2626,6 +2647,36 @@ function getCompatRuntimeFile() {
|
|
|
2626
2647
|
var import_compiler23 = require("@marko/compiler");
|
|
2627
2648
|
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
|
2628
2649
|
|
|
2650
|
+
// src/translator/util/binding-has-prop.ts
|
|
2651
|
+
function bindingHasProperty(binding, properties) {
|
|
2652
|
+
if (binding.pruned) {
|
|
2653
|
+
return false;
|
|
2654
|
+
} else if (binding.pruned === void 0) {
|
|
2655
|
+
throw new Error("Binding must be pruned before checking properties");
|
|
2656
|
+
}
|
|
2657
|
+
if (binding.reads.size || !properties) {
|
|
2658
|
+
return true;
|
|
2659
|
+
}
|
|
2660
|
+
let property;
|
|
2661
|
+
let rest2;
|
|
2662
|
+
if (Array.isArray(properties)) {
|
|
2663
|
+
property = properties[0];
|
|
2664
|
+
rest2 = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
2665
|
+
} else {
|
|
2666
|
+
property = properties;
|
|
2667
|
+
}
|
|
2668
|
+
const propBinding = binding.propertyAliases.get(property);
|
|
2669
|
+
if (propBinding && bindingHasProperty(propBinding, rest2)) {
|
|
2670
|
+
return true;
|
|
2671
|
+
}
|
|
2672
|
+
for (const alias of binding.aliases) {
|
|
2673
|
+
if (bindingHasProperty(alias, properties)) {
|
|
2674
|
+
return true;
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
return false;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2629
2680
|
// src/translator/util/get-style-file.ts
|
|
2630
2681
|
var import_path = __toESM(require("path"));
|
|
2631
2682
|
function getStyleFile(file) {
|
|
@@ -3998,7 +4049,7 @@ function writeHoists(section) {
|
|
|
3998
4049
|
import_compiler22.types.variableDeclaration("const", [
|
|
3999
4050
|
import_compiler22.types.variableDeclarator(
|
|
4000
4051
|
hoistIdentifier,
|
|
4001
|
-
hoistedBinding.
|
|
4052
|
+
hoistedBinding.reads.size ? callRuntime(
|
|
4002
4053
|
"_resume",
|
|
4003
4054
|
// TODO: add _hoist_resume runtime
|
|
4004
4055
|
import_compiler22.types.stringLiteral(
|
|
@@ -4013,7 +4064,7 @@ function writeHoists(section) {
|
|
|
4013
4064
|
)
|
|
4014
4065
|
])
|
|
4015
4066
|
);
|
|
4016
|
-
if (hoistedBinding.
|
|
4067
|
+
if (hoistedBinding.reads.size) {
|
|
4017
4068
|
addValue(
|
|
4018
4069
|
hoistedBinding.section,
|
|
4019
4070
|
void 0,
|
|
@@ -4493,7 +4544,7 @@ var dom_default = {
|
|
|
4493
4544
|
const walksIdentifier = import_compiler23.types.identifier(domExports.walks);
|
|
4494
4545
|
const setupIdentifier = import_compiler23.types.identifier(domExports.setup);
|
|
4495
4546
|
const inputBinding = program.node.params[0].extra?.binding;
|
|
4496
|
-
const programInputSignal = inputBinding &&
|
|
4547
|
+
const programInputSignal = inputBinding && !inputBinding.pruned ? initValue(inputBinding) : void 0;
|
|
4497
4548
|
let extraDecls = decls;
|
|
4498
4549
|
const styleFile = getStyleFile(program.hub.file);
|
|
4499
4550
|
if (styleFile) {
|
|
@@ -4527,7 +4578,10 @@ var dom_default = {
|
|
|
4527
4578
|
const { walks: walks2, writes: writes2, decls: decls2 } = getSectionMeta(childSection);
|
|
4528
4579
|
const setup = getSetup(childSection);
|
|
4529
4580
|
writeSignals(childSection);
|
|
4530
|
-
if (!childSection.downstreamBinding ||
|
|
4581
|
+
if (!childSection.downstreamBinding || bindingHasProperty(
|
|
4582
|
+
childSection.downstreamBinding.binding,
|
|
4583
|
+
childSection.downstreamBinding.properties
|
|
4584
|
+
)) {
|
|
4531
4585
|
if (getSectionParentIsOwner(childSection)) {
|
|
4532
4586
|
setBranchRendererArgs(childSection, [
|
|
4533
4587
|
writes2,
|
|
@@ -4653,7 +4707,7 @@ var html_default = {
|
|
|
4653
4707
|
const sectionDynamicSubscribers = /* @__PURE__ */ new Set();
|
|
4654
4708
|
forEach(section.hoisted, (binding) => {
|
|
4655
4709
|
for (const hoistedBinding of binding.hoists.values()) {
|
|
4656
|
-
if (hoistedBinding.
|
|
4710
|
+
if (hoistedBinding.reads.size) {
|
|
4657
4711
|
getHTMLSectionStatements(hoistedBinding.section).push(
|
|
4658
4712
|
import_compiler24.types.variableDeclaration("const", [
|
|
4659
4713
|
import_compiler24.types.variableDeclarator(
|
|
@@ -5208,7 +5262,7 @@ var program_default = {
|
|
|
5208
5262
|
finalizeReferences();
|
|
5209
5263
|
const programExtra = program.node.extra;
|
|
5210
5264
|
const paramsBinding = programExtra.binding;
|
|
5211
|
-
if (paramsBinding &&
|
|
5265
|
+
if (paramsBinding && !paramsBinding.pruned) {
|
|
5212
5266
|
programExtra.domExports.params = getBindingPropTree(paramsBinding);
|
|
5213
5267
|
}
|
|
5214
5268
|
}
|
|
@@ -5401,40 +5455,39 @@ var [getTagDownstreams] = createSectionState(
|
|
|
5401
5455
|
() => /* @__PURE__ */ new Map()
|
|
5402
5456
|
);
|
|
5403
5457
|
function setTagDownstream(tag, binding) {
|
|
5404
|
-
|
|
5458
|
+
if (binding) {
|
|
5459
|
+
getTagDownstreams(getSection(tag)).set(tag, binding);
|
|
5460
|
+
}
|
|
5405
5461
|
}
|
|
5406
5462
|
function finalizeTagDownstreams(section) {
|
|
5407
5463
|
for (const [tag, binding] of getTagDownstreams(section)) {
|
|
5408
|
-
crawlSectionsAndSetBinding(
|
|
5409
|
-
tag,
|
|
5410
|
-
binding,
|
|
5411
|
-
binding ? getBindingPropTree(binding) : void 0
|
|
5412
|
-
);
|
|
5464
|
+
crawlSectionsAndSetBinding(tag, binding);
|
|
5413
5465
|
}
|
|
5414
5466
|
}
|
|
5415
|
-
function crawlSectionsAndSetBinding(tag, binding,
|
|
5416
|
-
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5467
|
+
function crawlSectionsAndSetBinding(tag, binding, properties, skip2) {
|
|
5417
5468
|
if (!skip2) {
|
|
5418
5469
|
const contentSection = getSectionForBody(tag.get("body"));
|
|
5419
5470
|
if (contentSection) {
|
|
5420
|
-
contentSection.downstreamBinding =
|
|
5471
|
+
contentSection.downstreamBinding = {
|
|
5472
|
+
binding,
|
|
5473
|
+
properties: concat(properties, "content")
|
|
5474
|
+
};
|
|
5421
5475
|
}
|
|
5422
5476
|
}
|
|
5477
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
5478
|
+
if (!attrTagLookup) return;
|
|
5479
|
+
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5423
5480
|
for (const child of attrTags2) {
|
|
5424
5481
|
if (child.isMarkoTag()) {
|
|
5425
5482
|
if ((0, import_babel_utils19.isAttributeTag)(child)) {
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
}
|
|
5433
|
-
} else {
|
|
5434
|
-
crawlSectionsAndSetBinding(child, binding, void 0);
|
|
5435
|
-
}
|
|
5483
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
5484
|
+
crawlSectionsAndSetBinding(
|
|
5485
|
+
child,
|
|
5486
|
+
binding,
|
|
5487
|
+
concat(properties, attrTagMeta.name)
|
|
5488
|
+
);
|
|
5436
5489
|
} else {
|
|
5437
|
-
crawlSectionsAndSetBinding(child, binding,
|
|
5490
|
+
crawlSectionsAndSetBinding(child, binding, properties, true);
|
|
5438
5491
|
}
|
|
5439
5492
|
}
|
|
5440
5493
|
}
|
|
@@ -5621,7 +5674,7 @@ var native_tag_default = {
|
|
|
5621
5674
|
const valueExtra = attr.value.extra ??= {};
|
|
5622
5675
|
if (import_compiler33.types.isMarkoAttribute(attr)) {
|
|
5623
5676
|
if (seen[attr.name]) {
|
|
5624
|
-
|
|
5677
|
+
dropNodes(attr.value);
|
|
5625
5678
|
continue;
|
|
5626
5679
|
}
|
|
5627
5680
|
seen[attr.name] = attr;
|
|
@@ -6612,7 +6665,7 @@ var for_default = {
|
|
|
6612
6665
|
if (isAttrTag) return;
|
|
6613
6666
|
const bodySection = startSection(tagBody);
|
|
6614
6667
|
if (!bodySection) {
|
|
6615
|
-
|
|
6668
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
6616
6669
|
return;
|
|
6617
6670
|
}
|
|
6618
6671
|
const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
|
|
@@ -6627,7 +6680,7 @@ var for_default = {
|
|
|
6627
6680
|
const keyBinding = paramsBinding.propertyAliases.get(
|
|
6628
6681
|
forType === "of" ? "1" : "0"
|
|
6629
6682
|
);
|
|
6630
|
-
if (keyBinding) {
|
|
6683
|
+
if (keyBinding && !getKnownAttrValues(tag.node).by) {
|
|
6631
6684
|
keyBinding.type = 7 /* constant */;
|
|
6632
6685
|
keyBinding.scopeAccessor = getAccessorProp().LoopKey;
|
|
6633
6686
|
}
|
|
@@ -6937,15 +6990,14 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6937
6990
|
|
|
6938
6991
|
// src/translator/util/translate-attrs.ts
|
|
6939
6992
|
var contentProps = /* @__PURE__ */ new WeakSet();
|
|
6940
|
-
function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "content") {
|
|
6941
|
-
const templateExports = propTree && !propTree.rest ? propTree.props : void 0;
|
|
6993
|
+
function translateAttrs(tag, propTree = true, skip2, statements = [], contentKey = "content") {
|
|
6942
6994
|
const properties = [];
|
|
6943
6995
|
const attrTagLookup = tag.node.extra?.attributeTags;
|
|
6944
6996
|
const seen = new Set(skip2);
|
|
6945
6997
|
if (attrTagLookup) {
|
|
6946
6998
|
for (const name2 in attrTagLookup) {
|
|
6947
6999
|
const attrTagMeta = attrTagLookup[name2];
|
|
6948
|
-
if (!seen.has(attrTagMeta.name) &&
|
|
7000
|
+
if (!seen.has(attrTagMeta.name) && getKnownFromPropTree(propTree, attrTagMeta.name)) {
|
|
6949
7001
|
seen.add(attrTagMeta.name);
|
|
6950
7002
|
if (attrTagMeta.dynamic) {
|
|
6951
7003
|
statements.push(
|
|
@@ -6975,13 +7027,13 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6975
7027
|
i,
|
|
6976
7028
|
attrTagLookup,
|
|
6977
7029
|
statements,
|
|
6978
|
-
|
|
7030
|
+
propTree,
|
|
6979
7031
|
contentKey
|
|
6980
7032
|
);
|
|
6981
7033
|
} else {
|
|
6982
7034
|
const translatedAttrTag = translateAttrs(
|
|
6983
7035
|
child,
|
|
6984
|
-
|
|
7036
|
+
getKnownFromPropTree(propTree, attrTagMeta.name),
|
|
6985
7037
|
void 0,
|
|
6986
7038
|
statements,
|
|
6987
7039
|
contentKey
|
|
@@ -7023,14 +7075,14 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
7023
7075
|
i,
|
|
7024
7076
|
attrTagLookup,
|
|
7025
7077
|
statements,
|
|
7026
|
-
|
|
7078
|
+
propTree,
|
|
7027
7079
|
contentKey
|
|
7028
7080
|
);
|
|
7029
7081
|
}
|
|
7030
7082
|
}
|
|
7031
7083
|
}
|
|
7032
7084
|
}
|
|
7033
|
-
if (!seen.has(contentKey) &&
|
|
7085
|
+
if (!seen.has(contentKey) && getKnownFromPropTree(propTree, contentKey)) {
|
|
7034
7086
|
const contentExpression = buildContent(tag.get("body"));
|
|
7035
7087
|
if (contentExpression) {
|
|
7036
7088
|
const contentProp = import_compiler36.types.objectProperty(
|
|
@@ -7048,7 +7100,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
7048
7100
|
const { value } = attr;
|
|
7049
7101
|
if (import_compiler36.types.isMarkoSpreadAttribute(attr)) {
|
|
7050
7102
|
properties.push(import_compiler36.types.spreadElement(value));
|
|
7051
|
-
} else if (!seen.has(attr.name) &&
|
|
7103
|
+
} else if (!seen.has(attr.name) && getKnownFromPropTree(propTree, attr.name)) {
|
|
7052
7104
|
seen.add(attr.name);
|
|
7053
7105
|
properties.push(toObjectProperty(attr.name, value));
|
|
7054
7106
|
}
|
|
@@ -7063,15 +7115,16 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
7063
7115
|
}
|
|
7064
7116
|
}
|
|
7065
7117
|
}
|
|
7066
|
-
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements,
|
|
7118
|
+
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, propTree, contentKey = "content") {
|
|
7067
7119
|
const tag = attrTags2[index];
|
|
7068
7120
|
if (tag.isMarkoTag()) {
|
|
7069
7121
|
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
7070
7122
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
7071
|
-
|
|
7123
|
+
const attrTagExport = getKnownFromPropTree(propTree, attrTagMeta.name);
|
|
7124
|
+
if (attrTagExport && attrTagMeta.dynamic) {
|
|
7072
7125
|
const translatedAttrTag = translateAttrs(
|
|
7073
7126
|
tag,
|
|
7074
|
-
|
|
7127
|
+
attrTagExport,
|
|
7075
7128
|
void 0,
|
|
7076
7129
|
statements,
|
|
7077
7130
|
contentKey
|
|
@@ -7113,7 +7166,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7113
7166
|
index,
|
|
7114
7167
|
attrTagLookup,
|
|
7115
7168
|
statements,
|
|
7116
|
-
|
|
7169
|
+
propTree,
|
|
7117
7170
|
contentKey
|
|
7118
7171
|
);
|
|
7119
7172
|
case "for": {
|
|
@@ -7122,7 +7175,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7122
7175
|
index,
|
|
7123
7176
|
attrTagLookup,
|
|
7124
7177
|
statements,
|
|
7125
|
-
|
|
7178
|
+
propTree,
|
|
7126
7179
|
contentKey
|
|
7127
7180
|
);
|
|
7128
7181
|
}
|
|
@@ -7134,14 +7187,14 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7134
7187
|
function propsToExpression(props) {
|
|
7135
7188
|
return props.length === 1 && import_compiler36.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler36.types.objectExpression(props);
|
|
7136
7189
|
}
|
|
7137
|
-
function translateForAttrTag(attrTags2, index, attrTagLookup, statements,
|
|
7190
|
+
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, propTree, contentKey) {
|
|
7138
7191
|
const forTag = attrTags2[index];
|
|
7139
7192
|
const bodyStatements = [];
|
|
7140
7193
|
addAllAttrTagsAsDynamic(
|
|
7141
7194
|
forTag,
|
|
7142
7195
|
attrTagLookup,
|
|
7143
7196
|
bodyStatements,
|
|
7144
|
-
|
|
7197
|
+
propTree,
|
|
7145
7198
|
contentKey
|
|
7146
7199
|
);
|
|
7147
7200
|
statements.push(
|
|
@@ -7154,7 +7207,7 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
7154
7207
|
);
|
|
7155
7208
|
return index;
|
|
7156
7209
|
}
|
|
7157
|
-
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements,
|
|
7210
|
+
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, propTree, contentKey) {
|
|
7158
7211
|
const ifTag = attrTags2[index];
|
|
7159
7212
|
const consequentStatements = [];
|
|
7160
7213
|
let ifStatement = import_compiler36.types.ifStatement(
|
|
@@ -7166,7 +7219,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7166
7219
|
ifTag,
|
|
7167
7220
|
attrTagLookup,
|
|
7168
7221
|
consequentStatements,
|
|
7169
|
-
|
|
7222
|
+
propTree,
|
|
7170
7223
|
contentKey
|
|
7171
7224
|
);
|
|
7172
7225
|
let nextIndex = index + 1;
|
|
@@ -7182,7 +7235,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7182
7235
|
nextTag,
|
|
7183
7236
|
attrTagLookup,
|
|
7184
7237
|
alternateStatements,
|
|
7185
|
-
|
|
7238
|
+
propTree,
|
|
7186
7239
|
contentKey
|
|
7187
7240
|
);
|
|
7188
7241
|
if (testValue) {
|
|
@@ -7203,7 +7256,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7203
7256
|
}
|
|
7204
7257
|
return nextIndex - 1;
|
|
7205
7258
|
}
|
|
7206
|
-
function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements,
|
|
7259
|
+
function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements, propTree, contentKey) {
|
|
7207
7260
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
7208
7261
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
7209
7262
|
i = addDynamicAttrTagStatements(
|
|
@@ -7211,14 +7264,11 @@ function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements, templateExports
|
|
|
7211
7264
|
i,
|
|
7212
7265
|
attrTagLookup,
|
|
7213
7266
|
statements,
|
|
7214
|
-
|
|
7267
|
+
propTree,
|
|
7215
7268
|
contentKey
|
|
7216
7269
|
);
|
|
7217
7270
|
}
|
|
7218
7271
|
}
|
|
7219
|
-
function usesExport(templateExports, name2) {
|
|
7220
|
-
return !templateExports || !!templateExports[name2];
|
|
7221
|
-
}
|
|
7222
7272
|
function findObjectProperty(name2, props) {
|
|
7223
7273
|
for (const prop of props) {
|
|
7224
7274
|
if (prop.type === "ObjectProperty") {
|
|
@@ -7537,7 +7587,7 @@ function finalizeKnownTags(section) {
|
|
|
7537
7587
|
function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
7538
7588
|
const inputExpr = {};
|
|
7539
7589
|
if (!propTree) {
|
|
7540
|
-
|
|
7590
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
7541
7591
|
return inputExpr;
|
|
7542
7592
|
}
|
|
7543
7593
|
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
@@ -7555,7 +7605,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7555
7605
|
for (const arg of tag.node.arguments) {
|
|
7556
7606
|
const argExport = propTree.props[i];
|
|
7557
7607
|
if (!argExport) {
|
|
7558
|
-
|
|
7608
|
+
dropNodes(arg);
|
|
7559
7609
|
continue;
|
|
7560
7610
|
}
|
|
7561
7611
|
const argValueExtra = arg.extra ??= {};
|
|
@@ -7575,7 +7625,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7575
7625
|
} else {
|
|
7576
7626
|
const args = tag.node.arguments;
|
|
7577
7627
|
tag.node.arguments = null;
|
|
7578
|
-
|
|
7628
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
7579
7629
|
tag.node.arguments = args;
|
|
7580
7630
|
}
|
|
7581
7631
|
return inputExpr;
|
|
@@ -7594,10 +7644,12 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7594
7644
|
const known = inputExpr.known = {};
|
|
7595
7645
|
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7596
7646
|
const seen = /* @__PURE__ */ new Set();
|
|
7597
|
-
const
|
|
7647
|
+
const remaining = new Set(getAllKnownPropNames(propTree));
|
|
7648
|
+
const dropReferenceNodes = [];
|
|
7649
|
+
let restReferenceNodes;
|
|
7598
7650
|
if (attrTagLookup) {
|
|
7599
7651
|
const nodeReferencesByGroup = /* @__PURE__ */ new Map();
|
|
7600
|
-
const
|
|
7652
|
+
const analyzeDynamicAttrTagChildGroup = (group, child) => {
|
|
7601
7653
|
const referenceNodes = getAllTagReferenceNodes(child.node);
|
|
7602
7654
|
const groupReferences = nodeReferencesByGroup.get(group);
|
|
7603
7655
|
if (groupReferences) {
|
|
@@ -7617,35 +7669,44 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7617
7669
|
if (child.isMarkoTag()) {
|
|
7618
7670
|
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7619
7671
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7620
|
-
const
|
|
7621
|
-
|
|
7622
|
-
|
|
7623
|
-
|
|
7624
|
-
|
|
7625
|
-
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
}
|
|
7672
|
+
const childAttrExport = getKnownFromPropTree(
|
|
7673
|
+
propTree,
|
|
7674
|
+
attrTagMeta.name
|
|
7675
|
+
);
|
|
7676
|
+
if (!childAttrExport) {
|
|
7677
|
+
getAllTagReferenceNodes(child.node, dropReferenceNodes);
|
|
7678
|
+
} else if (attrTagMeta.dynamic) {
|
|
7679
|
+
analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
|
|
7680
|
+
} else if (childAttrExport === true) {
|
|
7681
|
+
getAllTagReferenceNodes(child.node, restReferenceNodes ||= []);
|
|
7682
|
+
known[attrTagMeta.name] = {
|
|
7683
|
+
value: rootTagExtra
|
|
7684
|
+
};
|
|
7685
|
+
} else if (childAttrExport.props) {
|
|
7686
|
+
remaining.delete(attrTagMeta.name);
|
|
7687
|
+
known[attrTagMeta.name] = analyzeAttrs(
|
|
7688
|
+
rootTagExtra,
|
|
7689
|
+
section,
|
|
7690
|
+
child,
|
|
7691
|
+
childAttrExport,
|
|
7692
|
+
rootAttrExprs
|
|
7693
|
+
);
|
|
7633
7694
|
} else {
|
|
7634
|
-
|
|
7695
|
+
analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
|
|
7635
7696
|
}
|
|
7636
7697
|
} else {
|
|
7637
7698
|
const group = child.node.extra.attributeTagGroup;
|
|
7638
7699
|
let childUsesGroupProp = false;
|
|
7639
7700
|
for (const name2 of group) {
|
|
7640
|
-
if (propTree
|
|
7701
|
+
if (getKnownFromPropTree(propTree, attrTagLookup[name2].name)) {
|
|
7641
7702
|
childUsesGroupProp = true;
|
|
7642
7703
|
break;
|
|
7643
7704
|
}
|
|
7644
7705
|
}
|
|
7645
7706
|
if (childUsesGroupProp) {
|
|
7646
|
-
|
|
7707
|
+
analyzeDynamicAttrTagChildGroup(group, child);
|
|
7647
7708
|
} else {
|
|
7648
|
-
|
|
7709
|
+
getAllTagReferenceNodes(child.node, dropReferenceNodes);
|
|
7649
7710
|
}
|
|
7650
7711
|
}
|
|
7651
7712
|
}
|
|
@@ -7657,126 +7718,146 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7657
7718
|
referenceNodes
|
|
7658
7719
|
}
|
|
7659
7720
|
] of nodeReferencesByGroup) {
|
|
7660
|
-
const groupExtra = mergeReferences(section, node, referenceNodes);
|
|
7661
|
-
const groupKnownValue = { value: groupExtra };
|
|
7662
7721
|
let bindings;
|
|
7663
|
-
|
|
7722
|
+
let hasRest = false;
|
|
7664
7723
|
for (const tagName of group) {
|
|
7665
7724
|
const attrName = tagName.slice(1);
|
|
7666
|
-
const templateExportAttr = propTree
|
|
7667
|
-
if (
|
|
7668
|
-
|
|
7725
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attrName);
|
|
7726
|
+
if (templateExportAttr === true) {
|
|
7727
|
+
hasRest = true;
|
|
7669
7728
|
break;
|
|
7729
|
+
} else {
|
|
7730
|
+
bindings = bindingUtil.add(bindings, templateExportAttr.binding);
|
|
7731
|
+
}
|
|
7732
|
+
}
|
|
7733
|
+
if (hasRest) {
|
|
7734
|
+
const groupKnownValue2 = {
|
|
7735
|
+
value: rootTagExtra
|
|
7736
|
+
};
|
|
7737
|
+
restReferenceNodes ||= [];
|
|
7738
|
+
for (const node2 of referenceNodes) {
|
|
7739
|
+
restReferenceNodes.push(node2);
|
|
7740
|
+
}
|
|
7741
|
+
for (const name2 of group) {
|
|
7742
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7743
|
+
known[attrTagMeta.name] = groupKnownValue2;
|
|
7670
7744
|
}
|
|
7671
|
-
|
|
7745
|
+
continue;
|
|
7672
7746
|
}
|
|
7747
|
+
const groupExtra = mergeReferences(section, node, referenceNodes);
|
|
7748
|
+
const groupKnownValue = { value: groupExtra };
|
|
7749
|
+
rootAttrExprs.add(groupExtra);
|
|
7673
7750
|
forEach(bindings, (binding) => {
|
|
7674
7751
|
setBindingDownstream(binding, groupExtra);
|
|
7675
7752
|
});
|
|
7676
7753
|
for (const name2 of group) {
|
|
7677
|
-
|
|
7754
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7755
|
+
remaining.delete(attrTagMeta.name);
|
|
7756
|
+
known[attrTagMeta.name] = groupKnownValue;
|
|
7678
7757
|
}
|
|
7679
7758
|
}
|
|
7680
7759
|
}
|
|
7681
|
-
|
|
7760
|
+
const contentExport = getKnownFromPropTree(propTree, "content");
|
|
7761
|
+
if (contentExport && !seen.has("content")) {
|
|
7682
7762
|
const bodySection = getSectionForBody(tag.get("body"));
|
|
7683
7763
|
if (bodySection) {
|
|
7684
7764
|
seen.add("content");
|
|
7685
|
-
|
|
7765
|
+
if (contentExport === true) {
|
|
7766
|
+
known.content = { value: rootTagExtra };
|
|
7767
|
+
} else {
|
|
7768
|
+
remaining.delete("content");
|
|
7769
|
+
known.content = { value: void 0 };
|
|
7770
|
+
}
|
|
7686
7771
|
}
|
|
7687
7772
|
}
|
|
7688
|
-
let
|
|
7773
|
+
let knownSpread;
|
|
7689
7774
|
let spreadReferenceNodes;
|
|
7690
7775
|
const { attributes } = tag.node;
|
|
7691
7776
|
for (let i = attributes.length; i--; ) {
|
|
7692
7777
|
const attr = attributes[i];
|
|
7693
7778
|
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7694
|
-
const templateExportAttr =
|
|
7779
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attr.name);
|
|
7695
7780
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7696
|
-
|
|
7781
|
+
dropReferenceNodes.push(attr.value);
|
|
7697
7782
|
continue;
|
|
7698
7783
|
}
|
|
7699
|
-
const attrExtra = attr.value.extra ??= {};
|
|
7700
7784
|
seen.add(attr.name);
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7704
|
-
|
|
7705
|
-
|
|
7706
|
-
|
|
7707
|
-
|
|
7785
|
+
if (spreadReferenceNodes) {
|
|
7786
|
+
spreadReferenceNodes.push(attr.value);
|
|
7787
|
+
} else if (templateExportAttr === true) {
|
|
7788
|
+
(restReferenceNodes ||= []).push(attr.value);
|
|
7789
|
+
known[attr.name] = { value: rootTagExtra };
|
|
7790
|
+
} else {
|
|
7791
|
+
const attrExtra = attr.value.extra ??= {};
|
|
7792
|
+
remaining.delete(attr.name);
|
|
7793
|
+
known[attr.name] = { value: attrExtra };
|
|
7794
|
+
rootAttrExprs.add(attrExtra);
|
|
7795
|
+
setBindingDownstream(templateExportAttr.binding, attrExtra);
|
|
7796
|
+
if (knownSpread && !includes(knownSpread.binding.excludeProperties, attr.name)) {
|
|
7797
|
+
const propBinding = getOrCreatePropertyAlias(
|
|
7798
|
+
knownSpread.binding,
|
|
7799
|
+
attr.name
|
|
7800
|
+
);
|
|
7801
|
+
addRead(attrExtra, void 0, propBinding, section);
|
|
7802
|
+
}
|
|
7708
7803
|
}
|
|
7709
|
-
}
|
|
7710
|
-
if (spreadReferenceNodes) {
|
|
7804
|
+
} else if (spreadReferenceNodes) {
|
|
7711
7805
|
spreadReferenceNodes.push(attr.value);
|
|
7712
|
-
} else
|
|
7713
|
-
|
|
7714
|
-
if (
|
|
7715
|
-
|
|
7716
|
-
dropRead(attr.value.extra);
|
|
7717
|
-
}
|
|
7806
|
+
} else {
|
|
7807
|
+
knownSpread = hasAllKnownProps(propTree) ? getSingleKnownSpread(attributes) : void 0;
|
|
7808
|
+
if (knownSpread) {
|
|
7809
|
+
dropNodes(attr.value);
|
|
7718
7810
|
} else {
|
|
7719
|
-
spreadReferenceNodes = [attr.value
|
|
7811
|
+
(spreadReferenceNodes = restReferenceNodes || []).push(attr.value);
|
|
7720
7812
|
}
|
|
7721
|
-
} else {
|
|
7722
|
-
const attrValueExtra = attr.value.extra ??= {};
|
|
7723
|
-
known[attr.name] = { value: attrValueExtra };
|
|
7724
|
-
rootAttrExprs.add(attrValueExtra);
|
|
7725
7813
|
}
|
|
7726
7814
|
}
|
|
7727
|
-
if (
|
|
7728
|
-
for (const prop of
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7815
|
+
if (knownSpread) {
|
|
7816
|
+
for (const prop of remaining) {
|
|
7817
|
+
const propBinding = getOrCreatePropertyAlias(knownSpread.binding, prop);
|
|
7818
|
+
const propExtra = { section };
|
|
7819
|
+
const templateExportAttr = getKnownFromPropTree(propTree, prop);
|
|
7820
|
+
known[prop] = { value: propExtra };
|
|
7821
|
+
rootAttrExprs.add(propExtra);
|
|
7822
|
+
addRead(propExtra, propExtra, propBinding, section);
|
|
7823
|
+
setBindingDownstream(
|
|
7824
|
+
templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding,
|
|
7825
|
+
propExtra
|
|
7826
|
+
);
|
|
7736
7827
|
}
|
|
7737
7828
|
} else if (spreadReferenceNodes) {
|
|
7738
|
-
|
|
7739
|
-
seen.size ? createBinding(
|
|
7740
|
-
generateUid(`${getTagName(tag)}_attrs`),
|
|
7741
|
-
propTree.binding.type,
|
|
7742
|
-
propTree.binding.section,
|
|
7743
|
-
propTree.binding,
|
|
7744
|
-
void 0,
|
|
7745
|
-
fromIter(seen),
|
|
7746
|
-
spreadReferenceNodes[0].loc,
|
|
7747
|
-
true
|
|
7748
|
-
) : propTree.binding,
|
|
7829
|
+
if (remaining.size || propTree.rest && !propTree.rest.props) {
|
|
7749
7830
|
inputExpr.value = mergeReferences(
|
|
7750
7831
|
section,
|
|
7751
7832
|
tag.node,
|
|
7752
7833
|
spreadReferenceNodes
|
|
7753
|
-
)
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
unknownReferences.flat()
|
|
7761
|
-
);
|
|
7762
|
-
setBindingDownstream(propTree.binding, restExtra);
|
|
7763
|
-
if (knownSpreadBinding && !propTree.rest.props) {
|
|
7764
|
-
addRead(restExtra, void 0, knownSpreadBinding, section);
|
|
7834
|
+
);
|
|
7835
|
+
setBindingDownstream(
|
|
7836
|
+
propTree.rest?.binding || propTree.binding,
|
|
7837
|
+
inputExpr.value
|
|
7838
|
+
);
|
|
7839
|
+
} else {
|
|
7840
|
+
dropNodes(spreadReferenceNodes);
|
|
7765
7841
|
}
|
|
7766
|
-
} else {
|
|
7767
|
-
|
|
7842
|
+
} else if (restReferenceNodes) {
|
|
7843
|
+
inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
|
|
7844
|
+
setBindingDownstream(propTree.rest.binding, inputExpr.value);
|
|
7768
7845
|
}
|
|
7846
|
+
dropNodes(dropReferenceNodes);
|
|
7769
7847
|
return inputExpr;
|
|
7770
7848
|
}
|
|
7771
|
-
function
|
|
7849
|
+
function getSingleKnownSpread(attributes) {
|
|
7772
7850
|
let binding;
|
|
7851
|
+
let extra;
|
|
7773
7852
|
for (let i = attributes.length; i--; ) {
|
|
7774
7853
|
const attr = attributes[i];
|
|
7775
|
-
if (attr.type === "MarkoSpreadAttribute" ? binding || !(binding = attr.value.extra?.spreadFrom) : binding && !includes(binding.excludeProperties, attr.name)) {
|
|
7854
|
+
if (attr.type === "MarkoSpreadAttribute" ? binding || !(binding = (extra = attr.value.extra)?.spreadFrom) : binding && !includes(binding.excludeProperties, attr.name)) {
|
|
7776
7855
|
return;
|
|
7777
7856
|
}
|
|
7778
7857
|
}
|
|
7779
|
-
|
|
7858
|
+
if (binding) {
|
|
7859
|
+
return { extra, binding };
|
|
7860
|
+
}
|
|
7780
7861
|
}
|
|
7781
7862
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
7782
7863
|
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
@@ -7848,275 +7929,420 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7848
7929
|
writeAttrsToSignals(tag, attrPropsTree, `${importAlias}_input`, info);
|
|
7849
7930
|
}
|
|
7850
7931
|
}
|
|
7851
|
-
function
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7932
|
+
function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
|
|
7933
|
+
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7934
|
+
const translatedAttrs = translateAttrs(
|
|
7935
|
+
tag,
|
|
7936
|
+
true,
|
|
7937
|
+
propTree.rest && new Set(toIter(propTree.rest.binding.excludeProperties))
|
|
7938
|
+
);
|
|
7939
|
+
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7940
|
+
if (translatedAttrs.statements.length) {
|
|
7941
|
+
addStatement(
|
|
7942
|
+
"render",
|
|
7943
|
+
info.tagSection,
|
|
7944
|
+
referencedBindings,
|
|
7945
|
+
translatedAttrs.statements
|
|
7946
|
+
);
|
|
7947
|
+
}
|
|
7948
|
+
if ((0, import_babel_utils25.isAttributeTag)(tag)) {
|
|
7949
|
+
const attrTagName = getTagName(tag);
|
|
7950
|
+
const parentTag = tag.parentPath;
|
|
7951
|
+
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
7952
|
+
if (repeated) {
|
|
7953
|
+
let attrTagCallsForTag = (info.attrTagCallsByTag ||= /* @__PURE__ */ new Map()).get(
|
|
7954
|
+
parentTag
|
|
7955
|
+
);
|
|
7956
|
+
if (!attrTagCallsForTag) {
|
|
7957
|
+
info.attrTagCallsByTag.set(parentTag, attrTagCallsForTag = /* @__PURE__ */ new Map());
|
|
7958
|
+
}
|
|
7959
|
+
const attrTagCall = attrTagCallsForTag.get(attrTagName);
|
|
7960
|
+
if (attrTagCall) {
|
|
7961
|
+
attrTagCall.expression = callRuntime(
|
|
7962
|
+
"attrTags",
|
|
7963
|
+
attrTagCall.expression,
|
|
7964
|
+
translatedProps
|
|
7877
7965
|
);
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7966
|
+
return;
|
|
7967
|
+
} else {
|
|
7968
|
+
attrTagCallsForTag.set(
|
|
7969
|
+
attrTagName,
|
|
7970
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
7971
|
+
callRuntime("attrTag", translatedProps)
|
|
7972
|
+
)
|
|
7973
|
+
);
|
|
7974
|
+
}
|
|
7975
|
+
} else {
|
|
7976
|
+
translatedProps = callRuntime("attrTag", translatedProps);
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
addStatement(
|
|
7980
|
+
"render",
|
|
7981
|
+
info.tagSection,
|
|
7982
|
+
referencedBindings,
|
|
7983
|
+
import_compiler37.types.expressionStatement(
|
|
7984
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
7985
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7986
|
+
translatedProps
|
|
7987
|
+
])
|
|
7988
|
+
),
|
|
7989
|
+
void 0,
|
|
7990
|
+
true
|
|
7991
|
+
);
|
|
7992
|
+
}
|
|
7993
|
+
function translateAttrTag(tag, attrTagMeta, info, statements) {
|
|
7994
|
+
const translatedAttrs = translateAttrs(tag, true, void 0, statements);
|
|
7995
|
+
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7996
|
+
const attrTagName = getTagName(tag);
|
|
7997
|
+
const parentTag = tag.parentPath;
|
|
7998
|
+
if (attrTagMeta.repeated) {
|
|
7999
|
+
let attrTagCallsForTag = (info.attrTagCallsByTag ||= /* @__PURE__ */ new Map()).get(
|
|
8000
|
+
parentTag
|
|
8001
|
+
);
|
|
8002
|
+
if (!attrTagCallsForTag) {
|
|
8003
|
+
info.attrTagCallsByTag.set(parentTag, attrTagCallsForTag = /* @__PURE__ */ new Map());
|
|
8004
|
+
}
|
|
8005
|
+
const attrTagCall = attrTagCallsForTag.get(attrTagName);
|
|
8006
|
+
if (attrTagCall) {
|
|
8007
|
+
attrTagCall.expression = callRuntime(
|
|
8008
|
+
"attrTags",
|
|
8009
|
+
attrTagCall.expression,
|
|
8010
|
+
translatedProps
|
|
8011
|
+
);
|
|
8012
|
+
return;
|
|
8013
|
+
} else {
|
|
8014
|
+
attrTagCallsForTag.set(
|
|
8015
|
+
attrTagName,
|
|
8016
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
8017
|
+
callRuntime("attrTag", translatedProps)
|
|
8018
|
+
)
|
|
8019
|
+
);
|
|
8020
|
+
}
|
|
8021
|
+
} else {
|
|
8022
|
+
translatedProps = callRuntime("attrTag", translatedProps);
|
|
8023
|
+
}
|
|
8024
|
+
return translatedProps;
|
|
8025
|
+
}
|
|
8026
|
+
function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
8027
|
+
if (!propTree.props) {
|
|
8028
|
+
applyAttrObject(
|
|
8029
|
+
tag,
|
|
8030
|
+
propTree,
|
|
8031
|
+
info.getBindingIdentifier(propTree.binding, importAlias),
|
|
8032
|
+
info
|
|
8033
|
+
);
|
|
8034
|
+
return;
|
|
8035
|
+
}
|
|
8036
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
8037
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8038
|
+
const tagReferencedBindings = tag.node.extra?.referencedBindings;
|
|
8039
|
+
const remaining = new Set(getAllKnownPropNames(propTree));
|
|
8040
|
+
let restProps;
|
|
8041
|
+
if (attrTagLookup) {
|
|
8042
|
+
const attrTags2 = tag.get("attributeTags");
|
|
8043
|
+
const statementsByGroup = /* @__PURE__ */ new Map();
|
|
8044
|
+
const translateDynamicAttrTagChildInGroup = (group, index) => {
|
|
8045
|
+
const child = attrTags2[index];
|
|
8046
|
+
let statements = statementsByGroup.get(group)?.statements;
|
|
8047
|
+
if (!statements) {
|
|
8048
|
+
statements = [];
|
|
8049
|
+
statementsByGroup.set(group, {
|
|
8050
|
+
referencedBindings: child.node.extra?.referencedBindings,
|
|
8051
|
+
statements
|
|
8052
|
+
});
|
|
8053
|
+
}
|
|
8054
|
+
return addDynamicAttrTagStatements(
|
|
8055
|
+
attrTags2,
|
|
8056
|
+
index,
|
|
8057
|
+
attrTagLookup,
|
|
8058
|
+
statements,
|
|
8059
|
+
propTree
|
|
8060
|
+
);
|
|
8061
|
+
};
|
|
8062
|
+
for (const attrTagName in attrTagLookup) {
|
|
8063
|
+
seen.add(attrTagLookup[attrTagName].name);
|
|
8064
|
+
}
|
|
8065
|
+
for (let i = 0; i < attrTags2.length; i++) {
|
|
8066
|
+
const child = attrTags2[i];
|
|
8067
|
+
if (child.isMarkoTag()) {
|
|
8068
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
8069
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
8070
|
+
const childAttrExport = getKnownFromPropTree(
|
|
8071
|
+
propTree,
|
|
8072
|
+
attrTagMeta.name
|
|
8073
|
+
);
|
|
8074
|
+
if (!childAttrExport) {
|
|
8075
|
+
} else if (attrTagMeta.dynamic) {
|
|
8076
|
+
i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
|
|
8077
|
+
} else if (childAttrExport === true) {
|
|
8078
|
+
const statements = [];
|
|
8079
|
+
const translatedAttrs = translateAttrTag(
|
|
8080
|
+
child,
|
|
8081
|
+
attrTagMeta,
|
|
8082
|
+
info,
|
|
8083
|
+
statements
|
|
8084
|
+
);
|
|
8085
|
+
addStatement(
|
|
8086
|
+
"render",
|
|
8087
|
+
info.tagSection,
|
|
8088
|
+
tagReferencedBindings,
|
|
8089
|
+
statements
|
|
8090
|
+
);
|
|
8091
|
+
if (translatedAttrs) {
|
|
8092
|
+
(restProps ||= []).push(
|
|
8093
|
+
toObjectProperty(attrTagMeta.name, translatedAttrs)
|
|
8094
|
+
);
|
|
7899
8095
|
}
|
|
7900
|
-
} else
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
8096
|
+
} else {
|
|
8097
|
+
remaining.delete(attrTagMeta.name);
|
|
8098
|
+
writeAttrsToSignals(
|
|
8099
|
+
child,
|
|
8100
|
+
childAttrExport,
|
|
8101
|
+
`${importAlias}_${attrTagMeta.name}`,
|
|
8102
|
+
info
|
|
7904
8103
|
);
|
|
7905
8104
|
}
|
|
8105
|
+
} else {
|
|
8106
|
+
const group = child.node.extra.attributeTagGroup;
|
|
8107
|
+
let childUsesGroupProp = false;
|
|
8108
|
+
for (const name2 of group) {
|
|
8109
|
+
if (getKnownFromPropTree(propTree, attrTagLookup[name2].name)) {
|
|
8110
|
+
childUsesGroupProp = true;
|
|
8111
|
+
break;
|
|
8112
|
+
}
|
|
8113
|
+
}
|
|
8114
|
+
if (childUsesGroupProp) {
|
|
8115
|
+
i = translateDynamicAttrTagChildInGroup(group, i);
|
|
8116
|
+
} else if (getTagName(child) === "if") {
|
|
8117
|
+
while (++i < attrTags2.length) {
|
|
8118
|
+
const nextTag = attrTags2[i];
|
|
8119
|
+
switch (nextTag.isMarkoTag() && getTagName(nextTag)) {
|
|
8120
|
+
case "else":
|
|
8121
|
+
case "else-if":
|
|
8122
|
+
continue;
|
|
8123
|
+
}
|
|
8124
|
+
i--;
|
|
8125
|
+
break;
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
}
|
|
8129
|
+
}
|
|
8130
|
+
}
|
|
8131
|
+
for (const [
|
|
8132
|
+
group,
|
|
8133
|
+
{ referencedBindings, statements }
|
|
8134
|
+
] of statementsByGroup) {
|
|
8135
|
+
const decls = [];
|
|
8136
|
+
let hasRest = false;
|
|
8137
|
+
for (const name2 of group) {
|
|
8138
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
8139
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8140
|
+
propTree,
|
|
8141
|
+
attrTagMeta.name
|
|
8142
|
+
);
|
|
8143
|
+
decls.push(import_compiler37.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
8144
|
+
if (childAttrExports === true) {
|
|
8145
|
+
hasRest = true;
|
|
7906
8146
|
}
|
|
7907
8147
|
}
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
8148
|
+
addStatement(
|
|
8149
|
+
"render",
|
|
8150
|
+
info.tagSection,
|
|
8151
|
+
hasRest ? tagReferencedBindings : referencedBindings,
|
|
8152
|
+
[import_compiler37.types.variableDeclaration("let", decls), ...statements]
|
|
8153
|
+
);
|
|
8154
|
+
if (hasRest) {
|
|
7913
8155
|
for (const name2 of group) {
|
|
7914
8156
|
const attrTagMeta = attrTagLookup[name2];
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
8157
|
+
(restProps ||= []).push(
|
|
8158
|
+
toObjectProperty(
|
|
8159
|
+
attrTagMeta.name,
|
|
8160
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
8161
|
+
)
|
|
7920
8162
|
);
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
8163
|
+
}
|
|
8164
|
+
} else {
|
|
8165
|
+
for (const name2 of group) {
|
|
8166
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
8167
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8168
|
+
propTree,
|
|
8169
|
+
attrTagMeta.name
|
|
8170
|
+
);
|
|
8171
|
+
remaining.delete(attrTagMeta.name);
|
|
7926
8172
|
addStatement(
|
|
7927
8173
|
"render",
|
|
7928
8174
|
info.tagSection,
|
|
7929
8175
|
referencedBindings,
|
|
7930
8176
|
import_compiler37.types.expressionStatement(
|
|
7931
|
-
import_compiler37.types.callExpression(
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
8177
|
+
import_compiler37.types.callExpression(
|
|
8178
|
+
info.getBindingIdentifier(
|
|
8179
|
+
childAttrExports.binding,
|
|
8180
|
+
`${importAlias}_${attrTagMeta.name}`
|
|
7935
8181
|
),
|
|
7936
|
-
|
|
7937
|
-
|
|
8182
|
+
[
|
|
8183
|
+
createScopeReadExpression(
|
|
8184
|
+
info.childScopeBinding,
|
|
8185
|
+
info.tagSection
|
|
8186
|
+
),
|
|
8187
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
8188
|
+
]
|
|
8189
|
+
)
|
|
7938
8190
|
)
|
|
7939
8191
|
);
|
|
7940
8192
|
}
|
|
7941
8193
|
}
|
|
7942
8194
|
}
|
|
7943
|
-
|
|
7944
|
-
|
|
8195
|
+
}
|
|
8196
|
+
const contentExport = getKnownFromPropTree(propTree, "content");
|
|
8197
|
+
if (!seen.has("content") && contentExport) {
|
|
8198
|
+
const bodySection = getSectionForBody(tag.get("body"));
|
|
8199
|
+
if (bodySection) {
|
|
7945
8200
|
seen.add("content");
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
);
|
|
8201
|
+
const bodyValue = import_compiler37.types.callExpression(import_compiler37.types.identifier(bodySection.name), [
|
|
8202
|
+
scopeIdentifier
|
|
8203
|
+
]);
|
|
8204
|
+
if (contentExport === true) {
|
|
8205
|
+
(restProps ||= []).push(toObjectProperty("content", bodyValue));
|
|
8206
|
+
} else {
|
|
8207
|
+
remaining.delete("content");
|
|
7951
8208
|
addStatement(
|
|
7952
8209
|
"render",
|
|
7953
8210
|
info.tagSection,
|
|
7954
8211
|
void 0,
|
|
7955
8212
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7956
8213
|
import_compiler37.types.expressionStatement(
|
|
7957
|
-
import_compiler37.types.callExpression(
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
8214
|
+
import_compiler37.types.callExpression(
|
|
8215
|
+
info.getBindingIdentifier(
|
|
8216
|
+
contentExport.binding,
|
|
8217
|
+
`${importAlias}_content`
|
|
7961
8218
|
),
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
8219
|
+
[
|
|
8220
|
+
createScopeReadExpression(
|
|
8221
|
+
info.childScopeBinding,
|
|
8222
|
+
info.tagSection
|
|
8223
|
+
),
|
|
8224
|
+
bodyValue
|
|
8225
|
+
]
|
|
8226
|
+
)
|
|
7966
8227
|
),
|
|
7967
8228
|
void 0,
|
|
7968
8229
|
true
|
|
7969
8230
|
);
|
|
7970
8231
|
}
|
|
7971
8232
|
}
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
}
|
|
8233
|
+
}
|
|
8234
|
+
let knownSpread;
|
|
8235
|
+
let spreadProps;
|
|
8236
|
+
const staticAttrs = [];
|
|
8237
|
+
const { attributes } = tag.node;
|
|
8238
|
+
for (let i = attributes.length; i--; ) {
|
|
8239
|
+
const attr = attributes[i];
|
|
8240
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
8241
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attr.name);
|
|
8242
|
+
if (!templateExportAttr || seen.has(attr.name)) {
|
|
8243
|
+
continue;
|
|
8244
|
+
}
|
|
8245
|
+
seen.add(attr.name);
|
|
8246
|
+
if (spreadProps) {
|
|
8247
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
8248
|
+
} else if (templateExportAttr === true) {
|
|
8249
|
+
(restProps ||= []).push(toObjectProperty(attr.name, attr.value));
|
|
8250
|
+
} else {
|
|
8251
|
+
staticAttrs.push(attr);
|
|
8252
|
+
}
|
|
8253
|
+
} else if (spreadProps) {
|
|
8254
|
+
spreadProps.push(import_compiler37.types.spreadElement(attr.value));
|
|
8255
|
+
} else {
|
|
8256
|
+
knownSpread = hasAllKnownProps(propTree) ? getSingleKnownSpread(attributes) : void 0;
|
|
8257
|
+
if (!knownSpread) {
|
|
8258
|
+
(spreadProps = restProps || []).push(import_compiler37.types.spreadElement(attr.value));
|
|
8259
|
+
}
|
|
7992
8260
|
}
|
|
7993
|
-
|
|
7994
|
-
|
|
8261
|
+
}
|
|
8262
|
+
for (let i = staticAttrs.length; i--; ) {
|
|
8263
|
+
const attr = staticAttrs[i];
|
|
8264
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8265
|
+
propTree,
|
|
8266
|
+
attr.name
|
|
8267
|
+
);
|
|
8268
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8269
|
+
childAttrExports.binding,
|
|
8270
|
+
`${importAlias}_${attr.name}`
|
|
8271
|
+
);
|
|
8272
|
+
remaining.delete(attr.name);
|
|
8273
|
+
addStatement(
|
|
8274
|
+
"render",
|
|
8275
|
+
info.tagSection,
|
|
8276
|
+
attr.value.extra?.referencedBindings,
|
|
8277
|
+
import_compiler37.types.expressionStatement(
|
|
8278
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8279
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8280
|
+
attr.value
|
|
8281
|
+
// TODO: use spreadBinding property alias after we optimize `in`
|
|
8282
|
+
])
|
|
8283
|
+
),
|
|
8284
|
+
void 0,
|
|
8285
|
+
true
|
|
8286
|
+
);
|
|
8287
|
+
}
|
|
8288
|
+
if (knownSpread) {
|
|
8289
|
+
for (const prop of remaining) {
|
|
8290
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8291
|
+
propTree,
|
|
8292
|
+
prop
|
|
8293
|
+
);
|
|
7995
8294
|
const attrExportIdentifier = info.getBindingIdentifier(
|
|
7996
8295
|
childAttrExports.binding,
|
|
7997
|
-
`${importAlias}_${
|
|
8296
|
+
`${importAlias}_${prop}`
|
|
7998
8297
|
);
|
|
8298
|
+
const propBinding = knownSpread.binding.propertyAliases.get(prop);
|
|
7999
8299
|
addStatement(
|
|
8000
8300
|
"render",
|
|
8001
8301
|
info.tagSection,
|
|
8002
|
-
|
|
8302
|
+
propBinding,
|
|
8003
8303
|
import_compiler37.types.expressionStatement(
|
|
8004
8304
|
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8005
8305
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8006
|
-
|
|
8007
|
-
attr.value
|
|
8306
|
+
createScopeReadExpression(propBinding, info.tagSection)
|
|
8008
8307
|
])
|
|
8009
8308
|
),
|
|
8010
8309
|
void 0,
|
|
8011
8310
|
true
|
|
8012
8311
|
);
|
|
8013
8312
|
}
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
const propBinding = knownSpreadBinding.propertyAliases.get(prop);
|
|
8025
|
-
addStatement(
|
|
8026
|
-
"render",
|
|
8027
|
-
info.tagSection,
|
|
8028
|
-
propBinding,
|
|
8029
|
-
import_compiler37.types.expressionStatement(
|
|
8030
|
-
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8031
|
-
createScopeReadExpression(
|
|
8032
|
-
info.childScopeBinding,
|
|
8033
|
-
info.tagSection
|
|
8034
|
-
),
|
|
8035
|
-
createScopeReadExpression(propBinding, info.tagSection)
|
|
8036
|
-
])
|
|
8037
|
-
),
|
|
8038
|
-
void 0,
|
|
8039
|
-
true
|
|
8040
|
-
);
|
|
8041
|
-
}
|
|
8042
|
-
} else {
|
|
8043
|
-
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
8044
|
-
if (spreadProps) {
|
|
8045
|
-
const spreadExpr = propsToExpression(
|
|
8046
|
-
propTree.rest ? (translatedAttrs = translateAttrs(tag, propTree, seen)).properties : spreadProps.reverse()
|
|
8047
|
-
);
|
|
8048
|
-
if (isSimpleReference(spreadExpr)) {
|
|
8049
|
-
spreadId = spreadExpr;
|
|
8050
|
-
} else {
|
|
8051
|
-
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
8052
|
-
if (translatedAttrs) {
|
|
8053
|
-
translatedAttrs.properties = [import_compiler37.types.spreadElement(spreadId)];
|
|
8054
|
-
}
|
|
8055
|
-
addStatement("render", info.tagSection, referencedBindings, [
|
|
8056
|
-
import_compiler37.types.variableDeclaration("const", [
|
|
8057
|
-
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
8058
|
-
])
|
|
8059
|
-
]);
|
|
8060
|
-
}
|
|
8061
|
-
}
|
|
8062
|
-
for (const name2 of missing) {
|
|
8063
|
-
const childAttrExports = getBindingPropTreeProp(propTree, name2);
|
|
8064
|
-
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8065
|
-
childAttrExports.binding,
|
|
8066
|
-
`${importAlias}_${name2}`
|
|
8067
|
-
);
|
|
8068
|
-
addStatement(
|
|
8069
|
-
"render",
|
|
8070
|
-
info.tagSection,
|
|
8071
|
-
spreadProps && referencedBindings,
|
|
8072
|
-
import_compiler37.types.expressionStatement(
|
|
8073
|
-
import_compiler37.types.callExpression(
|
|
8074
|
-
attrExportIdentifier,
|
|
8075
|
-
spreadId ? [
|
|
8076
|
-
createScopeReadExpression(
|
|
8077
|
-
info.childScopeBinding,
|
|
8078
|
-
info.tagSection
|
|
8079
|
-
),
|
|
8080
|
-
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
8081
|
-
] : [
|
|
8082
|
-
createScopeReadExpression(
|
|
8083
|
-
info.childScopeBinding,
|
|
8084
|
-
info.tagSection
|
|
8085
|
-
)
|
|
8086
|
-
]
|
|
8087
|
-
)
|
|
8088
|
-
)
|
|
8089
|
-
);
|
|
8090
|
-
}
|
|
8091
|
-
}
|
|
8092
|
-
}
|
|
8093
|
-
}
|
|
8094
|
-
if (!propTree.props || propTree.rest && !propTree.rest.props) {
|
|
8095
|
-
if (!translatedAttrs) {
|
|
8096
|
-
if (propTree.rest) {
|
|
8097
|
-
seen ||= /* @__PURE__ */ new Set();
|
|
8098
|
-
forEach(
|
|
8099
|
-
propTree.rest.binding.excludeProperties,
|
|
8100
|
-
(prop) => seen.add(prop)
|
|
8101
|
-
);
|
|
8102
|
-
}
|
|
8103
|
-
translatedAttrs = translateAttrs(tag, propTree.rest, seen);
|
|
8313
|
+
} else if (spreadProps) {
|
|
8314
|
+
const spreadExpr = propsToExpression(spreadProps.reverse());
|
|
8315
|
+
let spreadId = spreadExpr;
|
|
8316
|
+
if (!isSimpleReference(spreadExpr)) {
|
|
8317
|
+
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
8318
|
+
addStatement("render", info.tagSection, tagReferencedBindings, [
|
|
8319
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
8320
|
+
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
8321
|
+
])
|
|
8322
|
+
]);
|
|
8104
8323
|
}
|
|
8105
|
-
const
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8324
|
+
for (const name2 of remaining) {
|
|
8325
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8326
|
+
propTree,
|
|
8327
|
+
name2
|
|
8328
|
+
);
|
|
8329
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8330
|
+
childAttrExports.binding,
|
|
8331
|
+
`${importAlias}_${name2}`
|
|
8332
|
+
);
|
|
8111
8333
|
addStatement(
|
|
8112
8334
|
"render",
|
|
8113
8335
|
info.tagSection,
|
|
8114
|
-
|
|
8115
|
-
|
|
8336
|
+
tagReferencedBindings,
|
|
8337
|
+
import_compiler37.types.expressionStatement(
|
|
8338
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8339
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8340
|
+
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
8341
|
+
])
|
|
8342
|
+
)
|
|
8116
8343
|
);
|
|
8117
8344
|
}
|
|
8118
|
-
|
|
8119
|
-
if (propTree.rest && spreadId) {
|
|
8345
|
+
if (propTree.rest && !propTree.rest.props) {
|
|
8120
8346
|
const props = [];
|
|
8121
8347
|
const restId = import_compiler37.types.identifier(propTree.rest.binding.name);
|
|
8122
8348
|
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
@@ -8132,58 +8358,77 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
8132
8358
|
);
|
|
8133
8359
|
});
|
|
8134
8360
|
props.push(import_compiler37.types.restElement(restId));
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8361
|
+
addStatement(
|
|
8362
|
+
"render",
|
|
8363
|
+
info.tagSection,
|
|
8364
|
+
tagReferencedBindings,
|
|
8365
|
+
import_compiler37.types.expressionStatement(
|
|
8366
|
+
import_compiler37.types.callExpression(
|
|
8367
|
+
info.getBindingIdentifier(
|
|
8368
|
+
propTree.rest.binding,
|
|
8369
|
+
importAlias + "_$rest"
|
|
8370
|
+
),
|
|
8371
|
+
[
|
|
8372
|
+
createScopeReadExpression(
|
|
8373
|
+
info.childScopeBinding,
|
|
8374
|
+
info.tagSection
|
|
8375
|
+
),
|
|
8376
|
+
import_compiler37.types.callExpression(
|
|
8377
|
+
import_compiler37.types.arrowFunctionExpression([import_compiler37.types.objectPattern(props)], restId),
|
|
8378
|
+
[spreadId]
|
|
8379
|
+
)
|
|
8380
|
+
]
|
|
8381
|
+
)
|
|
8382
|
+
),
|
|
8383
|
+
void 0,
|
|
8384
|
+
true
|
|
8138
8385
|
);
|
|
8139
8386
|
}
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
const
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8387
|
+
} else {
|
|
8388
|
+
for (const name2 of remaining) {
|
|
8389
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8390
|
+
propTree,
|
|
8391
|
+
name2
|
|
8392
|
+
);
|
|
8393
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8394
|
+
childAttrExports.binding,
|
|
8395
|
+
`${importAlias}_${name2}`
|
|
8396
|
+
);
|
|
8397
|
+
addStatement(
|
|
8398
|
+
"render",
|
|
8399
|
+
info.tagSection,
|
|
8400
|
+
void 0,
|
|
8401
|
+
import_compiler37.types.expressionStatement(
|
|
8402
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8403
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection)
|
|
8404
|
+
])
|
|
8405
|
+
)
|
|
8406
|
+
);
|
|
8407
|
+
}
|
|
8408
|
+
if (propTree.rest && !propTree.rest.props) {
|
|
8409
|
+
addStatement(
|
|
8410
|
+
"render",
|
|
8411
|
+
info.tagSection,
|
|
8412
|
+
tagReferencedBindings,
|
|
8413
|
+
import_compiler37.types.expressionStatement(
|
|
8414
|
+
import_compiler37.types.callExpression(
|
|
8415
|
+
info.getBindingIdentifier(
|
|
8416
|
+
propTree.rest.binding,
|
|
8417
|
+
importAlias + "_$rest"
|
|
8418
|
+
),
|
|
8419
|
+
[
|
|
8420
|
+
createScopeReadExpression(
|
|
8421
|
+
info.childScopeBinding,
|
|
8422
|
+
info.tagSection
|
|
8423
|
+
),
|
|
8424
|
+
import_compiler37.types.objectExpression(restProps || [])
|
|
8425
|
+
]
|
|
8426
|
+
)
|
|
8427
|
+
),
|
|
8428
|
+
void 0,
|
|
8429
|
+
true
|
|
8430
|
+
);
|
|
8173
8431
|
}
|
|
8174
|
-
addStatement(
|
|
8175
|
-
"render",
|
|
8176
|
-
info.tagSection,
|
|
8177
|
-
referencedBindings,
|
|
8178
|
-
import_compiler37.types.expressionStatement(
|
|
8179
|
-
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
8180
|
-
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8181
|
-
translatedProps
|
|
8182
|
-
])
|
|
8183
|
-
),
|
|
8184
|
-
void 0,
|
|
8185
|
-
true
|
|
8186
|
-
);
|
|
8187
8432
|
}
|
|
8188
8433
|
}
|
|
8189
8434
|
function mapParamReasonToExpr(exprs, reason) {
|
|
@@ -8248,15 +8493,16 @@ function createBinding(name2, type, section, upstreamAlias, property, excludePro
|
|
|
8248
8493
|
assignmentSections: void 0,
|
|
8249
8494
|
excludeProperties,
|
|
8250
8495
|
sources: void 0,
|
|
8496
|
+
reads: /* @__PURE__ */ new Set(),
|
|
8251
8497
|
aliases: /* @__PURE__ */ new Set(),
|
|
8252
8498
|
hoists: /* @__PURE__ */ new Map(),
|
|
8253
8499
|
propertyAliases: /* @__PURE__ */ new Map(),
|
|
8254
8500
|
upstreamAlias,
|
|
8255
|
-
downstreamExpressions: /* @__PURE__ */ new Set(),
|
|
8256
8501
|
scopeOffset: void 0,
|
|
8257
8502
|
scopeAccessor: void 0,
|
|
8258
8503
|
export: void 0,
|
|
8259
|
-
nullable: excludeProperties === void 0
|
|
8504
|
+
nullable: excludeProperties === void 0,
|
|
8505
|
+
pruned: void 0
|
|
8260
8506
|
};
|
|
8261
8507
|
if (property) {
|
|
8262
8508
|
if (declared) upstreamAlias.nullable = false;
|
|
@@ -8534,6 +8780,7 @@ function trackAssignment(assignment, binding) {
|
|
|
8534
8780
|
true
|
|
8535
8781
|
);
|
|
8536
8782
|
idExtra.assignmentTo = changeBinding;
|
|
8783
|
+
changeBinding.pruned = false;
|
|
8537
8784
|
addReadToExpression(id, changeBinding);
|
|
8538
8785
|
}
|
|
8539
8786
|
}
|
|
@@ -8581,7 +8828,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8581
8828
|
scope,
|
|
8582
8829
|
section,
|
|
8583
8830
|
patternBinding,
|
|
8584
|
-
|
|
8831
|
+
void 0,
|
|
8585
8832
|
excludeProperties
|
|
8586
8833
|
);
|
|
8587
8834
|
} else {
|
|
@@ -8673,13 +8920,48 @@ function trackReference(referencePath, binding) {
|
|
|
8673
8920
|
}
|
|
8674
8921
|
addReadToExpression(root, reference);
|
|
8675
8922
|
}
|
|
8676
|
-
var [getMergedReferences] = createProgramState(
|
|
8677
|
-
() => /* @__PURE__ */ new Map()
|
|
8678
|
-
);
|
|
8679
8923
|
function mergeReferences(section, target, nodes) {
|
|
8680
8924
|
const targetExtra = target.extra ??= {};
|
|
8925
|
+
const readsByExpression = getReadsByExpression();
|
|
8926
|
+
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
8927
|
+
let reads = readsByExpression.get(targetExtra);
|
|
8928
|
+
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
8929
|
+
let { isEffect } = targetExtra;
|
|
8930
|
+
for (const node of nodes) {
|
|
8931
|
+
if (!node) continue;
|
|
8932
|
+
const extra = node.extra ??= {};
|
|
8933
|
+
extra.merged = targetExtra;
|
|
8934
|
+
if (isReferencedExtra(extra)) {
|
|
8935
|
+
const additionalReads = readsByExpression.get(extra);
|
|
8936
|
+
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
8937
|
+
isEffect ||= extra.isEffect;
|
|
8938
|
+
if (additionalReads) {
|
|
8939
|
+
forEach(additionalReads, (read) => {
|
|
8940
|
+
read.binding.reads.delete(extra);
|
|
8941
|
+
read.binding.reads.add(targetExtra);
|
|
8942
|
+
});
|
|
8943
|
+
reads = concat(reads, additionalReads);
|
|
8944
|
+
readsByExpression.delete(extra);
|
|
8945
|
+
}
|
|
8946
|
+
if (additionalExprFnReads) {
|
|
8947
|
+
if (exprFnReads) {
|
|
8948
|
+
for (const [key, value] of additionalExprFnReads) {
|
|
8949
|
+
exprFnReads.set(key, value);
|
|
8950
|
+
}
|
|
8951
|
+
} else {
|
|
8952
|
+
fnReadsByExpression.set(
|
|
8953
|
+
targetExtra,
|
|
8954
|
+
exprFnReads = new Map(additionalExprFnReads)
|
|
8955
|
+
);
|
|
8956
|
+
}
|
|
8957
|
+
}
|
|
8958
|
+
} else if (extra?.pruned) {
|
|
8959
|
+
throw new Error("Cannot merged a dropped reference.");
|
|
8960
|
+
}
|
|
8961
|
+
}
|
|
8962
|
+
readsByExpression.set(targetExtra, reads);
|
|
8963
|
+
targetExtra.isEffect = isEffect;
|
|
8681
8964
|
targetExtra.section = section;
|
|
8682
|
-
getMergedReferences().set(target, nodes);
|
|
8683
8965
|
return targetExtra;
|
|
8684
8966
|
}
|
|
8685
8967
|
function compareReferences(a, b) {
|
|
@@ -8703,53 +8985,20 @@ function finalizeReferences() {
|
|
|
8703
8985
|
const bindings = getBindings();
|
|
8704
8986
|
const readsByExpression = getReadsByExpression();
|
|
8705
8987
|
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
8706
|
-
const mergedReferences = getMergedReferences();
|
|
8707
|
-
if (mergedReferences.size) {
|
|
8708
|
-
for (const [target, nodes] of mergedReferences) {
|
|
8709
|
-
const targetExtra = target.extra;
|
|
8710
|
-
let reads = readsByExpression.get(targetExtra);
|
|
8711
|
-
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
8712
|
-
let { isEffect } = targetExtra;
|
|
8713
|
-
for (const node of nodes) {
|
|
8714
|
-
const extra = node?.extra;
|
|
8715
|
-
if (extra) {
|
|
8716
|
-
setCanonicalExtra(extra, targetExtra);
|
|
8717
|
-
if (isReferencedExtra(extra)) {
|
|
8718
|
-
const additionalReads = readsByExpression.get(extra);
|
|
8719
|
-
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
8720
|
-
isEffect ||= extra.isEffect;
|
|
8721
|
-
if (additionalReads) {
|
|
8722
|
-
reads = concat(reads, additionalReads);
|
|
8723
|
-
readsByExpression.delete(extra);
|
|
8724
|
-
}
|
|
8725
|
-
if (additionalExprFnReads) {
|
|
8726
|
-
if (exprFnReads) {
|
|
8727
|
-
for (const [key, value] of additionalExprFnReads) {
|
|
8728
|
-
exprFnReads.set(key, value);
|
|
8729
|
-
}
|
|
8730
|
-
} else {
|
|
8731
|
-
fnReadsByExpression.set(
|
|
8732
|
-
targetExtra,
|
|
8733
|
-
exprFnReads = new Map(additionalExprFnReads)
|
|
8734
|
-
);
|
|
8735
|
-
}
|
|
8736
|
-
}
|
|
8737
|
-
}
|
|
8738
|
-
}
|
|
8739
|
-
}
|
|
8740
|
-
readsByExpression.set(targetExtra, reads);
|
|
8741
|
-
targetExtra.isEffect = isEffect;
|
|
8742
|
-
}
|
|
8743
|
-
}
|
|
8744
8988
|
const intersectionsBySection = /* @__PURE__ */ new Map();
|
|
8745
8989
|
for (const [expr, reads] of readsByExpression) {
|
|
8746
8990
|
if (isReferencedExtra(expr)) {
|
|
8747
8991
|
const { referencedBindings, constantBindings } = resolveReferencedBindings(expr, reads, intersectionsBySection);
|
|
8748
8992
|
expr.referencedBindings = referencedBindings;
|
|
8749
|
-
if (
|
|
8993
|
+
if (expr.isEffect) {
|
|
8750
8994
|
forEach(referencedBindings, (binding) => {
|
|
8751
|
-
binding.
|
|
8995
|
+
addSerializeReason(binding.section, true, binding);
|
|
8996
|
+
});
|
|
8997
|
+
forEach(constantBindings, (binding) => {
|
|
8998
|
+
addSerializeReason(binding.section, true, binding);
|
|
8752
8999
|
});
|
|
9000
|
+
}
|
|
9001
|
+
if (referencedBindings) {
|
|
8753
9002
|
const exprFnReads = fnReadsByExpression.get(expr);
|
|
8754
9003
|
if (exprFnReads) {
|
|
8755
9004
|
for (const [fn, fnReads] of exprFnReads) {
|
|
@@ -8764,16 +9013,13 @@ function finalizeReferences() {
|
|
|
8764
9013
|
}
|
|
8765
9014
|
}
|
|
8766
9015
|
}
|
|
8767
|
-
if (constantBindings) {
|
|
8768
|
-
forEach(constantBindings, (binding) => {
|
|
8769
|
-
binding.downstreamExpressions.add(expr);
|
|
8770
|
-
});
|
|
8771
|
-
}
|
|
8772
9016
|
}
|
|
8773
9017
|
}
|
|
8774
9018
|
for (const binding of bindings) {
|
|
8775
|
-
if (binding.type !== 0 /* dom */
|
|
8776
|
-
pruneBinding(
|
|
9019
|
+
if (binding.type !== 0 /* dom */) {
|
|
9020
|
+
if (pruneBinding(binding)) {
|
|
9021
|
+
bindings.delete(binding);
|
|
9022
|
+
}
|
|
8777
9023
|
}
|
|
8778
9024
|
}
|
|
8779
9025
|
forEachSection(finalizeTagDownstreams);
|
|
@@ -8796,11 +9042,7 @@ function finalizeReferences() {
|
|
|
8796
9042
|
section.bindings,
|
|
8797
9043
|
getCanonicalBinding(binding)
|
|
8798
9044
|
);
|
|
8799
|
-
for (const {
|
|
8800
|
-
referencedBindings,
|
|
8801
|
-
isEffect,
|
|
8802
|
-
section: section2
|
|
8803
|
-
} of binding.downstreamExpressions) {
|
|
9045
|
+
for (const { isEffect, section: section2 } of binding.reads) {
|
|
8804
9046
|
if (section2 !== binding.section) {
|
|
8805
9047
|
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
|
8806
9048
|
canonicalUpstreamAlias.closureSections = sectionUtil.add(
|
|
@@ -8824,12 +9066,6 @@ function finalizeReferences() {
|
|
|
8824
9066
|
);
|
|
8825
9067
|
}
|
|
8826
9068
|
}
|
|
8827
|
-
if (isEffect) {
|
|
8828
|
-
forEach(
|
|
8829
|
-
referencedBindings,
|
|
8830
|
-
(binding2) => addSerializeReason(binding2.section, true, binding2)
|
|
8831
|
-
);
|
|
8832
|
-
}
|
|
8833
9069
|
}
|
|
8834
9070
|
}
|
|
8835
9071
|
forEachSection((section) => {
|
|
@@ -8940,7 +9176,7 @@ function finalizeReferences() {
|
|
|
8940
9176
|
finalizeFunctionRegistry();
|
|
8941
9177
|
const referencedExprs = /* @__PURE__ */ new Set();
|
|
8942
9178
|
for (const binding of bindings) {
|
|
8943
|
-
for (const expr of binding.
|
|
9179
|
+
for (const expr of binding.reads) {
|
|
8944
9180
|
referencedExprs.add(expr);
|
|
8945
9181
|
}
|
|
8946
9182
|
}
|
|
@@ -8999,7 +9235,6 @@ function finalizeReferences() {
|
|
|
8999
9235
|
programExtra.returnValueExpr
|
|
9000
9236
|
);
|
|
9001
9237
|
}
|
|
9002
|
-
mergedReferences.clear();
|
|
9003
9238
|
readsByExpression.clear();
|
|
9004
9239
|
fnReadsByExpression.clear();
|
|
9005
9240
|
}
|
|
@@ -9160,12 +9395,10 @@ var [getReadsByExpression] = createProgramState(
|
|
|
9160
9395
|
var [getFunctionReadsByExpression] = createProgramState(
|
|
9161
9396
|
() => /* @__PURE__ */ new Map()
|
|
9162
9397
|
);
|
|
9163
|
-
function addRead(exprExtra,
|
|
9398
|
+
function addRead(exprExtra, extra, binding, section) {
|
|
9164
9399
|
const readsByExpression = getReadsByExpression();
|
|
9165
|
-
const read = {
|
|
9166
|
-
|
|
9167
|
-
extra: readExtra
|
|
9168
|
-
};
|
|
9400
|
+
const read = { binding, extra };
|
|
9401
|
+
binding.reads.add(exprExtra);
|
|
9169
9402
|
exprExtra.section = section;
|
|
9170
9403
|
readsByExpression.set(
|
|
9171
9404
|
exprExtra,
|
|
@@ -9173,8 +9406,28 @@ function addRead(exprExtra, readExtra, binding, section) {
|
|
|
9173
9406
|
);
|
|
9174
9407
|
return read;
|
|
9175
9408
|
}
|
|
9176
|
-
function
|
|
9177
|
-
|
|
9409
|
+
function dropNodes(node) {
|
|
9410
|
+
if (Array.isArray(node)) {
|
|
9411
|
+
for (const item of node) {
|
|
9412
|
+
dropExtra(item.extra ??= {});
|
|
9413
|
+
}
|
|
9414
|
+
} else {
|
|
9415
|
+
dropExtra(node.extra ??= {});
|
|
9416
|
+
}
|
|
9417
|
+
}
|
|
9418
|
+
function dropExtra(exprExtra) {
|
|
9419
|
+
if (exprExtra.merged) {
|
|
9420
|
+
throw new Error("Cannot drop a merged reference");
|
|
9421
|
+
}
|
|
9422
|
+
const readsByExpr = getReadsByExpression();
|
|
9423
|
+
const reads = readsByExpr.get(exprExtra);
|
|
9424
|
+
exprExtra.pruned = true;
|
|
9425
|
+
if (reads) {
|
|
9426
|
+
readsByExpr.delete(exprExtra);
|
|
9427
|
+
forEach(reads, (read) => {
|
|
9428
|
+
read.binding.reads.delete(exprExtra);
|
|
9429
|
+
});
|
|
9430
|
+
}
|
|
9178
9431
|
}
|
|
9179
9432
|
function addReadToExpression(root, binding) {
|
|
9180
9433
|
const { node } = root;
|
|
@@ -9197,15 +9450,6 @@ function addReadToExpression(root, binding) {
|
|
|
9197
9450
|
exprFnReads.set(fnExtra, push(exprFnReads.get(fnExtra), read));
|
|
9198
9451
|
}
|
|
9199
9452
|
}
|
|
9200
|
-
function dropReferences(node) {
|
|
9201
|
-
if (Array.isArray(node)) {
|
|
9202
|
-
for (const item of node) {
|
|
9203
|
-
(item.extra ??= {}).pruned = true;
|
|
9204
|
-
}
|
|
9205
|
-
} else {
|
|
9206
|
-
(node.extra ??= {}).pruned = true;
|
|
9207
|
-
}
|
|
9208
|
-
}
|
|
9209
9453
|
function getCanonicalBinding(binding) {
|
|
9210
9454
|
const alias = binding.upstreamAlias;
|
|
9211
9455
|
if (alias && binding.property === void 0 && binding.excludeProperties === void 0) {
|
|
@@ -9390,28 +9634,38 @@ function hasNonConstantPropertyAlias(ref) {
|
|
|
9390
9634
|
}
|
|
9391
9635
|
return false;
|
|
9392
9636
|
}
|
|
9393
|
-
function pruneBinding(
|
|
9394
|
-
|
|
9637
|
+
function pruneBinding(binding) {
|
|
9638
|
+
if (binding.pruned !== void 0) {
|
|
9639
|
+
return binding.pruned;
|
|
9640
|
+
}
|
|
9641
|
+
for (const read of binding.reads) {
|
|
9642
|
+
let upstream = binding.upstreamAlias;
|
|
9643
|
+
while (upstream && !upstream.reads.has(read)) {
|
|
9644
|
+
upstream = upstream.upstreamAlias;
|
|
9645
|
+
}
|
|
9646
|
+
if (upstream) {
|
|
9647
|
+
binding.reads.delete(read);
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9650
|
+
let shouldPrune = !binding.reads.size;
|
|
9395
9651
|
if (binding.hoists.size) {
|
|
9396
9652
|
shouldPrune = false;
|
|
9397
9653
|
}
|
|
9398
9654
|
for (const alias of binding.aliases) {
|
|
9399
|
-
if (pruneBinding(
|
|
9655
|
+
if (pruneBinding(alias)) {
|
|
9400
9656
|
binding.aliases.delete(alias);
|
|
9401
9657
|
} else if (alias.type !== 7 /* constant */) {
|
|
9402
9658
|
shouldPrune = false;
|
|
9403
9659
|
}
|
|
9404
9660
|
}
|
|
9405
9661
|
for (const [key, alias] of binding.propertyAliases) {
|
|
9406
|
-
if (pruneBinding(
|
|
9662
|
+
if (pruneBinding(alias)) {
|
|
9407
9663
|
binding.propertyAliases.delete(key);
|
|
9408
9664
|
} else if (alias.type !== 7 /* constant */) {
|
|
9409
9665
|
shouldPrune = false;
|
|
9410
9666
|
}
|
|
9411
9667
|
}
|
|
9412
|
-
|
|
9413
|
-
bindings.delete(binding);
|
|
9414
|
-
}
|
|
9668
|
+
binding.pruned = shouldPrune;
|
|
9415
9669
|
return shouldPrune;
|
|
9416
9670
|
}
|
|
9417
9671
|
function resolveReferencedBindingsInFunction(refs, reads) {
|
|
@@ -9597,6 +9851,7 @@ function getCanonicalExtra(extra) {
|
|
|
9597
9851
|
}
|
|
9598
9852
|
var serializeReasonCache = /* @__PURE__ */ new WeakMap();
|
|
9599
9853
|
function getAllSerializeReasonsForExtra(extra) {
|
|
9854
|
+
if (extra.isEffect) return true;
|
|
9600
9855
|
let reason = serializeReasonCache.get(extra);
|
|
9601
9856
|
if (reason === false) return;
|
|
9602
9857
|
if (reason === void 0) {
|
|
@@ -9607,7 +9862,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9607
9862
|
forEach(extra.downstream, (binding) => {
|
|
9608
9863
|
reason = mergeSerializeReasons(
|
|
9609
9864
|
reason,
|
|
9610
|
-
getAllSerializeReasonsForBinding(binding)
|
|
9865
|
+
getAllSerializeReasonsForBinding(binding, true)
|
|
9611
9866
|
);
|
|
9612
9867
|
});
|
|
9613
9868
|
}
|
|
@@ -9617,32 +9872,34 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9617
9872
|
}
|
|
9618
9873
|
return reason;
|
|
9619
9874
|
}
|
|
9620
|
-
function getAllSerializeReasonsForBinding(binding) {
|
|
9875
|
+
function getAllSerializeReasonsForBinding(binding, properties) {
|
|
9621
9876
|
let reason = serializeReasonCache.get(binding);
|
|
9622
|
-
if (reason === false) return;
|
|
9623
9877
|
if (reason === void 0) {
|
|
9624
9878
|
reason = getSerializeReason(binding.section, binding);
|
|
9625
9879
|
if (reason !== true) {
|
|
9626
|
-
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
|
|
9880
|
+
serializeReasonCache.set(binding, reason || false);
|
|
9881
|
+
if (properties !== true && binding.upstreamAlias) {
|
|
9882
|
+
reason = mergeSerializeReasons(
|
|
9883
|
+
reason,
|
|
9884
|
+
getAllSerializeReasonsForBinding(
|
|
9885
|
+
binding.upstreamAlias,
|
|
9886
|
+
binding.property
|
|
9887
|
+
)
|
|
9888
|
+
);
|
|
9632
9889
|
}
|
|
9633
9890
|
if (reason !== true) {
|
|
9634
|
-
for (const
|
|
9891
|
+
for (const expr of binding.reads) {
|
|
9635
9892
|
reason = mergeSerializeReasons(
|
|
9636
9893
|
reason,
|
|
9637
|
-
|
|
9894
|
+
getAllSerializeReasonsForExtra(expr)
|
|
9638
9895
|
);
|
|
9639
9896
|
if (reason === true) break;
|
|
9640
9897
|
}
|
|
9641
9898
|
if (reason !== true) {
|
|
9642
|
-
for (const
|
|
9899
|
+
for (const alias of binding.aliases) {
|
|
9643
9900
|
reason = mergeSerializeReasons(
|
|
9644
9901
|
reason,
|
|
9645
|
-
getAllSerializeReasonsForBinding(
|
|
9902
|
+
getAllSerializeReasonsForBinding(alias, properties)
|
|
9646
9903
|
);
|
|
9647
9904
|
if (reason === true) break;
|
|
9648
9905
|
}
|
|
@@ -9653,11 +9910,56 @@ function getAllSerializeReasonsForBinding(binding) {
|
|
|
9653
9910
|
serializeReasonCache.set(binding, reason);
|
|
9654
9911
|
}
|
|
9655
9912
|
}
|
|
9913
|
+
if (reason === false) {
|
|
9914
|
+
reason = void 0;
|
|
9915
|
+
}
|
|
9916
|
+
if (properties !== void 0) {
|
|
9917
|
+
if (properties === true) {
|
|
9918
|
+
if (reason !== true) {
|
|
9919
|
+
for (const propBinding of binding.propertyAliases.values()) {
|
|
9920
|
+
reason = mergeSerializeReasons(
|
|
9921
|
+
reason,
|
|
9922
|
+
getAllSerializeReasonsForBinding(propBinding, true)
|
|
9923
|
+
);
|
|
9924
|
+
if (reason === true) break;
|
|
9925
|
+
}
|
|
9926
|
+
}
|
|
9927
|
+
} else {
|
|
9928
|
+
let property;
|
|
9929
|
+
let rest2;
|
|
9930
|
+
if (Array.isArray(properties)) {
|
|
9931
|
+
property = properties[0];
|
|
9932
|
+
rest2 = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
9933
|
+
} else {
|
|
9934
|
+
property = properties;
|
|
9935
|
+
}
|
|
9936
|
+
if (includes(binding.excludeProperties, property)) {
|
|
9937
|
+
reason = void 0;
|
|
9938
|
+
} else {
|
|
9939
|
+
const propBinding = binding.propertyAliases.get(property);
|
|
9940
|
+
if (propBinding) {
|
|
9941
|
+
reason = mergeSerializeReasons(
|
|
9942
|
+
reason,
|
|
9943
|
+
getAllSerializeReasonsForBinding(propBinding, rest2)
|
|
9944
|
+
);
|
|
9945
|
+
}
|
|
9946
|
+
if (reason !== true) {
|
|
9947
|
+
for (const alias of binding.aliases) {
|
|
9948
|
+
const propBinding2 = alias.propertyAliases.get(property);
|
|
9949
|
+
if (propBinding2) {
|
|
9950
|
+
reason = mergeSerializeReasons(
|
|
9951
|
+
reason,
|
|
9952
|
+
getAllSerializeReasonsForBinding(propBinding2, rest2)
|
|
9953
|
+
);
|
|
9954
|
+
if (reason === true) break;
|
|
9955
|
+
}
|
|
9956
|
+
}
|
|
9957
|
+
}
|
|
9958
|
+
}
|
|
9959
|
+
}
|
|
9960
|
+
}
|
|
9656
9961
|
return reason;
|
|
9657
9962
|
}
|
|
9658
|
-
function setCanonicalExtra(extra, merged) {
|
|
9659
|
-
extra.merged = merged;
|
|
9660
|
-
}
|
|
9661
9963
|
function addNumericPropertiesUntil(props, len) {
|
|
9662
9964
|
let result = props;
|
|
9663
9965
|
for (let i = len; i--; ) {
|
|
@@ -9876,7 +10178,7 @@ var const_default = {
|
|
|
9876
10178
|
const valueExtra = evaluate(valueAttr.value);
|
|
9877
10179
|
const upstreamAlias = import_compiler41.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
9878
10180
|
if (upstreamAlias) {
|
|
9879
|
-
|
|
10181
|
+
dropNodes(valueAttr.value);
|
|
9880
10182
|
}
|
|
9881
10183
|
const binding = trackVarReferences(tag, 5 /* derived */, upstreamAlias);
|
|
9882
10184
|
if (binding) {
|
|
@@ -9987,7 +10289,7 @@ var define_default = {
|
|
|
9987
10289
|
const bodySection = startSection(tagBody);
|
|
9988
10290
|
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
|
9989
10291
|
if (!varBinding) {
|
|
9990
|
-
|
|
10292
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
9991
10293
|
return;
|
|
9992
10294
|
}
|
|
9993
10295
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
@@ -10004,13 +10306,13 @@ var define_default = {
|
|
|
10004
10306
|
}
|
|
10005
10307
|
if (ref.parent.type === "MarkoTag" && ref.parent.name === ref.node) {
|
|
10006
10308
|
(ref.parent.extra ??= {}).defineBodySection = bodySection;
|
|
10007
|
-
|
|
10309
|
+
dropNodes(ref.parent.name);
|
|
10008
10310
|
} else {
|
|
10009
10311
|
allDirectReferences = false;
|
|
10010
10312
|
}
|
|
10011
10313
|
}
|
|
10012
10314
|
if (allDirectReferences) {
|
|
10013
|
-
|
|
10315
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
10014
10316
|
return;
|
|
10015
10317
|
}
|
|
10016
10318
|
}
|
|
@@ -10897,7 +11199,7 @@ var let_default = {
|
|
|
10897
11199
|
// src/translator/core/lifecycle.ts
|
|
10898
11200
|
var import_compiler50 = require("@marko/compiler");
|
|
10899
11201
|
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
10900
|
-
var
|
|
11202
|
+
var [getIndex, setIndex] = createSectionState("lifecycleIndex", () => 0);
|
|
10901
11203
|
var lifecycle_default = {
|
|
10902
11204
|
analyze(tag) {
|
|
10903
11205
|
(0, import_babel_utils39.assertNoArgs)(tag);
|
|
@@ -10911,12 +11213,7 @@ var lifecycle_default = {
|
|
|
10911
11213
|
tag.node,
|
|
10912
11214
|
getAllTagReferenceNodes(tag.node)
|
|
10913
11215
|
);
|
|
10914
|
-
|
|
10915
|
-
generateUid("lifecycle"),
|
|
10916
|
-
5 /* derived */,
|
|
10917
|
-
section
|
|
10918
|
-
);
|
|
10919
|
-
binding.downstreamExpressions.add(tagExtra);
|
|
11216
|
+
tagExtra.isEffect = true;
|
|
10920
11217
|
if (node.attributes.length === 0) {
|
|
10921
11218
|
throw tag.get("name").buildCodeFrameError(
|
|
10922
11219
|
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) requires at least one attribute."
|
|
@@ -10928,7 +11225,6 @@ var lifecycle_default = {
|
|
|
10928
11225
|
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://markojs.com/docs/reference/language#spread-attributes)."
|
|
10929
11226
|
);
|
|
10930
11227
|
}
|
|
10931
|
-
(attr.value.extra ??= {}).isEffect = true;
|
|
10932
11228
|
}
|
|
10933
11229
|
(0, import_babel_utils39.getProgram)().node.extra.isInteractive = true;
|
|
10934
11230
|
},
|
|
@@ -10938,16 +11234,17 @@ var lifecycle_default = {
|
|
|
10938
11234
|
const section = getSection(tag);
|
|
10939
11235
|
const tagExtra = node.extra;
|
|
10940
11236
|
const { referencedBindings } = tagExtra;
|
|
10941
|
-
const lifecycleAttrsRef = tagExtra[kRef];
|
|
10942
11237
|
if (isOutputDOM()) {
|
|
10943
11238
|
const translatedAttrs = translateAttrs(tag);
|
|
11239
|
+
const index = getIndex(section);
|
|
11240
|
+
setIndex(section, index + 1);
|
|
10944
11241
|
translatedAttrs.statements.push(
|
|
10945
11242
|
import_compiler50.types.expressionStatement(
|
|
10946
11243
|
callRuntime(
|
|
10947
11244
|
"_lifecycle",
|
|
10948
11245
|
scopeIdentifier,
|
|
10949
|
-
|
|
10950
|
-
|
|
11246
|
+
propsToExpression(translatedAttrs.properties),
|
|
11247
|
+
index > 0 ? import_compiler50.types.numericLiteral(index) : void 0
|
|
10951
11248
|
)
|
|
10952
11249
|
)
|
|
10953
11250
|
);
|
|
@@ -11093,7 +11390,7 @@ var script_default = {
|
|
|
11093
11390
|
}
|
|
11094
11391
|
}
|
|
11095
11392
|
if (!seenValueAttr) {
|
|
11096
|
-
|
|
11393
|
+
dropNodes(getAllTagReferenceNodes(node));
|
|
11097
11394
|
}
|
|
11098
11395
|
},
|
|
11099
11396
|
translate: {
|