marko 6.0.131 → 6.0.133
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 +6 -5
- package/dist/debug/dom.mjs +6 -5
- package/dist/dom/dom.d.ts +2 -2
- package/dist/dom.js +4 -4
- package/dist/dom.mjs +4 -4
- package/dist/translator/core/lifecycle.d.ts +0 -7
- package/dist/translator/index.js +852 -568
- 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 +7 -6
- 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 +2 -2
- 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;
|
|
@@ -1764,7 +1773,7 @@ function getOrCreateSection(path7) {
|
|
|
1764
1773
|
let cur = path7;
|
|
1765
1774
|
while (true) {
|
|
1766
1775
|
if (cur.type === "Program" || cur.type === "MarkoTagBody" && !cur.node.attributeTags && !isNativeNode(cur.parentPath)) {
|
|
1767
|
-
return
|
|
1776
|
+
return startSection(cur);
|
|
1768
1777
|
}
|
|
1769
1778
|
cur = cur.parentPath;
|
|
1770
1779
|
}
|
|
@@ -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;
|
|
@@ -2240,26 +2255,17 @@ var import_compiler27 = require("@marko/compiler");
|
|
|
2240
2255
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
2241
2256
|
var import_path2 = __toESM(require("path"));
|
|
2242
2257
|
|
|
2243
|
-
// src/translator/util/binding-has-downstream-expressions.ts
|
|
2244
|
-
function bindingHasDownstreamExpressions(binding) {
|
|
2245
|
-
if (binding.downstreamExpressions.size) return true;
|
|
2246
|
-
for (const alias of binding.aliases) {
|
|
2247
|
-
if (bindingHasDownstreamExpressions(alias)) return true;
|
|
2248
|
-
}
|
|
2249
|
-
for (const alias of binding.propertyAliases.values()) {
|
|
2250
|
-
if (bindingHasDownstreamExpressions(alias)) return true;
|
|
2251
|
-
}
|
|
2252
|
-
return false;
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2255
2258
|
// src/translator/util/binding-prop-tree.ts
|
|
2256
2259
|
function getBindingPropTree(binding) {
|
|
2260
|
+
if (pruneBinding(binding)) {
|
|
2261
|
+
return void 0;
|
|
2262
|
+
}
|
|
2257
2263
|
const props = {
|
|
2258
2264
|
binding,
|
|
2259
2265
|
props: void 0,
|
|
2260
2266
|
rest: void 0
|
|
2261
2267
|
};
|
|
2262
|
-
if (!binding.
|
|
2268
|
+
if (!binding.reads.size) {
|
|
2263
2269
|
if (!binding.aliases.size) {
|
|
2264
2270
|
props.props = {};
|
|
2265
2271
|
for (const [property, alias] of binding.propertyAliases) {
|
|
@@ -2298,12 +2304,20 @@ function hasSupersetExcludeProperties(binding, excludeProperties) {
|
|
|
2298
2304
|
}
|
|
2299
2305
|
return true;
|
|
2300
2306
|
}
|
|
2301
|
-
function
|
|
2302
|
-
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;
|
|
2303
2309
|
}
|
|
2304
|
-
function
|
|
2310
|
+
function getAllKnownPropNames(propTree) {
|
|
2305
2311
|
const keys = propTree.props ? Object.keys(propTree.props) : [];
|
|
2306
|
-
|
|
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);
|
|
2307
2321
|
}
|
|
2308
2322
|
|
|
2309
2323
|
// src/translator/util/entry-builder.ts
|
|
@@ -2356,9 +2370,7 @@ var entry_builder_default = {
|
|
|
2356
2370
|
};
|
|
2357
2371
|
const programExtra = file.path.node.extra;
|
|
2358
2372
|
const { analyzedTags } = file.metadata.marko;
|
|
2359
|
-
state.imports.push(
|
|
2360
|
-
(0, import_babel_utils12.resolveRelativePath)(entryFile, file.opts.filename)
|
|
2361
|
-
);
|
|
2373
|
+
state.imports.push((0, import_babel_utils12.resolveRelativePath)(entryFile, file.opts.filename));
|
|
2362
2374
|
if (programExtra.isInteractive || programExtra.needsCompat) {
|
|
2363
2375
|
state.init = true;
|
|
2364
2376
|
}
|
|
@@ -2633,6 +2645,36 @@ function getCompatRuntimeFile() {
|
|
|
2633
2645
|
var import_compiler23 = require("@marko/compiler");
|
|
2634
2646
|
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
|
2635
2647
|
|
|
2648
|
+
// src/translator/util/binding-has-prop.ts
|
|
2649
|
+
function bindingHasProperty(binding, properties) {
|
|
2650
|
+
if (binding.pruned) {
|
|
2651
|
+
return false;
|
|
2652
|
+
} else if (binding.pruned === void 0) {
|
|
2653
|
+
throw new Error("Binding must be pruned before checking properties");
|
|
2654
|
+
}
|
|
2655
|
+
if (binding.reads.size || !properties) {
|
|
2656
|
+
return true;
|
|
2657
|
+
}
|
|
2658
|
+
let property;
|
|
2659
|
+
let rest2;
|
|
2660
|
+
if (Array.isArray(properties)) {
|
|
2661
|
+
property = properties[0];
|
|
2662
|
+
rest2 = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
2663
|
+
} else {
|
|
2664
|
+
property = properties;
|
|
2665
|
+
}
|
|
2666
|
+
const propBinding = binding.propertyAliases.get(property);
|
|
2667
|
+
if (propBinding && bindingHasProperty(propBinding, rest2)) {
|
|
2668
|
+
return true;
|
|
2669
|
+
}
|
|
2670
|
+
for (const alias of binding.aliases) {
|
|
2671
|
+
if (bindingHasProperty(alias, properties)) {
|
|
2672
|
+
return true;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return false;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2636
2678
|
// src/translator/util/get-style-file.ts
|
|
2637
2679
|
var import_path = __toESM(require("path"));
|
|
2638
2680
|
function getStyleFile(file) {
|
|
@@ -4005,7 +4047,7 @@ function writeHoists(section) {
|
|
|
4005
4047
|
import_compiler22.types.variableDeclaration("const", [
|
|
4006
4048
|
import_compiler22.types.variableDeclarator(
|
|
4007
4049
|
hoistIdentifier,
|
|
4008
|
-
hoistedBinding.
|
|
4050
|
+
hoistedBinding.reads.size ? callRuntime(
|
|
4009
4051
|
"_resume",
|
|
4010
4052
|
// TODO: add _hoist_resume runtime
|
|
4011
4053
|
import_compiler22.types.stringLiteral(
|
|
@@ -4020,7 +4062,7 @@ function writeHoists(section) {
|
|
|
4020
4062
|
)
|
|
4021
4063
|
])
|
|
4022
4064
|
);
|
|
4023
|
-
if (hoistedBinding.
|
|
4065
|
+
if (hoistedBinding.reads.size) {
|
|
4024
4066
|
addValue(
|
|
4025
4067
|
hoistedBinding.section,
|
|
4026
4068
|
void 0,
|
|
@@ -4500,7 +4542,7 @@ var dom_default = {
|
|
|
4500
4542
|
const walksIdentifier = import_compiler23.types.identifier(domExports.walks);
|
|
4501
4543
|
const setupIdentifier = import_compiler23.types.identifier(domExports.setup);
|
|
4502
4544
|
const inputBinding = program.node.params[0].extra?.binding;
|
|
4503
|
-
const programInputSignal = inputBinding &&
|
|
4545
|
+
const programInputSignal = inputBinding && !inputBinding.pruned ? initValue(inputBinding) : void 0;
|
|
4504
4546
|
let extraDecls = decls;
|
|
4505
4547
|
const styleFile = getStyleFile(program.hub.file);
|
|
4506
4548
|
if (styleFile) {
|
|
@@ -4534,7 +4576,10 @@ var dom_default = {
|
|
|
4534
4576
|
const { walks: walks2, writes: writes2, decls: decls2 } = getSectionMeta(childSection);
|
|
4535
4577
|
const setup = getSetup(childSection);
|
|
4536
4578
|
writeSignals(childSection);
|
|
4537
|
-
if (!childSection.downstreamBinding ||
|
|
4579
|
+
if (!childSection.downstreamBinding || bindingHasProperty(
|
|
4580
|
+
childSection.downstreamBinding.binding,
|
|
4581
|
+
childSection.downstreamBinding.properties
|
|
4582
|
+
)) {
|
|
4538
4583
|
if (getSectionParentIsOwner(childSection)) {
|
|
4539
4584
|
setBranchRendererArgs(childSection, [
|
|
4540
4585
|
writes2,
|
|
@@ -4660,7 +4705,7 @@ var html_default = {
|
|
|
4660
4705
|
const sectionDynamicSubscribers = /* @__PURE__ */ new Set();
|
|
4661
4706
|
forEach(section.hoisted, (binding) => {
|
|
4662
4707
|
for (const hoistedBinding of binding.hoists.values()) {
|
|
4663
|
-
if (hoistedBinding.
|
|
4708
|
+
if (hoistedBinding.reads.size) {
|
|
4664
4709
|
getHTMLSectionStatements(hoistedBinding.section).push(
|
|
4665
4710
|
import_compiler24.types.variableDeclaration("const", [
|
|
4666
4711
|
import_compiler24.types.variableDeclarator(
|
|
@@ -5215,7 +5260,7 @@ var program_default = {
|
|
|
5215
5260
|
finalizeReferences();
|
|
5216
5261
|
const programExtra = program.node.extra;
|
|
5217
5262
|
const paramsBinding = programExtra.binding;
|
|
5218
|
-
if (paramsBinding &&
|
|
5263
|
+
if (paramsBinding && !paramsBinding.pruned) {
|
|
5219
5264
|
programExtra.domExports.params = getBindingPropTree(paramsBinding);
|
|
5220
5265
|
}
|
|
5221
5266
|
}
|
|
@@ -5408,40 +5453,39 @@ var [getTagDownstreams] = createSectionState(
|
|
|
5408
5453
|
() => /* @__PURE__ */ new Map()
|
|
5409
5454
|
);
|
|
5410
5455
|
function setTagDownstream(tag, binding) {
|
|
5411
|
-
|
|
5456
|
+
if (binding) {
|
|
5457
|
+
getTagDownstreams(getSection(tag)).set(tag, binding);
|
|
5458
|
+
}
|
|
5412
5459
|
}
|
|
5413
5460
|
function finalizeTagDownstreams(section) {
|
|
5414
5461
|
for (const [tag, binding] of getTagDownstreams(section)) {
|
|
5415
|
-
crawlSectionsAndSetBinding(
|
|
5416
|
-
tag,
|
|
5417
|
-
binding,
|
|
5418
|
-
binding ? getBindingPropTree(binding) : void 0
|
|
5419
|
-
);
|
|
5462
|
+
crawlSectionsAndSetBinding(tag, binding);
|
|
5420
5463
|
}
|
|
5421
5464
|
}
|
|
5422
|
-
function crawlSectionsAndSetBinding(tag, binding,
|
|
5423
|
-
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5465
|
+
function crawlSectionsAndSetBinding(tag, binding, properties, skip2) {
|
|
5424
5466
|
if (!skip2) {
|
|
5425
5467
|
const contentSection = getSectionForBody(tag.get("body"));
|
|
5426
5468
|
if (contentSection) {
|
|
5427
|
-
contentSection.downstreamBinding =
|
|
5469
|
+
contentSection.downstreamBinding = {
|
|
5470
|
+
binding,
|
|
5471
|
+
properties: concat(properties, "content")
|
|
5472
|
+
};
|
|
5428
5473
|
}
|
|
5429
5474
|
}
|
|
5475
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
5476
|
+
if (!attrTagLookup) return;
|
|
5477
|
+
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5430
5478
|
for (const child of attrTags2) {
|
|
5431
5479
|
if (child.isMarkoTag()) {
|
|
5432
5480
|
if ((0, import_babel_utils19.isAttributeTag)(child)) {
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
}
|
|
5440
|
-
} else {
|
|
5441
|
-
crawlSectionsAndSetBinding(child, binding, void 0);
|
|
5442
|
-
}
|
|
5481
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
5482
|
+
crawlSectionsAndSetBinding(
|
|
5483
|
+
child,
|
|
5484
|
+
binding,
|
|
5485
|
+
concat(properties, attrTagMeta.name)
|
|
5486
|
+
);
|
|
5443
5487
|
} else {
|
|
5444
|
-
crawlSectionsAndSetBinding(child, binding,
|
|
5488
|
+
crawlSectionsAndSetBinding(child, binding, properties, true);
|
|
5445
5489
|
}
|
|
5446
5490
|
}
|
|
5447
5491
|
}
|
|
@@ -5628,7 +5672,7 @@ var native_tag_default = {
|
|
|
5628
5672
|
const valueExtra = attr.value.extra ??= {};
|
|
5629
5673
|
if (import_compiler33.types.isMarkoAttribute(attr)) {
|
|
5630
5674
|
if (seen[attr.name]) {
|
|
5631
|
-
|
|
5675
|
+
dropNodes(attr.value);
|
|
5632
5676
|
continue;
|
|
5633
5677
|
}
|
|
5634
5678
|
seen[attr.name] = attr;
|
|
@@ -6619,7 +6663,7 @@ var for_default = {
|
|
|
6619
6663
|
if (isAttrTag) return;
|
|
6620
6664
|
const bodySection = startSection(tagBody);
|
|
6621
6665
|
if (!bodySection) {
|
|
6622
|
-
|
|
6666
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
6623
6667
|
return;
|
|
6624
6668
|
}
|
|
6625
6669
|
const nodeBinding = getOptimizedOnlyChildNodeBinding(tag, tagSection);
|
|
@@ -6634,7 +6678,7 @@ var for_default = {
|
|
|
6634
6678
|
const keyBinding = paramsBinding.propertyAliases.get(
|
|
6635
6679
|
forType === "of" ? "1" : "0"
|
|
6636
6680
|
);
|
|
6637
|
-
if (keyBinding) {
|
|
6681
|
+
if (keyBinding && !getKnownAttrValues(tag.node).by) {
|
|
6638
6682
|
keyBinding.type = 7 /* constant */;
|
|
6639
6683
|
keyBinding.scopeAccessor = getAccessorProp().LoopKey;
|
|
6640
6684
|
}
|
|
@@ -6944,15 +6988,14 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6944
6988
|
|
|
6945
6989
|
// src/translator/util/translate-attrs.ts
|
|
6946
6990
|
var contentProps = /* @__PURE__ */ new WeakSet();
|
|
6947
|
-
function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "content") {
|
|
6948
|
-
const templateExports = propTree && !propTree.rest ? propTree.props : void 0;
|
|
6991
|
+
function translateAttrs(tag, propTree = true, skip2, statements = [], contentKey = "content") {
|
|
6949
6992
|
const properties = [];
|
|
6950
6993
|
const attrTagLookup = tag.node.extra?.attributeTags;
|
|
6951
6994
|
const seen = new Set(skip2);
|
|
6952
6995
|
if (attrTagLookup) {
|
|
6953
6996
|
for (const name2 in attrTagLookup) {
|
|
6954
6997
|
const attrTagMeta = attrTagLookup[name2];
|
|
6955
|
-
if (!seen.has(attrTagMeta.name) &&
|
|
6998
|
+
if (!seen.has(attrTagMeta.name) && getKnownFromPropTree(propTree, attrTagMeta.name)) {
|
|
6956
6999
|
seen.add(attrTagMeta.name);
|
|
6957
7000
|
if (attrTagMeta.dynamic) {
|
|
6958
7001
|
statements.push(
|
|
@@ -6982,13 +7025,13 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6982
7025
|
i,
|
|
6983
7026
|
attrTagLookup,
|
|
6984
7027
|
statements,
|
|
6985
|
-
|
|
7028
|
+
propTree,
|
|
6986
7029
|
contentKey
|
|
6987
7030
|
);
|
|
6988
7031
|
} else {
|
|
6989
7032
|
const translatedAttrTag = translateAttrs(
|
|
6990
7033
|
child,
|
|
6991
|
-
|
|
7034
|
+
getKnownFromPropTree(propTree, attrTagMeta.name),
|
|
6992
7035
|
void 0,
|
|
6993
7036
|
statements,
|
|
6994
7037
|
contentKey
|
|
@@ -7030,14 +7073,14 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
7030
7073
|
i,
|
|
7031
7074
|
attrTagLookup,
|
|
7032
7075
|
statements,
|
|
7033
|
-
|
|
7076
|
+
propTree,
|
|
7034
7077
|
contentKey
|
|
7035
7078
|
);
|
|
7036
7079
|
}
|
|
7037
7080
|
}
|
|
7038
7081
|
}
|
|
7039
7082
|
}
|
|
7040
|
-
if (!seen.has(contentKey) &&
|
|
7083
|
+
if (!seen.has(contentKey) && getKnownFromPropTree(propTree, contentKey)) {
|
|
7041
7084
|
const contentExpression = buildContent(tag.get("body"));
|
|
7042
7085
|
if (contentExpression) {
|
|
7043
7086
|
const contentProp = import_compiler36.types.objectProperty(
|
|
@@ -7055,7 +7098,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
7055
7098
|
const { value } = attr;
|
|
7056
7099
|
if (import_compiler36.types.isMarkoSpreadAttribute(attr)) {
|
|
7057
7100
|
properties.push(import_compiler36.types.spreadElement(value));
|
|
7058
|
-
} else if (!seen.has(attr.name) &&
|
|
7101
|
+
} else if (!seen.has(attr.name) && getKnownFromPropTree(propTree, attr.name)) {
|
|
7059
7102
|
seen.add(attr.name);
|
|
7060
7103
|
properties.push(toObjectProperty(attr.name, value));
|
|
7061
7104
|
}
|
|
@@ -7070,15 +7113,16 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
7070
7113
|
}
|
|
7071
7114
|
}
|
|
7072
7115
|
}
|
|
7073
|
-
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements,
|
|
7116
|
+
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, propTree, contentKey = "content") {
|
|
7074
7117
|
const tag = attrTags2[index];
|
|
7075
7118
|
if (tag.isMarkoTag()) {
|
|
7076
7119
|
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
7077
7120
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
7078
|
-
|
|
7121
|
+
const attrTagExport = getKnownFromPropTree(propTree, attrTagMeta.name);
|
|
7122
|
+
if (attrTagExport && attrTagMeta.dynamic) {
|
|
7079
7123
|
const translatedAttrTag = translateAttrs(
|
|
7080
7124
|
tag,
|
|
7081
|
-
|
|
7125
|
+
attrTagExport,
|
|
7082
7126
|
void 0,
|
|
7083
7127
|
statements,
|
|
7084
7128
|
contentKey
|
|
@@ -7120,7 +7164,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7120
7164
|
index,
|
|
7121
7165
|
attrTagLookup,
|
|
7122
7166
|
statements,
|
|
7123
|
-
|
|
7167
|
+
propTree,
|
|
7124
7168
|
contentKey
|
|
7125
7169
|
);
|
|
7126
7170
|
case "for": {
|
|
@@ -7129,7 +7173,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7129
7173
|
index,
|
|
7130
7174
|
attrTagLookup,
|
|
7131
7175
|
statements,
|
|
7132
|
-
|
|
7176
|
+
propTree,
|
|
7133
7177
|
contentKey
|
|
7134
7178
|
);
|
|
7135
7179
|
}
|
|
@@ -7141,14 +7185,14 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
7141
7185
|
function propsToExpression(props) {
|
|
7142
7186
|
return props.length === 1 && import_compiler36.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler36.types.objectExpression(props);
|
|
7143
7187
|
}
|
|
7144
|
-
function translateForAttrTag(attrTags2, index, attrTagLookup, statements,
|
|
7188
|
+
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, propTree, contentKey) {
|
|
7145
7189
|
const forTag = attrTags2[index];
|
|
7146
7190
|
const bodyStatements = [];
|
|
7147
7191
|
addAllAttrTagsAsDynamic(
|
|
7148
7192
|
forTag,
|
|
7149
7193
|
attrTagLookup,
|
|
7150
7194
|
bodyStatements,
|
|
7151
|
-
|
|
7195
|
+
propTree,
|
|
7152
7196
|
contentKey
|
|
7153
7197
|
);
|
|
7154
7198
|
statements.push(
|
|
@@ -7161,7 +7205,7 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
7161
7205
|
);
|
|
7162
7206
|
return index;
|
|
7163
7207
|
}
|
|
7164
|
-
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements,
|
|
7208
|
+
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, propTree, contentKey) {
|
|
7165
7209
|
const ifTag = attrTags2[index];
|
|
7166
7210
|
const consequentStatements = [];
|
|
7167
7211
|
let ifStatement = import_compiler36.types.ifStatement(
|
|
@@ -7173,7 +7217,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7173
7217
|
ifTag,
|
|
7174
7218
|
attrTagLookup,
|
|
7175
7219
|
consequentStatements,
|
|
7176
|
-
|
|
7220
|
+
propTree,
|
|
7177
7221
|
contentKey
|
|
7178
7222
|
);
|
|
7179
7223
|
let nextIndex = index + 1;
|
|
@@ -7189,7 +7233,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7189
7233
|
nextTag,
|
|
7190
7234
|
attrTagLookup,
|
|
7191
7235
|
alternateStatements,
|
|
7192
|
-
|
|
7236
|
+
propTree,
|
|
7193
7237
|
contentKey
|
|
7194
7238
|
);
|
|
7195
7239
|
if (testValue) {
|
|
@@ -7210,7 +7254,7 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
7210
7254
|
}
|
|
7211
7255
|
return nextIndex - 1;
|
|
7212
7256
|
}
|
|
7213
|
-
function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements,
|
|
7257
|
+
function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements, propTree, contentKey) {
|
|
7214
7258
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
7215
7259
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
7216
7260
|
i = addDynamicAttrTagStatements(
|
|
@@ -7218,14 +7262,11 @@ function addAllAttrTagsAsDynamic(tag, attrTagLookup, statements, templateExports
|
|
|
7218
7262
|
i,
|
|
7219
7263
|
attrTagLookup,
|
|
7220
7264
|
statements,
|
|
7221
|
-
|
|
7265
|
+
propTree,
|
|
7222
7266
|
contentKey
|
|
7223
7267
|
);
|
|
7224
7268
|
}
|
|
7225
7269
|
}
|
|
7226
|
-
function usesExport(templateExports, name2) {
|
|
7227
|
-
return !templateExports || !!templateExports[name2];
|
|
7228
|
-
}
|
|
7229
7270
|
function findObjectProperty(name2, props) {
|
|
7230
7271
|
for (const prop of props) {
|
|
7231
7272
|
if (prop.type === "ObjectProperty") {
|
|
@@ -7544,7 +7585,7 @@ function finalizeKnownTags(section) {
|
|
|
7544
7585
|
function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
7545
7586
|
const inputExpr = {};
|
|
7546
7587
|
if (!propTree) {
|
|
7547
|
-
|
|
7588
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
7548
7589
|
return inputExpr;
|
|
7549
7590
|
}
|
|
7550
7591
|
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
@@ -7562,7 +7603,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7562
7603
|
for (const arg of tag.node.arguments) {
|
|
7563
7604
|
const argExport = propTree.props[i];
|
|
7564
7605
|
if (!argExport) {
|
|
7565
|
-
|
|
7606
|
+
dropNodes(arg);
|
|
7566
7607
|
continue;
|
|
7567
7608
|
}
|
|
7568
7609
|
const argValueExtra = arg.extra ??= {};
|
|
@@ -7582,7 +7623,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7582
7623
|
} else {
|
|
7583
7624
|
const args = tag.node.arguments;
|
|
7584
7625
|
tag.node.arguments = null;
|
|
7585
|
-
|
|
7626
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
7586
7627
|
tag.node.arguments = args;
|
|
7587
7628
|
}
|
|
7588
7629
|
return inputExpr;
|
|
@@ -7601,10 +7642,12 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7601
7642
|
const known = inputExpr.known = {};
|
|
7602
7643
|
const attrTagLookup = analyzeAttributeTags(tag);
|
|
7603
7644
|
const seen = /* @__PURE__ */ new Set();
|
|
7604
|
-
const
|
|
7645
|
+
const remaining = new Set(getAllKnownPropNames(propTree));
|
|
7646
|
+
const dropReferenceNodes = [];
|
|
7647
|
+
let restReferenceNodes;
|
|
7605
7648
|
if (attrTagLookup) {
|
|
7606
7649
|
const nodeReferencesByGroup = /* @__PURE__ */ new Map();
|
|
7607
|
-
const
|
|
7650
|
+
const analyzeDynamicAttrTagChildGroup = (group, child) => {
|
|
7608
7651
|
const referenceNodes = getAllTagReferenceNodes(child.node);
|
|
7609
7652
|
const groupReferences = nodeReferencesByGroup.get(group);
|
|
7610
7653
|
if (groupReferences) {
|
|
@@ -7624,35 +7667,44 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7624
7667
|
if (child.isMarkoTag()) {
|
|
7625
7668
|
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7626
7669
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7627
|
-
const
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
}
|
|
7670
|
+
const childAttrExport = getKnownFromPropTree(
|
|
7671
|
+
propTree,
|
|
7672
|
+
attrTagMeta.name
|
|
7673
|
+
);
|
|
7674
|
+
if (!childAttrExport) {
|
|
7675
|
+
getAllTagReferenceNodes(child.node, dropReferenceNodes);
|
|
7676
|
+
} else if (attrTagMeta.dynamic) {
|
|
7677
|
+
analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
|
|
7678
|
+
} else if (childAttrExport === true) {
|
|
7679
|
+
getAllTagReferenceNodes(child.node, restReferenceNodes ||= []);
|
|
7680
|
+
known[attrTagMeta.name] = {
|
|
7681
|
+
value: rootTagExtra
|
|
7682
|
+
};
|
|
7683
|
+
} else if (childAttrExport.props) {
|
|
7684
|
+
remaining.delete(attrTagMeta.name);
|
|
7685
|
+
known[attrTagMeta.name] = analyzeAttrs(
|
|
7686
|
+
rootTagExtra,
|
|
7687
|
+
section,
|
|
7688
|
+
child,
|
|
7689
|
+
childAttrExport,
|
|
7690
|
+
rootAttrExprs
|
|
7691
|
+
);
|
|
7640
7692
|
} else {
|
|
7641
|
-
|
|
7693
|
+
analyzeDynamicAttrTagChildGroup(attrTagMeta.group, child);
|
|
7642
7694
|
}
|
|
7643
7695
|
} else {
|
|
7644
7696
|
const group = child.node.extra.attributeTagGroup;
|
|
7645
7697
|
let childUsesGroupProp = false;
|
|
7646
7698
|
for (const name2 of group) {
|
|
7647
|
-
if (propTree
|
|
7699
|
+
if (getKnownFromPropTree(propTree, attrTagLookup[name2].name)) {
|
|
7648
7700
|
childUsesGroupProp = true;
|
|
7649
7701
|
break;
|
|
7650
7702
|
}
|
|
7651
7703
|
}
|
|
7652
7704
|
if (childUsesGroupProp) {
|
|
7653
|
-
|
|
7705
|
+
analyzeDynamicAttrTagChildGroup(group, child);
|
|
7654
7706
|
} else {
|
|
7655
|
-
|
|
7707
|
+
getAllTagReferenceNodes(child.node, dropReferenceNodes);
|
|
7656
7708
|
}
|
|
7657
7709
|
}
|
|
7658
7710
|
}
|
|
@@ -7664,126 +7716,146 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7664
7716
|
referenceNodes
|
|
7665
7717
|
}
|
|
7666
7718
|
] of nodeReferencesByGroup) {
|
|
7667
|
-
const groupExtra = mergeReferences(section, node, referenceNodes);
|
|
7668
|
-
const groupKnownValue = { value: groupExtra };
|
|
7669
7719
|
let bindings;
|
|
7670
|
-
|
|
7720
|
+
let hasRest = false;
|
|
7671
7721
|
for (const tagName of group) {
|
|
7672
7722
|
const attrName = tagName.slice(1);
|
|
7673
|
-
const templateExportAttr = propTree
|
|
7674
|
-
if (
|
|
7675
|
-
|
|
7723
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attrName);
|
|
7724
|
+
if (templateExportAttr === true) {
|
|
7725
|
+
hasRest = true;
|
|
7676
7726
|
break;
|
|
7727
|
+
} else {
|
|
7728
|
+
bindings = bindingUtil.add(bindings, templateExportAttr.binding);
|
|
7729
|
+
}
|
|
7730
|
+
}
|
|
7731
|
+
if (hasRest) {
|
|
7732
|
+
const groupKnownValue2 = {
|
|
7733
|
+
value: rootTagExtra
|
|
7734
|
+
};
|
|
7735
|
+
restReferenceNodes ||= [];
|
|
7736
|
+
for (const node2 of referenceNodes) {
|
|
7737
|
+
restReferenceNodes.push(node2);
|
|
7738
|
+
}
|
|
7739
|
+
for (const name2 of group) {
|
|
7740
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7741
|
+
known[attrTagMeta.name] = groupKnownValue2;
|
|
7677
7742
|
}
|
|
7678
|
-
|
|
7743
|
+
continue;
|
|
7679
7744
|
}
|
|
7745
|
+
const groupExtra = mergeReferences(section, node, referenceNodes);
|
|
7746
|
+
const groupKnownValue = { value: groupExtra };
|
|
7747
|
+
rootAttrExprs.add(groupExtra);
|
|
7680
7748
|
forEach(bindings, (binding) => {
|
|
7681
7749
|
setBindingDownstream(binding, groupExtra);
|
|
7682
7750
|
});
|
|
7683
7751
|
for (const name2 of group) {
|
|
7684
|
-
|
|
7752
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
7753
|
+
remaining.delete(attrTagMeta.name);
|
|
7754
|
+
known[attrTagMeta.name] = groupKnownValue;
|
|
7685
7755
|
}
|
|
7686
7756
|
}
|
|
7687
7757
|
}
|
|
7688
|
-
|
|
7758
|
+
const contentExport = getKnownFromPropTree(propTree, "content");
|
|
7759
|
+
if (contentExport && !seen.has("content")) {
|
|
7689
7760
|
const bodySection = getSectionForBody(tag.get("body"));
|
|
7690
7761
|
if (bodySection) {
|
|
7691
7762
|
seen.add("content");
|
|
7692
|
-
|
|
7763
|
+
if (contentExport === true) {
|
|
7764
|
+
known.content = { value: rootTagExtra };
|
|
7765
|
+
} else {
|
|
7766
|
+
remaining.delete("content");
|
|
7767
|
+
known.content = { value: void 0 };
|
|
7768
|
+
}
|
|
7693
7769
|
}
|
|
7694
7770
|
}
|
|
7695
|
-
let
|
|
7771
|
+
let knownSpread;
|
|
7696
7772
|
let spreadReferenceNodes;
|
|
7697
7773
|
const { attributes } = tag.node;
|
|
7698
7774
|
for (let i = attributes.length; i--; ) {
|
|
7699
7775
|
const attr = attributes[i];
|
|
7700
7776
|
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7701
|
-
const templateExportAttr =
|
|
7777
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attr.name);
|
|
7702
7778
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7703
|
-
|
|
7779
|
+
dropReferenceNodes.push(attr.value);
|
|
7704
7780
|
continue;
|
|
7705
7781
|
}
|
|
7706
|
-
const attrExtra = attr.value.extra ??= {};
|
|
7707
7782
|
seen.add(attr.name);
|
|
7708
|
-
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7783
|
+
if (spreadReferenceNodes) {
|
|
7784
|
+
spreadReferenceNodes.push(attr.value);
|
|
7785
|
+
} else if (templateExportAttr === true) {
|
|
7786
|
+
(restReferenceNodes ||= []).push(attr.value);
|
|
7787
|
+
known[attr.name] = { value: rootTagExtra };
|
|
7788
|
+
} else {
|
|
7789
|
+
const attrExtra = attr.value.extra ??= {};
|
|
7790
|
+
remaining.delete(attr.name);
|
|
7791
|
+
known[attr.name] = { value: attrExtra };
|
|
7792
|
+
rootAttrExprs.add(attrExtra);
|
|
7793
|
+
setBindingDownstream(templateExportAttr.binding, attrExtra);
|
|
7794
|
+
if (knownSpread && !includes(knownSpread.binding.excludeProperties, attr.name)) {
|
|
7795
|
+
const propBinding = getOrCreatePropertyAlias(
|
|
7796
|
+
knownSpread.binding,
|
|
7797
|
+
attr.name
|
|
7798
|
+
);
|
|
7799
|
+
addRead(attrExtra, void 0, propBinding, section);
|
|
7800
|
+
}
|
|
7715
7801
|
}
|
|
7716
|
-
}
|
|
7717
|
-
if (spreadReferenceNodes) {
|
|
7802
|
+
} else if (spreadReferenceNodes) {
|
|
7718
7803
|
spreadReferenceNodes.push(attr.value);
|
|
7719
|
-
} else
|
|
7720
|
-
|
|
7721
|
-
if (
|
|
7722
|
-
|
|
7723
|
-
dropRead(attr.value.extra);
|
|
7724
|
-
}
|
|
7804
|
+
} else {
|
|
7805
|
+
knownSpread = hasAllKnownProps(propTree) ? getSingleKnownSpread(attributes) : void 0;
|
|
7806
|
+
if (knownSpread) {
|
|
7807
|
+
dropNodes(attr.value);
|
|
7725
7808
|
} else {
|
|
7726
|
-
spreadReferenceNodes = [attr.value
|
|
7809
|
+
(spreadReferenceNodes = restReferenceNodes || []).push(attr.value);
|
|
7727
7810
|
}
|
|
7728
|
-
} else {
|
|
7729
|
-
const attrValueExtra = attr.value.extra ??= {};
|
|
7730
|
-
known[attr.name] = { value: attrValueExtra };
|
|
7731
|
-
rootAttrExprs.add(attrValueExtra);
|
|
7732
7811
|
}
|
|
7733
7812
|
}
|
|
7734
|
-
if (
|
|
7735
|
-
for (const prop of
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7813
|
+
if (knownSpread) {
|
|
7814
|
+
for (const prop of remaining) {
|
|
7815
|
+
const propBinding = getOrCreatePropertyAlias(knownSpread.binding, prop);
|
|
7816
|
+
const propExtra = { section };
|
|
7817
|
+
const templateExportAttr = getKnownFromPropTree(propTree, prop);
|
|
7818
|
+
known[prop] = { value: propExtra };
|
|
7819
|
+
rootAttrExprs.add(propExtra);
|
|
7820
|
+
addRead(propExtra, propExtra, propBinding, section);
|
|
7821
|
+
setBindingDownstream(
|
|
7822
|
+
templateExportAttr === true ? propTree.rest.binding : templateExportAttr.binding,
|
|
7823
|
+
propExtra
|
|
7824
|
+
);
|
|
7743
7825
|
}
|
|
7744
7826
|
} else if (spreadReferenceNodes) {
|
|
7745
|
-
|
|
7746
|
-
seen.size ? createBinding(
|
|
7747
|
-
generateUid(`${getTagName(tag)}_attrs`),
|
|
7748
|
-
propTree.binding.type,
|
|
7749
|
-
propTree.binding.section,
|
|
7750
|
-
propTree.binding,
|
|
7751
|
-
void 0,
|
|
7752
|
-
fromIter(seen),
|
|
7753
|
-
spreadReferenceNodes[0].loc,
|
|
7754
|
-
true
|
|
7755
|
-
) : propTree.binding,
|
|
7827
|
+
if (remaining.size || propTree.rest && !propTree.rest.props) {
|
|
7756
7828
|
inputExpr.value = mergeReferences(
|
|
7757
7829
|
section,
|
|
7758
7830
|
tag.node,
|
|
7759
7831
|
spreadReferenceNodes
|
|
7760
|
-
)
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
unknownReferences.flat()
|
|
7768
|
-
);
|
|
7769
|
-
setBindingDownstream(propTree.binding, restExtra);
|
|
7770
|
-
if (knownSpreadBinding && !propTree.rest.props) {
|
|
7771
|
-
addRead(restExtra, void 0, knownSpreadBinding, section);
|
|
7832
|
+
);
|
|
7833
|
+
setBindingDownstream(
|
|
7834
|
+
propTree.rest?.binding || propTree.binding,
|
|
7835
|
+
inputExpr.value
|
|
7836
|
+
);
|
|
7837
|
+
} else {
|
|
7838
|
+
dropNodes(spreadReferenceNodes);
|
|
7772
7839
|
}
|
|
7773
|
-
} else {
|
|
7774
|
-
|
|
7840
|
+
} else if (restReferenceNodes) {
|
|
7841
|
+
inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
|
|
7842
|
+
setBindingDownstream(propTree.rest.binding, inputExpr.value);
|
|
7775
7843
|
}
|
|
7844
|
+
dropNodes(dropReferenceNodes);
|
|
7776
7845
|
return inputExpr;
|
|
7777
7846
|
}
|
|
7778
|
-
function
|
|
7847
|
+
function getSingleKnownSpread(attributes) {
|
|
7779
7848
|
let binding;
|
|
7849
|
+
let extra;
|
|
7780
7850
|
for (let i = attributes.length; i--; ) {
|
|
7781
7851
|
const attr = attributes[i];
|
|
7782
|
-
if (attr.type === "MarkoSpreadAttribute" ? binding || !(binding = attr.value.extra?.spreadFrom) : binding && !includes(binding.excludeProperties, attr.name)) {
|
|
7852
|
+
if (attr.type === "MarkoSpreadAttribute" ? binding || !(binding = (extra = attr.value.extra)?.spreadFrom) : binding && !includes(binding.excludeProperties, attr.name)) {
|
|
7783
7853
|
return;
|
|
7784
7854
|
}
|
|
7785
7855
|
}
|
|
7786
|
-
|
|
7856
|
+
if (binding) {
|
|
7857
|
+
return { extra, binding };
|
|
7858
|
+
}
|
|
7787
7859
|
}
|
|
7788
7860
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
7789
7861
|
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
@@ -7855,275 +7927,420 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7855
7927
|
writeAttrsToSignals(tag, attrPropsTree, `${importAlias}_input`, info);
|
|
7856
7928
|
}
|
|
7857
7929
|
}
|
|
7858
|
-
function
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7930
|
+
function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
|
|
7931
|
+
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7932
|
+
const translatedAttrs = translateAttrs(
|
|
7933
|
+
tag,
|
|
7934
|
+
true,
|
|
7935
|
+
propTree.rest && new Set(toIter(propTree.rest.binding.excludeProperties))
|
|
7936
|
+
);
|
|
7937
|
+
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7938
|
+
if (translatedAttrs.statements.length) {
|
|
7939
|
+
addStatement(
|
|
7940
|
+
"render",
|
|
7941
|
+
info.tagSection,
|
|
7942
|
+
referencedBindings,
|
|
7943
|
+
translatedAttrs.statements
|
|
7944
|
+
);
|
|
7945
|
+
}
|
|
7946
|
+
if ((0, import_babel_utils25.isAttributeTag)(tag)) {
|
|
7947
|
+
const attrTagName = getTagName(tag);
|
|
7948
|
+
const parentTag = tag.parentPath;
|
|
7949
|
+
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
7950
|
+
if (repeated) {
|
|
7951
|
+
let attrTagCallsForTag = (info.attrTagCallsByTag ||= /* @__PURE__ */ new Map()).get(
|
|
7952
|
+
parentTag
|
|
7953
|
+
);
|
|
7954
|
+
if (!attrTagCallsForTag) {
|
|
7955
|
+
info.attrTagCallsByTag.set(parentTag, attrTagCallsForTag = /* @__PURE__ */ new Map());
|
|
7956
|
+
}
|
|
7957
|
+
const attrTagCall = attrTagCallsForTag.get(attrTagName);
|
|
7958
|
+
if (attrTagCall) {
|
|
7959
|
+
attrTagCall.expression = callRuntime(
|
|
7960
|
+
"attrTags",
|
|
7961
|
+
attrTagCall.expression,
|
|
7962
|
+
translatedProps
|
|
7884
7963
|
);
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7964
|
+
return;
|
|
7965
|
+
} else {
|
|
7966
|
+
attrTagCallsForTag.set(
|
|
7967
|
+
attrTagName,
|
|
7968
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
7969
|
+
callRuntime("attrTag", translatedProps)
|
|
7970
|
+
)
|
|
7971
|
+
);
|
|
7972
|
+
}
|
|
7973
|
+
} else {
|
|
7974
|
+
translatedProps = callRuntime("attrTag", translatedProps);
|
|
7975
|
+
}
|
|
7976
|
+
}
|
|
7977
|
+
addStatement(
|
|
7978
|
+
"render",
|
|
7979
|
+
info.tagSection,
|
|
7980
|
+
referencedBindings,
|
|
7981
|
+
import_compiler37.types.expressionStatement(
|
|
7982
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
7983
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7984
|
+
translatedProps
|
|
7985
|
+
])
|
|
7986
|
+
),
|
|
7987
|
+
void 0,
|
|
7988
|
+
true
|
|
7989
|
+
);
|
|
7990
|
+
}
|
|
7991
|
+
function translateAttrTag(tag, attrTagMeta, info, statements) {
|
|
7992
|
+
const translatedAttrs = translateAttrs(tag, true, void 0, statements);
|
|
7993
|
+
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7994
|
+
const attrTagName = getTagName(tag);
|
|
7995
|
+
const parentTag = tag.parentPath;
|
|
7996
|
+
if (attrTagMeta.repeated) {
|
|
7997
|
+
let attrTagCallsForTag = (info.attrTagCallsByTag ||= /* @__PURE__ */ new Map()).get(
|
|
7998
|
+
parentTag
|
|
7999
|
+
);
|
|
8000
|
+
if (!attrTagCallsForTag) {
|
|
8001
|
+
info.attrTagCallsByTag.set(parentTag, attrTagCallsForTag = /* @__PURE__ */ new Map());
|
|
8002
|
+
}
|
|
8003
|
+
const attrTagCall = attrTagCallsForTag.get(attrTagName);
|
|
8004
|
+
if (attrTagCall) {
|
|
8005
|
+
attrTagCall.expression = callRuntime(
|
|
8006
|
+
"attrTags",
|
|
8007
|
+
attrTagCall.expression,
|
|
8008
|
+
translatedProps
|
|
8009
|
+
);
|
|
8010
|
+
return;
|
|
8011
|
+
} else {
|
|
8012
|
+
attrTagCallsForTag.set(
|
|
8013
|
+
attrTagName,
|
|
8014
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
8015
|
+
callRuntime("attrTag", translatedProps)
|
|
8016
|
+
)
|
|
8017
|
+
);
|
|
8018
|
+
}
|
|
8019
|
+
} else {
|
|
8020
|
+
translatedProps = callRuntime("attrTag", translatedProps);
|
|
8021
|
+
}
|
|
8022
|
+
return translatedProps;
|
|
8023
|
+
}
|
|
8024
|
+
function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
8025
|
+
if (!propTree.props) {
|
|
8026
|
+
applyAttrObject(
|
|
8027
|
+
tag,
|
|
8028
|
+
propTree,
|
|
8029
|
+
info.getBindingIdentifier(propTree.binding, importAlias),
|
|
8030
|
+
info
|
|
8031
|
+
);
|
|
8032
|
+
return;
|
|
8033
|
+
}
|
|
8034
|
+
const attrTagLookup = analyzeAttributeTags(tag);
|
|
8035
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8036
|
+
const tagReferencedBindings = tag.node.extra?.referencedBindings;
|
|
8037
|
+
const remaining = new Set(getAllKnownPropNames(propTree));
|
|
8038
|
+
let restProps;
|
|
8039
|
+
if (attrTagLookup) {
|
|
8040
|
+
const attrTags2 = tag.get("attributeTags");
|
|
8041
|
+
const statementsByGroup = /* @__PURE__ */ new Map();
|
|
8042
|
+
const translateDynamicAttrTagChildInGroup = (group, index) => {
|
|
8043
|
+
const child = attrTags2[index];
|
|
8044
|
+
let statements = statementsByGroup.get(group)?.statements;
|
|
8045
|
+
if (!statements) {
|
|
8046
|
+
statements = [];
|
|
8047
|
+
statementsByGroup.set(group, {
|
|
8048
|
+
referencedBindings: child.node.extra?.referencedBindings,
|
|
8049
|
+
statements
|
|
8050
|
+
});
|
|
8051
|
+
}
|
|
8052
|
+
return addDynamicAttrTagStatements(
|
|
8053
|
+
attrTags2,
|
|
8054
|
+
index,
|
|
8055
|
+
attrTagLookup,
|
|
8056
|
+
statements,
|
|
8057
|
+
propTree
|
|
8058
|
+
);
|
|
8059
|
+
};
|
|
8060
|
+
for (const attrTagName in attrTagLookup) {
|
|
8061
|
+
seen.add(attrTagLookup[attrTagName].name);
|
|
8062
|
+
}
|
|
8063
|
+
for (let i = 0; i < attrTags2.length; i++) {
|
|
8064
|
+
const child = attrTags2[i];
|
|
8065
|
+
if (child.isMarkoTag()) {
|
|
8066
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
8067
|
+
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
8068
|
+
const childAttrExport = getKnownFromPropTree(
|
|
8069
|
+
propTree,
|
|
8070
|
+
attrTagMeta.name
|
|
8071
|
+
);
|
|
8072
|
+
if (!childAttrExport) {
|
|
8073
|
+
} else if (attrTagMeta.dynamic) {
|
|
8074
|
+
i = translateDynamicAttrTagChildInGroup(attrTagMeta.group, i);
|
|
8075
|
+
} else if (childAttrExport === true) {
|
|
8076
|
+
const statements = [];
|
|
8077
|
+
const translatedAttrs = translateAttrTag(
|
|
8078
|
+
child,
|
|
8079
|
+
attrTagMeta,
|
|
8080
|
+
info,
|
|
8081
|
+
statements
|
|
8082
|
+
);
|
|
8083
|
+
addStatement(
|
|
8084
|
+
"render",
|
|
8085
|
+
info.tagSection,
|
|
8086
|
+
tagReferencedBindings,
|
|
8087
|
+
statements
|
|
8088
|
+
);
|
|
8089
|
+
if (translatedAttrs) {
|
|
8090
|
+
(restProps ||= []).push(
|
|
8091
|
+
toObjectProperty(attrTagMeta.name, translatedAttrs)
|
|
8092
|
+
);
|
|
7906
8093
|
}
|
|
7907
|
-
} else
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
8094
|
+
} else {
|
|
8095
|
+
remaining.delete(attrTagMeta.name);
|
|
8096
|
+
writeAttrsToSignals(
|
|
8097
|
+
child,
|
|
8098
|
+
childAttrExport,
|
|
8099
|
+
`${importAlias}_${attrTagMeta.name}`,
|
|
8100
|
+
info
|
|
7911
8101
|
);
|
|
7912
8102
|
}
|
|
8103
|
+
} else {
|
|
8104
|
+
const group = child.node.extra.attributeTagGroup;
|
|
8105
|
+
let childUsesGroupProp = false;
|
|
8106
|
+
for (const name2 of group) {
|
|
8107
|
+
if (getKnownFromPropTree(propTree, attrTagLookup[name2].name)) {
|
|
8108
|
+
childUsesGroupProp = true;
|
|
8109
|
+
break;
|
|
8110
|
+
}
|
|
8111
|
+
}
|
|
8112
|
+
if (childUsesGroupProp) {
|
|
8113
|
+
i = translateDynamicAttrTagChildInGroup(group, i);
|
|
8114
|
+
} else if (getTagName(child) === "if") {
|
|
8115
|
+
while (++i < attrTags2.length) {
|
|
8116
|
+
const nextTag = attrTags2[i];
|
|
8117
|
+
switch (nextTag.isMarkoTag() && getTagName(nextTag)) {
|
|
8118
|
+
case "else":
|
|
8119
|
+
case "else-if":
|
|
8120
|
+
continue;
|
|
8121
|
+
}
|
|
8122
|
+
i--;
|
|
8123
|
+
break;
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
}
|
|
8129
|
+
for (const [
|
|
8130
|
+
group,
|
|
8131
|
+
{ referencedBindings, statements }
|
|
8132
|
+
] of statementsByGroup) {
|
|
8133
|
+
const decls = [];
|
|
8134
|
+
let hasRest = false;
|
|
8135
|
+
for (const name2 of group) {
|
|
8136
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
8137
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8138
|
+
propTree,
|
|
8139
|
+
attrTagMeta.name
|
|
8140
|
+
);
|
|
8141
|
+
decls.push(import_compiler37.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
8142
|
+
if (childAttrExports === true) {
|
|
8143
|
+
hasRest = true;
|
|
7913
8144
|
}
|
|
7914
8145
|
}
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
8146
|
+
addStatement(
|
|
8147
|
+
"render",
|
|
8148
|
+
info.tagSection,
|
|
8149
|
+
hasRest ? tagReferencedBindings : referencedBindings,
|
|
8150
|
+
[import_compiler37.types.variableDeclaration("let", decls), ...statements]
|
|
8151
|
+
);
|
|
8152
|
+
if (hasRest) {
|
|
7920
8153
|
for (const name2 of group) {
|
|
7921
8154
|
const attrTagMeta = attrTagLookup[name2];
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
8155
|
+
(restProps ||= []).push(
|
|
8156
|
+
toObjectProperty(
|
|
8157
|
+
attrTagMeta.name,
|
|
8158
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
8159
|
+
)
|
|
7927
8160
|
);
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
8161
|
+
}
|
|
8162
|
+
} else {
|
|
8163
|
+
for (const name2 of group) {
|
|
8164
|
+
const attrTagMeta = attrTagLookup[name2];
|
|
8165
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8166
|
+
propTree,
|
|
8167
|
+
attrTagMeta.name
|
|
8168
|
+
);
|
|
8169
|
+
remaining.delete(attrTagMeta.name);
|
|
7933
8170
|
addStatement(
|
|
7934
8171
|
"render",
|
|
7935
8172
|
info.tagSection,
|
|
7936
8173
|
referencedBindings,
|
|
7937
8174
|
import_compiler37.types.expressionStatement(
|
|
7938
|
-
import_compiler37.types.callExpression(
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
8175
|
+
import_compiler37.types.callExpression(
|
|
8176
|
+
info.getBindingIdentifier(
|
|
8177
|
+
childAttrExports.binding,
|
|
8178
|
+
`${importAlias}_${attrTagMeta.name}`
|
|
7942
8179
|
),
|
|
7943
|
-
|
|
7944
|
-
|
|
8180
|
+
[
|
|
8181
|
+
createScopeReadExpression(
|
|
8182
|
+
info.childScopeBinding,
|
|
8183
|
+
info.tagSection
|
|
8184
|
+
),
|
|
8185
|
+
getAttrTagIdentifier(attrTagMeta)
|
|
8186
|
+
]
|
|
8187
|
+
)
|
|
7945
8188
|
)
|
|
7946
8189
|
);
|
|
7947
8190
|
}
|
|
7948
8191
|
}
|
|
7949
8192
|
}
|
|
7950
|
-
|
|
7951
|
-
|
|
8193
|
+
}
|
|
8194
|
+
const contentExport = getKnownFromPropTree(propTree, "content");
|
|
8195
|
+
if (!seen.has("content") && contentExport) {
|
|
8196
|
+
const bodySection = getSectionForBody(tag.get("body"));
|
|
8197
|
+
if (bodySection) {
|
|
7952
8198
|
seen.add("content");
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
);
|
|
8199
|
+
const bodyValue = import_compiler37.types.callExpression(import_compiler37.types.identifier(bodySection.name), [
|
|
8200
|
+
scopeIdentifier
|
|
8201
|
+
]);
|
|
8202
|
+
if (contentExport === true) {
|
|
8203
|
+
(restProps ||= []).push(toObjectProperty("content", bodyValue));
|
|
8204
|
+
} else {
|
|
8205
|
+
remaining.delete("content");
|
|
7958
8206
|
addStatement(
|
|
7959
8207
|
"render",
|
|
7960
8208
|
info.tagSection,
|
|
7961
8209
|
void 0,
|
|
7962
8210
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7963
8211
|
import_compiler37.types.expressionStatement(
|
|
7964
|
-
import_compiler37.types.callExpression(
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
8212
|
+
import_compiler37.types.callExpression(
|
|
8213
|
+
info.getBindingIdentifier(
|
|
8214
|
+
contentExport.binding,
|
|
8215
|
+
`${importAlias}_content`
|
|
7968
8216
|
),
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
8217
|
+
[
|
|
8218
|
+
createScopeReadExpression(
|
|
8219
|
+
info.childScopeBinding,
|
|
8220
|
+
info.tagSection
|
|
8221
|
+
),
|
|
8222
|
+
bodyValue
|
|
8223
|
+
]
|
|
8224
|
+
)
|
|
7973
8225
|
),
|
|
7974
8226
|
void 0,
|
|
7975
8227
|
true
|
|
7976
8228
|
);
|
|
7977
8229
|
}
|
|
7978
8230
|
}
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
}
|
|
7999
|
-
}
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8231
|
+
}
|
|
8232
|
+
let knownSpread;
|
|
8233
|
+
let spreadProps;
|
|
8234
|
+
const staticAttrs = [];
|
|
8235
|
+
const { attributes } = tag.node;
|
|
8236
|
+
for (let i = attributes.length; i--; ) {
|
|
8237
|
+
const attr = attributes[i];
|
|
8238
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
8239
|
+
const templateExportAttr = getKnownFromPropTree(propTree, attr.name);
|
|
8240
|
+
if (!templateExportAttr || seen.has(attr.name)) {
|
|
8241
|
+
continue;
|
|
8242
|
+
}
|
|
8243
|
+
seen.add(attr.name);
|
|
8244
|
+
if (spreadProps) {
|
|
8245
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
8246
|
+
} else if (templateExportAttr === true) {
|
|
8247
|
+
(restProps ||= []).push(toObjectProperty(attr.name, attr.value));
|
|
8248
|
+
} else {
|
|
8249
|
+
staticAttrs.push(attr);
|
|
8250
|
+
}
|
|
8251
|
+
} else if (spreadProps) {
|
|
8252
|
+
spreadProps.push(import_compiler37.types.spreadElement(attr.value));
|
|
8253
|
+
} else {
|
|
8254
|
+
knownSpread = hasAllKnownProps(propTree) ? getSingleKnownSpread(attributes) : void 0;
|
|
8255
|
+
if (!knownSpread) {
|
|
8256
|
+
(spreadProps = restProps || []).push(import_compiler37.types.spreadElement(attr.value));
|
|
8257
|
+
}
|
|
8258
|
+
}
|
|
8259
|
+
}
|
|
8260
|
+
for (let i = staticAttrs.length; i--; ) {
|
|
8261
|
+
const attr = staticAttrs[i];
|
|
8262
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8263
|
+
propTree,
|
|
8264
|
+
attr.name
|
|
8265
|
+
);
|
|
8266
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8267
|
+
childAttrExports.binding,
|
|
8268
|
+
`${importAlias}_${attr.name}`
|
|
8269
|
+
);
|
|
8270
|
+
remaining.delete(attr.name);
|
|
8271
|
+
addStatement(
|
|
8272
|
+
"render",
|
|
8273
|
+
info.tagSection,
|
|
8274
|
+
attr.value.extra?.referencedBindings,
|
|
8275
|
+
import_compiler37.types.expressionStatement(
|
|
8276
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8277
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8278
|
+
attr.value
|
|
8279
|
+
// TODO: use spreadBinding property alias after we optimize `in`
|
|
8280
|
+
])
|
|
8281
|
+
),
|
|
8282
|
+
void 0,
|
|
8283
|
+
true
|
|
8284
|
+
);
|
|
8285
|
+
}
|
|
8286
|
+
if (knownSpread) {
|
|
8287
|
+
for (const prop of remaining) {
|
|
8288
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8289
|
+
propTree,
|
|
8290
|
+
prop
|
|
8291
|
+
);
|
|
8292
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8003
8293
|
childAttrExports.binding,
|
|
8004
|
-
`${importAlias}_${
|
|
8294
|
+
`${importAlias}_${prop}`
|
|
8005
8295
|
);
|
|
8296
|
+
const propBinding = knownSpread.binding.propertyAliases.get(prop);
|
|
8006
8297
|
addStatement(
|
|
8007
8298
|
"render",
|
|
8008
8299
|
info.tagSection,
|
|
8009
|
-
|
|
8300
|
+
propBinding,
|
|
8010
8301
|
import_compiler37.types.expressionStatement(
|
|
8011
8302
|
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8012
8303
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8013
|
-
|
|
8014
|
-
attr.value
|
|
8304
|
+
createScopeReadExpression(propBinding, info.tagSection)
|
|
8015
8305
|
])
|
|
8016
8306
|
),
|
|
8017
8307
|
void 0,
|
|
8018
8308
|
true
|
|
8019
8309
|
);
|
|
8020
8310
|
}
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
const propBinding = knownSpreadBinding.propertyAliases.get(prop);
|
|
8032
|
-
addStatement(
|
|
8033
|
-
"render",
|
|
8034
|
-
info.tagSection,
|
|
8035
|
-
propBinding,
|
|
8036
|
-
import_compiler37.types.expressionStatement(
|
|
8037
|
-
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8038
|
-
createScopeReadExpression(
|
|
8039
|
-
info.childScopeBinding,
|
|
8040
|
-
info.tagSection
|
|
8041
|
-
),
|
|
8042
|
-
createScopeReadExpression(propBinding, info.tagSection)
|
|
8043
|
-
])
|
|
8044
|
-
),
|
|
8045
|
-
void 0,
|
|
8046
|
-
true
|
|
8047
|
-
);
|
|
8048
|
-
}
|
|
8049
|
-
} else {
|
|
8050
|
-
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
8051
|
-
if (spreadProps) {
|
|
8052
|
-
const spreadExpr = propsToExpression(
|
|
8053
|
-
propTree.rest ? (translatedAttrs = translateAttrs(tag, propTree, seen)).properties : spreadProps.reverse()
|
|
8054
|
-
);
|
|
8055
|
-
if (isSimpleReference(spreadExpr)) {
|
|
8056
|
-
spreadId = spreadExpr;
|
|
8057
|
-
} else {
|
|
8058
|
-
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
8059
|
-
if (translatedAttrs) {
|
|
8060
|
-
translatedAttrs.properties = [import_compiler37.types.spreadElement(spreadId)];
|
|
8061
|
-
}
|
|
8062
|
-
addStatement("render", info.tagSection, referencedBindings, [
|
|
8063
|
-
import_compiler37.types.variableDeclaration("const", [
|
|
8064
|
-
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
8065
|
-
])
|
|
8066
|
-
]);
|
|
8067
|
-
}
|
|
8068
|
-
}
|
|
8069
|
-
for (const name2 of missing) {
|
|
8070
|
-
const childAttrExports = getBindingPropTreeProp(propTree, name2);
|
|
8071
|
-
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8072
|
-
childAttrExports.binding,
|
|
8073
|
-
`${importAlias}_${name2}`
|
|
8074
|
-
);
|
|
8075
|
-
addStatement(
|
|
8076
|
-
"render",
|
|
8077
|
-
info.tagSection,
|
|
8078
|
-
spreadProps && referencedBindings,
|
|
8079
|
-
import_compiler37.types.expressionStatement(
|
|
8080
|
-
import_compiler37.types.callExpression(
|
|
8081
|
-
attrExportIdentifier,
|
|
8082
|
-
spreadId ? [
|
|
8083
|
-
createScopeReadExpression(
|
|
8084
|
-
info.childScopeBinding,
|
|
8085
|
-
info.tagSection
|
|
8086
|
-
),
|
|
8087
|
-
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
8088
|
-
] : [
|
|
8089
|
-
createScopeReadExpression(
|
|
8090
|
-
info.childScopeBinding,
|
|
8091
|
-
info.tagSection
|
|
8092
|
-
)
|
|
8093
|
-
]
|
|
8094
|
-
)
|
|
8095
|
-
)
|
|
8096
|
-
);
|
|
8097
|
-
}
|
|
8098
|
-
}
|
|
8099
|
-
}
|
|
8100
|
-
}
|
|
8101
|
-
if (!propTree.props || propTree.rest && !propTree.rest.props) {
|
|
8102
|
-
if (!translatedAttrs) {
|
|
8103
|
-
if (propTree.rest) {
|
|
8104
|
-
seen ||= /* @__PURE__ */ new Set();
|
|
8105
|
-
forEach(
|
|
8106
|
-
propTree.rest.binding.excludeProperties,
|
|
8107
|
-
(prop) => seen.add(prop)
|
|
8108
|
-
);
|
|
8109
|
-
}
|
|
8110
|
-
translatedAttrs = translateAttrs(tag, propTree.rest, seen);
|
|
8311
|
+
} else if (spreadProps) {
|
|
8312
|
+
const spreadExpr = propsToExpression(spreadProps.reverse());
|
|
8313
|
+
let spreadId = spreadExpr;
|
|
8314
|
+
if (!isSimpleReference(spreadExpr)) {
|
|
8315
|
+
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
8316
|
+
addStatement("render", info.tagSection, tagReferencedBindings, [
|
|
8317
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
8318
|
+
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
8319
|
+
])
|
|
8320
|
+
]);
|
|
8111
8321
|
}
|
|
8112
|
-
const
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8322
|
+
for (const name2 of remaining) {
|
|
8323
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8324
|
+
propTree,
|
|
8325
|
+
name2
|
|
8326
|
+
);
|
|
8327
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8328
|
+
childAttrExports.binding,
|
|
8329
|
+
`${importAlias}_${name2}`
|
|
8330
|
+
);
|
|
8118
8331
|
addStatement(
|
|
8119
8332
|
"render",
|
|
8120
8333
|
info.tagSection,
|
|
8121
|
-
|
|
8122
|
-
|
|
8334
|
+
tagReferencedBindings,
|
|
8335
|
+
import_compiler37.types.expressionStatement(
|
|
8336
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8337
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8338
|
+
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
8339
|
+
])
|
|
8340
|
+
)
|
|
8123
8341
|
);
|
|
8124
8342
|
}
|
|
8125
|
-
|
|
8126
|
-
if (propTree.rest && spreadId) {
|
|
8343
|
+
if (propTree.rest && !propTree.rest.props) {
|
|
8127
8344
|
const props = [];
|
|
8128
8345
|
const restId = import_compiler37.types.identifier(propTree.rest.binding.name);
|
|
8129
8346
|
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
@@ -8139,58 +8356,77 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
8139
8356
|
);
|
|
8140
8357
|
});
|
|
8141
8358
|
props.push(import_compiler37.types.restElement(restId));
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8359
|
+
addStatement(
|
|
8360
|
+
"render",
|
|
8361
|
+
info.tagSection,
|
|
8362
|
+
tagReferencedBindings,
|
|
8363
|
+
import_compiler37.types.expressionStatement(
|
|
8364
|
+
import_compiler37.types.callExpression(
|
|
8365
|
+
info.getBindingIdentifier(
|
|
8366
|
+
propTree.rest.binding,
|
|
8367
|
+
importAlias + "_$rest"
|
|
8368
|
+
),
|
|
8369
|
+
[
|
|
8370
|
+
createScopeReadExpression(
|
|
8371
|
+
info.childScopeBinding,
|
|
8372
|
+
info.tagSection
|
|
8373
|
+
),
|
|
8374
|
+
import_compiler37.types.callExpression(
|
|
8375
|
+
import_compiler37.types.arrowFunctionExpression([import_compiler37.types.objectPattern(props)], restId),
|
|
8376
|
+
[spreadId]
|
|
8377
|
+
)
|
|
8378
|
+
]
|
|
8379
|
+
)
|
|
8380
|
+
),
|
|
8381
|
+
void 0,
|
|
8382
|
+
true
|
|
8145
8383
|
);
|
|
8146
8384
|
}
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
const
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8385
|
+
} else {
|
|
8386
|
+
for (const name2 of remaining) {
|
|
8387
|
+
const childAttrExports = getKnownFromPropTree(
|
|
8388
|
+
propTree,
|
|
8389
|
+
name2
|
|
8390
|
+
);
|
|
8391
|
+
const attrExportIdentifier = info.getBindingIdentifier(
|
|
8392
|
+
childAttrExports.binding,
|
|
8393
|
+
`${importAlias}_${name2}`
|
|
8394
|
+
);
|
|
8395
|
+
addStatement(
|
|
8396
|
+
"render",
|
|
8397
|
+
info.tagSection,
|
|
8398
|
+
void 0,
|
|
8399
|
+
import_compiler37.types.expressionStatement(
|
|
8400
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
8401
|
+
createScopeReadExpression(info.childScopeBinding, info.tagSection)
|
|
8402
|
+
])
|
|
8403
|
+
)
|
|
8404
|
+
);
|
|
8405
|
+
}
|
|
8406
|
+
if (propTree.rest && !propTree.rest.props) {
|
|
8407
|
+
addStatement(
|
|
8408
|
+
"render",
|
|
8409
|
+
info.tagSection,
|
|
8410
|
+
tagReferencedBindings,
|
|
8411
|
+
import_compiler37.types.expressionStatement(
|
|
8412
|
+
import_compiler37.types.callExpression(
|
|
8413
|
+
info.getBindingIdentifier(
|
|
8414
|
+
propTree.rest.binding,
|
|
8415
|
+
importAlias + "_$rest"
|
|
8416
|
+
),
|
|
8417
|
+
[
|
|
8418
|
+
createScopeReadExpression(
|
|
8419
|
+
info.childScopeBinding,
|
|
8420
|
+
info.tagSection
|
|
8421
|
+
),
|
|
8422
|
+
import_compiler37.types.objectExpression(restProps || [])
|
|
8423
|
+
]
|
|
8424
|
+
)
|
|
8425
|
+
),
|
|
8426
|
+
void 0,
|
|
8427
|
+
true
|
|
8428
|
+
);
|
|
8180
8429
|
}
|
|
8181
|
-
addStatement(
|
|
8182
|
-
"render",
|
|
8183
|
-
info.tagSection,
|
|
8184
|
-
referencedBindings,
|
|
8185
|
-
import_compiler37.types.expressionStatement(
|
|
8186
|
-
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
8187
|
-
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
8188
|
-
translatedProps
|
|
8189
|
-
])
|
|
8190
|
-
),
|
|
8191
|
-
void 0,
|
|
8192
|
-
true
|
|
8193
|
-
);
|
|
8194
8430
|
}
|
|
8195
8431
|
}
|
|
8196
8432
|
function mapParamReasonToExpr(exprs, reason) {
|
|
@@ -8255,15 +8491,16 @@ function createBinding(name2, type, section, upstreamAlias, property, excludePro
|
|
|
8255
8491
|
assignmentSections: void 0,
|
|
8256
8492
|
excludeProperties,
|
|
8257
8493
|
sources: void 0,
|
|
8494
|
+
reads: /* @__PURE__ */ new Set(),
|
|
8258
8495
|
aliases: /* @__PURE__ */ new Set(),
|
|
8259
8496
|
hoists: /* @__PURE__ */ new Map(),
|
|
8260
8497
|
propertyAliases: /* @__PURE__ */ new Map(),
|
|
8261
8498
|
upstreamAlias,
|
|
8262
|
-
downstreamExpressions: /* @__PURE__ */ new Set(),
|
|
8263
8499
|
scopeOffset: void 0,
|
|
8264
8500
|
scopeAccessor: void 0,
|
|
8265
8501
|
export: void 0,
|
|
8266
|
-
nullable: excludeProperties === void 0
|
|
8502
|
+
nullable: excludeProperties === void 0,
|
|
8503
|
+
pruned: void 0
|
|
8267
8504
|
};
|
|
8268
8505
|
if (property) {
|
|
8269
8506
|
if (declared) upstreamAlias.nullable = false;
|
|
@@ -8365,18 +8602,11 @@ function trackVarReferences(tag, type, upstreamAlias) {
|
|
|
8365
8602
|
return tagVar.extra?.binding;
|
|
8366
8603
|
}
|
|
8367
8604
|
}
|
|
8368
|
-
function trackParamsReferences(body, type
|
|
8605
|
+
function trackParamsReferences(body, type) {
|
|
8369
8606
|
const params = body.node.params;
|
|
8370
8607
|
if (body.node.body.length && params.length) {
|
|
8371
|
-
const
|
|
8372
|
-
|
|
8373
|
-
if (canonicalUpstreamAlias) {
|
|
8374
|
-
section = canonicalUpstreamAlias.section;
|
|
8375
|
-
type = canonicalUpstreamAlias.type;
|
|
8376
|
-
} else {
|
|
8377
|
-
section = getOrCreateSection(body);
|
|
8378
|
-
}
|
|
8379
|
-
const paramsBinding = canonicalUpstreamAlias || ((body.node.extra ??= {}).binding = createBinding(
|
|
8608
|
+
const section = getOrCreateSection(body);
|
|
8609
|
+
const paramsBinding = (body.node.extra ??= {}).binding = createBinding(
|
|
8380
8610
|
generateUid("params"),
|
|
8381
8611
|
type,
|
|
8382
8612
|
section,
|
|
@@ -8384,8 +8614,11 @@ function trackParamsReferences(body, type, upstreamAlias) {
|
|
|
8384
8614
|
void 0,
|
|
8385
8615
|
void 0,
|
|
8386
8616
|
params[0].loc
|
|
8387
|
-
)
|
|
8388
|
-
|
|
8617
|
+
);
|
|
8618
|
+
const bodySection = getSectionForBody(body);
|
|
8619
|
+
if (bodySection) {
|
|
8620
|
+
bodySection.params = paramsBinding;
|
|
8621
|
+
}
|
|
8389
8622
|
for (let i = 0; i < params.length; i++) {
|
|
8390
8623
|
const param = params[i];
|
|
8391
8624
|
if (param.type === "RestElement") {
|
|
@@ -8541,6 +8774,7 @@ function trackAssignment(assignment, binding) {
|
|
|
8541
8774
|
true
|
|
8542
8775
|
);
|
|
8543
8776
|
idExtra.assignmentTo = changeBinding;
|
|
8777
|
+
changeBinding.pruned = false;
|
|
8544
8778
|
addReadToExpression(id, changeBinding);
|
|
8545
8779
|
}
|
|
8546
8780
|
}
|
|
@@ -8588,7 +8822,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8588
8822
|
scope,
|
|
8589
8823
|
section,
|
|
8590
8824
|
patternBinding,
|
|
8591
|
-
|
|
8825
|
+
void 0,
|
|
8592
8826
|
excludeProperties
|
|
8593
8827
|
);
|
|
8594
8828
|
} else {
|
|
@@ -8680,13 +8914,48 @@ function trackReference(referencePath, binding) {
|
|
|
8680
8914
|
}
|
|
8681
8915
|
addReadToExpression(root, reference);
|
|
8682
8916
|
}
|
|
8683
|
-
var [getMergedReferences] = createProgramState(
|
|
8684
|
-
() => /* @__PURE__ */ new Map()
|
|
8685
|
-
);
|
|
8686
8917
|
function mergeReferences(section, target, nodes) {
|
|
8687
8918
|
const targetExtra = target.extra ??= {};
|
|
8919
|
+
const readsByExpression = getReadsByExpression();
|
|
8920
|
+
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
8921
|
+
let reads = readsByExpression.get(targetExtra);
|
|
8922
|
+
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
8923
|
+
let { isEffect } = targetExtra;
|
|
8924
|
+
for (const node of nodes) {
|
|
8925
|
+
if (!node) continue;
|
|
8926
|
+
const extra = node.extra ??= {};
|
|
8927
|
+
extra.merged = targetExtra;
|
|
8928
|
+
if (isReferencedExtra(extra)) {
|
|
8929
|
+
const additionalReads = readsByExpression.get(extra);
|
|
8930
|
+
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
8931
|
+
isEffect ||= extra.isEffect;
|
|
8932
|
+
if (additionalReads) {
|
|
8933
|
+
forEach(additionalReads, (read) => {
|
|
8934
|
+
read.binding.reads.delete(extra);
|
|
8935
|
+
read.binding.reads.add(targetExtra);
|
|
8936
|
+
});
|
|
8937
|
+
reads = concat(reads, additionalReads);
|
|
8938
|
+
readsByExpression.delete(extra);
|
|
8939
|
+
}
|
|
8940
|
+
if (additionalExprFnReads) {
|
|
8941
|
+
if (exprFnReads) {
|
|
8942
|
+
for (const [key, value] of additionalExprFnReads) {
|
|
8943
|
+
exprFnReads.set(key, value);
|
|
8944
|
+
}
|
|
8945
|
+
} else {
|
|
8946
|
+
fnReadsByExpression.set(
|
|
8947
|
+
targetExtra,
|
|
8948
|
+
exprFnReads = new Map(additionalExprFnReads)
|
|
8949
|
+
);
|
|
8950
|
+
}
|
|
8951
|
+
}
|
|
8952
|
+
} else if (extra?.pruned) {
|
|
8953
|
+
throw new Error("Cannot merged a dropped reference.");
|
|
8954
|
+
}
|
|
8955
|
+
}
|
|
8956
|
+
readsByExpression.set(targetExtra, reads);
|
|
8957
|
+
targetExtra.isEffect = isEffect;
|
|
8688
8958
|
targetExtra.section = section;
|
|
8689
|
-
getMergedReferences().set(target, nodes);
|
|
8690
8959
|
return targetExtra;
|
|
8691
8960
|
}
|
|
8692
8961
|
function compareReferences(a, b) {
|
|
@@ -8710,53 +8979,20 @@ function finalizeReferences() {
|
|
|
8710
8979
|
const bindings = getBindings();
|
|
8711
8980
|
const readsByExpression = getReadsByExpression();
|
|
8712
8981
|
const fnReadsByExpression = getFunctionReadsByExpression();
|
|
8713
|
-
const mergedReferences = getMergedReferences();
|
|
8714
|
-
if (mergedReferences.size) {
|
|
8715
|
-
for (const [target, nodes] of mergedReferences) {
|
|
8716
|
-
const targetExtra = target.extra;
|
|
8717
|
-
let reads = readsByExpression.get(targetExtra);
|
|
8718
|
-
let exprFnReads = fnReadsByExpression.get(targetExtra);
|
|
8719
|
-
let { isEffect } = targetExtra;
|
|
8720
|
-
for (const node of nodes) {
|
|
8721
|
-
const extra = node?.extra;
|
|
8722
|
-
if (extra) {
|
|
8723
|
-
setCanonicalExtra(extra, targetExtra);
|
|
8724
|
-
if (isReferencedExtra(extra)) {
|
|
8725
|
-
const additionalReads = readsByExpression.get(extra);
|
|
8726
|
-
const additionalExprFnReads = fnReadsByExpression.get(extra);
|
|
8727
|
-
isEffect ||= extra.isEffect;
|
|
8728
|
-
if (additionalReads) {
|
|
8729
|
-
reads = concat(reads, additionalReads);
|
|
8730
|
-
readsByExpression.delete(extra);
|
|
8731
|
-
}
|
|
8732
|
-
if (additionalExprFnReads) {
|
|
8733
|
-
if (exprFnReads) {
|
|
8734
|
-
for (const [key, value] of additionalExprFnReads) {
|
|
8735
|
-
exprFnReads.set(key, value);
|
|
8736
|
-
}
|
|
8737
|
-
} else {
|
|
8738
|
-
fnReadsByExpression.set(
|
|
8739
|
-
targetExtra,
|
|
8740
|
-
exprFnReads = new Map(additionalExprFnReads)
|
|
8741
|
-
);
|
|
8742
|
-
}
|
|
8743
|
-
}
|
|
8744
|
-
}
|
|
8745
|
-
}
|
|
8746
|
-
}
|
|
8747
|
-
readsByExpression.set(targetExtra, reads);
|
|
8748
|
-
targetExtra.isEffect = isEffect;
|
|
8749
|
-
}
|
|
8750
|
-
}
|
|
8751
8982
|
const intersectionsBySection = /* @__PURE__ */ new Map();
|
|
8752
8983
|
for (const [expr, reads] of readsByExpression) {
|
|
8753
8984
|
if (isReferencedExtra(expr)) {
|
|
8754
8985
|
const { referencedBindings, constantBindings } = resolveReferencedBindings(expr, reads, intersectionsBySection);
|
|
8755
8986
|
expr.referencedBindings = referencedBindings;
|
|
8756
|
-
if (
|
|
8987
|
+
if (expr.isEffect) {
|
|
8757
8988
|
forEach(referencedBindings, (binding) => {
|
|
8758
|
-
binding.
|
|
8989
|
+
addSerializeReason(binding.section, true, binding);
|
|
8990
|
+
});
|
|
8991
|
+
forEach(constantBindings, (binding) => {
|
|
8992
|
+
addSerializeReason(binding.section, true, binding);
|
|
8759
8993
|
});
|
|
8994
|
+
}
|
|
8995
|
+
if (referencedBindings) {
|
|
8760
8996
|
const exprFnReads = fnReadsByExpression.get(expr);
|
|
8761
8997
|
if (exprFnReads) {
|
|
8762
8998
|
for (const [fn, fnReads] of exprFnReads) {
|
|
@@ -8771,16 +9007,13 @@ function finalizeReferences() {
|
|
|
8771
9007
|
}
|
|
8772
9008
|
}
|
|
8773
9009
|
}
|
|
8774
|
-
if (constantBindings) {
|
|
8775
|
-
forEach(constantBindings, (binding) => {
|
|
8776
|
-
binding.downstreamExpressions.add(expr);
|
|
8777
|
-
});
|
|
8778
|
-
}
|
|
8779
9010
|
}
|
|
8780
9011
|
}
|
|
8781
9012
|
for (const binding of bindings) {
|
|
8782
|
-
if (binding.type !== 0 /* dom */
|
|
8783
|
-
pruneBinding(
|
|
9013
|
+
if (binding.type !== 0 /* dom */) {
|
|
9014
|
+
if (pruneBinding(binding)) {
|
|
9015
|
+
bindings.delete(binding);
|
|
9016
|
+
}
|
|
8784
9017
|
}
|
|
8785
9018
|
}
|
|
8786
9019
|
forEachSection(finalizeTagDownstreams);
|
|
@@ -8803,11 +9036,7 @@ function finalizeReferences() {
|
|
|
8803
9036
|
section.bindings,
|
|
8804
9037
|
getCanonicalBinding(binding)
|
|
8805
9038
|
);
|
|
8806
|
-
for (const {
|
|
8807
|
-
referencedBindings,
|
|
8808
|
-
isEffect,
|
|
8809
|
-
section: section2
|
|
8810
|
-
} of binding.downstreamExpressions) {
|
|
9039
|
+
for (const { isEffect, section: section2 } of binding.reads) {
|
|
8811
9040
|
if (section2 !== binding.section) {
|
|
8812
9041
|
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
|
8813
9042
|
canonicalUpstreamAlias.closureSections = sectionUtil.add(
|
|
@@ -8831,12 +9060,6 @@ function finalizeReferences() {
|
|
|
8831
9060
|
);
|
|
8832
9061
|
}
|
|
8833
9062
|
}
|
|
8834
|
-
if (isEffect) {
|
|
8835
|
-
forEach(
|
|
8836
|
-
referencedBindings,
|
|
8837
|
-
(binding2) => addSerializeReason(binding2.section, true, binding2)
|
|
8838
|
-
);
|
|
8839
|
-
}
|
|
8840
9063
|
}
|
|
8841
9064
|
}
|
|
8842
9065
|
forEachSection((section) => {
|
|
@@ -8947,7 +9170,7 @@ function finalizeReferences() {
|
|
|
8947
9170
|
finalizeFunctionRegistry();
|
|
8948
9171
|
const referencedExprs = /* @__PURE__ */ new Set();
|
|
8949
9172
|
for (const binding of bindings) {
|
|
8950
|
-
for (const expr of binding.
|
|
9173
|
+
for (const expr of binding.reads) {
|
|
8951
9174
|
referencedExprs.add(expr);
|
|
8952
9175
|
}
|
|
8953
9176
|
}
|
|
@@ -9006,7 +9229,6 @@ function finalizeReferences() {
|
|
|
9006
9229
|
programExtra.returnValueExpr
|
|
9007
9230
|
);
|
|
9008
9231
|
}
|
|
9009
|
-
mergedReferences.clear();
|
|
9010
9232
|
readsByExpression.clear();
|
|
9011
9233
|
fnReadsByExpression.clear();
|
|
9012
9234
|
}
|
|
@@ -9167,12 +9389,10 @@ var [getReadsByExpression] = createProgramState(
|
|
|
9167
9389
|
var [getFunctionReadsByExpression] = createProgramState(
|
|
9168
9390
|
() => /* @__PURE__ */ new Map()
|
|
9169
9391
|
);
|
|
9170
|
-
function addRead(exprExtra,
|
|
9392
|
+
function addRead(exprExtra, extra, binding, section) {
|
|
9171
9393
|
const readsByExpression = getReadsByExpression();
|
|
9172
|
-
const read = {
|
|
9173
|
-
|
|
9174
|
-
extra: readExtra
|
|
9175
|
-
};
|
|
9394
|
+
const read = { binding, extra };
|
|
9395
|
+
binding.reads.add(exprExtra);
|
|
9176
9396
|
exprExtra.section = section;
|
|
9177
9397
|
readsByExpression.set(
|
|
9178
9398
|
exprExtra,
|
|
@@ -9180,8 +9400,28 @@ function addRead(exprExtra, readExtra, binding, section) {
|
|
|
9180
9400
|
);
|
|
9181
9401
|
return read;
|
|
9182
9402
|
}
|
|
9183
|
-
function
|
|
9184
|
-
|
|
9403
|
+
function dropNodes(node) {
|
|
9404
|
+
if (Array.isArray(node)) {
|
|
9405
|
+
for (const item of node) {
|
|
9406
|
+
dropExtra(item.extra ??= {});
|
|
9407
|
+
}
|
|
9408
|
+
} else {
|
|
9409
|
+
dropExtra(node.extra ??= {});
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9412
|
+
function dropExtra(exprExtra) {
|
|
9413
|
+
if (exprExtra.merged) {
|
|
9414
|
+
throw new Error("Cannot drop a merged reference");
|
|
9415
|
+
}
|
|
9416
|
+
const readsByExpr = getReadsByExpression();
|
|
9417
|
+
const reads = readsByExpr.get(exprExtra);
|
|
9418
|
+
exprExtra.pruned = true;
|
|
9419
|
+
if (reads) {
|
|
9420
|
+
readsByExpr.delete(exprExtra);
|
|
9421
|
+
forEach(reads, (read) => {
|
|
9422
|
+
read.binding.reads.delete(exprExtra);
|
|
9423
|
+
});
|
|
9424
|
+
}
|
|
9185
9425
|
}
|
|
9186
9426
|
function addReadToExpression(root, binding) {
|
|
9187
9427
|
const { node } = root;
|
|
@@ -9204,15 +9444,6 @@ function addReadToExpression(root, binding) {
|
|
|
9204
9444
|
exprFnReads.set(fnExtra, push(exprFnReads.get(fnExtra), read));
|
|
9205
9445
|
}
|
|
9206
9446
|
}
|
|
9207
|
-
function dropReferences(node) {
|
|
9208
|
-
if (Array.isArray(node)) {
|
|
9209
|
-
for (const item of node) {
|
|
9210
|
-
(item.extra ??= {}).pruned = true;
|
|
9211
|
-
}
|
|
9212
|
-
} else {
|
|
9213
|
-
(node.extra ??= {}).pruned = true;
|
|
9214
|
-
}
|
|
9215
|
-
}
|
|
9216
9447
|
function getCanonicalBinding(binding) {
|
|
9217
9448
|
const alias = binding.upstreamAlias;
|
|
9218
9449
|
if (alias && binding.property === void 0 && binding.excludeProperties === void 0) {
|
|
@@ -9397,28 +9628,38 @@ function hasNonConstantPropertyAlias(ref) {
|
|
|
9397
9628
|
}
|
|
9398
9629
|
return false;
|
|
9399
9630
|
}
|
|
9400
|
-
function pruneBinding(
|
|
9401
|
-
|
|
9631
|
+
function pruneBinding(binding) {
|
|
9632
|
+
if (binding.pruned !== void 0) {
|
|
9633
|
+
return binding.pruned;
|
|
9634
|
+
}
|
|
9635
|
+
for (const read of binding.reads) {
|
|
9636
|
+
let upstream = binding.upstreamAlias;
|
|
9637
|
+
while (upstream && !upstream.reads.has(read)) {
|
|
9638
|
+
upstream = upstream.upstreamAlias;
|
|
9639
|
+
}
|
|
9640
|
+
if (upstream) {
|
|
9641
|
+
binding.reads.delete(read);
|
|
9642
|
+
}
|
|
9643
|
+
}
|
|
9644
|
+
let shouldPrune = !binding.reads.size;
|
|
9402
9645
|
if (binding.hoists.size) {
|
|
9403
9646
|
shouldPrune = false;
|
|
9404
9647
|
}
|
|
9405
9648
|
for (const alias of binding.aliases) {
|
|
9406
|
-
if (pruneBinding(
|
|
9649
|
+
if (pruneBinding(alias)) {
|
|
9407
9650
|
binding.aliases.delete(alias);
|
|
9408
9651
|
} else if (alias.type !== 7 /* constant */) {
|
|
9409
9652
|
shouldPrune = false;
|
|
9410
9653
|
}
|
|
9411
9654
|
}
|
|
9412
9655
|
for (const [key, alias] of binding.propertyAliases) {
|
|
9413
|
-
if (pruneBinding(
|
|
9656
|
+
if (pruneBinding(alias)) {
|
|
9414
9657
|
binding.propertyAliases.delete(key);
|
|
9415
9658
|
} else if (alias.type !== 7 /* constant */) {
|
|
9416
9659
|
shouldPrune = false;
|
|
9417
9660
|
}
|
|
9418
9661
|
}
|
|
9419
|
-
|
|
9420
|
-
bindings.delete(binding);
|
|
9421
|
-
}
|
|
9662
|
+
binding.pruned = shouldPrune;
|
|
9422
9663
|
return shouldPrune;
|
|
9423
9664
|
}
|
|
9424
9665
|
function resolveReferencedBindingsInFunction(refs, reads) {
|
|
@@ -9604,6 +9845,7 @@ function getCanonicalExtra(extra) {
|
|
|
9604
9845
|
}
|
|
9605
9846
|
var serializeReasonCache = /* @__PURE__ */ new WeakMap();
|
|
9606
9847
|
function getAllSerializeReasonsForExtra(extra) {
|
|
9848
|
+
if (extra.isEffect) return true;
|
|
9607
9849
|
let reason = serializeReasonCache.get(extra);
|
|
9608
9850
|
if (reason === false) return;
|
|
9609
9851
|
if (reason === void 0) {
|
|
@@ -9614,7 +9856,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9614
9856
|
forEach(extra.downstream, (binding) => {
|
|
9615
9857
|
reason = mergeSerializeReasons(
|
|
9616
9858
|
reason,
|
|
9617
|
-
getAllSerializeReasonsForBinding(binding)
|
|
9859
|
+
getAllSerializeReasonsForBinding(binding, true)
|
|
9618
9860
|
);
|
|
9619
9861
|
});
|
|
9620
9862
|
}
|
|
@@ -9624,32 +9866,34 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9624
9866
|
}
|
|
9625
9867
|
return reason;
|
|
9626
9868
|
}
|
|
9627
|
-
function getAllSerializeReasonsForBinding(binding) {
|
|
9869
|
+
function getAllSerializeReasonsForBinding(binding, properties) {
|
|
9628
9870
|
let reason = serializeReasonCache.get(binding);
|
|
9629
|
-
if (reason === false) return;
|
|
9630
9871
|
if (reason === void 0) {
|
|
9631
9872
|
reason = getSerializeReason(binding.section, binding);
|
|
9632
9873
|
if (reason !== true) {
|
|
9633
|
-
|
|
9634
|
-
|
|
9635
|
-
|
|
9636
|
-
|
|
9637
|
-
|
|
9638
|
-
|
|
9874
|
+
serializeReasonCache.set(binding, reason || false);
|
|
9875
|
+
if (properties !== true && binding.upstreamAlias) {
|
|
9876
|
+
reason = mergeSerializeReasons(
|
|
9877
|
+
reason,
|
|
9878
|
+
getAllSerializeReasonsForBinding(
|
|
9879
|
+
binding.upstreamAlias,
|
|
9880
|
+
binding.property
|
|
9881
|
+
)
|
|
9882
|
+
);
|
|
9639
9883
|
}
|
|
9640
9884
|
if (reason !== true) {
|
|
9641
|
-
for (const
|
|
9885
|
+
for (const expr of binding.reads) {
|
|
9642
9886
|
reason = mergeSerializeReasons(
|
|
9643
9887
|
reason,
|
|
9644
|
-
|
|
9888
|
+
getAllSerializeReasonsForExtra(expr)
|
|
9645
9889
|
);
|
|
9646
9890
|
if (reason === true) break;
|
|
9647
9891
|
}
|
|
9648
9892
|
if (reason !== true) {
|
|
9649
|
-
for (const
|
|
9893
|
+
for (const alias of binding.aliases) {
|
|
9650
9894
|
reason = mergeSerializeReasons(
|
|
9651
9895
|
reason,
|
|
9652
|
-
getAllSerializeReasonsForBinding(
|
|
9896
|
+
getAllSerializeReasonsForBinding(alias, properties)
|
|
9653
9897
|
);
|
|
9654
9898
|
if (reason === true) break;
|
|
9655
9899
|
}
|
|
@@ -9660,11 +9904,56 @@ function getAllSerializeReasonsForBinding(binding) {
|
|
|
9660
9904
|
serializeReasonCache.set(binding, reason);
|
|
9661
9905
|
}
|
|
9662
9906
|
}
|
|
9907
|
+
if (reason === false) {
|
|
9908
|
+
reason = void 0;
|
|
9909
|
+
}
|
|
9910
|
+
if (properties !== void 0) {
|
|
9911
|
+
if (properties === true) {
|
|
9912
|
+
if (reason !== true) {
|
|
9913
|
+
for (const propBinding of binding.propertyAliases.values()) {
|
|
9914
|
+
reason = mergeSerializeReasons(
|
|
9915
|
+
reason,
|
|
9916
|
+
getAllSerializeReasonsForBinding(propBinding, true)
|
|
9917
|
+
);
|
|
9918
|
+
if (reason === true) break;
|
|
9919
|
+
}
|
|
9920
|
+
}
|
|
9921
|
+
} else {
|
|
9922
|
+
let property;
|
|
9923
|
+
let rest2;
|
|
9924
|
+
if (Array.isArray(properties)) {
|
|
9925
|
+
property = properties[0];
|
|
9926
|
+
rest2 = properties.length === 2 ? properties[1] : properties.slice(1);
|
|
9927
|
+
} else {
|
|
9928
|
+
property = properties;
|
|
9929
|
+
}
|
|
9930
|
+
if (includes(binding.excludeProperties, property)) {
|
|
9931
|
+
reason = void 0;
|
|
9932
|
+
} else {
|
|
9933
|
+
const propBinding = binding.propertyAliases.get(property);
|
|
9934
|
+
if (propBinding) {
|
|
9935
|
+
reason = mergeSerializeReasons(
|
|
9936
|
+
reason,
|
|
9937
|
+
getAllSerializeReasonsForBinding(propBinding, rest2)
|
|
9938
|
+
);
|
|
9939
|
+
}
|
|
9940
|
+
if (reason !== true) {
|
|
9941
|
+
for (const alias of binding.aliases) {
|
|
9942
|
+
const propBinding2 = alias.propertyAliases.get(property);
|
|
9943
|
+
if (propBinding2) {
|
|
9944
|
+
reason = mergeSerializeReasons(
|
|
9945
|
+
reason,
|
|
9946
|
+
getAllSerializeReasonsForBinding(propBinding2, rest2)
|
|
9947
|
+
);
|
|
9948
|
+
if (reason === true) break;
|
|
9949
|
+
}
|
|
9950
|
+
}
|
|
9951
|
+
}
|
|
9952
|
+
}
|
|
9953
|
+
}
|
|
9954
|
+
}
|
|
9663
9955
|
return reason;
|
|
9664
9956
|
}
|
|
9665
|
-
function setCanonicalExtra(extra, merged) {
|
|
9666
|
-
extra.merged = merged;
|
|
9667
|
-
}
|
|
9668
9957
|
function addNumericPropertiesUntil(props, len) {
|
|
9669
9958
|
let result = props;
|
|
9670
9959
|
for (let i = len; i--; ) {
|
|
@@ -9883,7 +10172,7 @@ var const_default = {
|
|
|
9883
10172
|
const valueExtra = evaluate(valueAttr.value);
|
|
9884
10173
|
const upstreamAlias = import_compiler41.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
9885
10174
|
if (upstreamAlias) {
|
|
9886
|
-
|
|
10175
|
+
dropNodes(valueAttr.value);
|
|
9887
10176
|
}
|
|
9888
10177
|
const binding = trackVarReferences(tag, 5 /* derived */, upstreamAlias);
|
|
9889
10178
|
if (binding) {
|
|
@@ -9994,7 +10283,7 @@ var define_default = {
|
|
|
9994
10283
|
const bodySection = startSection(tagBody);
|
|
9995
10284
|
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
|
9996
10285
|
if (!varBinding) {
|
|
9997
|
-
|
|
10286
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
9998
10287
|
return;
|
|
9999
10288
|
}
|
|
10000
10289
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
@@ -10011,13 +10300,13 @@ var define_default = {
|
|
|
10011
10300
|
}
|
|
10012
10301
|
if (ref.parent.type === "MarkoTag" && ref.parent.name === ref.node) {
|
|
10013
10302
|
(ref.parent.extra ??= {}).defineBodySection = bodySection;
|
|
10014
|
-
|
|
10303
|
+
dropNodes(ref.parent.name);
|
|
10015
10304
|
} else {
|
|
10016
10305
|
allDirectReferences = false;
|
|
10017
10306
|
}
|
|
10018
10307
|
}
|
|
10019
10308
|
if (allDirectReferences) {
|
|
10020
|
-
|
|
10309
|
+
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
10021
10310
|
return;
|
|
10022
10311
|
}
|
|
10023
10312
|
}
|
|
@@ -10904,7 +11193,7 @@ var let_default = {
|
|
|
10904
11193
|
// src/translator/core/lifecycle.ts
|
|
10905
11194
|
var import_compiler50 = require("@marko/compiler");
|
|
10906
11195
|
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
10907
|
-
var
|
|
11196
|
+
var [getIndex, setIndex] = createSectionState("lifecycleIndex", () => 0);
|
|
10908
11197
|
var lifecycle_default = {
|
|
10909
11198
|
analyze(tag) {
|
|
10910
11199
|
(0, import_babel_utils39.assertNoArgs)(tag);
|
|
@@ -10918,12 +11207,7 @@ var lifecycle_default = {
|
|
|
10918
11207
|
tag.node,
|
|
10919
11208
|
getAllTagReferenceNodes(tag.node)
|
|
10920
11209
|
);
|
|
10921
|
-
|
|
10922
|
-
generateUid("lifecycle"),
|
|
10923
|
-
5 /* derived */,
|
|
10924
|
-
section
|
|
10925
|
-
);
|
|
10926
|
-
binding.downstreamExpressions.add(tagExtra);
|
|
11210
|
+
tagExtra.isEffect = true;
|
|
10927
11211
|
if (node.attributes.length === 0) {
|
|
10928
11212
|
throw tag.get("name").buildCodeFrameError(
|
|
10929
11213
|
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) requires at least one attribute."
|
|
@@ -10935,7 +11219,6 @@ var lifecycle_default = {
|
|
|
10935
11219
|
"The [`<lifecycle>` tag](https://markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://markojs.com/docs/reference/language#spread-attributes)."
|
|
10936
11220
|
);
|
|
10937
11221
|
}
|
|
10938
|
-
(attr.value.extra ??= {}).isEffect = true;
|
|
10939
11222
|
}
|
|
10940
11223
|
(0, import_babel_utils39.getProgram)().node.extra.isInteractive = true;
|
|
10941
11224
|
},
|
|
@@ -10945,16 +11228,17 @@ var lifecycle_default = {
|
|
|
10945
11228
|
const section = getSection(tag);
|
|
10946
11229
|
const tagExtra = node.extra;
|
|
10947
11230
|
const { referencedBindings } = tagExtra;
|
|
10948
|
-
const lifecycleAttrsRef = tagExtra[kRef];
|
|
10949
11231
|
if (isOutputDOM()) {
|
|
10950
11232
|
const translatedAttrs = translateAttrs(tag);
|
|
11233
|
+
const index = getIndex(section);
|
|
11234
|
+
setIndex(section, index + 1);
|
|
10951
11235
|
translatedAttrs.statements.push(
|
|
10952
11236
|
import_compiler50.types.expressionStatement(
|
|
10953
11237
|
callRuntime(
|
|
10954
11238
|
"_lifecycle",
|
|
10955
11239
|
scopeIdentifier,
|
|
10956
|
-
|
|
10957
|
-
|
|
11240
|
+
propsToExpression(translatedAttrs.properties),
|
|
11241
|
+
index > 0 ? import_compiler50.types.numericLiteral(index) : void 0
|
|
10958
11242
|
)
|
|
10959
11243
|
)
|
|
10960
11244
|
);
|
|
@@ -11100,7 +11384,7 @@ var script_default = {
|
|
|
11100
11384
|
}
|
|
11101
11385
|
}
|
|
11102
11386
|
if (!seenValueAttr) {
|
|
11103
|
-
|
|
11387
|
+
dropNodes(getAllTagReferenceNodes(node));
|
|
11104
11388
|
}
|
|
11105
11389
|
},
|
|
11106
11390
|
translate: {
|