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/html.mjs
CHANGED
@@ -1032,8 +1032,8 @@ function withContext(key, value, cb) {
|
|
1032
1032
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
1033
1033
|
}
|
1034
1034
|
}
|
1035
|
-
function setTagVar(parentScopeId, scopeOffsetAccessor,
|
1036
|
-
ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(),
|
1035
|
+
function setTagVar(parentScopeId, scopeOffsetAccessor, childScopeId, registryId) {
|
1036
|
+
ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), ensureScopeWithId(childScopeId).e = register2(
|
1037
1037
|
{},
|
1038
1038
|
registryId,
|
1039
1039
|
parentScopeId
|
@@ -1052,17 +1052,24 @@ function nextScopeId() {
|
|
1052
1052
|
function peekNextScopeId() {
|
1053
1053
|
return $chunk.boundary.state.scopeId;
|
1054
1054
|
}
|
1055
|
-
function peekNextScope() {
|
1056
|
-
return ensureScopeWithId(peekNextScopeId());
|
1057
|
-
}
|
1058
1055
|
function getScopeById(scopeId) {
|
1059
1056
|
if (scopeId !== void 0)
|
1060
1057
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1061
1058
|
}
|
1062
|
-
function
|
1059
|
+
function serializeIf(condition, key) {
|
1060
|
+
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1061
|
+
}
|
1062
|
+
function serializeGuard(condition, key) {
|
1063
|
+
return condition && (condition === 1 || condition[key]) ? 1 : 0;
|
1064
|
+
}
|
1065
|
+
function markResumeNode(scopeId, accessor, shouldResume) {
|
1066
|
+
if (shouldResume === 0) return "";
|
1063
1067
|
let { state } = $chunk.boundary;
|
1064
1068
|
return state.needsMainRuntime = !0, state.mark("*" /* Node */, scopeId + " " + accessor);
|
1065
1069
|
}
|
1070
|
+
function commentSeparator(shouldResume) {
|
1071
|
+
return shouldResume === 0 ? "" : "<!>";
|
1072
|
+
}
|
1066
1073
|
function nodeRef(scopeId, id) {
|
1067
1074
|
let getter = () => {
|
1068
1075
|
};
|
@@ -1081,7 +1088,9 @@ var branchIdKey = Symbol();
|
|
1081
1088
|
function withBranchId(branchId, cb) {
|
1082
1089
|
return withContext(branchIdKey, branchId, cb);
|
1083
1090
|
}
|
1084
|
-
function resumeForOf(list, cb, by, scopeId, accessor) {
|
1091
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
|
1092
|
+
if (serializeBranch === 0)
|
1093
|
+
return forOf(list, cb);
|
1085
1094
|
let loopScopes = /* @__PURE__ */ new Map();
|
1086
1095
|
forOf(list, (item, index) => {
|
1087
1096
|
let branchId = peekNextScopeId();
|
@@ -1102,7 +1111,9 @@ function resumeForOf(list, cb, by, scopeId, accessor) {
|
|
1102
1111
|
)
|
1103
1112
|
);
|
1104
1113
|
}
|
1105
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
|
1114
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
|
1115
|
+
if (serializeBranch === 0)
|
1116
|
+
return forOf(list, cb);
|
1106
1117
|
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1107
1118
|
forOf(list, (item, index) => {
|
1108
1119
|
let branchId = peekNextScopeId();
|
@@ -1121,7 +1132,9 @@ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParen
|
|
1121
1132
|
function forOfBy(by, item, index) {
|
1122
1133
|
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1123
1134
|
}
|
1124
|
-
function resumeForIn(obj, cb, by, scopeId, accessor) {
|
1135
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
|
1136
|
+
if (serializeBranch === 0)
|
1137
|
+
return forIn(obj, cb);
|
1125
1138
|
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1126
1139
|
forIn(obj, (key, value) => {
|
1127
1140
|
let branchId = peekNextScopeId();
|
@@ -1139,7 +1152,9 @@ function resumeForIn(obj, cb, by, scopeId, accessor) {
|
|
1139
1152
|
)
|
1140
1153
|
);
|
1141
1154
|
}
|
1142
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
1155
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1156
|
+
if (serializeBranch === 0)
|
1157
|
+
return forIn(obj, cb);
|
1143
1158
|
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1144
1159
|
forIn(obj, (key, value) => {
|
1145
1160
|
let branchId = peekNextScopeId();
|
@@ -1158,7 +1173,9 @@ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
|
1158
1173
|
function forInBy(by, name, value) {
|
1159
1174
|
return by ? by(name, value) : name;
|
1160
1175
|
}
|
1161
|
-
function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
1176
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
|
1177
|
+
if (serializeBranch === 0)
|
1178
|
+
return forTo(to, from, step, cb);
|
1162
1179
|
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1163
1180
|
forTo(to, from, step, (index) => {
|
1164
1181
|
let branchId = peekNextScopeId();
|
@@ -1176,7 +1193,9 @@ function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
|
1176
1193
|
)
|
1177
1194
|
);
|
1178
1195
|
}
|
1179
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
|
1196
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
|
1197
|
+
if (serializeBranch === 0)
|
1198
|
+
return forTo(to, from, step, cb);
|
1180
1199
|
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1181
1200
|
forTo(to, from, step, (index) => {
|
1182
1201
|
let branchId = peekNextScopeId();
|
@@ -1195,28 +1214,32 @@ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyCh
|
|
1195
1214
|
function forToBy(by, index) {
|
1196
1215
|
return by ? by(index) : index;
|
1197
1216
|
}
|
1198
|
-
function resumeConditional(cb, scopeId, accessor,
|
1217
|
+
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1218
|
+
if (serializeBranch === 0)
|
1219
|
+
return cb();
|
1199
1220
|
let branchId = peekNextScopeId();
|
1200
|
-
|
1221
|
+
serializeMarker && $chunk.writeHTML(
|
1201
1222
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1202
1223
|
);
|
1203
1224
|
let branchIndex = withBranchId(branchId, cb);
|
1204
1225
|
branchIndex !== void 0 ? writeScope(scopeId, {
|
1205
|
-
["c" /* ConditionalRenderer */ + accessor]:
|
1226
|
+
["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1206
1227
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1207
|
-
}) : nextScopeId(),
|
1228
|
+
}) : nextScopeId(), serializeMarker && $chunk.writeHTML(
|
1208
1229
|
$chunk.boundary.state.mark(
|
1209
1230
|
"]" /* BranchEnd */,
|
1210
1231
|
scopeId + " " + accessor
|
1211
1232
|
)
|
1212
1233
|
);
|
1213
1234
|
}
|
1214
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor,
|
1235
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
|
1236
|
+
if (serializeBranch === 0)
|
1237
|
+
return cb();
|
1215
1238
|
let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
|
1216
1239
|
rendered ? writeScope(scopeId, {
|
1217
|
-
["c" /* ConditionalRenderer */ + accessor]:
|
1240
|
+
["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1218
1241
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1219
|
-
}) : nextScopeId(),
|
1242
|
+
}) : nextScopeId(), serializeMarker && $chunk.writeHTML(
|
1220
1243
|
$chunk.boundary.state.mark(
|
1221
1244
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1222
1245
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
@@ -1227,8 +1250,8 @@ var writeScope = (scopeId, partialScope) => {
|
|
1227
1250
|
let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
|
1228
1251
|
return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.writeScopes = { [scopeId]: scope }, scope;
|
1229
1252
|
};
|
1230
|
-
function writeExistingScope(
|
1231
|
-
return writeScope(
|
1253
|
+
function writeExistingScope(scopeId) {
|
1254
|
+
return writeScope(scopeId, ensureScopeWithId(scopeId));
|
1232
1255
|
}
|
1233
1256
|
function ensureScopeWithId(scopeId) {
|
1234
1257
|
let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
|
@@ -1776,153 +1799,11 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1776
1799
|
// src/common/meta.ts
|
1777
1800
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
1778
1801
|
|
1779
|
-
// src/html/dynamic-tag.ts
|
1780
|
-
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
|
1781
|
-
let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
|
1782
|
-
if (typeof renderer == "string") {
|
1783
|
-
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1784
|
-
nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
|
1785
|
-
renderer === "textarea" ? write(
|
1786
|
-
controllable_textarea_value(
|
1787
|
-
scopeId,
|
1788
|
-
accessor,
|
1789
|
-
input.value,
|
1790
|
-
input.valueChange
|
1791
|
-
)
|
1792
|
-
) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1793
|
-
scopeId,
|
1794
|
-
accessor,
|
1795
|
-
input.value,
|
1796
|
-
input.valueChange,
|
1797
|
-
content
|
1798
|
-
) : content());
|
1799
|
-
}), write(`</${renderer}>`)), resume && write(
|
1800
|
-
state.mark(
|
1801
|
-
"|" /* BranchSingleNode */,
|
1802
|
-
scopeId + " " + accessor + " " + branchId
|
1803
|
-
)
|
1804
|
-
);
|
1805
|
-
} else
|
1806
|
-
resume && write(state.mark("[" /* BranchStart */, branchId + "")), result = withBranchId(branchId, () => {
|
1807
|
-
if (renderer)
|
1808
|
-
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
1809
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
1810
|
-
);
|
1811
|
-
if (content)
|
1812
|
-
return content();
|
1813
|
-
}), resume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
1814
|
-
return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
|
1815
|
-
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
1816
|
-
["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
|
1817
|
-
}) : nextScopeId(), result;
|
1818
|
-
};
|
1819
|
-
function createContent(id, fn) {
|
1820
|
-
return fn.h = id, fn;
|
1821
|
-
}
|
1822
|
-
function registerContent(id, fn, scopeId) {
|
1823
|
-
return register2(createContent(id, fn), id, scopeId);
|
1824
|
-
}
|
1825
|
-
function patchDynamicTag(patch) {
|
1826
|
-
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
1827
|
-
let patched = patch(scopeId, accessor, tag);
|
1828
|
-
return patched.h = tag, originalDynamicTag(
|
1829
|
-
scopeId,
|
1830
|
-
accessor,
|
1831
|
-
patched,
|
1832
|
-
input,
|
1833
|
-
content,
|
1834
|
-
inputIsArgs,
|
1835
|
-
resume
|
1836
|
-
);
|
1837
|
-
})(dynamicTag);
|
1838
|
-
}
|
1839
|
-
|
1840
|
-
// src/html/compat.ts
|
1841
|
-
var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
1842
|
-
fork,
|
1843
|
-
write,
|
1844
|
-
writeScript,
|
1845
|
-
nextScopeId,
|
1846
|
-
isTagsAPI(fn) {
|
1847
|
-
return !!fn.h;
|
1848
|
-
},
|
1849
|
-
patchDynamicTag,
|
1850
|
-
writeSetScopeForComponent(m5c) {
|
1851
|
-
let scopeId = nextScopeId();
|
1852
|
-
writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
1853
|
-
},
|
1854
|
-
toJSON() {
|
1855
|
-
let compatRegistered = COMPAT_REGISTRY.get(this);
|
1856
|
-
if (!compatRegistered) {
|
1857
|
-
let registered = getRegistered(this);
|
1858
|
-
if (registered) {
|
1859
|
-
let scopeId = getScopeId(registered.scope);
|
1860
|
-
scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
|
1861
|
-
this,
|
1862
|
-
compatRegistered = [registered.id, scopeId]
|
1863
|
-
);
|
1864
|
-
}
|
1865
|
-
}
|
1866
|
-
return compatRegistered;
|
1867
|
-
},
|
1868
|
-
render(renderer, willRerender, classAPIOut, component, input) {
|
1869
|
-
let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
1870
|
-
state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
|
1871
|
-
let boundary = new Boundary(state), head = new Chunk(
|
1872
|
-
boundary,
|
1873
|
-
null,
|
1874
|
-
null
|
1875
|
-
), normalizedInput = input;
|
1876
|
-
if ("renderBody" in input) {
|
1877
|
-
normalizedInput = {};
|
1878
|
-
for (let key in input)
|
1879
|
-
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1880
|
-
}
|
1881
|
-
head.render(() => {
|
1882
|
-
if (willRerender) {
|
1883
|
-
let scopeId = peekNextScopeId();
|
1884
|
-
writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
1885
|
-
}
|
1886
|
-
renderer(normalizedInput);
|
1887
|
-
});
|
1888
|
-
let asyncOut = classAPIOut.beginAsync();
|
1889
|
-
queueMicrotask(
|
1890
|
-
boundary.onNext = () => {
|
1891
|
-
if (boundary.signal.aborted)
|
1892
|
-
asyncOut.error(boundary.signal.reason);
|
1893
|
-
else if (boundary.done) {
|
1894
|
-
let { scripts, html } = head.consume().flushScript();
|
1895
|
-
asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
|
1896
|
-
}
|
1897
|
-
}
|
1898
|
-
);
|
1899
|
-
},
|
1900
|
-
registerRenderer(renderer, id) {
|
1901
|
-
return register(
|
1902
|
-
RENDERER_REGISTER_ID,
|
1903
|
-
renderer,
|
1904
|
-
register(id, () => {
|
1905
|
-
})
|
1906
|
-
);
|
1907
|
-
},
|
1908
|
-
registerRenderBody(fn) {
|
1909
|
-
register(RENDER_BODY_ID, fn);
|
1910
|
-
}
|
1911
|
-
};
|
1912
|
-
|
1913
|
-
// src/html/for.ts
|
1914
|
-
function forOfBy2(by, item, index) {
|
1915
|
-
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1916
|
-
}
|
1917
|
-
function forInBy2(by, name, value) {
|
1918
|
-
return by ? by(name, value) : name;
|
1919
|
-
}
|
1920
|
-
function forToBy2(by, index) {
|
1921
|
-
return by ? by(index) : index;
|
1922
|
-
}
|
1923
|
-
|
1924
1802
|
// src/html/template.ts
|
1925
1803
|
var createTemplate = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, registerContent(templateId, renderer));
|
1804
|
+
function isTemplate(renderer) {
|
1805
|
+
return !!renderer._;
|
1806
|
+
}
|
1926
1807
|
function render(input = {}) {
|
1927
1808
|
let { $global: $global2 } = input;
|
1928
1809
|
$global2 ? ({ $global: $global2, ...input } = input, $global2 = {
|
@@ -2059,6 +1940,165 @@ var ServerRendered = class {
|
|
2059
1940
|
};
|
2060
1941
|
function NOOP2() {
|
2061
1942
|
}
|
1943
|
+
|
1944
|
+
// src/html/dynamic-tag.ts
|
1945
|
+
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, shouldResume) => {
|
1946
|
+
let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
|
1947
|
+
if (typeof renderer == "string") {
|
1948
|
+
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1949
|
+
if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
1950
|
+
let renderNativeTag = () => {
|
1951
|
+
renderer === "textarea" ? write(
|
1952
|
+
controllable_textarea_value(
|
1953
|
+
scopeId,
|
1954
|
+
accessor,
|
1955
|
+
input.value,
|
1956
|
+
input.valueChange
|
1957
|
+
)
|
1958
|
+
) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1959
|
+
scopeId,
|
1960
|
+
accessor,
|
1961
|
+
input.value,
|
1962
|
+
input.valueChange,
|
1963
|
+
content
|
1964
|
+
) : content());
|
1965
|
+
};
|
1966
|
+
shouldResume ? withBranchId(branchId, renderNativeTag) : renderNativeTag(), write(`</${renderer}>`);
|
1967
|
+
}
|
1968
|
+
shouldResume && write(
|
1969
|
+
state.mark(
|
1970
|
+
"|" /* BranchSingleNode */,
|
1971
|
+
scopeId + " " + accessor + " " + branchId
|
1972
|
+
)
|
1973
|
+
);
|
1974
|
+
} else {
|
1975
|
+
shouldResume && write(state.mark("[" /* BranchStart */, branchId + ""));
|
1976
|
+
let render2 = () => {
|
1977
|
+
if (renderer) {
|
1978
|
+
if (isTemplate(renderer)) {
|
1979
|
+
let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
|
1980
|
+
return renderer(
|
1981
|
+
content ? { ...input, content } : input,
|
1982
|
+
shouldResume
|
1983
|
+
);
|
1984
|
+
}
|
1985
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
1986
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
1987
|
+
);
|
1988
|
+
} else if (content)
|
1989
|
+
return content();
|
1990
|
+
};
|
1991
|
+
result = shouldResume ? withBranchId(branchId, render2) : render2(), shouldResume && write(state.mark("]" /* BranchEnd */, scopeId + " " + accessor));
|
1992
|
+
}
|
1993
|
+
return peekNextScopeId() !== branchId ? shouldResume && writeScope(scopeId, {
|
1994
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
1995
|
+
["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
|
1996
|
+
}) : nextScopeId(), result;
|
1997
|
+
};
|
1998
|
+
function createContent(id, fn) {
|
1999
|
+
return fn.h = id, fn;
|
2000
|
+
}
|
2001
|
+
function registerContent(id, fn, scopeId) {
|
2002
|
+
return register2(createContent(id, fn), id, scopeId);
|
2003
|
+
}
|
2004
|
+
function patchDynamicTag(patch) {
|
2005
|
+
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
2006
|
+
let patched = patch(scopeId, accessor, tag);
|
2007
|
+
return patched.h = tag, originalDynamicTag(
|
2008
|
+
scopeId,
|
2009
|
+
accessor,
|
2010
|
+
patched,
|
2011
|
+
input,
|
2012
|
+
content,
|
2013
|
+
inputIsArgs,
|
2014
|
+
resume
|
2015
|
+
);
|
2016
|
+
})(dynamicTag);
|
2017
|
+
}
|
2018
|
+
|
2019
|
+
// src/html/compat.ts
|
2020
|
+
var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
|
2021
|
+
fork,
|
2022
|
+
write,
|
2023
|
+
writeScript,
|
2024
|
+
nextScopeId,
|
2025
|
+
isTagsAPI(fn) {
|
2026
|
+
return !!fn.h;
|
2027
|
+
},
|
2028
|
+
patchDynamicTag,
|
2029
|
+
writeSetScopeForComponent(m5c) {
|
2030
|
+
let scopeId = nextScopeId();
|
2031
|
+
writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2032
|
+
},
|
2033
|
+
toJSON() {
|
2034
|
+
let compatRegistered = COMPAT_REGISTRY.get(this);
|
2035
|
+
if (!compatRegistered) {
|
2036
|
+
let registered = getRegistered(this);
|
2037
|
+
if (registered) {
|
2038
|
+
let scopeId = getScopeId(registered.scope);
|
2039
|
+
scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
|
2040
|
+
this,
|
2041
|
+
compatRegistered = [registered.id, scopeId]
|
2042
|
+
);
|
2043
|
+
}
|
2044
|
+
}
|
2045
|
+
return compatRegistered;
|
2046
|
+
},
|
2047
|
+
render(renderer, willRerender, classAPIOut, component, input) {
|
2048
|
+
let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
|
2049
|
+
state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
|
2050
|
+
let boundary = new Boundary(state), head = new Chunk(
|
2051
|
+
boundary,
|
2052
|
+
null,
|
2053
|
+
null
|
2054
|
+
), normalizedInput = input;
|
2055
|
+
if ("renderBody" in input) {
|
2056
|
+
normalizedInput = {};
|
2057
|
+
for (let key in input)
|
2058
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2059
|
+
}
|
2060
|
+
head.render(() => {
|
2061
|
+
if (willRerender) {
|
2062
|
+
let scopeId = peekNextScopeId();
|
2063
|
+
writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2064
|
+
}
|
2065
|
+
isTemplate(renderer) && willRerender ? renderer(normalizedInput, 1) : renderer(normalizedInput);
|
2066
|
+
});
|
2067
|
+
let asyncOut = classAPIOut.beginAsync();
|
2068
|
+
queueMicrotask(
|
2069
|
+
boundary.onNext = () => {
|
2070
|
+
if (boundary.signal.aborted)
|
2071
|
+
asyncOut.error(boundary.signal.reason);
|
2072
|
+
else if (boundary.done) {
|
2073
|
+
let { scripts, html } = head.consume().flushScript();
|
2074
|
+
asyncOut.script(scripts), asyncOut.write(html), asyncOut.end();
|
2075
|
+
}
|
2076
|
+
}
|
2077
|
+
);
|
2078
|
+
},
|
2079
|
+
registerRenderer(renderer, id) {
|
2080
|
+
return register(
|
2081
|
+
RENDERER_REGISTER_ID,
|
2082
|
+
renderer,
|
2083
|
+
register(id, () => {
|
2084
|
+
})
|
2085
|
+
);
|
2086
|
+
},
|
2087
|
+
registerRenderBody(fn) {
|
2088
|
+
register(RENDER_BODY_ID, fn);
|
2089
|
+
}
|
2090
|
+
};
|
2091
|
+
|
2092
|
+
// src/html/for.ts
|
2093
|
+
function forOfBy2(by, item, index) {
|
2094
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
2095
|
+
}
|
2096
|
+
function forInBy2(by, name, value) {
|
2097
|
+
return by ? by(name, value) : name;
|
2098
|
+
}
|
2099
|
+
function forToBy2(by, index) {
|
2100
|
+
return by ? by(index) : index;
|
2101
|
+
}
|
2062
2102
|
export {
|
2063
2103
|
$global,
|
2064
2104
|
attr,
|
@@ -2066,6 +2106,7 @@ export {
|
|
2066
2106
|
attrTags,
|
2067
2107
|
attrs,
|
2068
2108
|
classAttr,
|
2109
|
+
commentSeparator,
|
2069
2110
|
compat,
|
2070
2111
|
controllable_detailsOrDialog_open,
|
2071
2112
|
controllable_input_checked,
|
@@ -2095,7 +2136,7 @@ export {
|
|
2095
2136
|
nodeRef,
|
2096
2137
|
optionValueAttr,
|
2097
2138
|
partialAttrs,
|
2098
|
-
|
2139
|
+
peekNextScopeId,
|
2099
2140
|
register2 as register,
|
2100
2141
|
registerContent,
|
2101
2142
|
resumeClosestBranch,
|
@@ -2107,6 +2148,8 @@ export {
|
|
2107
2148
|
resumeSingleNodeForIn,
|
2108
2149
|
resumeSingleNodeForOf,
|
2109
2150
|
resumeSingleNodeForTo,
|
2151
|
+
serializeGuard,
|
2152
|
+
serializeIf,
|
2110
2153
|
setTagVar,
|
2111
2154
|
styleAttr,
|
2112
2155
|
toString,
|