marko 6.4.15 → 6.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/compat.feat.js +1 -1
- package/dist/debug/dom/compat.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +1 -1
- package/dist/debug/dom/lazy.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-sfzdCRAg.js → dom-BLoTKI2r.js} +3 -3
- package/dist/debug/{dom-BORByF2b.mjs → dom-DlBA4dCe.mjs} +2 -2
- package/dist/debug/dom.js +3 -2
- package/dist/debug/dom.mjs +2 -2
- package/dist/debug/html/compat.feat.js +1 -1
- package/dist/debug/html/compat.feat.mjs +1 -1
- package/dist/debug/{html-C17tAtch.mjs → html-DM7X2D_b.mjs} +33 -29
- package/dist/debug/{html-7qRi22mK.js → html-Du0z056z.js} +33 -29
- package/dist/debug/html.js +1 -1
- package/dist/debug/html.mjs +1 -1
- package/dist/dom/catch.feat.js +1 -1
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/compat.feat.js +1 -1
- package/dist/dom/compat.feat.mjs +1 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.js +1 -1
- package/dist/dom/lazy.feat.mjs +1 -1
- package/dist/dom/placeholder.feat.js +1 -1
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/{dom-DRiewpRL.js → dom-BRtFOIF-.js} +2 -2
- package/dist/{dom-DKn1bCPC.mjs → dom-Cqajrs_w.mjs} +2 -2
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +2 -2
- package/dist/dom.mjs +2 -2
- package/dist/html/assets.d.ts +1 -1
- package/dist/html/compat.feat.js +1 -1
- package/dist/html/compat.feat.mjs +1 -1
- package/dist/html/control-flow.d.ts +9 -9
- package/dist/html/for.d.ts +3 -3
- package/dist/html/serializer.d.ts +2 -0
- package/dist/html/writer.d.ts +3 -2
- package/dist/{html-BaAyg2TB.js → html-4A3vJpIT.js} +31 -31
- package/dist/{html-6w1jd6wm.mjs → html-C3dQGQ2x.mjs} +31 -31
- package/dist/html.js +1 -1
- package/dist/html.mjs +1 -1
- package/dist/translator/index.js +251 -160
- package/dist/translator/interop/build-aggregate-error.d.ts +1 -1
- package/dist/translator/util/cyclic-memo.d.ts +2 -0
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/util/solve-reasons.d.ts +6 -4
- package/dist/translator/util/write-guard.d.ts +2 -0
- package/dist/translator/util/writer.d.ts +1 -2
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -591,6 +591,9 @@ function joinRepeatable(compare, a, b) {
|
|
|
591
591
|
const compareResult = compare(a, b);
|
|
592
592
|
return compareResult === 0 ? a : compareResult < 0 ? [a, b] : [b, a];
|
|
593
593
|
}
|
|
594
|
+
function at(data, index) {
|
|
595
|
+
return Array.isArray(data) ? data[index] : index ? void 0 : data;
|
|
596
|
+
}
|
|
594
597
|
function first(data) {
|
|
595
598
|
return Array.isArray(data) ? data[0] : data;
|
|
596
599
|
}
|
|
@@ -1021,20 +1024,30 @@ function resetPassMemos() {
|
|
|
1021
1024
|
for (const reset of passResets) reset();
|
|
1022
1025
|
}
|
|
1023
1026
|
function createPassPathMemo(compute, cycleAnswer) {
|
|
1024
|
-
const
|
|
1027
|
+
const getKey = createPathKeys();
|
|
1025
1028
|
const memo = createPassMemo(([key, path]) => compute(key, path), cycleAnswer);
|
|
1029
|
+
return (key, path) => memo(getKey(key, path));
|
|
1030
|
+
}
|
|
1031
|
+
function createPathKeys() {
|
|
1032
|
+
const keys = /* @__PURE__ */ new WeakMap();
|
|
1026
1033
|
return (key, path) => {
|
|
1027
1034
|
let pathKeys = keys.get(key);
|
|
1028
|
-
if (!pathKeys) keys.set(key, pathKeys =
|
|
1029
|
-
|
|
1030
|
-
return memo(reduce(path, ensurePropKeys, pathKeys).value ??= [key, path]);
|
|
1035
|
+
if (!pathKeys) keys.set(key, pathKeys = createPathKeysRecord());
|
|
1036
|
+
return path === true ? pathKeys.all ??= [key, path] : reduce(path, ensurePropKeys, pathKeys).value ??= [key, path];
|
|
1031
1037
|
};
|
|
1032
1038
|
}
|
|
1033
1039
|
function ensurePropKeys(pathKeys, property) {
|
|
1034
1040
|
let next = pathKeys.properties?.get(property);
|
|
1035
|
-
if (!next) (pathKeys.properties ??= /* @__PURE__ */ new Map()).set(property, next =
|
|
1041
|
+
if (!next) (pathKeys.properties ??= /* @__PURE__ */ new Map()).set(property, next = createPathKeysRecord());
|
|
1036
1042
|
return next;
|
|
1037
1043
|
}
|
|
1044
|
+
function createPathKeysRecord() {
|
|
1045
|
+
return {
|
|
1046
|
+
value: void 0,
|
|
1047
|
+
all: void 0,
|
|
1048
|
+
properties: void 0
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1038
1051
|
// src/translator/util/for-each-identifier.ts
|
|
1039
1052
|
function forEachIdentifier(node, cb) {
|
|
1040
1053
|
switch (node.type) {
|
|
@@ -1951,6 +1964,7 @@ const pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
|
1951
1964
|
"_try",
|
|
1952
1965
|
"_dynamic_tag",
|
|
1953
1966
|
"_dynamic_tag_content",
|
|
1967
|
+
"_content",
|
|
1954
1968
|
"_content_closures",
|
|
1955
1969
|
"_template",
|
|
1956
1970
|
"_return_setup",
|
|
@@ -1979,17 +1993,9 @@ const pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
|
1979
1993
|
"_load_media_trigger",
|
|
1980
1994
|
"_load_race_trigger"
|
|
1981
1995
|
]);
|
|
1982
|
-
const [getRuntimeImports] = createOutputState(() => /* @__PURE__ */ new Map());
|
|
1983
1996
|
function importRuntime(name) {
|
|
1984
1997
|
assertTranslate("importRuntime", name);
|
|
1985
|
-
|
|
1986
|
-
const imports = getRuntimeImports();
|
|
1987
|
-
let localName = imports.get(name);
|
|
1988
|
-
if (!localName) {
|
|
1989
|
-
localName = (0, _marko_compiler_babel_utils.importNamed)((0, _marko_compiler_babel_utils.getFile)(), getRuntimePath(output), name).name;
|
|
1990
|
-
imports.set(name, localName);
|
|
1991
|
-
}
|
|
1992
|
-
return _marko_compiler.types.identifier(localName);
|
|
1998
|
+
return (0, _marko_compiler_babel_utils.importNamed)((0, _marko_compiler_babel_utils.getFile)(), getRuntimePath(getMarkoOpts().output), name);
|
|
1993
1999
|
}
|
|
1994
2000
|
function registerRuntimeValue(id, value) {
|
|
1995
2001
|
return _marko_compiler.types.assignmentExpression("=", toMemberExpression(importRuntime("_resumed"), id), value);
|
|
@@ -2032,9 +2038,16 @@ function importRuntimeFeature(feature) {
|
|
|
2032
2038
|
function getRuntimeFeatureImport(feature) {
|
|
2033
2039
|
return _marko_compiler.types.importDeclaration([], _marko_compiler.types.stringLiteral(`${getRuntimePath("dom")}/${feature}.feat`));
|
|
2034
2040
|
}
|
|
2041
|
+
const runtimePaths = {
|
|
2042
|
+
dom: `${runtime_info_default.name}/dom`,
|
|
2043
|
+
html: `${runtime_info_default.name}/html`
|
|
2044
|
+
};
|
|
2045
|
+
const debugRuntimePaths = {
|
|
2046
|
+
dom: `${runtime_info_default.name}/debug/dom`,
|
|
2047
|
+
html: `${runtime_info_default.name}/debug/html`
|
|
2048
|
+
};
|
|
2035
2049
|
function getRuntimePath(output) {
|
|
2036
|
-
|
|
2037
|
-
return `${runtime_info_default.name}/${optimize ? "" : "debug/"}${output === "html" ? "html" : "dom"}`;
|
|
2050
|
+
return (getMarkoOpts().optimize ? runtimePaths : debugRuntimePaths)[output === "html" ? "html" : "dom"];
|
|
2038
2051
|
}
|
|
2039
2052
|
function assertTranslate(helper, name) {
|
|
2040
2053
|
if (!isTranslate()) throw new Error(`\`${helper}(${JSON.stringify(name)})\` may only be called during the translate stage.`);
|
|
@@ -2114,6 +2127,12 @@ function getScopeReasonStatement(section) {
|
|
|
2114
2127
|
function getWriteReason(binding) {
|
|
2115
2128
|
return findSlot(binding)?.reason;
|
|
2116
2129
|
}
|
|
2130
|
+
function getMarkerGuard(nodeBinding) {
|
|
2131
|
+
return getWriteGuard(nodeBinding.section, getWriteReason(nodeBinding), true);
|
|
2132
|
+
}
|
|
2133
|
+
function isMarkerWritten(nodeBinding) {
|
|
2134
|
+
return getWriteBit(nodeBinding.section, getWriteReason(nodeBinding)) !== 0;
|
|
2135
|
+
}
|
|
2117
2136
|
function getBranchWriteReason(section) {
|
|
2118
2137
|
return findSectionSlot(section, 9)?.reason;
|
|
2119
2138
|
}
|
|
@@ -2581,7 +2600,6 @@ function addRegisteredFnReasons(fnReadsByExpression) {
|
|
|
2581
2600
|
}
|
|
2582
2601
|
const LANDS_RETAINED = 1;
|
|
2583
2602
|
const LANDS_RETAINED_INPUT = 2;
|
|
2584
|
-
const LANDS_UNSEEN = 4;
|
|
2585
2603
|
const UNREAD = {
|
|
2586
2604
|
reason: void 0,
|
|
2587
2605
|
lands: 0
|
|
@@ -2590,18 +2608,6 @@ const ALWAYS_READ = {
|
|
|
2590
2608
|
reason: ALWAYS,
|
|
2591
2609
|
lands: 0
|
|
2592
2610
|
};
|
|
2593
|
-
const UNSEEN_READ = {
|
|
2594
|
-
reason: void 0,
|
|
2595
|
-
lands: LANDS_UNSEEN
|
|
2596
|
-
};
|
|
2597
|
-
const RETAINED_TAG_NAME_READ = {
|
|
2598
|
-
reason: void 0,
|
|
2599
|
-
lands: LANDS_RETAINED
|
|
2600
|
-
};
|
|
2601
|
-
const RETAINED_INPUT_READ = {
|
|
2602
|
-
reason: void 0,
|
|
2603
|
-
lands: 3
|
|
2604
|
-
};
|
|
2605
2611
|
const exprReaders = createPassMemo(computeExprReaders, UNREAD);
|
|
2606
2612
|
const bindingReaders = createPassPathMemo(computeBindingReaders, UNREAD);
|
|
2607
2613
|
function getReasonForBinding(binding, properties) {
|
|
@@ -2614,34 +2620,49 @@ function bindingLandsRetained(binding, properties) {
|
|
|
2614
2620
|
return !!(bindingReaders(binding, properties).lands & LANDS_RETAINED_INPUT);
|
|
2615
2621
|
}
|
|
2616
2622
|
function getContentSites({ binding, properties }) {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2623
|
+
return reduce(binding, (sites, part) => joinSites(sites, getSitesAt(getWalkKey(part, properties))), NO_SITES);
|
|
2624
|
+
}
|
|
2625
|
+
const NO_SITES = { unseen: false };
|
|
2626
|
+
const UNSEEN_SITES = { unseen: true };
|
|
2627
|
+
const [getSitesAt] = createAnalysisMemo(([binding, properties]) => {
|
|
2628
|
+
let sites;
|
|
2629
|
+
let deepSites;
|
|
2630
|
+
const unseen = someReachedRead(binding, properties, (read, reader, pastCall) => {
|
|
2631
|
+
if (read.isEffect) return false;
|
|
2632
|
+
if (!isNamedBy(read, reader)) return !read.derives;
|
|
2633
|
+
if (pastCall) deepSites = push(deepSites, read);
|
|
2634
|
+
else sites = push(sites, read);
|
|
2635
|
+
return false;
|
|
2636
|
+
});
|
|
2637
|
+
return unseen ? UNSEEN_SITES : {
|
|
2638
|
+
unseen,
|
|
2620
2639
|
sites,
|
|
2621
2640
|
deepSites
|
|
2622
2641
|
};
|
|
2642
|
+
}, NO_SITES);
|
|
2643
|
+
function joinSites(a, b) {
|
|
2644
|
+
return a === NO_SITES ? b : a.unseen || b.unseen ? UNSEEN_SITES : {
|
|
2645
|
+
unseen: false,
|
|
2646
|
+
sites: concat(a.sites, b.sites),
|
|
2647
|
+
deepSites: concat(a.deepSites, b.deepSites)
|
|
2648
|
+
};
|
|
2623
2649
|
}
|
|
2624
2650
|
function landsRetained(extra) {
|
|
2625
2651
|
return !!extra.retained || !extra.isEffect && !!(exprReaders(extra).lands & LANDS_RETAINED);
|
|
2626
2652
|
}
|
|
2627
2653
|
function computeExprReaders(extra) {
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
const exprs = extra.callSiteExprs;
|
|
2641
|
-
return exprs && (linked.reason || linked.sites) ? {
|
|
2642
|
-
reason: linked.reason && mapParamReason(binding.section.program, linked.reason, exprs, true),
|
|
2643
|
-
lands: linked.lands,
|
|
2644
|
-
deepSites: mergeSites(linked.deepSites, linked.sites)
|
|
2654
|
+
const folding = {
|
|
2655
|
+
readers: isReturned(extra) ? ALWAYS_READ : UNREAD,
|
|
2656
|
+
head: void 0
|
|
2657
|
+
};
|
|
2658
|
+
forEachDerivedStep(extra, void 0, void 0, READERS_STEP, folding);
|
|
2659
|
+
return folding.readers;
|
|
2660
|
+
}
|
|
2661
|
+
function readersOf(binding, path, exprs) {
|
|
2662
|
+
const linked = bindingReaders(binding, path);
|
|
2663
|
+
return exprs && linked.reason ? {
|
|
2664
|
+
reason: mapParamReason(binding.section.program, linked.reason, exprs, true),
|
|
2665
|
+
lands: linked.lands
|
|
2645
2666
|
} : linked;
|
|
2646
2667
|
}
|
|
2647
2668
|
function getDerivedPath(extra, binding, part, properties) {
|
|
@@ -2662,72 +2683,119 @@ function isPartOf(binding, value) {
|
|
|
2662
2683
|
return !!value && binding.aliasOf === value && !isDirectAlias(binding);
|
|
2663
2684
|
}
|
|
2664
2685
|
function computeBindingReaders(binding, properties) {
|
|
2686
|
+
if (isLeftOut(binding, properties)) return UNREAD;
|
|
2665
2687
|
const head = properties === true || properties === void 0 ? void 0 : first(properties);
|
|
2666
2688
|
const reason = findSlot(binding)?.reason;
|
|
2667
|
-
|
|
2668
|
-
reason
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
continue;
|
|
2677
|
-
}
|
|
2678
|
-
readers = mergeReaders(readers, landingReaders(expr, binding));
|
|
2679
|
-
readers = mergeReaders(readers, renderingReaders(expr, binding));
|
|
2680
|
-
readers = mergeReaders(readers, readersOfDerives(expr, binding, properties));
|
|
2681
|
-
}
|
|
2682
|
-
for (const alias of binding.aliases) readers = mergeReaders(readers, bindingReaders(alias, properties));
|
|
2683
|
-
if (properties === void 0) return readers;
|
|
2684
|
-
if (properties === true) {
|
|
2685
|
-
for (const propBinding of binding.propertyAliases.values()) readers = mergeReaders(readers, bindingReaders(propBinding, true));
|
|
2686
|
-
return readers;
|
|
2687
|
-
}
|
|
2688
|
-
const property = first(properties);
|
|
2689
|
-
if (propertiesUtil.has(binding.excludeProperties, property)) return UNREAD;
|
|
2690
|
-
readers = mergePropertyReaders(readers, binding, property, properties);
|
|
2691
|
-
for (const alias of binding.aliases) readers = mergePropertyReaders(readers, alias, property, properties);
|
|
2692
|
-
return readers;
|
|
2689
|
+
const folding = {
|
|
2690
|
+
readers: reason ? {
|
|
2691
|
+
reason,
|
|
2692
|
+
lands: 0
|
|
2693
|
+
} : UNREAD,
|
|
2694
|
+
head
|
|
2695
|
+
};
|
|
2696
|
+
forEachStep(binding, properties, READERS_STEP, folding);
|
|
2697
|
+
return folding.readers;
|
|
2693
2698
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2699
|
+
const READERS_STEP = {
|
|
2700
|
+
land(folding, read, binding) {
|
|
2701
|
+
folding.readers = landIn(folding.readers, read, binding, folding.head);
|
|
2702
|
+
},
|
|
2703
|
+
reach(folding, binding, path, exprs) {
|
|
2704
|
+
folding.readers = mergeReaders(folding.readers, readersOf(binding, path, exprs));
|
|
2705
|
+
}
|
|
2706
|
+
};
|
|
2707
|
+
function landIn(readers, read, binding, head) {
|
|
2708
|
+
if (read.isEffect) return head === "content" && read.rendersContent && bindingUtil.has(read.spreadFrom, binding) ? readers : mergeReaders(readers, ALWAYS_READ);
|
|
2709
|
+
return withLands(isReturned(read) ? mergeReaders(readers, ALWAYS_READ) : readers, getLandingBits(read, binding));
|
|
2697
2710
|
}
|
|
2698
2711
|
function mergeReaders(a, b) {
|
|
2699
2712
|
if (a === UNREAD) return b;
|
|
2700
2713
|
if (b === UNREAD) return a;
|
|
2701
2714
|
const reason = mergeSources(a.reason, b.reason);
|
|
2702
2715
|
const lands = a.lands | b.lands;
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
if (reason === a.reason && lands === a.lands && sites === a.sites && deepSites === a.deepSites) return a;
|
|
2706
|
-
if (reason === b.reason && lands === b.lands && sites === b.sites && deepSites === b.deepSites) return b;
|
|
2716
|
+
if (reason === a.reason && lands === a.lands) return a;
|
|
2717
|
+
if (reason === b.reason && lands === b.lands) return b;
|
|
2707
2718
|
return {
|
|
2708
2719
|
reason,
|
|
2709
|
-
lands
|
|
2710
|
-
sites,
|
|
2711
|
-
deepSites
|
|
2720
|
+
lands
|
|
2712
2721
|
};
|
|
2713
2722
|
}
|
|
2714
|
-
function
|
|
2715
|
-
return
|
|
2723
|
+
function withLands(readers, lands) {
|
|
2724
|
+
return (readers.lands | lands) === readers.lands ? readers : {
|
|
2725
|
+
reason: readers.reason,
|
|
2726
|
+
lands: readers.lands | lands
|
|
2727
|
+
};
|
|
2716
2728
|
}
|
|
2717
|
-
function
|
|
2718
|
-
return
|
|
2729
|
+
function getLandingBits(read, binding) {
|
|
2730
|
+
return read.retained ? isNamedBy(read, binding) ? LANDS_RETAINED : 3 : 0;
|
|
2731
|
+
}
|
|
2732
|
+
function isNamedBy(read, binding) {
|
|
2733
|
+
return every(binding.reads.get(read), isTagNameRead);
|
|
2719
2734
|
}
|
|
2720
2735
|
function isTagNameRead({ extra }) {
|
|
2721
2736
|
return !!extra.exprRoot?.tagName;
|
|
2722
2737
|
}
|
|
2723
|
-
function
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2738
|
+
function isLeftOut(binding, properties) {
|
|
2739
|
+
return properties !== void 0 && properties !== true && propertiesUtil.has(binding.excludeProperties, first(properties));
|
|
2740
|
+
}
|
|
2741
|
+
function forEachStep(binding, properties, step, state) {
|
|
2742
|
+
const aliased = binding.aliasOf;
|
|
2743
|
+
if (properties !== true && aliased) step.reach(state, aliased, concat(binding.property, properties), void 0);
|
|
2744
|
+
for (const read of binding.reads.keys()) {
|
|
2745
|
+
step.land(state, read, binding);
|
|
2746
|
+
if (!read.isEffect) forEachDerivedStep(read, binding, properties, step, state);
|
|
2747
|
+
}
|
|
2748
|
+
for (const alias of binding.aliases) step.reach(state, alias, properties, void 0);
|
|
2749
|
+
if (properties === true) for (const part of binding.propertyAliases.values()) step.reach(state, part, true, void 0);
|
|
2750
|
+
else if (properties !== void 0) {
|
|
2751
|
+
const property = first(properties);
|
|
2752
|
+
let part = binding.propertyAliases.get(property);
|
|
2753
|
+
if (part) step.reach(state, part, rest(properties), void 0);
|
|
2754
|
+
for (const alias of binding.aliases) {
|
|
2755
|
+
part = alias.propertyAliases.get(property);
|
|
2756
|
+
if (part) step.reach(state, part, rest(properties), void 0);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
function forEachDerivedStep(read, part, properties, step, state) {
|
|
2761
|
+
const { derives } = read;
|
|
2762
|
+
if (!isReturned(read)) for (let i = 0; i < size(derives); i++) {
|
|
2763
|
+
const binding = at(derives, i);
|
|
2764
|
+
if (!isPartOf(binding, part)) step.reach(state, binding, getDerivedPath(read, binding, part, properties), binding.exposed ? read.callSiteExprs : void 0);
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
function isReturned(extra) {
|
|
2768
|
+
return extra === (0, _marko_compiler_babel_utils.getProgram)().node.extra.section.returnValueExpr;
|
|
2769
|
+
}
|
|
2770
|
+
const getWalkKey = createPathKeys();
|
|
2771
|
+
function someReachedRead(binding, properties, test) {
|
|
2772
|
+
const walk = {
|
|
2773
|
+
test,
|
|
2774
|
+
found: false,
|
|
2775
|
+
pastCall: false,
|
|
2776
|
+
walked: /* @__PURE__ */ new Set(),
|
|
2777
|
+
walkedPastCall: /* @__PURE__ */ new Set()
|
|
2729
2778
|
};
|
|
2730
|
-
|
|
2779
|
+
walkFrom(walk, binding, properties);
|
|
2780
|
+
return walk.found;
|
|
2781
|
+
}
|
|
2782
|
+
const WALK_STEP = {
|
|
2783
|
+
land(walk, read, binding) {
|
|
2784
|
+
walk.found ||= walk.test(read, binding, walk.pastCall);
|
|
2785
|
+
},
|
|
2786
|
+
reach(walk, binding, path, exprs) {
|
|
2787
|
+
const { pastCall } = walk;
|
|
2788
|
+
walk.pastCall ||= !!exprs;
|
|
2789
|
+
walkFrom(walk, binding, path);
|
|
2790
|
+
walk.pastCall = pastCall;
|
|
2791
|
+
}
|
|
2792
|
+
};
|
|
2793
|
+
function walkFrom(walk, binding, properties) {
|
|
2794
|
+
const seen = walk.pastCall ? walk.walkedPastCall : walk.walked;
|
|
2795
|
+
const key = getWalkKey(binding, properties);
|
|
2796
|
+
if (walk.found || seen.has(key) || isLeftOut(binding, properties)) return;
|
|
2797
|
+
seen.add(key);
|
|
2798
|
+
forEachStep(binding, properties, WALK_STEP, walk);
|
|
2731
2799
|
}
|
|
2732
2800
|
// src/common/helpers.ts
|
|
2733
2801
|
const invalidNativeAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
@@ -3683,17 +3751,21 @@ function getNodeContentType(path, edge) {
|
|
|
3683
3751
|
function isKnownChild(section) {
|
|
3684
3752
|
return !section.parent || !!section.renderedBy;
|
|
3685
3753
|
}
|
|
3686
|
-
const [getSectionTextBefore] = createAnalysisMemo(
|
|
3687
|
-
function
|
|
3754
|
+
const [getSectionTextBefore] = createAnalysisMemo(computeSectionTextBefore, false);
|
|
3755
|
+
function computeSectionTextBefore(section) {
|
|
3688
3756
|
const { branch, derives } = section;
|
|
3689
|
-
if (branch)
|
|
3690
|
-
const { tag } = branch;
|
|
3691
|
-
const tagSection = tag.nodeBinding.section;
|
|
3692
|
-
return !isStartMarked(branch, section, content) && (branch.kind === "for" && mayEndWithText(section) || (tag.textBefore ?? (content ? getTextBeforeIn(tagSection, content) : getSectionTextBefore(tagSection))));
|
|
3693
|
-
}
|
|
3757
|
+
if (branch) return getBranchTextBefore(branch, section, void 0);
|
|
3694
3758
|
if (!section.parent) return void 0;
|
|
3695
3759
|
return !derives || !!section.renderedBy || mayContentFollowText(section);
|
|
3696
3760
|
}
|
|
3761
|
+
function getTextBeforeIn(section, content) {
|
|
3762
|
+
const { branch } = section;
|
|
3763
|
+
return content && branch ? getBranchTextBefore(branch, section, content) : getSectionTextBefore(section);
|
|
3764
|
+
}
|
|
3765
|
+
function getBranchTextBefore(branch, section, content) {
|
|
3766
|
+
const { tag } = branch;
|
|
3767
|
+
return !isStartMarked(branch, section, content) && (isLoopBody(section) && mayEndWithText(section) || (tag.textBefore ?? getTextBeforeIn(tag.nodeBinding.section, content)));
|
|
3768
|
+
}
|
|
3697
3769
|
function mayContentFollowText(section) {
|
|
3698
3770
|
const { tag } = section.derives;
|
|
3699
3771
|
const { unseen, sites, deepSites } = getContentSites(section.derives);
|
|
@@ -3768,6 +3840,9 @@ function isOptionalBranch(section) {
|
|
|
3768
3840
|
const kind = section.branch?.kind;
|
|
3769
3841
|
return kind === "if" || kind === "for";
|
|
3770
3842
|
}
|
|
3843
|
+
function isLoopBody(section) {
|
|
3844
|
+
return section.branch?.kind === "for";
|
|
3845
|
+
}
|
|
3771
3846
|
function isInParentSection(binding, section) {
|
|
3772
3847
|
return section.parent?.id === binding.section.id;
|
|
3773
3848
|
}
|
|
@@ -3790,7 +3865,7 @@ function getForClosureIndex(closure, closureSection) {
|
|
|
3790
3865
|
let index = 0;
|
|
3791
3866
|
find(closure.closureSections, (section) => {
|
|
3792
3867
|
if (section === closureSection) return true;
|
|
3793
|
-
if (section
|
|
3868
|
+
if (isLoopBody(section) && section.parent === closure.section && !isForSelectorClosure(section, closure)) index++;
|
|
3794
3869
|
return false;
|
|
3795
3870
|
});
|
|
3796
3871
|
return index;
|
|
@@ -4959,14 +5034,9 @@ function flushInto(path) {
|
|
|
4959
5034
|
if (expr) target.node.body.push(expr);
|
|
4960
5035
|
return target;
|
|
4961
5036
|
}
|
|
4962
|
-
function markNode(path, nodeBinding,
|
|
5037
|
+
function markNode(path, nodeBinding, deferred) {
|
|
4963
5038
|
if (nodeBinding.type !== 0) throw path.buildCodeFrameError("POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze.");
|
|
4964
|
-
if (isOutputHTML()) {
|
|
4965
|
-
if (reason) {
|
|
4966
|
-
const section = getSection(path);
|
|
4967
|
-
writeTo$1(path, deferred)`${callRuntime("_el_mark", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getWriteGuard(section, reason, true))}`;
|
|
4968
|
-
}
|
|
4969
|
-
}
|
|
5039
|
+
if (isOutputHTML() && isMarkerWritten(nodeBinding)) writeTo$1(path, deferred)`${callRuntime("_el_mark", getScopeIdIdentifier(nodeBinding.section), getScopeAccessorLiteral(nodeBinding), getMarkerGuard(nodeBinding))}`;
|
|
4970
5040
|
}
|
|
4971
5041
|
function unwrapWrite(write) {
|
|
4972
5042
|
return typeof write === "function" ? write() || "" : write;
|
|
@@ -6633,7 +6703,7 @@ function getNodeReasons(section) {
|
|
|
6633
6703
|
return section.structure?.reduce(addNodeReason, void 0);
|
|
6634
6704
|
}
|
|
6635
6705
|
function addNodeReason(reasons, op) {
|
|
6636
|
-
const reason = typeof op === "object" && op.kind === "node" && op.binding &&
|
|
6706
|
+
const reason = typeof op === "object" && op.kind === "node" && op.binding && getWriteReason(op.binding);
|
|
6637
6707
|
return reason ? sourcesUtil.add(reasons, reason) : reasons;
|
|
6638
6708
|
}
|
|
6639
6709
|
let reasonsVersion = 0;
|
|
@@ -8398,7 +8468,7 @@ var for_default = {
|
|
|
8398
8468
|
const forAttrs = getKnownAttrValues(node);
|
|
8399
8469
|
const signal = getSignal(tagSection, nodeBinding, "for");
|
|
8400
8470
|
signal.build = () => {
|
|
8401
|
-
return callRuntime(
|
|
8471
|
+
return callRuntime(isUnkeyed(forType, forAttrs) ? forTypeToUnkeyedBranchRuntime(forType) : forTypeToBranchRuntime(forType), getScopeAccessorLiteral(nodeBinding, true), ...trimEmptyArgs(getBranchRendererArgs(bodySection)));
|
|
8402
8472
|
};
|
|
8403
8473
|
addValue(tagSection, tagExtra, signal, _marko_compiler.types.arrayExpression(getLoopArgs(forType, forAttrs)));
|
|
8404
8474
|
replaceWithStatements(tag);
|
|
@@ -8436,7 +8506,7 @@ function getMemberChainAlias(node, rootName, item) {
|
|
|
8436
8506
|
}
|
|
8437
8507
|
}
|
|
8438
8508
|
}
|
|
8439
|
-
function
|
|
8509
|
+
function isUnkeyed(type, attrs) {
|
|
8440
8510
|
if (attrs.by) return false;
|
|
8441
8511
|
switch (type) {
|
|
8442
8512
|
case "of": return true;
|
|
@@ -8522,7 +8592,7 @@ var html_comment_default = {
|
|
|
8522
8592
|
const textLiteral = bodyToText(tag.node.body);
|
|
8523
8593
|
if (!_marko_compiler.types.isStringLiteral(textLiteral)) addStatement("render", tagSection, tagExtra, callRuntime("_text", createScopeReadExpression(nodeBinding), textLiteral));
|
|
8524
8594
|
}
|
|
8525
|
-
if (nodeBinding) markNode(tag, nodeBinding
|
|
8595
|
+
if (nodeBinding) markNode(tag, nodeBinding);
|
|
8526
8596
|
replaceWithStatements(tag);
|
|
8527
8597
|
} },
|
|
8528
8598
|
parseOptions: { text: true },
|
|
@@ -8590,13 +8660,16 @@ var id_default = {
|
|
|
8590
8660
|
return;
|
|
8591
8661
|
}
|
|
8592
8662
|
const id = isOutputHTML() ? callRuntime("_id") : callRuntime("_id", scopeIdentifier);
|
|
8593
|
-
if (isOutputHTML())
|
|
8594
|
-
|
|
8663
|
+
if (isOutputHTML()) {
|
|
8664
|
+
translateVar(tag, valueAttr ? _marko_compiler.types.logicalExpression("||", valueAttr.value, id) : id);
|
|
8665
|
+
replaceWithStatements(tag);
|
|
8666
|
+
} else {
|
|
8595
8667
|
const section = getSection(tag);
|
|
8596
|
-
const
|
|
8668
|
+
const binding = node.var.extra.binding;
|
|
8669
|
+
const signal = initValue(binding);
|
|
8597
8670
|
if (valueAttr) {
|
|
8598
8671
|
const { value } = valueAttr;
|
|
8599
|
-
addValue(section, value.extra, signal, _marko_compiler.types.logicalExpression("||", value, evaluate(value).confident ? id : callRuntime("_id", scopeIdentifier, _marko_compiler.types.stringLiteral(getPrefixedScopeAccessor(
|
|
8672
|
+
addValue(section, value.extra, signal, _marko_compiler.types.logicalExpression("||", value, evaluate(value).confident ? id : callRuntime("_id", scopeIdentifier, _marko_compiler.types.stringLiteral(getPrefixedScopeAccessor(binding, getAccessorPrefix().IdFallback)))));
|
|
8600
8673
|
} else addValue(section, void 0, signal, id);
|
|
8601
8674
|
replaceWithStatements(tag);
|
|
8602
8675
|
}
|
|
@@ -9190,7 +9263,7 @@ function translateHTML$1(tag) {
|
|
|
9190
9263
|
const binding = node.extra?.nodeBinding;
|
|
9191
9264
|
if (binding) {
|
|
9192
9265
|
writeTo$1(tag)`${callRuntime("_style_html", buildStyleDecls(node))}`;
|
|
9193
|
-
markNode(tag, binding
|
|
9266
|
+
markNode(tag, binding);
|
|
9194
9267
|
}
|
|
9195
9268
|
emitStyleImport(tag);
|
|
9196
9269
|
replaceWithStatements(tag);
|
|
@@ -9639,10 +9712,9 @@ function translateExit(placeholder) {
|
|
|
9639
9712
|
if (isHTML) write`${node.escape ? _escape(computed) : _unescaped(computed)}`;
|
|
9640
9713
|
} else {
|
|
9641
9714
|
const section = getSection(placeholder);
|
|
9642
|
-
const markerReason = nodeBinding && getWriteReason(nodeBinding);
|
|
9643
9715
|
if (isHTML) {
|
|
9644
|
-
if (
|
|
9645
|
-
const guard =
|
|
9716
|
+
if (nodeBinding && isMarkerWritten(nodeBinding)) {
|
|
9717
|
+
const guard = getMarkerGuard(nodeBinding);
|
|
9646
9718
|
write`${callRuntime(node.escape ? "_text_mark" : "_html_mark", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), value, extra.textBefore ?? getSectionTextBefore(section) ?? true ? guard ? _marko_compiler.types.binaryExpression("*", guard, _marko_compiler.types.numericLiteral(2)) : _marko_compiler.types.numericLiteral(2) : guard)}`;
|
|
9647
9719
|
} else write`${method === "_escape" ? buildEscapedTextExpression(value) : callRuntime(method, value)}`;
|
|
9648
9720
|
} else addStatement("render", section, value.extra, method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding)), true);
|
|
@@ -9954,15 +10026,23 @@ var dynamic_tag_default = {
|
|
|
9954
10026
|
} else args.push(propsToExpression(properties));
|
|
9955
10027
|
if (isOutputHTML()) {
|
|
9956
10028
|
writeHTMLResumeStatements(tag);
|
|
9957
|
-
const markerGuard =
|
|
10029
|
+
const markerGuard = getMarkerGuard(nodeBinding);
|
|
9958
10030
|
const debugTagVar = !isOptimize() && node.var && _marko_compiler.types.numericLiteral(1);
|
|
9959
|
-
const
|
|
9960
|
-
|
|
10031
|
+
const varId = node.var && isTagVarResumed(tag) && getResumeRegistryId(tagSection, node.var.extra?.binding, "var");
|
|
10032
|
+
const input = args[0];
|
|
10033
|
+
const scopeIdArg = getScopeIdIdentifier(tagSection);
|
|
10034
|
+
const accessorArg = getScopeAccessorLiteral(nodeBinding);
|
|
10035
|
+
const inputArg = hasTagArgs ? _marko_compiler.types.arrayExpression(args) : input;
|
|
10036
|
+
const contentArg = contentProp ? contentProp.value : absentArg(0);
|
|
10037
|
+
const inputIsArgs = hasTagArgs ? _marko_compiler.types.numericLiteral(1) : absentArg(0);
|
|
10038
|
+
const markerArg = markerGuard || absentArg(1);
|
|
10039
|
+
const dynamicTagExpr = callRuntime("_dynamic_tag", scopeIdArg, accessorArg, tagExpression, inputArg, contentArg, inputIsArgs, markerArg, debugTagVar);
|
|
10040
|
+
if (varId) {
|
|
9961
10041
|
const dynamicScopeIdentifier = generateUidIdentifier(tag.get("name").toString() + "_scope");
|
|
9962
10042
|
const mutatesTagVar = isTagVarAssigned(tag);
|
|
9963
10043
|
statements.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(dynamicScopeIdentifier, callRuntime("_peek_scope_id"))]));
|
|
9964
10044
|
translateVar(tag, dynamicTagExpr, "let", statements);
|
|
9965
|
-
statements.push(_marko_compiler.types.expressionStatement(callRuntime("_var", getScopeIdIdentifier(tagSection), getScopeOffsetAccessorLiteral(nodeBinding), dynamicScopeIdentifier, _marko_compiler.types.stringLiteral(
|
|
10045
|
+
statements.push(_marko_compiler.types.expressionStatement(callRuntime("_var", getScopeIdIdentifier(tagSection), getScopeOffsetAccessorLiteral(nodeBinding), dynamicScopeIdentifier, _marko_compiler.types.stringLiteral(varId), mutatesTagVar ? getScopeAccessorLiteral(nodeBinding) : void 0)));
|
|
9966
10046
|
} else if (node.var) translateVar(tag, dynamicTagExpr, "let", statements);
|
|
9967
10047
|
else statements.push(_marko_compiler.types.expressionStatement(dynamicTagExpr));
|
|
9968
10048
|
replaceWithStatements(tag, statements);
|
|
@@ -10082,16 +10162,16 @@ var dom_default = { translate: {
|
|
|
10082
10162
|
}
|
|
10083
10163
|
});
|
|
10084
10164
|
const registerWrapper = !!(registerReason && objProps.length);
|
|
10085
|
-
|
|
10165
|
+
const registerClosures = !!registerReason && !!getDynamicTagContentClosures(childSection);
|
|
10166
|
+
let renderer = callRuntime(registerReason && !registerWrapper && !registerClosures ? "_content_resume" : "_content", _marko_compiler.types.stringLiteral(registryId), ...trimEmptyArgs([
|
|
10086
10167
|
writes,
|
|
10087
10168
|
walks,
|
|
10088
10169
|
...markReturn(childSection, setupIdentifier, tagParamsIdentifier),
|
|
10089
10170
|
childSection.hoisted || childSection.isHoistThrough ? getSectionScopesAccessorLiteral(childSection) : void 0
|
|
10090
10171
|
]));
|
|
10091
|
-
if (!registerReason || registerWrapper) renderer = _marko_compiler.types.addComment(renderer, "leading", "@__PURE__");
|
|
10092
10172
|
if (objProps.length) renderer = callRuntime("_content_closures", renderer, _marko_compiler.types.objectExpression(objProps));
|
|
10093
10173
|
program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(childSection.name), renderer)]));
|
|
10094
|
-
if (
|
|
10174
|
+
if (registerClosures) program.node.body.push(_marko_compiler.types.expressionStatement(callRuntime("_content_closures_resume", _marko_compiler.types.identifier(childSection.name), registerWrapper && _marko_compiler.types.numericLiteral(1))));
|
|
10095
10175
|
else if (registerWrapper) program.node.body.push(_marko_compiler.types.expressionStatement(registerRuntimeValue(registryId, _marko_compiler.types.identifier(childSection.name))));
|
|
10096
10176
|
}
|
|
10097
10177
|
}
|
|
@@ -10861,9 +10941,9 @@ var native_tag_default = {
|
|
|
10861
10941
|
else if (contentAttr) {
|
|
10862
10942
|
write`>`;
|
|
10863
10943
|
htmlContentAttrTags.add(tag.node);
|
|
10864
|
-
tag.node.body.body = [_marko_compiler.types.expressionStatement(callRuntime("_attr_content", nodeAccessor, getScopeIdIdentifier(tagSection), contentAttr.value,
|
|
10944
|
+
tag.node.body.body = [_marko_compiler.types.expressionStatement(callRuntime("_attr_content", nodeAccessor, getScopeIdIdentifier(tagSection), contentAttr.value, getMarkerGuard(nodeBinding)))];
|
|
10865
10945
|
} else if (spreadContent) {
|
|
10866
|
-
const markerGuard =
|
|
10946
|
+
const markerGuard = getMarkerGuard(nodeBinding);
|
|
10867
10947
|
htmlContentAttrTags.add(tag.node);
|
|
10868
10948
|
tag.node.body.body = [skipExpression ? _marko_compiler.types.expressionStatement(callRuntime("_attrs_partial_content", spreadExpression, skipExpression, nodeAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName), markerGuard)) : _marko_compiler.types.expressionStatement(callRuntime("_attrs_content", spreadExpression, nodeAccessor, getScopeIdIdentifier(tagSection), _marko_compiler.types.stringLiteral(tagName), markerGuard))];
|
|
10869
10949
|
} else write`>`;
|
|
@@ -10897,7 +10977,7 @@ var native_tag_default = {
|
|
|
10897
10977
|
if (tagName === "head" && getMarkoOpts().linkAssets) write`${callRuntime("_flush_head")}`;
|
|
10898
10978
|
write`</${tagName}>`;
|
|
10899
10979
|
}
|
|
10900
|
-
if (markerReason) markNode(tag, nodeBinding,
|
|
10980
|
+
if (markerReason) markNode(tag, nodeBinding, tagName === "html");
|
|
10901
10981
|
replaceWithStatements(tag, statements);
|
|
10902
10982
|
}
|
|
10903
10983
|
},
|
|
@@ -11519,10 +11599,10 @@ var text_default = {
|
|
|
11519
11599
|
} }
|
|
11520
11600
|
};
|
|
11521
11601
|
// src/translator/interop/build-aggregate-error.ts
|
|
11522
|
-
function buildAggregateError(file, rootMsg, ...
|
|
11602
|
+
function buildAggregateError(file, rootMsg, ...features) {
|
|
11523
11603
|
const err = /* @__PURE__ */ new SyntaxError();
|
|
11524
11604
|
const fileName = path.default.relative(_marko_compiler_modules.cwd, file.opts.filename);
|
|
11525
|
-
const finalMsg = `${rootMsg}:\n\n${
|
|
11605
|
+
const finalMsg = `${rootMsg}:\n\n${features.map(([msg, node]) => `\x1b[90m${msg} at ${getFileNameWithLoc(fileName, node)}:\x1b[0m\n${getFrame(file, node)}`).join("\n\n")}`;
|
|
11526
11606
|
if (!("MARKO_DEBUG" in process.env)) err.stack = finalMsg;
|
|
11527
11607
|
Object.defineProperty(err, "message", {
|
|
11528
11608
|
get() {
|
|
@@ -11532,7 +11612,7 @@ function buildAggregateError(file, rootMsg, ...paths) {
|
|
|
11532
11612
|
});
|
|
11533
11613
|
return err;
|
|
11534
11614
|
}
|
|
11535
|
-
function getFrame(file, {
|
|
11615
|
+
function getFrame(file, { loc }) {
|
|
11536
11616
|
return loc ? (0, _marko_compiler_internal_babel.codeFrameColumns)(file.code, {
|
|
11537
11617
|
start: {
|
|
11538
11618
|
line: loc.start.line,
|
|
@@ -11544,7 +11624,7 @@ function getFrame(file, { node: { loc } }) {
|
|
|
11544
11624
|
} : void 0
|
|
11545
11625
|
}, { highlightCode: true }) : "";
|
|
11546
11626
|
}
|
|
11547
|
-
function getFileNameWithLoc(fileName, {
|
|
11627
|
+
function getFileNameWithLoc(fileName, { loc }) {
|
|
11548
11628
|
if (loc) return `${fileName}(${loc.start.line},${loc.start.column + 1})`;
|
|
11549
11629
|
return fileName;
|
|
11550
11630
|
}
|
|
@@ -11559,9 +11639,9 @@ function isTagsAPI(file = (0, _marko_compiler_babel_utils.getFile)()) {
|
|
|
11559
11639
|
if (!featureType) {
|
|
11560
11640
|
const lookup = (0, _marko_compiler_babel_utils.getTaglibLookup)(file);
|
|
11561
11641
|
const tagsDir = getTagsDir(lookup, file.opts.filename);
|
|
11562
|
-
const state = {};
|
|
11563
|
-
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) addFeature(state, Tags, "Template file within a tags directory", program);
|
|
11564
|
-
scanBody(state, program.
|
|
11642
|
+
const state = { file };
|
|
11643
|
+
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) addFeature(state, Tags, "Template file within a tags directory", program.node);
|
|
11644
|
+
scanBody(state, program.node.body, void 0);
|
|
11565
11645
|
featureType = file.metadata.marko.api = programExtra.featureType = state.feature?.type || (lookup.exclusiveTagDiscoveryDirs === "tags" ? "tags" : "class");
|
|
11566
11646
|
}
|
|
11567
11647
|
return featureType === Tags;
|
|
@@ -11571,45 +11651,56 @@ function getTagsDir(lookup, filename) {
|
|
|
11571
11651
|
for (const dir of lookup.discoveryDirs || []) if (filename.startsWith(dir) && (filename[dir.length] === "/" || filename[dir.length] === "\\") && (!nearest || dir.length > nearest.length)) nearest = dir;
|
|
11572
11652
|
return !!nearest && /[/\\]tags$/.test(nearest) && nearest;
|
|
11573
11653
|
}
|
|
11574
|
-
|
|
11654
|
+
/** Scans `body`, in the tag whose fully resolved name is `parentName`. */
|
|
11655
|
+
function scanBody(state, body, parentName) {
|
|
11575
11656
|
for (const child of body) switch (child.type) {
|
|
11576
11657
|
case "MarkoTag":
|
|
11577
|
-
scanTag(state, child);
|
|
11658
|
+
scanTag(state, child, parentName);
|
|
11578
11659
|
break;
|
|
11579
11660
|
case "MarkoComment":
|
|
11580
|
-
if (/^\s*use tags\s*$/.test(child.
|
|
11581
|
-
else if (/^\s*use class\s*$/.test(child.
|
|
11661
|
+
if (/^\s*use tags\s*$/.test(child.value)) addFeature(state, Tags, "<!-- use tags -->", child);
|
|
11662
|
+
else if (/^\s*use class\s*$/.test(child.value)) addFeature(state, Class, "<!-- use class -->", child);
|
|
11582
11663
|
break;
|
|
11583
11664
|
case "MarkoScriptlet":
|
|
11584
|
-
if (!child.
|
|
11665
|
+
if (!child.static) addFeature(state, Class, "Scriptlet", child);
|
|
11585
11666
|
break;
|
|
11586
|
-
case "MarkoClass": addFeature(state, Class, "Class block", child.
|
|
11667
|
+
case "MarkoClass": addFeature(state, Class, "Class block", child.body);
|
|
11587
11668
|
}
|
|
11588
11669
|
}
|
|
11589
|
-
function scanTag(state, tag) {
|
|
11590
|
-
if (tag.
|
|
11591
|
-
const
|
|
11670
|
+
function scanTag(state, tag, parentName) {
|
|
11671
|
+
if (tag.var) addFeature(state, Tags, "Tag variable", tag.var);
|
|
11672
|
+
const { name } = tag;
|
|
11673
|
+
const fullName = name.type !== "StringLiteral" ? "*" : name.value[0] === "@" ? (parentName ? parentName + ":" : "") + name.value.slice(1) : name.value;
|
|
11674
|
+
const tagDef = getNodeTagDef(state.file, tag, fullName);
|
|
11592
11675
|
if (tagDef) {
|
|
11593
11676
|
if (tagDef.name === "style") {
|
|
11594
|
-
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(tag.
|
|
11677
|
+
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(tag.rawValue || "")) addFeature(state, Class, `style block`, tag.name);
|
|
11595
11678
|
} else if (tagDef.taglibId === runtime_info_default.taglibId) {
|
|
11596
11679
|
const feature = getFeatureTypeFromCoreTagName(tagDef.name);
|
|
11597
|
-
if (feature) addFeature(state, feature, `<${tagDef.name}> tag`, tag.
|
|
11680
|
+
if (feature) addFeature(state, feature, `<${tagDef.name}> tag`, tag.name);
|
|
11598
11681
|
}
|
|
11599
11682
|
}
|
|
11600
11683
|
if (!tagDef?.parseOptions?.rawOpenTag) {
|
|
11601
|
-
for (const attr of tag.
|
|
11602
|
-
if (attr.
|
|
11603
|
-
addFeature(state, Class, "Attribute arguments", attr.
|
|
11684
|
+
for (const attr of tag.attributes) if (attr.type === "MarkoAttribute") {
|
|
11685
|
+
if (attr.arguments?.length) {
|
|
11686
|
+
addFeature(state, Class, "Attribute arguments", attr.arguments[0]);
|
|
11604
11687
|
break;
|
|
11605
|
-
} else if (attr.
|
|
11688
|
+
} else if (attr.bound) {
|
|
11606
11689
|
addFeature(state, Tags, "Bound attribute", attr);
|
|
11607
11690
|
break;
|
|
11608
11691
|
}
|
|
11609
11692
|
}
|
|
11610
11693
|
}
|
|
11611
|
-
|
|
11612
|
-
scanBody(state, tag.
|
|
11694
|
+
const childParentName = (0, _marko_compiler_babel_utils.isTransparentTag)({ node: tag }) ? parentName : fullName;
|
|
11695
|
+
scanBody(state, tag.body.body, childParentName);
|
|
11696
|
+
scanBody(state, tag.attributeTags, childParentName);
|
|
11697
|
+
}
|
|
11698
|
+
function getNodeTagDef(file, tag, fullName) {
|
|
11699
|
+
if (tag.tagDef === void 0) {
|
|
11700
|
+
const { name } = tag;
|
|
11701
|
+
tag.tagDef = name.type !== "StringLiteral" || (0, _marko_compiler_babel_utils.hasMacro)(file.path, name.value) ? null : (0, _marko_compiler_babel_utils.getTagDefForTagName)(file, fullName) || null;
|
|
11702
|
+
}
|
|
11703
|
+
return tag.tagDef;
|
|
11613
11704
|
}
|
|
11614
11705
|
function getFeatureTypeFromCoreTagName(tagName) {
|
|
11615
11706
|
switch (tagName) {
|
|
@@ -11636,12 +11727,12 @@ function getFeatureTypeFromCoreTagName(tagName) {
|
|
|
11636
11727
|
default: return;
|
|
11637
11728
|
}
|
|
11638
11729
|
}
|
|
11639
|
-
function addFeature(state, type, name,
|
|
11730
|
+
function addFeature(state, type, name, node) {
|
|
11640
11731
|
if (state.feature) {
|
|
11641
|
-
if (state.feature.type !== type) throw buildAggregateError(
|
|
11732
|
+
if (state.feature.type !== type) throw buildAggregateError(state.file, "Cannot mix Tags API and Class API features in the same file", [state.feature.name, state.feature.node], [name, node]);
|
|
11642
11733
|
} else state.feature = {
|
|
11643
11734
|
name,
|
|
11644
|
-
|
|
11735
|
+
node,
|
|
11645
11736
|
type
|
|
11646
11737
|
};
|
|
11647
11738
|
}
|