marko 6.0.79 → 6.0.80
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.js +8 -0
- package/dist/debug/dom.mjs +8 -0
- package/dist/debug/html.js +261 -252
- package/dist/debug/html.mjs +259 -252
- package/dist/dom/signals.d.ts +7 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +6 -0
- package/dist/dom.mjs +6 -0
- package/dist/html/compat.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/writer.d.ts +3 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +168 -157
- package/dist/html.mjs +166 -157
- package/dist/translator/index.js +1767 -1394
- package/dist/translator/util/binding-prop-tree.d.ts +8 -0
- package/dist/translator/util/generate-uid.d.ts +2 -1
- package/dist/translator/util/known-tag.d.ts +23 -0
- package/dist/translator/util/nested-attribute-tags.d.ts +1 -0
- package/dist/translator/util/optional.d.ts +2 -1
- package/dist/translator/util/references.d.ts +5 -2
- package/dist/translator/util/sections.d.ts +5 -2
- package/dist/translator/util/serialize-guard.d.ts +5 -0
- package/dist/translator/util/serialize-reasons.d.ts +6 -2
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/util/writer.d.ts +7 -3
- package/dist/translator/visitors/program/html.d.ts +0 -4
- package/dist/translator/visitors/program/index.d.ts +10 -17
- package/dist/translator/visitors/tag/custom-tag.d.ts +0 -12
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -0
- package/package.json +1 -1
package/dist/html.mjs
CHANGED
@@ -1079,6 +1079,13 @@ function getScopeById(scopeId) {
|
|
1079
1079
|
if (scopeId !== void 0)
|
1080
1080
|
return $chunk.boundary.state.scopes.get(scopeId);
|
1081
1081
|
}
|
1082
|
+
function _set_serialize_reason(reason) {
|
1083
|
+
$chunk.boundary.state.serializeReason = reason;
|
1084
|
+
}
|
1085
|
+
function _get_serialize_reason() {
|
1086
|
+
let reason = $chunk.boundary.state.serializeReason;
|
1087
|
+
return $chunk.boundary.state.serializeReason = void 0, reason;
|
1088
|
+
}
|
1082
1089
|
function _serialize_if(condition, key) {
|
1083
1090
|
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
1084
1091
|
}
|
@@ -1393,6 +1400,7 @@ var State2 = class {
|
|
1393
1400
|
writeReorders = null;
|
1394
1401
|
scopes = /* @__PURE__ */ new Map();
|
1395
1402
|
writeScopes = null;
|
1403
|
+
serializeReason;
|
1396
1404
|
get runtimePrefix() {
|
1397
1405
|
let { $global: $global2 } = this;
|
1398
1406
|
return $global2.runtimeId + "." + $global2.renderId;
|
@@ -1812,151 +1820,6 @@ function replaceUnsafeDoubleQuoteAttrChar(match) {
|
|
1812
1820
|
// src/common/compat-meta.ts
|
1813
1821
|
var RENDERER_REGISTER_ID = "$C_r", SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b";
|
1814
1822
|
|
1815
|
-
// src/html/template.ts
|
1816
|
-
var _template = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, _content_resume(templateId, renderer));
|
1817
|
-
function isTemplate(renderer) {
|
1818
|
-
return !!renderer._;
|
1819
|
-
}
|
1820
|
-
function render(input = {}) {
|
1821
|
-
let { $global: $global2 } = input;
|
1822
|
-
$global2 ? ({ $global: $global2, ...input } = input, $global2 = {
|
1823
|
-
runtimeId: "M",
|
1824
|
-
renderId: "_",
|
1825
|
-
...$global2
|
1826
|
-
}) : $global2 = { runtimeId: "M", renderId: "_" };
|
1827
|
-
let head = new Chunk(
|
1828
|
-
new Boundary(new State2($global2), $global2.signal),
|
1829
|
-
null,
|
1830
|
-
null
|
1831
|
-
);
|
1832
|
-
return head.render(this, input), new ServerRendered(head);
|
1833
|
-
}
|
1834
|
-
var ServerRendered = class {
|
1835
|
-
#head;
|
1836
|
-
#cachedPromise = null;
|
1837
|
-
constructor(head) {
|
1838
|
-
this.#head = head;
|
1839
|
-
}
|
1840
|
-
[Symbol.asyncIterator]() {
|
1841
|
-
let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read(
|
1842
|
-
(html) => {
|
1843
|
-
value += html, resolve && (resolve({ value, done }), value = "");
|
1844
|
-
},
|
1845
|
-
(err) => {
|
1846
|
-
aborted = !0, reason = err, reject && reject(err);
|
1847
|
-
},
|
1848
|
-
() => {
|
1849
|
-
done = !0, resolve && (resolve({ value, done: !value }), value = "");
|
1850
|
-
}
|
1851
|
-
);
|
1852
|
-
return {
|
1853
|
-
next() {
|
1854
|
-
if (aborted)
|
1855
|
-
return Promise.reject(reason);
|
1856
|
-
if (value) {
|
1857
|
-
let result = { value, done: !1 };
|
1858
|
-
return value = "", Promise.resolve(result);
|
1859
|
-
} else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
|
1860
|
-
},
|
1861
|
-
throw(error) {
|
1862
|
-
return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
|
1863
|
-
},
|
1864
|
-
return(value2) {
|
1865
|
-
return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
|
1866
|
-
}
|
1867
|
-
};
|
1868
|
-
function exec(_resolve, _reject) {
|
1869
|
-
resolve = _resolve, reject = _reject;
|
1870
|
-
}
|
1871
|
-
}
|
1872
|
-
pipe(stream) {
|
1873
|
-
this.#read(
|
1874
|
-
(html) => {
|
1875
|
-
stream.write(html);
|
1876
|
-
},
|
1877
|
-
(err) => {
|
1878
|
-
let socket = "socket" in stream && stream.socket;
|
1879
|
-
if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err))
|
1880
|
-
throw err;
|
1881
|
-
},
|
1882
|
-
() => {
|
1883
|
-
stream.end();
|
1884
|
-
}
|
1885
|
-
);
|
1886
|
-
}
|
1887
|
-
toReadable() {
|
1888
|
-
let cancelled = !1, boundary, encoder = new TextEncoder();
|
1889
|
-
return new ReadableStream({
|
1890
|
-
start: (ctrl) => {
|
1891
|
-
boundary = this.#read(
|
1892
|
-
(html) => {
|
1893
|
-
ctrl.enqueue(encoder.encode(html));
|
1894
|
-
},
|
1895
|
-
(err) => {
|
1896
|
-
boundary = void 0, cancelled || ctrl.error(err);
|
1897
|
-
},
|
1898
|
-
() => {
|
1899
|
-
boundary = void 0, ctrl.close();
|
1900
|
-
}
|
1901
|
-
);
|
1902
|
-
},
|
1903
|
-
cancel: (reason) => {
|
1904
|
-
cancelled = !0, boundary?.abort(reason);
|
1905
|
-
}
|
1906
|
-
});
|
1907
|
-
}
|
1908
|
-
then(onfulfilled, onrejected) {
|
1909
|
-
return this.#promise().then(onfulfilled, onrejected);
|
1910
|
-
}
|
1911
|
-
catch(onrejected) {
|
1912
|
-
return this.#promise().catch(onrejected);
|
1913
|
-
}
|
1914
|
-
finally(onfinally) {
|
1915
|
-
return this.#promise().finally(onfinally);
|
1916
|
-
}
|
1917
|
-
#promise() {
|
1918
|
-
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
1919
|
-
let head = this.#head;
|
1920
|
-
if (this.#head = null, !head)
|
1921
|
-
return reject(new Error("Cannot read from a consumed render result"));
|
1922
|
-
let { boundary } = head;
|
1923
|
-
(boundary.onNext = () => {
|
1924
|
-
boundary.signal.aborted ? (boundary.onNext = NOOP2, reject(boundary.signal.reason)) : !boundary.count && boundary.done && resolve(head.consume().flushHTML());
|
1925
|
-
})();
|
1926
|
-
});
|
1927
|
-
}
|
1928
|
-
#read(onWrite, onAbort, onClose) {
|
1929
|
-
let tick2 = !0, head = this.#head;
|
1930
|
-
if (this.#head = null, !head) {
|
1931
|
-
onAbort(new Error("Cannot read from a consumed render result"));
|
1932
|
-
return;
|
1933
|
-
}
|
1934
|
-
let { boundary } = head, onNext = boundary.onNext = (write) => {
|
1935
|
-
if (boundary.signal.aborted)
|
1936
|
-
tick2 || offTick(onNext), boundary.onNext = NOOP2, onAbort(boundary.signal.reason);
|
1937
|
-
else {
|
1938
|
-
let { done } = boundary;
|
1939
|
-
if (done || write) {
|
1940
|
-
let html = (head = head.consume()).flushHTML();
|
1941
|
-
html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
|
1942
|
-
} else tick2 && (tick2 = !1, queueTick(onNext));
|
1943
|
-
}
|
1944
|
-
};
|
1945
|
-
return onNext(), boundary;
|
1946
|
-
}
|
1947
|
-
toString() {
|
1948
|
-
let head = this.#head;
|
1949
|
-
if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
|
1950
|
-
let { boundary } = head;
|
1951
|
-
if (!boundary.done)
|
1952
|
-
throw new Error("Cannot consume asynchronous render with 'toString'");
|
1953
|
-
if (boundary.signal.aborted) throw boundary.signal.reason;
|
1954
|
-
return head.consume().flushHTML();
|
1955
|
-
}
|
1956
|
-
};
|
1957
|
-
function NOOP2() {
|
1958
|
-
}
|
1959
|
-
|
1960
1823
|
// src/html/dynamic-tag.ts
|
1961
1824
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, serializeReason) => {
|
1962
1825
|
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered = !1, result;
|
@@ -2007,18 +1870,15 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
|
|
2007
1870
|
} else {
|
2008
1871
|
shouldResume && _html(state.mark("[" /* BranchStart */, ""));
|
2009
1872
|
let render2 = () => {
|
2010
|
-
if (renderer)
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
content ? { ...input, content } : input,
|
2015
|
-
shouldResume ? 1 : 0
|
1873
|
+
if (renderer)
|
1874
|
+
try {
|
1875
|
+
return _set_serialize_reason(shouldResume ? 1 : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
1876
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
2016
1877
|
);
|
1878
|
+
} finally {
|
1879
|
+
_set_serialize_reason(void 0);
|
2017
1880
|
}
|
2018
|
-
|
2019
|
-
content ? { ...inputOrArgs, content } : inputOrArgs
|
2020
|
-
);
|
2021
|
-
} else if (content)
|
1881
|
+
else if (content)
|
2022
1882
|
return content();
|
2023
1883
|
};
|
2024
1884
|
result = shouldResume ? withBranchId(branchId, render2) : render2(), rendered = _peek_scope_id() !== branchId, shouldResume && _html(
|
@@ -2120,11 +1980,16 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
2120
1980
|
let scopeId = _peek_scope_id();
|
2121
1981
|
writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
|
2122
1982
|
}
|
2123
|
-
|
1983
|
+
_set_serialize_reason(willRerender ? 1 : 0);
|
1984
|
+
try {
|
1985
|
+
renderer(normalizedInput);
|
1986
|
+
} finally {
|
1987
|
+
_set_serialize_reason(void 0);
|
1988
|
+
}
|
2124
1989
|
let asyncOut = classAPIOut.beginAsync({ last: !0, timeout: -1 });
|
2125
1990
|
classAPIOut.onLast((next) => {
|
2126
1991
|
(boundary.onNext = () => {
|
2127
|
-
boundary.signal.aborted ? (asyncOut.error(boundary.signal.reason), boundary.onNext =
|
1992
|
+
boundary.signal.aborted ? (asyncOut.error(boundary.signal.reason), boundary.onNext = NOOP2) : boundary.count || (boundary.onNext = NOOP2, head = head.consume(), asyncOut.write(head.html), asyncOut.script(head.scripts), asyncOut.end(), head.html = head.scripts = "", completeChunks.push(head), next());
|
2128
1993
|
})();
|
2129
1994
|
});
|
2130
1995
|
});
|
@@ -2141,6 +2006,148 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
2141
2006
|
register(RENDER_BODY_ID, fn);
|
2142
2007
|
}
|
2143
2008
|
};
|
2009
|
+
function NOOP2() {
|
2010
|
+
}
|
2011
|
+
|
2012
|
+
// src/html/template.ts
|
2013
|
+
var _template = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, _content_resume(templateId, renderer));
|
2014
|
+
function render(input = {}) {
|
2015
|
+
let { $global: $global2 } = input;
|
2016
|
+
$global2 ? ({ $global: $global2, ...input } = input, $global2 = {
|
2017
|
+
runtimeId: "M",
|
2018
|
+
renderId: "_",
|
2019
|
+
...$global2
|
2020
|
+
}) : $global2 = { runtimeId: "M", renderId: "_" };
|
2021
|
+
let head = new Chunk(
|
2022
|
+
new Boundary(new State2($global2), $global2.signal),
|
2023
|
+
null,
|
2024
|
+
null
|
2025
|
+
);
|
2026
|
+
return head.render(this, input), new ServerRendered(head);
|
2027
|
+
}
|
2028
|
+
var ServerRendered = class {
|
2029
|
+
#head;
|
2030
|
+
#cachedPromise = null;
|
2031
|
+
constructor(head) {
|
2032
|
+
this.#head = head;
|
2033
|
+
}
|
2034
|
+
[Symbol.asyncIterator]() {
|
2035
|
+
let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read(
|
2036
|
+
(html) => {
|
2037
|
+
value += html, resolve && (resolve({ value, done }), value = "");
|
2038
|
+
},
|
2039
|
+
(err) => {
|
2040
|
+
aborted = !0, reason = err, reject && reject(err);
|
2041
|
+
},
|
2042
|
+
() => {
|
2043
|
+
done = !0, resolve && (resolve({ value, done: !value }), value = "");
|
2044
|
+
}
|
2045
|
+
);
|
2046
|
+
return {
|
2047
|
+
next() {
|
2048
|
+
if (aborted)
|
2049
|
+
return Promise.reject(reason);
|
2050
|
+
if (value) {
|
2051
|
+
let result = { value, done: !1 };
|
2052
|
+
return value = "", Promise.resolve(result);
|
2053
|
+
} else return done ? Promise.resolve({ value: "", done }) : new Promise(exec);
|
2054
|
+
},
|
2055
|
+
throw(error) {
|
2056
|
+
return done || aborted || boundary?.abort(error), Promise.resolve({ value: "", done: !0 });
|
2057
|
+
},
|
2058
|
+
return(value2) {
|
2059
|
+
return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({ value: value2, done: !0 });
|
2060
|
+
}
|
2061
|
+
};
|
2062
|
+
function exec(_resolve, _reject) {
|
2063
|
+
resolve = _resolve, reject = _reject;
|
2064
|
+
}
|
2065
|
+
}
|
2066
|
+
pipe(stream) {
|
2067
|
+
this.#read(
|
2068
|
+
(html) => {
|
2069
|
+
stream.write(html);
|
2070
|
+
},
|
2071
|
+
(err) => {
|
2072
|
+
let socket = "socket" in stream && stream.socket;
|
2073
|
+
if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err))
|
2074
|
+
throw err;
|
2075
|
+
},
|
2076
|
+
() => {
|
2077
|
+
stream.end();
|
2078
|
+
}
|
2079
|
+
);
|
2080
|
+
}
|
2081
|
+
toReadable() {
|
2082
|
+
let cancelled = !1, boundary, encoder = new TextEncoder();
|
2083
|
+
return new ReadableStream({
|
2084
|
+
start: (ctrl) => {
|
2085
|
+
boundary = this.#read(
|
2086
|
+
(html) => {
|
2087
|
+
ctrl.enqueue(encoder.encode(html));
|
2088
|
+
},
|
2089
|
+
(err) => {
|
2090
|
+
boundary = void 0, cancelled || ctrl.error(err);
|
2091
|
+
},
|
2092
|
+
() => {
|
2093
|
+
boundary = void 0, ctrl.close();
|
2094
|
+
}
|
2095
|
+
);
|
2096
|
+
},
|
2097
|
+
cancel: (reason) => {
|
2098
|
+
cancelled = !0, boundary?.abort(reason);
|
2099
|
+
}
|
2100
|
+
});
|
2101
|
+
}
|
2102
|
+
then(onfulfilled, onrejected) {
|
2103
|
+
return this.#promise().then(onfulfilled, onrejected);
|
2104
|
+
}
|
2105
|
+
catch(onrejected) {
|
2106
|
+
return this.#promise().catch(onrejected);
|
2107
|
+
}
|
2108
|
+
finally(onfinally) {
|
2109
|
+
return this.#promise().finally(onfinally);
|
2110
|
+
}
|
2111
|
+
#promise() {
|
2112
|
+
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
2113
|
+
let head = this.#head;
|
2114
|
+
if (this.#head = null, !head)
|
2115
|
+
return reject(new Error("Cannot read from a consumed render result"));
|
2116
|
+
let { boundary } = head;
|
2117
|
+
(boundary.onNext = () => {
|
2118
|
+
boundary.signal.aborted ? (boundary.onNext = NOOP3, reject(boundary.signal.reason)) : !boundary.count && boundary.done && resolve(head.consume().flushHTML());
|
2119
|
+
})();
|
2120
|
+
});
|
2121
|
+
}
|
2122
|
+
#read(onWrite, onAbort, onClose) {
|
2123
|
+
let tick2 = !0, head = this.#head;
|
2124
|
+
if (this.#head = null, !head) {
|
2125
|
+
onAbort(new Error("Cannot read from a consumed render result"));
|
2126
|
+
return;
|
2127
|
+
}
|
2128
|
+
let { boundary } = head, onNext = boundary.onNext = (write) => {
|
2129
|
+
if (boundary.signal.aborted)
|
2130
|
+
tick2 || offTick(onNext), boundary.onNext = NOOP3, onAbort(boundary.signal.reason);
|
2131
|
+
else {
|
2132
|
+
let { done } = boundary;
|
2133
|
+
if (done || write) {
|
2134
|
+
let html = (head = head.consume()).flushHTML();
|
2135
|
+
html && onWrite(html), done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
|
2136
|
+
} else tick2 && (tick2 = !1, queueTick(onNext));
|
2137
|
+
}
|
2138
|
+
};
|
2139
|
+
return onNext(), boundary;
|
2140
|
+
}
|
2141
|
+
toString() {
|
2142
|
+
let head = this.#head;
|
2143
|
+
if (this.#head = null, !head) throw new Error("Cannot read from a consumed render result");
|
2144
|
+
let { boundary } = head;
|
2145
|
+
if (!boundary.done)
|
2146
|
+
throw new Error("Cannot consume asynchronous render with 'toString'");
|
2147
|
+
if (boundary.signal.aborted) throw boundary.signal.reason;
|
2148
|
+
return head.consume().flushHTML();
|
2149
|
+
}
|
2150
|
+
};
|
2144
2151
|
function NOOP3() {
|
2145
2152
|
}
|
2146
2153
|
export {
|
@@ -2176,6 +2183,7 @@ export {
|
|
2176
2183
|
_for_of,
|
2177
2184
|
_for_to,
|
2178
2185
|
_for_until,
|
2186
|
+
_get_serialize_reason,
|
2179
2187
|
_hoist,
|
2180
2188
|
_html,
|
2181
2189
|
_id,
|
@@ -2190,6 +2198,7 @@ export {
|
|
2190
2198
|
_sep,
|
2191
2199
|
_serialize_guard,
|
2192
2200
|
_serialize_if,
|
2201
|
+
_set_serialize_reason,
|
2193
2202
|
_subscribe,
|
2194
2203
|
_template,
|
2195
2204
|
_trailers,
|