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.js
CHANGED
@@ -26,6 +26,7 @@ __export(html_exports, {
|
|
26
26
|
attrTags: () => attrTags,
|
27
27
|
attrs: () => attrs,
|
28
28
|
classAttr: () => classAttr,
|
29
|
+
commentSeparator: () => commentSeparator,
|
29
30
|
compat: () => compat,
|
30
31
|
controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
|
31
32
|
controllable_input_checked: () => controllable_input_checked,
|
@@ -55,7 +56,7 @@ __export(html_exports, {
|
|
55
56
|
nodeRef: () => nodeRef,
|
56
57
|
optionValueAttr: () => optionValueAttr,
|
57
58
|
partialAttrs: () => partialAttrs,
|
58
|
-
|
59
|
+
peekNextScopeId: () => peekNextScopeId,
|
59
60
|
register: () => register2,
|
60
61
|
registerContent: () => registerContent,
|
61
62
|
resumeClosestBranch: () => resumeClosestBranch,
|
@@ -67,6 +68,8 @@ __export(html_exports, {
|
|
67
68
|
resumeSingleNodeForIn: () => resumeSingleNodeForIn,
|
68
69
|
resumeSingleNodeForOf: () => resumeSingleNodeForOf,
|
69
70
|
resumeSingleNodeForTo: () => resumeSingleNodeForTo,
|
71
|
+
serializeGuard: () => serializeGuard,
|
72
|
+
serializeIf: () => serializeIf,
|
70
73
|
setTagVar: () => setTagVar,
|
71
74
|
styleAttr: () => styleAttr,
|
72
75
|
toString: () => toString,
|
@@ -1698,9 +1701,9 @@ function withContext(key, value, cb) {
|
|
1698
1701
|
ctx[key] = prev;
|
1699
1702
|
}
|
1700
1703
|
}
|
1701
|
-
function setTagVar(parentScopeId, scopeOffsetAccessor,
|
1704
|
+
function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
1702
1705
|
ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId();
|
1703
|
-
|
1706
|
+
ensureScopeWithId(childScopeId)["#TagVariable" /* TagVariable */] = register2(
|
1704
1707
|
{},
|
1705
1708
|
registryId,
|
1706
1709
|
parentScopeId
|
@@ -1720,19 +1723,26 @@ function nextScopeId() {
|
|
1720
1723
|
function peekNextScopeId() {
|
1721
1724
|
return $chunk.boundary.state.scopeId;
|
1722
1725
|
}
|
1723
|
-
function peekNextScope() {
|
1724
|
-
return ensureScopeWithId(peekNextScopeId());
|
1725
|
-
}
|
1726
1726
|
function getScopeById(scopeId) {
|
1727
1727
|
if (scopeId !== void 0) {
|
1728
1728
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1729
1729
|
}
|
1730
1730
|
}
|
1731
|
-
function
|
1731
|
+
function serializeIf(condition, key) {
|
1732
|
+
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1733
|
+
}
|
1734
|
+
function serializeGuard(condition, key) {
|
1735
|
+
return condition && (condition === 1 || condition[key]) ? 1 : 0;
|
1736
|
+
}
|
1737
|
+
function markResumeNode(scopeId, accessor, shouldResume) {
|
1738
|
+
if (shouldResume === 0) return "";
|
1732
1739
|
const { state } = $chunk.boundary;
|
1733
1740
|
state.needsMainRuntime = true;
|
1734
1741
|
return state.mark("*" /* Node */, scopeId + " " + accessor);
|
1735
1742
|
}
|
1743
|
+
function commentSeparator(shouldResume) {
|
1744
|
+
return shouldResume === 0 ? "" : "<!>";
|
1745
|
+
}
|
1736
1746
|
function nodeRef(scopeId, id) {
|
1737
1747
|
const getter = () => {
|
1738
1748
|
if (true) {
|
@@ -1760,7 +1770,10 @@ var branchIdKey = Symbol();
|
|
1760
1770
|
function withBranchId(branchId, cb) {
|
1761
1771
|
return withContext(branchIdKey, branchId, cb);
|
1762
1772
|
}
|
1763
|
-
function resumeForOf(list, cb, by, scopeId, accessor) {
|
1773
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
|
1774
|
+
if (serializeBranch === 0) {
|
1775
|
+
return forOf(list, cb);
|
1776
|
+
}
|
1764
1777
|
const loopScopes = /* @__PURE__ */ new Map();
|
1765
1778
|
forOf(list, (item, index) => {
|
1766
1779
|
const branchId = peekNextScopeId();
|
@@ -1787,7 +1800,10 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
|
|
1787
1800
|
)
|
1788
1801
|
);
|
1789
1802
|
}
|
1790
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
|
1803
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
|
1804
|
+
if (serializeBranch === 0) {
|
1805
|
+
return forOf(list, cb);
|
1806
|
+
}
|
1791
1807
|
const loopScopes = /* @__PURE__ */ new Map();
|
1792
1808
|
let branchIds = "";
|
1793
1809
|
forOf(list, (item, index) => {
|
@@ -1819,7 +1835,10 @@ function forOfBy(by, item, index) {
|
|
1819
1835
|
}
|
1820
1836
|
return index;
|
1821
1837
|
}
|
1822
|
-
function resumeForIn(obj, cb, by, scopeId, accessor) {
|
1838
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
|
1839
|
+
if (serializeBranch === 0) {
|
1840
|
+
return forIn(obj, cb);
|
1841
|
+
}
|
1823
1842
|
const loopScopes = /* @__PURE__ */ new Map();
|
1824
1843
|
let sep = "";
|
1825
1844
|
forIn(obj, (key, value) => {
|
@@ -1845,7 +1864,10 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
|
|
1845
1864
|
)
|
1846
1865
|
);
|
1847
1866
|
}
|
1848
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
1867
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1868
|
+
if (serializeBranch === 0) {
|
1869
|
+
return forIn(obj, cb);
|
1870
|
+
}
|
1849
1871
|
const loopScopes = /* @__PURE__ */ new Map();
|
1850
1872
|
let branchIds = "";
|
1851
1873
|
forIn(obj, (key, value) => {
|
@@ -1874,7 +1896,10 @@ function forInBy(by, name, value) {
|
|
1874
1896
|
}
|
1875
1897
|
return name;
|
1876
1898
|
}
|
1877
|
-
function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
1899
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
|
1900
|
+
if (serializeBranch === 0) {
|
1901
|
+
return forTo(to, from, step, cb);
|
1902
|
+
}
|
1878
1903
|
const loopScopes = /* @__PURE__ */ new Map();
|
1879
1904
|
let sep = "";
|
1880
1905
|
forTo(to, from, step, (index) => {
|
@@ -1900,7 +1925,10 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
|
1900
1925
|
)
|
1901
1926
|
);
|
1902
1927
|
}
|
1903
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
|
1928
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1929
|
+
if (serializeBranch === 0) {
|
1930
|
+
return forTo(to, from, step, cb);
|
1931
|
+
}
|
1904
1932
|
const loopScopes = /* @__PURE__ */ new Map();
|
1905
1933
|
let branchIds = "";
|
1906
1934
|
forTo(to, from, step, (index) => {
|
@@ -1929,9 +1957,12 @@ function forToBy(by, index) {
|
|
1929
1957
|
}
|
1930
1958
|
return index;
|
1931
1959
|
}
|
1932
|
-
function resumeConditional(cb, scopeId, accessor,
|
1960
|
+
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1961
|
+
if (serializeBranch === 0) {
|
1962
|
+
return cb();
|
1963
|
+
}
|
1933
1964
|
const branchId = peekNextScopeId();
|
1934
|
-
if (
|
1965
|
+
if (serializeMarker) {
|
1935
1966
|
$chunk.writeHTML(
|
1936
1967
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1937
1968
|
);
|
@@ -1939,13 +1970,13 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
|
|
1939
1970
|
const branchIndex = withBranchId(branchId, cb);
|
1940
1971
|
if (branchIndex !== void 0) {
|
1941
1972
|
writeScope(scopeId, {
|
1942
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]:
|
1973
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1943
1974
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1944
1975
|
});
|
1945
1976
|
} else {
|
1946
1977
|
nextScopeId();
|
1947
1978
|
}
|
1948
|
-
if (
|
1979
|
+
if (serializeMarker) {
|
1949
1980
|
$chunk.writeHTML(
|
1950
1981
|
$chunk.boundary.state.mark(
|
1951
1982
|
"]" /* BranchEnd */,
|
@@ -1954,19 +1985,22 @@ function resumeConditional(cb, scopeId, accessor, dynamic) {
|
|
1954
1985
|
);
|
1955
1986
|
}
|
1956
1987
|
}
|
1957
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor,
|
1988
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
|
1989
|
+
if (serializeBranch === 0) {
|
1990
|
+
return cb();
|
1991
|
+
}
|
1958
1992
|
const branchId = peekNextScopeId();
|
1959
1993
|
const branchIndex = withBranchId(branchId, cb);
|
1960
1994
|
const rendered = branchIndex !== void 0;
|
1961
1995
|
if (rendered) {
|
1962
1996
|
writeScope(scopeId, {
|
1963
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]:
|
1997
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1964
1998
|
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1965
1999
|
});
|
1966
2000
|
} else {
|
1967
2001
|
nextScopeId();
|
1968
2002
|
}
|
1969
|
-
if (
|
2003
|
+
if (serializeMarker) {
|
1970
2004
|
$chunk.writeHTML(
|
1971
2005
|
$chunk.boundary.state.mark(
|
1972
2006
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -2003,8 +2037,8 @@ if (true) {
|
|
2003
2037
|
return scope;
|
2004
2038
|
})(writeScope);
|
2005
2039
|
}
|
2006
|
-
function writeExistingScope(
|
2007
|
-
return writeScope(
|
2040
|
+
function writeExistingScope(scopeId) {
|
2041
|
+
return writeScope(scopeId, ensureScopeWithId(scopeId));
|
2008
2042
|
}
|
2009
2043
|
function ensureScopeWithId(scopeId) {
|
2010
2044
|
const { state } = $chunk.boundary;
|
@@ -2838,230 +2872,6 @@ var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
|
2838
2872
|
var DEFAULT_RUNTIME_ID = "M";
|
2839
2873
|
var DEFAULT_RENDER_ID = "_";
|
2840
2874
|
|
2841
|
-
// src/html/dynamic-tag.ts
|
2842
|
-
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2843
|
-
var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
|
2844
|
-
const renderer = normalizeDynamicRenderer(tag);
|
2845
|
-
if (true) {
|
2846
|
-
if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
|
2847
|
-
throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
|
2848
|
-
}
|
2849
|
-
}
|
2850
|
-
const state = getState();
|
2851
|
-
const branchId = peekNextScopeId();
|
2852
|
-
let result;
|
2853
|
-
if (typeof renderer === "string") {
|
2854
|
-
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
2855
|
-
nextScopeId();
|
2856
|
-
write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
|
2857
|
-
if (!voidElementsReg.test(renderer)) {
|
2858
|
-
withBranchId(branchId, () => {
|
2859
|
-
if (renderer === "textarea") {
|
2860
|
-
if (content) {
|
2861
|
-
throw new Error(
|
2862
|
-
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2863
|
-
);
|
2864
|
-
}
|
2865
|
-
write(
|
2866
|
-
controllable_textarea_value(
|
2867
|
-
scopeId,
|
2868
|
-
accessor,
|
2869
|
-
input.value,
|
2870
|
-
input.valueChange
|
2871
|
-
)
|
2872
|
-
);
|
2873
|
-
} else if (content) {
|
2874
|
-
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
2875
|
-
controllable_select_value(
|
2876
|
-
scopeId,
|
2877
|
-
accessor,
|
2878
|
-
input.value,
|
2879
|
-
input.valueChange,
|
2880
|
-
content
|
2881
|
-
);
|
2882
|
-
} else {
|
2883
|
-
content();
|
2884
|
-
}
|
2885
|
-
}
|
2886
|
-
});
|
2887
|
-
write(`</${renderer}>`);
|
2888
|
-
} else if (content) {
|
2889
|
-
throw new Error(`Body content is not supported for a "${renderer}" tag.`);
|
2890
|
-
}
|
2891
|
-
if (resume) {
|
2892
|
-
write(
|
2893
|
-
state.mark(
|
2894
|
-
"|" /* BranchSingleNode */,
|
2895
|
-
scopeId + " " + accessor + " " + branchId
|
2896
|
-
)
|
2897
|
-
);
|
2898
|
-
}
|
2899
|
-
} else {
|
2900
|
-
if (resume) {
|
2901
|
-
write(state.mark("[" /* BranchStart */, branchId + ""));
|
2902
|
-
}
|
2903
|
-
result = withBranchId(branchId, () => {
|
2904
|
-
if (renderer) {
|
2905
|
-
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
2906
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
2907
|
-
);
|
2908
|
-
} else if (content) {
|
2909
|
-
return content();
|
2910
|
-
}
|
2911
|
-
});
|
2912
|
-
if (resume) {
|
2913
|
-
write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
2914
|
-
}
|
2915
|
-
}
|
2916
|
-
const rendered = peekNextScopeId() !== branchId;
|
2917
|
-
if (rendered) {
|
2918
|
-
if (resume) {
|
2919
|
-
writeScope(scopeId, {
|
2920
|
-
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
2921
|
-
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
|
2922
|
-
});
|
2923
|
-
}
|
2924
|
-
} else {
|
2925
|
-
nextScopeId();
|
2926
|
-
}
|
2927
|
-
return result;
|
2928
|
-
};
|
2929
|
-
function createContent(id, fn) {
|
2930
|
-
fn.___id = id;
|
2931
|
-
return fn;
|
2932
|
-
}
|
2933
|
-
function registerContent(id, fn, scopeId) {
|
2934
|
-
return register2(createContent(id, fn), id, scopeId);
|
2935
|
-
}
|
2936
|
-
function patchDynamicTag(patch) {
|
2937
|
-
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
2938
|
-
const patched = patch(scopeId, accessor, tag);
|
2939
|
-
patched.___id = tag;
|
2940
|
-
return originalDynamicTag(
|
2941
|
-
scopeId,
|
2942
|
-
accessor,
|
2943
|
-
patched,
|
2944
|
-
input,
|
2945
|
-
content,
|
2946
|
-
inputIsArgs,
|
2947
|
-
resume
|
2948
|
-
);
|
2949
|
-
})(dynamicTag);
|
2950
|
-
}
|
2951
|
-
|
2952
|
-
// src/html/compat.ts
|
2953
|
-
var K_TAGS_API_STATE = Symbol();
|
2954
|
-
var COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
2955
|
-
var compat = {
|
2956
|
-
fork,
|
2957
|
-
write,
|
2958
|
-
writeScript,
|
2959
|
-
nextScopeId,
|
2960
|
-
isTagsAPI(fn) {
|
2961
|
-
return !!fn.___id;
|
2962
|
-
},
|
2963
|
-
patchDynamicTag,
|
2964
|
-
writeSetScopeForComponent(m5c) {
|
2965
|
-
const scopeId = nextScopeId();
|
2966
|
-
writeScope(scopeId, { m5c });
|
2967
|
-
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2968
|
-
},
|
2969
|
-
toJSON() {
|
2970
|
-
let compatRegistered = COMPAT_REGISTRY.get(this);
|
2971
|
-
if (!compatRegistered) {
|
2972
|
-
const registered = getRegistered(this);
|
2973
|
-
if (registered) {
|
2974
|
-
const scopeId = getScopeId(registered.scope);
|
2975
|
-
if (scopeId !== void 0) {
|
2976
|
-
writeScope(scopeId, {});
|
2977
|
-
}
|
2978
|
-
COMPAT_REGISTRY.set(
|
2979
|
-
this,
|
2980
|
-
compatRegistered = [registered.id, scopeId]
|
2981
|
-
);
|
2982
|
-
}
|
2983
|
-
}
|
2984
|
-
return compatRegistered;
|
2985
|
-
},
|
2986
|
-
render(renderer, willRerender, classAPIOut, component, input) {
|
2987
|
-
const $global2 = classAPIOut.global;
|
2988
|
-
let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
2989
|
-
if (!state) {
|
2990
|
-
$global2.runtimeId ||= DEFAULT_RUNTIME_ID;
|
2991
|
-
$global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID;
|
2992
|
-
$global2[K_TAGS_API_STATE] = state = new State2($global2);
|
2993
|
-
}
|
2994
|
-
const boundary = new Boundary(state);
|
2995
|
-
const head = new Chunk(
|
2996
|
-
boundary,
|
2997
|
-
null,
|
2998
|
-
null
|
2999
|
-
);
|
3000
|
-
let normalizedInput = input;
|
3001
|
-
if ("renderBody" in input) {
|
3002
|
-
normalizedInput = {};
|
3003
|
-
for (const key in input) {
|
3004
|
-
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
3005
|
-
}
|
3006
|
-
}
|
3007
|
-
head.render(() => {
|
3008
|
-
if (willRerender) {
|
3009
|
-
const scopeId = peekNextScopeId();
|
3010
|
-
writeScope(scopeId, { m5c: component.id });
|
3011
|
-
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
3012
|
-
}
|
3013
|
-
renderer(normalizedInput);
|
3014
|
-
});
|
3015
|
-
const asyncOut = classAPIOut.beginAsync();
|
3016
|
-
queueMicrotask(
|
3017
|
-
boundary.onNext = () => {
|
3018
|
-
if (boundary.signal.aborted) {
|
3019
|
-
asyncOut.error(boundary.signal.reason);
|
3020
|
-
} else if (boundary.done) {
|
3021
|
-
const { scripts, html } = head.consume().flushScript();
|
3022
|
-
asyncOut.script(scripts);
|
3023
|
-
asyncOut.write(html);
|
3024
|
-
asyncOut.end();
|
3025
|
-
}
|
3026
|
-
}
|
3027
|
-
);
|
3028
|
-
},
|
3029
|
-
registerRenderer(renderer, id) {
|
3030
|
-
return register(
|
3031
|
-
RENDERER_REGISTER_ID,
|
3032
|
-
renderer,
|
3033
|
-
register(id, () => {
|
3034
|
-
})
|
3035
|
-
);
|
3036
|
-
},
|
3037
|
-
registerRenderBody(fn) {
|
3038
|
-
register(RENDER_BODY_ID, fn);
|
3039
|
-
}
|
3040
|
-
};
|
3041
|
-
|
3042
|
-
// src/html/for.ts
|
3043
|
-
function forOfBy2(by, item, index) {
|
3044
|
-
if (by) {
|
3045
|
-
if (typeof by === "string") {
|
3046
|
-
return item[by];
|
3047
|
-
}
|
3048
|
-
return by(item, index);
|
3049
|
-
}
|
3050
|
-
return index;
|
3051
|
-
}
|
3052
|
-
function forInBy2(by, name, value) {
|
3053
|
-
if (by) {
|
3054
|
-
return by(name, value);
|
3055
|
-
}
|
3056
|
-
return name;
|
3057
|
-
}
|
3058
|
-
function forToBy2(by, index) {
|
3059
|
-
if (by) {
|
3060
|
-
return by(index);
|
3061
|
-
}
|
3062
|
-
return index;
|
3063
|
-
}
|
3064
|
-
|
3065
2875
|
// src/html/template.ts
|
3066
2876
|
var createTemplate = (templateId, renderer) => {
|
3067
2877
|
renderer.render = render;
|
@@ -3075,6 +2885,9 @@ var createTemplate = (templateId, renderer) => {
|
|
3075
2885
|
}
|
3076
2886
|
return registerContent(templateId, renderer);
|
3077
2887
|
};
|
2888
|
+
function isTemplate(renderer) {
|
2889
|
+
return !!renderer._;
|
2890
|
+
}
|
3078
2891
|
function render(input = {}) {
|
3079
2892
|
let { $global: $global2 } = input;
|
3080
2893
|
if ($global2) {
|
@@ -3281,6 +3094,247 @@ var ServerRendered = class {
|
|
3281
3094
|
};
|
3282
3095
|
function NOOP2() {
|
3283
3096
|
}
|
3097
|
+
|
3098
|
+
// src/html/dynamic-tag.ts
|
3099
|
+
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
3100
|
+
var dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
|
3101
|
+
const renderer = normalizeDynamicRenderer(tag);
|
3102
|
+
if (true) {
|
3103
|
+
if (renderer && typeof renderer !== "function" && typeof renderer !== "string") {
|
3104
|
+
throw new Error(`Invalid renderer passed for dynamic tag: ${renderer}`);
|
3105
|
+
}
|
3106
|
+
}
|
3107
|
+
const state = getState();
|
3108
|
+
const branchId = peekNextScopeId();
|
3109
|
+
let result;
|
3110
|
+
if (typeof renderer === "string") {
|
3111
|
+
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
3112
|
+
nextScopeId();
|
3113
|
+
write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`);
|
3114
|
+
if (!voidElementsReg.test(renderer)) {
|
3115
|
+
const renderNativeTag = () => {
|
3116
|
+
if (renderer === "textarea") {
|
3117
|
+
if (content) {
|
3118
|
+
throw new Error(
|
3119
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
3120
|
+
);
|
3121
|
+
}
|
3122
|
+
write(
|
3123
|
+
controllable_textarea_value(
|
3124
|
+
scopeId,
|
3125
|
+
accessor,
|
3126
|
+
input.value,
|
3127
|
+
input.valueChange
|
3128
|
+
)
|
3129
|
+
);
|
3130
|
+
} else if (content) {
|
3131
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) {
|
3132
|
+
controllable_select_value(
|
3133
|
+
scopeId,
|
3134
|
+
accessor,
|
3135
|
+
input.value,
|
3136
|
+
input.valueChange,
|
3137
|
+
content
|
3138
|
+
);
|
3139
|
+
} else {
|
3140
|
+
content();
|
3141
|
+
}
|
3142
|
+
}
|
3143
|
+
};
|
3144
|
+
if (shouldResume) {
|
3145
|
+
withBranchId(branchId, renderNativeTag);
|
3146
|
+
} else {
|
3147
|
+
renderNativeTag();
|
3148
|
+
}
|
3149
|
+
write(`</${renderer}>`);
|
3150
|
+
} else if (content) {
|
3151
|
+
throw new Error(`Body content is not supported for a "${renderer}" tag.`);
|
3152
|
+
}
|
3153
|
+
if (shouldResume) {
|
3154
|
+
write(
|
3155
|
+
state.mark(
|
3156
|
+
"|" /* BranchSingleNode */,
|
3157
|
+
scopeId + " " + accessor + " " + branchId
|
3158
|
+
)
|
3159
|
+
);
|
3160
|
+
}
|
3161
|
+
} else {
|
3162
|
+
if (shouldResume) {
|
3163
|
+
write(state.mark("[" /* BranchStart */, branchId + ""));
|
3164
|
+
}
|
3165
|
+
const render2 = () => {
|
3166
|
+
if (renderer) {
|
3167
|
+
if (isTemplate(renderer)) {
|
3168
|
+
const input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
|
3169
|
+
return renderer(
|
3170
|
+
content ? { ...input, content } : input,
|
3171
|
+
shouldResume
|
3172
|
+
);
|
3173
|
+
}
|
3174
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
3175
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
3176
|
+
);
|
3177
|
+
} else if (content) {
|
3178
|
+
return content();
|
3179
|
+
}
|
3180
|
+
};
|
3181
|
+
result = shouldResume ? withBranchId(branchId, render2) : render2();
|
3182
|
+
if (shouldResume) {
|
3183
|
+
write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
3184
|
+
}
|
3185
|
+
}
|
3186
|
+
const rendered = peekNextScopeId() !== branchId;
|
3187
|
+
if (rendered) {
|
3188
|
+
if (shouldResume) {
|
3189
|
+
writeScope(scopeId, {
|
3190
|
+
["ConditionalScope:" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
3191
|
+
["ConditionalRenderer:" /* ConditionalRenderer */ + accessor]: renderer?.___id || renderer
|
3192
|
+
});
|
3193
|
+
}
|
3194
|
+
} else {
|
3195
|
+
nextScopeId();
|
3196
|
+
}
|
3197
|
+
return result;
|
3198
|
+
};
|
3199
|
+
function createContent(id, fn) {
|
3200
|
+
fn.___id = id;
|
3201
|
+
return fn;
|
3202
|
+
}
|
3203
|
+
function registerContent(id, fn, scopeId) {
|
3204
|
+
return register2(createContent(id, fn), id, scopeId);
|
3205
|
+
}
|
3206
|
+
function patchDynamicTag(patch) {
|
3207
|
+
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
3208
|
+
const patched = patch(scopeId, accessor, tag);
|
3209
|
+
patched.___id = tag;
|
3210
|
+
return originalDynamicTag(
|
3211
|
+
scopeId,
|
3212
|
+
accessor,
|
3213
|
+
patched,
|
3214
|
+
input,
|
3215
|
+
content,
|
3216
|
+
inputIsArgs,
|
3217
|
+
resume
|
3218
|
+
);
|
3219
|
+
})(dynamicTag);
|
3220
|
+
}
|
3221
|
+
|
3222
|
+
// src/html/compat.ts
|
3223
|
+
var K_TAGS_API_STATE = Symbol();
|
3224
|
+
var COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
|
3225
|
+
var compat = {
|
3226
|
+
fork,
|
3227
|
+
write,
|
3228
|
+
writeScript,
|
3229
|
+
nextScopeId,
|
3230
|
+
isTagsAPI(fn) {
|
3231
|
+
return !!fn.___id;
|
3232
|
+
},
|
3233
|
+
patchDynamicTag,
|
3234
|
+
writeSetScopeForComponent(m5c) {
|
3235
|
+
const scopeId = nextScopeId();
|
3236
|
+
writeScope(scopeId, { m5c });
|
3237
|
+
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
3238
|
+
},
|
3239
|
+
toJSON() {
|
3240
|
+
let compatRegistered = COMPAT_REGISTRY.get(this);
|
3241
|
+
if (!compatRegistered) {
|
3242
|
+
const registered = getRegistered(this);
|
3243
|
+
if (registered) {
|
3244
|
+
const scopeId = getScopeId(registered.scope);
|
3245
|
+
if (scopeId !== void 0) {
|
3246
|
+
writeScope(scopeId, {});
|
3247
|
+
}
|
3248
|
+
COMPAT_REGISTRY.set(
|
3249
|
+
this,
|
3250
|
+
compatRegistered = [registered.id, scopeId]
|
3251
|
+
);
|
3252
|
+
}
|
3253
|
+
}
|
3254
|
+
return compatRegistered;
|
3255
|
+
},
|
3256
|
+
render(renderer, willRerender, classAPIOut, component, input) {
|
3257
|
+
const $global2 = classAPIOut.global;
|
3258
|
+
let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
3259
|
+
if (!state) {
|
3260
|
+
$global2.runtimeId ||= DEFAULT_RUNTIME_ID;
|
3261
|
+
$global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID;
|
3262
|
+
$global2[K_TAGS_API_STATE] = state = new State2($global2);
|
3263
|
+
}
|
3264
|
+
const boundary = new Boundary(state);
|
3265
|
+
const head = new Chunk(
|
3266
|
+
boundary,
|
3267
|
+
null,
|
3268
|
+
null
|
3269
|
+
);
|
3270
|
+
let normalizedInput = input;
|
3271
|
+
if ("renderBody" in input) {
|
3272
|
+
normalizedInput = {};
|
3273
|
+
for (const key in input) {
|
3274
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
3275
|
+
}
|
3276
|
+
}
|
3277
|
+
head.render(() => {
|
3278
|
+
if (willRerender) {
|
3279
|
+
const scopeId = peekNextScopeId();
|
3280
|
+
writeScope(scopeId, { m5c: component.id });
|
3281
|
+
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
3282
|
+
}
|
3283
|
+
if (isTemplate(renderer) && willRerender) {
|
3284
|
+
renderer(normalizedInput, 1);
|
3285
|
+
} else {
|
3286
|
+
renderer(normalizedInput);
|
3287
|
+
}
|
3288
|
+
});
|
3289
|
+
const asyncOut = classAPIOut.beginAsync();
|
3290
|
+
queueMicrotask(
|
3291
|
+
boundary.onNext = () => {
|
3292
|
+
if (boundary.signal.aborted) {
|
3293
|
+
asyncOut.error(boundary.signal.reason);
|
3294
|
+
} else if (boundary.done) {
|
3295
|
+
const { scripts, html } = head.consume().flushScript();
|
3296
|
+
asyncOut.script(scripts);
|
3297
|
+
asyncOut.write(html);
|
3298
|
+
asyncOut.end();
|
3299
|
+
}
|
3300
|
+
}
|
3301
|
+
);
|
3302
|
+
},
|
3303
|
+
registerRenderer(renderer, id) {
|
3304
|
+
return register(
|
3305
|
+
RENDERER_REGISTER_ID,
|
3306
|
+
renderer,
|
3307
|
+
register(id, () => {
|
3308
|
+
})
|
3309
|
+
);
|
3310
|
+
},
|
3311
|
+
registerRenderBody(fn) {
|
3312
|
+
register(RENDER_BODY_ID, fn);
|
3313
|
+
}
|
3314
|
+
};
|
3315
|
+
|
3316
|
+
// src/html/for.ts
|
3317
|
+
function forOfBy2(by, item, index) {
|
3318
|
+
if (by) {
|
3319
|
+
if (typeof by === "string") {
|
3320
|
+
return item[by];
|
3321
|
+
}
|
3322
|
+
return by(item, index);
|
3323
|
+
}
|
3324
|
+
return index;
|
3325
|
+
}
|
3326
|
+
function forInBy2(by, name, value) {
|
3327
|
+
if (by) {
|
3328
|
+
return by(name, value);
|
3329
|
+
}
|
3330
|
+
return name;
|
3331
|
+
}
|
3332
|
+
function forToBy2(by, index) {
|
3333
|
+
if (by) {
|
3334
|
+
return by(index);
|
3335
|
+
}
|
3336
|
+
return index;
|
3337
|
+
}
|
3284
3338
|
// Annotate the CommonJS export names for ESM import in node:
|
3285
3339
|
0 && (module.exports = {
|
3286
3340
|
$global,
|
@@ -3289,6 +3343,7 @@ function NOOP2() {
|
|
3289
3343
|
attrTags,
|
3290
3344
|
attrs,
|
3291
3345
|
classAttr,
|
3346
|
+
commentSeparator,
|
3292
3347
|
compat,
|
3293
3348
|
controllable_detailsOrDialog_open,
|
3294
3349
|
controllable_input_checked,
|
@@ -3318,7 +3373,7 @@ function NOOP2() {
|
|
3318
3373
|
nodeRef,
|
3319
3374
|
optionValueAttr,
|
3320
3375
|
partialAttrs,
|
3321
|
-
|
3376
|
+
peekNextScopeId,
|
3322
3377
|
register,
|
3323
3378
|
registerContent,
|
3324
3379
|
resumeClosestBranch,
|
@@ -3330,6 +3385,8 @@ function NOOP2() {
|
|
3330
3385
|
resumeSingleNodeForIn,
|
3331
3386
|
resumeSingleNodeForOf,
|
3332
3387
|
resumeSingleNodeForTo,
|
3388
|
+
serializeGuard,
|
3389
|
+
serializeIf,
|
3333
3390
|
setTagVar,
|
3334
3391
|
styleAttr,
|
3335
3392
|
toString,
|