marko 6.0.0-next.3.85 → 6.0.0
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 -0
- package/dist/common/accessor.debug.d.ts +1 -0
- package/dist/debug/dom.js +11 -7
- package/dist/debug/dom.mjs +11 -7
- package/dist/debug/html.js +304 -247
- package/dist/debug/html.mjs +300 -246
- package/dist/dom.js +8 -5
- package/dist/dom.mjs +8 -5
- package/dist/html/compat.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +2 -2
- package/dist/html/template.d.ts +1 -0
- package/dist/html/writer.d.ts +14 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +214 -168
- package/dist/html.mjs +210 -167
- package/dist/translator/index.js +1464 -980
- package/dist/translator/util/evaluate.d.ts +2 -0
- package/dist/translator/util/generate-uid.d.ts +3 -0
- package/dist/translator/util/optional.d.ts +9 -7
- package/dist/translator/util/references.d.ts +9 -7
- package/dist/translator/util/sections.d.ts +7 -5
- package/dist/translator/util/serialize-reasons.d.ts +28 -17
- package/dist/translator/util/signals.d.ts +1 -2
- package/dist/translator/util/writer.d.ts +2 -1
- package/dist/translator/visitors/placeholder.d.ts +2 -2
- package/dist/translator/visitors/program/html.d.ts +3 -0
- package/dist/translator/visitors/program/index.d.ts +5 -1
- package/dist/translator/visitors/tag/custom-tag.d.ts +2 -0
- package/package.json +2 -2
package/dist/debug/html.mjs
CHANGED
@@ -1616,9 +1616,9 @@ function withContext(key, value, cb) {
|
|
1616
1616
|
ctx[key] = prev;
|
1617
1617
|
}
|
1618
1618
|
}
|
1619
|
-
function setTagVar(parentScopeId, scopeOffsetAccessor,
|
1619
|
+
function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
1620
1620
|
ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId();
|
1621
|
-
|
1621
|
+
ensureScopeWithId(childScopeId)["#TagVariable" /* TagVariable */] = register2(
|
1622
1622
|
{},
|
1623
1623
|
registryId,
|
1624
1624
|
parentScopeId
|
@@ -1638,19 +1638,26 @@ function nextScopeId() {
|
|
1638
1638
|
function peekNextScopeId() {
|
1639
1639
|
return $chunk.boundary.state.scopeId;
|
1640
1640
|
}
|
1641
|
-
function peekNextScope() {
|
1642
|
-
return ensureScopeWithId(peekNextScopeId());
|
1643
|
-
}
|
1644
1641
|
function getScopeById(scopeId) {
|
1645
1642
|
if (scopeId !== void 0) {
|
1646
1643
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1647
1644
|
}
|
1648
1645
|
}
|
1649
|
-
function
|
1646
|
+
function serializeIf(condition, key) {
|
1647
|
+
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1648
|
+
}
|
1649
|
+
function serializeGuard(condition, key) {
|
1650
|
+
return condition && (condition === 1 || condition[key]) ? 1 : 0;
|
1651
|
+
}
|
1652
|
+
function markResumeNode(scopeId, accessor, shouldResume) {
|
1653
|
+
if (shouldResume === 0) return "";
|
1650
1654
|
const { state } = $chunk.boundary;
|
1651
1655
|
state.needsMainRuntime = true;
|
1652
1656
|
return state.mark("*" /* Node */, scopeId + " " + accessor);
|
1653
1657
|
}
|
1658
|
+
function commentSeparator(shouldResume) {
|
1659
|
+
return shouldResume === 0 ? "" : "<!>";
|
1660
|
+
}
|
1654
1661
|
function nodeRef(scopeId, id) {
|
1655
1662
|
const getter = () => {
|
1656
1663
|
if (true) {
|
@@ -1678,7 +1685,10 @@ var branchIdKey = Symbol();
|
|
1678
1685
|
function withBranchId(branchId, cb) {
|
1679
1686
|
return withContext(branchIdKey, branchId, cb);
|
1680
1687
|
}
|
1681
|
-
function resumeForOf(list, cb, by, scopeId, accessor) {
|
1688
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
|
1689
|
+
if (serializeBranch === 0) {
|
1690
|
+
return forOf(list, cb);
|
1691
|
+
}
|
1682
1692
|
const loopScopes = /* @__PURE__ */ new Map();
|
1683
1693
|
forOf(list, (item, index) => {
|
1684
1694
|
const branchId = peekNextScopeId();
|
@@ -1705,7 +1715,10 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
|
|
1705
1715
|
)
|
1706
1716
|
);
|
1707
1717
|
}
|
1708
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
|
1718
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
|
1719
|
+
if (serializeBranch === 0) {
|
1720
|
+
return forOf(list, cb);
|
1721
|
+
}
|
1709
1722
|
const loopScopes = /* @__PURE__ */ new Map();
|
1710
1723
|
let branchIds = "";
|
1711
1724
|
forOf(list, (item, index) => {
|
@@ -1737,7 +1750,10 @@ function forOfBy(by, item, index) {
|
|
1737
1750
|
}
|
1738
1751
|
return index;
|
1739
1752
|
}
|
1740
|
-
function resumeForIn(obj, cb, by, scopeId, accessor) {
|
1753
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
|
1754
|
+
if (serializeBranch === 0) {
|
1755
|
+
return forIn(obj, cb);
|
1756
|
+
}
|
1741
1757
|
const loopScopes = /* @__PURE__ */ new Map();
|
1742
1758
|
let sep = "";
|
1743
1759
|
forIn(obj, (key, value) => {
|
@@ -1763,7 +1779,10 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
|
|
1763
1779
|
)
|
1764
1780
|
);
|
1765
1781
|
}
|
1766
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
1782
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1783
|
+
if (serializeBranch === 0) {
|
1784
|
+
return forIn(obj, cb);
|
1785
|
+
}
|
1767
1786
|
const loopScopes = /* @__PURE__ */ new Map();
|
1768
1787
|
let branchIds = "";
|
1769
1788
|
forIn(obj, (key, value) => {
|
@@ -1792,7 +1811,10 @@ function forInBy(by, name, value) {
|
|
1792
1811
|
}
|
1793
1812
|
return name;
|
1794
1813
|
}
|
1795
|
-
function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
1814
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
|
1815
|
+
if (serializeBranch === 0) {
|
1816
|
+
return forTo(to, from, step, cb);
|
1817
|
+
}
|
1796
1818
|
const loopScopes = /* @__PURE__ */ new Map();
|
1797
1819
|
let sep = "";
|
1798
1820
|
forTo(to, from, step, (index) => {
|
@@ -1818,7 +1840,10 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
|
1818
1840
|
)
|
1819
1841
|
);
|
1820
1842
|
}
|
1821
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
|
1843
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1844
|
+
if (serializeBranch === 0) {
|
1845
|
+
return forTo(to, from, step, cb);
|
1846
|
+
}
|
1822
1847
|
const loopScopes = /* @__PURE__ */ new Map();
|
1823
1848
|
let branchIds = "";
|
1824
1849
|
forTo(to, from, step, (index) => {
|
@@ -1847,9 +1872,12 @@ function forToBy(by, index) {
|
|
1847
1872
|
}
|
1848
1873
|
return index;
|
1849
1874
|
}
|
1850
|
-
function resumeConditional(cb, scopeId, accessor,
|
1875
|
+
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1876
|
+
if (serializeBranch === 0) {
|
1877
|
+
return cb();
|
1878
|
+
}
|
1851
1879
|
const branchId = peekNextScopeId();
|
1852
|
-
if (
|
1880
|
+
if (serializeMarker) {
|
1853
1881
|
$chunk.writeHTML(
|
1854
1882
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1855
1883
|
);
|
@@ -1857,13 +1885,13 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
|
|
1857
1885
|
const branchIndex = withBranchId(branchId, cb);
|
1858
1886
|
if (branchIndex !== void 0) {
|
1859
1887
|
writeScope(scopeId, {
|
1860
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]:
|
1888
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1861
1889
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1862
1890
|
});
|
1863
1891
|
} else {
|
1864
1892
|
nextScopeId();
|
1865
1893
|
}
|
1866
|
-
if (
|
1894
|
+
if (serializeMarker) {
|
1867
1895
|
$chunk.writeHTML(
|
1868
1896
|
$chunk.boundary.state.mark(
|
1869
1897
|
"]" /* BranchEnd */,
|
@@ -1872,19 +1900,22 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
|
|
1872
1900
|
);
|
1873
1901
|
}
|
1874
1902
|
}
|
1875
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor,
|
1903
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
|
1904
|
+
if (serializeBranch === 0) {
|
1905
|
+
return cb();
|
1906
|
+
}
|
1876
1907
|
const branchId = peekNextScopeId();
|
1877
1908
|
const branchIndex = withBranchId(branchId, cb);
|
1878
1909
|
const rendered = branchIndex !== void 0;
|
1879
1910
|
if (rendered) {
|
1880
1911
|
writeScope(scopeId, {
|
1881
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]:
|
1912
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1882
1913
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1883
1914
|
});
|
1884
1915
|
} else {
|
1885
1916
|
nextScopeId();
|
1886
1917
|
}
|
1887
|
-
if (
|
1918
|
+
if (serializeMarker) {
|
1888
1919
|
$chunk.writeHTML(
|
1889
1920
|
$chunk.boundary.state.mark(
|
1890
1921
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1921,8 +1952,8 @@ if (true) {
|
|
1921
1952
|
return scope;
|
1922
1953
|
})(writeScope);
|
1923
1954
|
}
|
1924
|
-
function writeExistingScope(
|
1925
|
-
return writeScope(
|
1955
|
+
function writeExistingScope(scopeId) {
|
1956
|
+
return writeScope(scopeId, ensureScopeWithId(scopeId));
|
1926
1957
|
}
|
1927
1958
|
function ensureScopeWithId(scopeId) {
|
1928
1959
|
const { state } = $chunk.boundary;
|
@@ -2756,230 +2787,6 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
|
2756
2787
|
var DEFAULT_RUNTIME_ID = "M";
|
2757
2788
|
var DEFAULT_RENDER_ID = "_";
|
2758
2789
|
|
2759
|
-
// src/html/dynamic-tag.ts
|
2760
|
-
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2761
|
-
var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
|
2762
|
-
const renderer = normalizeDynamicRenderer(tag);
|
2763
|
-
if (true) {
|
2764
|
-
if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
|
2765
|
-
throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
|
2766
|
-
}
|
2767
|
-
}
|
2768
|
-
const state = getState();
|
2769
|
-
const branchId = peekNextScopeId();
|
2770
|
-
let result;
|
2771
|
-
if (typeof renderer === "string") {
|
2772
|
-
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
2773
|
-
nextScopeId();
|
2774
|
-
write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
|
2775
|
-
if (!voidElementsReg.test(renderer)) {
|
2776
|
-
withBranchId(branchId, () => {
|
2777
|
-
if (renderer === "textarea") {
|
2778
|
-
if (content) {
|
2779
|
-
throw new Error(
|
2780
|
-
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2781
|
-
);
|
2782
|
-
}
|
2783
|
-
write(
|
2784
|
-
controllable_textarea_value(
|
2785
|
-
scopeId,
|
2786
|
-
accessor,
|
2787
|
-
input.value,
|
2788
|
-
input.valueChange
|
2789
|
-
)
|
2790
|
-
);
|
2791
|
-
} else if (content) {
|
2792
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
2793
|
-
controllable_select_value(
|
2794
|
-
scopeId,
|
2795
|
-
accessor,
|
2796
|
-
input.value,
|
2797
|
-
input.valueChange,
|
2798
|
-
content
|
2799
|
-
);
|
2800
|
-
} else {
|
2801
|
-
content();
|
2802
|
-
}
|
2803
|
-
}
|
2804
|
-
});
|
2805
|
-
write(`</${renderer}>`);
|
2806
|
-
} else if (content) {
|
2807
|
-
throw new Error(`Body content is not supported for a "${renderer}" tag.`);
|
2808
|
-
}
|
2809
|
-
if (resume) {
|
2810
|
-
write(
|
2811
|
-
state.mark(
|
2812
|
-
"|" /* BranchSingleNode */,
|
2813
|
-
scopeId + " " + accessor + " " + branchId
|
2814
|
-
)
|
2815
|
-
);
|
2816
|
-
}
|
2817
|
-
} else {
|
2818
|
-
if (resume) {
|
2819
|
-
write(state.mark("[" /* BranchStart */, branchId + ""));
|
2820
|
-
}
|
2821
|
-
result = withBranchId(branchId, () => {
|
2822
|
-
if (renderer) {
|
2823
|
-
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
2824
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
2825
|
-
);
|
2826
|
-
} else if (content) {
|
2827
|
-
return content();
|
2828
|
-
}
|
2829
|
-
});
|
2830
|
-
if (resume) {
|
2831
|
-
write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
2832
|
-
}
|
2833
|
-
}
|
2834
|
-
const rendered = peekNextScopeId() !== branchId;
|
2835
|
-
if (rendered) {
|
2836
|
-
if (resume) {
|
2837
|
-
writeScope(scopeId, {
|
2838
|
-
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
2839
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
|
2840
|
-
});
|
2841
|
-
}
|
2842
|
-
} else {
|
2843
|
-
nextScopeId();
|
2844
|
-
}
|
2845
|
-
return result;
|
2846
|
-
};
|
2847
|
-
function createContent(id, fn) {
|
2848
|
-
fn.___id = id;
|
2849
|
-
return fn;
|
2850
|
-
}
|
2851
|
-
function registerContent(id, fn, scopeId) {
|
2852
|
-
return register2(createContent(id, fn), id, scopeId);
|
2853
|
-
}
|
2854
|
-
function patchDynamicTag(patch) {
|
2855
|
-
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
2856
|
-
const patched = patch(scopeId, accessor, tag);
|
2857
|
-
patched.___id = tag;
|
2858
|
-
return originalDynamicTag(
|
2859
|
-
scopeId,
|
2860
|
-
accessor,
|
2861
|
-
patched,
|
2862
|
-
input,
|
2863
|
-
content,
|
2864
|
-
inputIsArgs,
|
2865
|
-
resume
|
2866
|
-
);
|
2867
|
-
})(dynamicTag);
|
2868
|
-
}
|
2869
|
-
|
2870
|
-
// src/html/compat.ts
|
2871
|
-
var K_TAGS_API_STATE = Symbol();
|
2872
|
-
var COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
2873
|
-
var compat = {
|
2874
|
-
fork,
|
2875
|
-
write,
|
2876
|
-
writeScript,
|
2877
|
-
nextScopeId,
|
2878
|
-
isTagsAPI(fn) {
|
2879
|
-
return !!fn.___id;
|
2880
|
-
},
|
2881
|
-
patchDynamicTag,
|
2882
|
-
writeSetScopeForComponent(m5c) {
|
2883
|
-
const scopeId = nextScopeId();
|
2884
|
-
writeScope(scopeId, { m5c });
|
2885
|
-
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2886
|
-
},
|
2887
|
-
toJSON() {
|
2888
|
-
let compatRegistered = COMPAT_REGISTRY.get(this);
|
2889
|
-
if (!compatRegistered) {
|
2890
|
-
const registered = getRegistered(this);
|
2891
|
-
if (registered) {
|
2892
|
-
const scopeId = getScopeId(registered.scope);
|
2893
|
-
if (scopeId !== void 0) {
|
2894
|
-
writeScope(scopeId, {});
|
2895
|
-
}
|
2896
|
-
COMPAT_REGISTRY.set(
|
2897
|
-
this,
|
2898
|
-
compatRegistered = [registered.id, scopeId]
|
2899
|
-
);
|
2900
|
-
}
|
2901
|
-
}
|
2902
|
-
return compatRegistered;
|
2903
|
-
},
|
2904
|
-
render(renderer, willRerender, classAPIOut, component, input) {
|
2905
|
-
const $global2 = classAPIOut.global;
|
2906
|
-
let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
2907
|
-
if (!state) {
|
2908
|
-
$global2.runtimeId ||= DEFAULT_RUNTIME_ID;
|
2909
|
-
$global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID;
|
2910
|
-
$global2[K_TAGS_API_STATE] = state = new State2($global2);
|
2911
|
-
}
|
2912
|
-
const boundary = new Boundary(state);
|
2913
|
-
const head = new Chunk(
|
2914
|
-
boundary,
|
2915
|
-
null,
|
2916
|
-
null
|
2917
|
-
);
|
2918
|
-
let normalizedInput = input;
|
2919
|
-
if ("renderBody" in input) {
|
2920
|
-
normalizedInput = {};
|
2921
|
-
for (const key in input) {
|
2922
|
-
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2923
|
-
}
|
2924
|
-
}
|
2925
|
-
head.render(() => {
|
2926
|
-
if (willRerender) {
|
2927
|
-
const scopeId = peekNextScopeId();
|
2928
|
-
writeScope(scopeId, { m5c: component.id });
|
2929
|
-
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2930
|
-
}
|
2931
|
-
renderer(normalizedInput);
|
2932
|
-
});
|
2933
|
-
const asyncOut = classAPIOut.beginAsync();
|
2934
|
-
queueMicrotask(
|
2935
|
-
boundary.onNext = () => {
|
2936
|
-
if (boundary.signal.aborted) {
|
2937
|
-
asyncOut.error(boundary.signal.reason);
|
2938
|
-
} else if (boundary.done) {
|
2939
|
-
const { scripts, html } = head.consume().flushScript();
|
2940
|
-
asyncOut.script(scripts);
|
2941
|
-
asyncOut.write(html);
|
2942
|
-
asyncOut.end();
|
2943
|
-
}
|
2944
|
-
}
|
2945
|
-
);
|
2946
|
-
},
|
2947
|
-
registerRenderer(renderer, id) {
|
2948
|
-
return register(
|
2949
|
-
RENDERER_REGISTER_ID,
|
2950
|
-
renderer,
|
2951
|
-
register(id, () => {
|
2952
|
-
})
|
2953
|
-
);
|
2954
|
-
},
|
2955
|
-
registerRenderBody(fn) {
|
2956
|
-
register(RENDER_BODY_ID, fn);
|
2957
|
-
}
|
2958
|
-
};
|
2959
|
-
|
2960
|
-
// src/html/for.ts
|
2961
|
-
function forOfBy2(by, item, index) {
|
2962
|
-
if (by) {
|
2963
|
-
if (typeof by === "string") {
|
2964
|
-
return item[by];
|
2965
|
-
}
|
2966
|
-
return by(item, index);
|
2967
|
-
}
|
2968
|
-
return index;
|
2969
|
-
}
|
2970
|
-
function forInBy2(by, name, value) {
|
2971
|
-
if (by) {
|
2972
|
-
return by(name, value);
|
2973
|
-
}
|
2974
|
-
return name;
|
2975
|
-
}
|
2976
|
-
function forToBy2(by, index) {
|
2977
|
-
if (by) {
|
2978
|
-
return by(index);
|
2979
|
-
}
|
2980
|
-
return index;
|
2981
|
-
}
|
2982
|
-
|
2983
2790
|
// src/html/template.ts
|
2984
2791
|
var createTemplate = (templateId, renderer) => {
|
2985
2792
|
renderer.render = render;
|
@@ -2993,6 +2800,9 @@ var createTemplate = (templateId, renderer) => {
|
|
2993
2800
|
}
|
2994
2801
|
return registerContent(templateId, renderer);
|
2995
2802
|
};
|
2803
|
+
function isTemplate(renderer) {
|
2804
|
+
return !!renderer._;
|
2805
|
+
}
|
2996
2806
|
function render(input = {}) {
|
2997
2807
|
let { $global: $global2 } = input;
|
2998
2808
|
if ($global2) {
|
@@ -3199,6 +3009,247 @@ var ServerRendered = class {
|
|
3199
3009
|
};
|
3200
3010
|
function NOOP2() {
|
3201
3011
|
}
|
3012
|
+
|
3013
|
+
// src/html/dynamic-tag.ts
|
3014
|
+
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
3015
|
+
var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
|
3016
|
+
const renderer = normalizeDynamicRenderer(tag);
|
3017
|
+
if (true) {
|
3018
|
+
if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
|
3019
|
+
throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
|
3020
|
+
}
|
3021
|
+
}
|
3022
|
+
const state = getState();
|
3023
|
+
const branchId = peekNextScopeId();
|
3024
|
+
let result;
|
3025
|
+
if (typeof renderer === "string") {
|
3026
|
+
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
3027
|
+
nextScopeId();
|
3028
|
+
write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
|
3029
|
+
if (!voidElementsReg.test(renderer)) {
|
3030
|
+
const renderNativeTag = () => {
|
3031
|
+
if (renderer === "textarea") {
|
3032
|
+
if (content) {
|
3033
|
+
throw new Error(
|
3034
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
3035
|
+
);
|
3036
|
+
}
|
3037
|
+
write(
|
3038
|
+
controllable_textarea_value(
|
3039
|
+
scopeId,
|
3040
|
+
accessor,
|
3041
|
+
input.value,
|
3042
|
+
input.valueChange
|
3043
|
+
)
|
3044
|
+
);
|
3045
|
+
} else if (content) {
|
3046
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3047
|
+
controllable_select_value(
|
3048
|
+
scopeId,
|
3049
|
+
accessor,
|
3050
|
+
input.value,
|
3051
|
+
input.valueChange,
|
3052
|
+
content
|
3053
|
+
);
|
3054
|
+
} else {
|
3055
|
+
content();
|
3056
|
+
}
|
3057
|
+
}
|
3058
|
+
};
|
3059
|
+
if (shouldResume) {
|
3060
|
+
withBranchId(branchId, renderNativeTag);
|
3061
|
+
} else {
|
3062
|
+
renderNativeTag();
|
3063
|
+
}
|
3064
|
+
write(`</${renderer}>`);
|
3065
|
+
} else if (content) {
|
3066
|
+
throw new Error(`Body content is not supported for a "${renderer}" tag.`);
|
3067
|
+
}
|
3068
|
+
if (shouldResume) {
|
3069
|
+
write(
|
3070
|
+
state.mark(
|
3071
|
+
"|" /* BranchSingleNode */,
|
3072
|
+
scopeId + " " + accessor + " " + branchId
|
3073
|
+
)
|
3074
|
+
);
|
3075
|
+
}
|
3076
|
+
} else {
|
3077
|
+
if (shouldResume) {
|
3078
|
+
write(state.mark("[" /* BranchStart */, branchId + ""));
|
3079
|
+
}
|
3080
|
+
const render2 = () => {
|
3081
|
+
if (renderer) {
|
3082
|
+
if (isTemplate(renderer)) {
|
3083
|
+
const input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
|
3084
|
+
return renderer(
|
3085
|
+
content ? { ...input, content } : input,
|
3086
|
+
shouldResume
|
3087
|
+
);
|
3088
|
+
}
|
3089
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
3090
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
3091
|
+
);
|
3092
|
+
} else if (content) {
|
3093
|
+
return content();
|
3094
|
+
}
|
3095
|
+
};
|
3096
|
+
result = shouldResume ? withBranchId(branchId, render2) : render2();
|
3097
|
+
if (shouldResume) {
|
3098
|
+
write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
3099
|
+
}
|
3100
|
+
}
|
3101
|
+
const rendered = peekNextScopeId() !== branchId;
|
3102
|
+
if (rendered) {
|
3103
|
+
if (shouldResume) {
|
3104
|
+
writeScope(scopeId, {
|
3105
|
+
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
3106
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
|
3107
|
+
});
|
3108
|
+
}
|
3109
|
+
} else {
|
3110
|
+
nextScopeId();
|
3111
|
+
}
|
3112
|
+
return result;
|
3113
|
+
};
|
3114
|
+
function createContent(id, fn) {
|
3115
|
+
fn.___id = id;
|
3116
|
+
return fn;
|
3117
|
+
}
|
3118
|
+
function registerContent(id, fn, scopeId) {
|
3119
|
+
return register2(createContent(id, fn), id, scopeId);
|
3120
|
+
}
|
3121
|
+
function patchDynamicTag(patch) {
|
3122
|
+
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
3123
|
+
const patched = patch(scopeId, accessor, tag);
|
3124
|
+
patched.___id = tag;
|
3125
|
+
return originalDynamicTag(
|
3126
|
+
scopeId,
|
3127
|
+
accessor,
|
3128
|
+
patched,
|
3129
|
+
input,
|
3130
|
+
content,
|
3131
|
+
inputIsArgs,
|
3132
|
+
resume
|
3133
|
+
);
|
3134
|
+
})(dynamicTag);
|
3135
|
+
}
|
3136
|
+
|
3137
|
+
// src/html/compat.ts
|
3138
|
+
var K_TAGS_API_STATE = Symbol();
|
3139
|
+
var COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
3140
|
+
var compat = {
|
3141
|
+
fork,
|
3142
|
+
write,
|
3143
|
+
writeScript,
|
3144
|
+
nextScopeId,
|
3145
|
+
isTagsAPI(fn) {
|
3146
|
+
return !!fn.___id;
|
3147
|
+
},
|
3148
|
+
patchDynamicTag,
|
3149
|
+
writeSetScopeForComponent(m5c) {
|
3150
|
+
const scopeId = nextScopeId();
|
3151
|
+
writeScope(scopeId, { m5c });
|
3152
|
+
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
3153
|
+
},
|
3154
|
+
toJSON() {
|
3155
|
+
let compatRegistered = COMPAT_REGISTRY.get(this);
|
3156
|
+
if (!compatRegistered) {
|
3157
|
+
const registered = getRegistered(this);
|
3158
|
+
if (registered) {
|
3159
|
+
const scopeId = getScopeId(registered.scope);
|
3160
|
+
if (scopeId !== void 0) {
|
3161
|
+
writeScope(scopeId, {});
|
3162
|
+
}
|
3163
|
+
COMPAT_REGISTRY.set(
|
3164
|
+
this,
|
3165
|
+
compatRegistered = [registered.id, scopeId]
|
3166
|
+
);
|
3167
|
+
}
|
3168
|
+
}
|
3169
|
+
return compatRegistered;
|
3170
|
+
},
|
3171
|
+
render(renderer, willRerender, classAPIOut, component, input) {
|
3172
|
+
const $global2 = classAPIOut.global;
|
3173
|
+
let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
3174
|
+
if (!state) {
|
3175
|
+
$global2.runtimeId ||= DEFAULT_RUNTIME_ID;
|
3176
|
+
$global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID;
|
3177
|
+
$global2[K_TAGS_API_STATE] = state = new State2($global2);
|
3178
|
+
}
|
3179
|
+
const boundary = new Boundary(state);
|
3180
|
+
const head = new Chunk(
|
3181
|
+
boundary,
|
3182
|
+
null,
|
3183
|
+
null
|
3184
|
+
);
|
3185
|
+
let normalizedInput = input;
|
3186
|
+
if ("renderBody" in input) {
|
3187
|
+
normalizedInput = {};
|
3188
|
+
for (const key in input) {
|
3189
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
3190
|
+
}
|
3191
|
+
}
|
3192
|
+
head.render(() => {
|
3193
|
+
if (willRerender) {
|
3194
|
+
const scopeId = peekNextScopeId();
|
3195
|
+
writeScope(scopeId, { m5c: component.id });
|
3196
|
+
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
3197
|
+
}
|
3198
|
+
if (isTemplate(renderer) && willRerender) {
|
3199
|
+
renderer(normalizedInput, 1);
|
3200
|
+
} else {
|
3201
|
+
renderer(normalizedInput);
|
3202
|
+
}
|
3203
|
+
});
|
3204
|
+
const asyncOut = classAPIOut.beginAsync();
|
3205
|
+
queueMicrotask(
|
3206
|
+
boundary.onNext = () => {
|
3207
|
+
if (boundary.signal.aborted) {
|
3208
|
+
asyncOut.error(boundary.signal.reason);
|
3209
|
+
} else if (boundary.done) {
|
3210
|
+
const { scripts, html } = head.consume().flushScript();
|
3211
|
+
asyncOut.script(scripts);
|
3212
|
+
asyncOut.write(html);
|
3213
|
+
asyncOut.end();
|
3214
|
+
}
|
3215
|
+
}
|
3216
|
+
);
|
3217
|
+
},
|
3218
|
+
registerRenderer(renderer, id) {
|
3219
|
+
return register(
|
3220
|
+
RENDERER_REGISTER_ID,
|
3221
|
+
renderer,
|
3222
|
+
register(id, () => {
|
3223
|
+
})
|
3224
|
+
);
|
3225
|
+
},
|
3226
|
+
registerRenderBody(fn) {
|
3227
|
+
register(RENDER_BODY_ID, fn);
|
3228
|
+
}
|
3229
|
+
};
|
3230
|
+
|
3231
|
+
// src/html/for.ts
|
3232
|
+
function forOfBy2(by, item, index) {
|
3233
|
+
if (by) {
|
3234
|
+
if (typeof by === "string") {
|
3235
|
+
return item[by];
|
3236
|
+
}
|
3237
|
+
return by(item, index);
|
3238
|
+
}
|
3239
|
+
return index;
|
3240
|
+
}
|
3241
|
+
function forInBy2(by, name, value) {
|
3242
|
+
if (by) {
|
3243
|
+
return by(name, value);
|
3244
|
+
}
|
3245
|
+
return name;
|
3246
|
+
}
|
3247
|
+
function forToBy2(by, index) {
|
3248
|
+
if (by) {
|
3249
|
+
return by(index);
|
3250
|
+
}
|
3251
|
+
return index;
|
3252
|
+
}
|
3202
3253
|
export {
|
3203
3254
|
$global,
|
3204
3255
|
attr,
|
@@ -3206,6 +3257,7 @@ export {
|
|
3206
3257
|
attrTags,
|
3207
3258
|
attrs,
|
3208
3259
|
classAttr,
|
3260
|
+
commentSeparator,
|
3209
3261
|
compat,
|
3210
3262
|
controllable_detailsOrDialog_open,
|
3211
3263
|
controllable_input_checked,
|
@@ -3235,7 +3287,7 @@ export {
|
|
3235
3287
|
nodeRef,
|
3236
3288
|
optionValueAttr,
|
3237
3289
|
partialAttrs,
|
3238
|
-
|
3290
|
+
peekNextScopeId,
|
3239
3291
|
register2 as register,
|
3240
3292
|
registerContent,
|
3241
3293
|
resumeClosestBranch,
|
@@ -3247,6 +3299,8 @@ export {
|
|
3247
3299
|
resumeSingleNodeForIn,
|
3248
3300
|
resumeSingleNodeForOf,
|
3249
3301
|
resumeSingleNodeForTo,
|
3302
|
+
serializeGuard,
|
3303
|
+
serializeIf,
|
3250
3304
|
setTagVar,
|
3251
3305
|
styleAttr,
|
3252
3306
|
toString,
|