marko 6.3.14 → 6.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/errors.d.ts +2 -0
- package/dist/debug/dom.js +12 -0
- package/dist/debug/dom.mjs +12 -0
- package/dist/debug/html.js +179 -161
- package/dist/debug/html.mjs +179 -161
- package/dist/html/writer.d.ts +36 -36
- package/dist/html.js +122 -118
- package/dist/html.mjs +122 -118
- package/dist/translator/core/class.d.ts +3 -0
- package/dist/translator/core/index.d.ts +1 -0
- package/dist/translator/index.d.ts +1 -0
- package/dist/translator/index.js +160 -151
- package/dist/translator/util/references.d.ts +1 -1
- package/dist/translator/util/signals.d.ts +0 -1
- package/package.json +1 -1
package/dist/common/errors.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function assertValidAttrValue(name: string, value: unknown): void;
|
|
2
2
|
export declare function assertValidTextValue(value: unknown): void;
|
|
3
3
|
export declare function assertValidLoopKey(key: unknown, seenKeys?: Set<unknown>): void;
|
|
4
|
+
export declare function assertValidList(value: unknown): void;
|
|
5
|
+
export declare function assertValidRangeBound(name: string, value: unknown): void;
|
|
4
6
|
export declare function assertValidAttrName(name: string): void;
|
|
5
7
|
export declare function _el_read_error(): void;
|
|
6
8
|
export declare function _hoist_read_error(): void;
|
package/dist/debug/dom.js
CHANGED
|
@@ -159,6 +159,15 @@ function assertValidLoopKey(key, seenKeys) {
|
|
|
159
159
|
seenKeys.add(key);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
+
function assertValidList(value) {
|
|
163
|
+
if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
|
|
164
|
+
}
|
|
165
|
+
function assertValidRangeBound(name, value) {
|
|
166
|
+
if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
167
|
+
}
|
|
168
|
+
function describeForValue(value) {
|
|
169
|
+
return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
|
|
170
|
+
}
|
|
162
171
|
function assertValidAttrName(name) {
|
|
163
172
|
if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
164
173
|
const suggestion = getWrongAttrSuggestion(name);
|
|
@@ -211,17 +220,20 @@ function forIn(obj, cb) {
|
|
|
211
220
|
for (const key in obj) cb(key, obj[key]);
|
|
212
221
|
}
|
|
213
222
|
function forOf(list, cb) {
|
|
223
|
+
assertValidList(list);
|
|
214
224
|
if (list) {
|
|
215
225
|
let i = 0;
|
|
216
226
|
for (const item of list) cb(item, i++);
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
229
|
function forTo(to, from, step, cb) {
|
|
230
|
+
assertValidRangeBound("to", to);
|
|
220
231
|
const start = from || 0;
|
|
221
232
|
const delta = step || 1;
|
|
222
233
|
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
223
234
|
}
|
|
224
235
|
function forUntil(until, from, step, cb) {
|
|
236
|
+
assertValidRangeBound("until", until);
|
|
225
237
|
const start = from || 0;
|
|
226
238
|
const delta = step || 1;
|
|
227
239
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -157,6 +157,15 @@ function assertValidLoopKey(key, seenKeys) {
|
|
|
157
157
|
seenKeys.add(key);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
function assertValidList(value) {
|
|
161
|
+
if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
|
|
162
|
+
}
|
|
163
|
+
function assertValidRangeBound(name, value) {
|
|
164
|
+
if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
165
|
+
}
|
|
166
|
+
function describeForValue(value) {
|
|
167
|
+
return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
|
|
168
|
+
}
|
|
160
169
|
function assertValidAttrName(name) {
|
|
161
170
|
if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
162
171
|
const suggestion = getWrongAttrSuggestion(name);
|
|
@@ -209,17 +218,20 @@ function forIn(obj, cb) {
|
|
|
209
218
|
for (const key in obj) cb(key, obj[key]);
|
|
210
219
|
}
|
|
211
220
|
function forOf(list, cb) {
|
|
221
|
+
assertValidList(list);
|
|
212
222
|
if (list) {
|
|
213
223
|
let i = 0;
|
|
214
224
|
for (const item of list) cb(item, i++);
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
227
|
function forTo(to, from, step, cb) {
|
|
228
|
+
assertValidRangeBound("to", to);
|
|
218
229
|
const start = from || 0;
|
|
219
230
|
const delta = step || 1;
|
|
220
231
|
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
221
232
|
}
|
|
222
233
|
function forUntil(until, from, step, cb) {
|
|
234
|
+
assertValidRangeBound("until", until);
|
|
223
235
|
const start = from || 0;
|
|
224
236
|
const delta = step || 1;
|
|
225
237
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
package/dist/debug/html.js
CHANGED
|
@@ -158,6 +158,15 @@ function assertValidLoopKey(key, seenKeys) {
|
|
|
158
158
|
seenKeys.add(key);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
function assertValidList(value) {
|
|
162
|
+
if (value && typeof value[Symbol.iterator] !== "function") throw new Error(`A \`<for>\` tag's \`of\` attribute must be an iterable, such as an array, but received ${describeForValue(value)}.`);
|
|
163
|
+
}
|
|
164
|
+
function assertValidRangeBound(name, value) {
|
|
165
|
+
if (!isFinite(value)) throw new Error(`A \`<for>\` tag's \`${name}\` attribute must be a finite number, but received ${describeForValue(value)}.`);
|
|
166
|
+
}
|
|
167
|
+
function describeForValue(value) {
|
|
168
|
+
return typeof value === "number" || typeof value === "bigint" ? `\`${value}\`` : value === null ? "null" : `type "${typeof value}"`;
|
|
169
|
+
}
|
|
161
170
|
function assertValidAttrName(name) {
|
|
162
171
|
if (htmlAttrNameReg.test(name)) throw new Error(`Invalid attribute name: ${JSON.stringify(name)}`);
|
|
163
172
|
const suggestion = getWrongAttrSuggestion(name);
|
|
@@ -1528,17 +1537,20 @@ function forIn(obj, cb) {
|
|
|
1528
1537
|
for (const key in obj) cb(key, obj[key]);
|
|
1529
1538
|
}
|
|
1530
1539
|
function forOf(list, cb) {
|
|
1540
|
+
assertValidList(list);
|
|
1531
1541
|
if (list) {
|
|
1532
1542
|
let i = 0;
|
|
1533
1543
|
for (const item of list) cb(item, i++);
|
|
1534
1544
|
}
|
|
1535
1545
|
}
|
|
1536
1546
|
function forTo(to, from, step, cb) {
|
|
1547
|
+
assertValidRangeBound("to", to);
|
|
1537
1548
|
const start = from || 0;
|
|
1538
1549
|
const delta = step || 1;
|
|
1539
1550
|
for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
|
|
1540
1551
|
}
|
|
1541
1552
|
function forUntil(until, from, step, cb) {
|
|
1553
|
+
assertValidRangeBound("until", until);
|
|
1542
1554
|
const start = from || 0;
|
|
1543
1555
|
const delta = step || 1;
|
|
1544
1556
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
@@ -1666,7 +1678,6 @@ const REORDER_RUNTIME_CODE = `((runtime) => {
|
|
|
1666
1678
|
//#endregion
|
|
1667
1679
|
//#region src/html/writer.ts
|
|
1668
1680
|
let $chunk;
|
|
1669
|
-
const NOOP$2 = () => {};
|
|
1670
1681
|
function getChunk() {
|
|
1671
1682
|
return $chunk;
|
|
1672
1683
|
}
|
|
@@ -1679,54 +1690,22 @@ function getState() {
|
|
|
1679
1690
|
function getScopeId(scope) {
|
|
1680
1691
|
return scope[K_SCOPE_ID];
|
|
1681
1692
|
}
|
|
1682
|
-
function
|
|
1683
|
-
$chunk.
|
|
1684
|
-
}
|
|
1685
|
-
function writeScript(script) {
|
|
1686
|
-
$chunk.writeScript(script);
|
|
1693
|
+
function getScopeById(scopeId) {
|
|
1694
|
+
if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
|
|
1687
1695
|
}
|
|
1688
|
-
function
|
|
1689
|
-
|
|
1690
|
-
const { boundary } = chunk;
|
|
1691
|
-
const body = new Chunk(boundary, null, chunk.context, {
|
|
1692
|
-
readyId,
|
|
1693
|
-
parent: chunk.serializeState,
|
|
1694
|
-
resumes: "",
|
|
1695
|
-
writeScopes: {},
|
|
1696
|
-
flushScopes: false
|
|
1697
|
-
});
|
|
1698
|
-
const bodyEnd = body.render(renderer, input);
|
|
1699
|
-
if (body === bodyEnd) {
|
|
1700
|
-
chunk.writeHTML(body.html);
|
|
1701
|
-
body.deferOwnReady();
|
|
1702
|
-
chunk.deferredReady = push(chunk.deferredReady, body);
|
|
1703
|
-
} else {
|
|
1704
|
-
bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
1705
|
-
chunk.next = body;
|
|
1706
|
-
}
|
|
1696
|
+
function $global() {
|
|
1697
|
+
return $chunk.boundary.state.$global;
|
|
1707
1698
|
}
|
|
1708
|
-
function
|
|
1709
|
-
|
|
1710
|
-
$
|
|
1711
|
-
$
|
|
1699
|
+
function _id() {
|
|
1700
|
+
const state = $chunk.boundary.state;
|
|
1701
|
+
const { $global } = state;
|
|
1702
|
+
return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
|
|
1712
1703
|
}
|
|
1713
|
-
function
|
|
1714
|
-
|
|
1715
|
-
const render = normalizeServerRender(content);
|
|
1716
|
-
const branchId = _peek_scope_id();
|
|
1717
|
-
if (render) if (shouldResume) withBranchId(branchId, render);
|
|
1718
|
-
else render();
|
|
1719
|
-
if (_peek_scope_id() !== branchId) {
|
|
1720
|
-
if (shouldResume) writeScope(scopeId, {
|
|
1721
|
-
["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
|
|
1722
|
-
["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
|
|
1723
|
-
});
|
|
1724
|
-
} else _scope_id();
|
|
1704
|
+
function _scope_id() {
|
|
1705
|
+
return $chunk.boundary.state.scopeId++;
|
|
1725
1706
|
}
|
|
1726
|
-
function
|
|
1727
|
-
|
|
1728
|
-
if (renderer) if (typeof renderer === "function") return renderer;
|
|
1729
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1707
|
+
function _peek_scope_id() {
|
|
1708
|
+
return $chunk.boundary.state.scopeId;
|
|
1730
1709
|
}
|
|
1731
1710
|
const kPendingContexts = Symbol("Pending Contexts");
|
|
1732
1711
|
function withContext(key, value, cb, cbValue) {
|
|
@@ -1741,49 +1720,41 @@ function withContext(key, value, cb, cbValue) {
|
|
|
1741
1720
|
ctx[key] = prev;
|
|
1742
1721
|
}
|
|
1743
1722
|
}
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
}
|
|
1749
|
-
function writeScopePassive(scopeId, partialScope) {
|
|
1750
|
-
const target = $chunk.serializeState;
|
|
1751
|
-
const scope = _scope_with_id(scopeId);
|
|
1752
|
-
const passive = target.passiveScopes ||= {};
|
|
1753
|
-
Object.assign(scope, partialScope);
|
|
1754
|
-
passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
|
|
1755
|
-
return scope;
|
|
1723
|
+
const kBranchId = Symbol("Branch Id");
|
|
1724
|
+
const kIsAsync = Symbol("Is Async");
|
|
1725
|
+
function isInResumedBranch() {
|
|
1726
|
+
return $chunk?.context?.[kBranchId] !== void 0;
|
|
1756
1727
|
}
|
|
1757
|
-
function
|
|
1758
|
-
return
|
|
1728
|
+
function withBranchId(branchId, cb) {
|
|
1729
|
+
return withContext(kBranchId, branchId, cb);
|
|
1759
1730
|
}
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1762
|
-
const { $global } = state;
|
|
1763
|
-
return "s" + $global.runtimeId + $global.renderId + (state.tagId++).toString(36);
|
|
1731
|
+
function withIsAsync(cb, value) {
|
|
1732
|
+
return withContext(kIsAsync, true, cb, value);
|
|
1764
1733
|
}
|
|
1765
|
-
function
|
|
1766
|
-
|
|
1734
|
+
function _html(html) {
|
|
1735
|
+
$chunk.writeHTML(html);
|
|
1767
1736
|
}
|
|
1768
|
-
function
|
|
1769
|
-
|
|
1737
|
+
function writeScript(script) {
|
|
1738
|
+
$chunk.writeScript(script);
|
|
1770
1739
|
}
|
|
1771
|
-
function
|
|
1772
|
-
if (
|
|
1740
|
+
function _script(scopeId, registryId) {
|
|
1741
|
+
if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
|
|
1742
|
+
$chunk.boundary.state.needsMainRuntime = true;
|
|
1743
|
+
$chunk.writeEffect(scopeId, registryId);
|
|
1773
1744
|
}
|
|
1774
|
-
function
|
|
1775
|
-
$chunk.boundary.state.
|
|
1745
|
+
function _trailers(html) {
|
|
1746
|
+
$chunk.boundary.state.trailerHTML += html;
|
|
1776
1747
|
}
|
|
1777
|
-
function
|
|
1778
|
-
|
|
1779
|
-
$chunk.boundary.state.serializeReason = void 0;
|
|
1780
|
-
return reason;
|
|
1748
|
+
function _resume(val, id, scopeId) {
|
|
1749
|
+
return register(id, val, scopeId === void 0 ? void 0 : _scope_with_id(scopeId));
|
|
1781
1750
|
}
|
|
1782
|
-
function
|
|
1783
|
-
return
|
|
1751
|
+
function _el(scopeId, id) {
|
|
1752
|
+
return _resume(() => _el_read_error(), id, scopeId);
|
|
1784
1753
|
}
|
|
1785
|
-
function
|
|
1786
|
-
|
|
1754
|
+
function _hoist(scopeId, id) {
|
|
1755
|
+
const getter = () => _hoist_read_error();
|
|
1756
|
+
getter[Symbol.iterator] = _hoist_read_error;
|
|
1757
|
+
return _resume(getter, id, scopeId);
|
|
1787
1758
|
}
|
|
1788
1759
|
function _el_resume(scopeId, accessor, shouldResume) {
|
|
1789
1760
|
if (shouldResume === 0) return "";
|
|
@@ -1794,28 +1765,51 @@ function _el_resume(scopeId, accessor, shouldResume) {
|
|
|
1794
1765
|
function _sep(shouldResume) {
|
|
1795
1766
|
return shouldResume === 0 ? "" : "<!>";
|
|
1796
1767
|
}
|
|
1797
|
-
function _el(scopeId, id) {
|
|
1798
|
-
return _resume(() => _el_read_error(), id, scopeId);
|
|
1799
|
-
}
|
|
1800
|
-
function _hoist(scopeId, id) {
|
|
1801
|
-
const getter = () => _hoist_read_error();
|
|
1802
|
-
getter[Symbol.iterator] = _hoist_read_error;
|
|
1803
|
-
return _resume(getter, id, scopeId);
|
|
1804
|
-
}
|
|
1805
1768
|
function _resume_branch(scopeId) {
|
|
1806
1769
|
const branchId = $chunk.context?.[kBranchId];
|
|
1807
1770
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
|
|
1808
1771
|
}
|
|
1809
|
-
|
|
1810
|
-
const
|
|
1811
|
-
|
|
1812
|
-
|
|
1772
|
+
function _attr_content(nodeAccessor, scopeId, content, serializeReason) {
|
|
1773
|
+
const shouldResume = serializeReason !== 0;
|
|
1774
|
+
const render = normalizeServerRender(content);
|
|
1775
|
+
const branchId = _peek_scope_id();
|
|
1776
|
+
if (render) if (shouldResume) withBranchId(branchId, render);
|
|
1777
|
+
else render();
|
|
1778
|
+
if (_peek_scope_id() !== branchId) {
|
|
1779
|
+
if (shouldResume) writeScope(scopeId, {
|
|
1780
|
+
["BranchScopes:" + nodeAccessor]: writeScope(branchId, {}),
|
|
1781
|
+
["ConditionalRenderer:" + nodeAccessor]: render?.["id"]
|
|
1782
|
+
});
|
|
1783
|
+
} else _scope_id();
|
|
1813
1784
|
}
|
|
1814
|
-
function
|
|
1815
|
-
|
|
1785
|
+
function normalizeServerRender(value) {
|
|
1786
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1787
|
+
if (renderer) if (typeof renderer === "function") return renderer;
|
|
1788
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1816
1789
|
}
|
|
1817
|
-
function
|
|
1818
|
-
|
|
1790
|
+
function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, nodeAccessor) {
|
|
1791
|
+
writeScopePassive(parentScopeId, { [scopeOffsetAccessor]: _scope_id() });
|
|
1792
|
+
const childScope = writeScopePassive(childScopeId, { ["#TagVariable"]: _resume({}, registryId, parentScopeId) });
|
|
1793
|
+
if (nodeAccessor !== void 0) writeScope(parentScopeId, { ["BranchScopes:" + nodeAccessor]: childScope });
|
|
1794
|
+
}
|
|
1795
|
+
function writeScopePassive(scopeId, partialScope) {
|
|
1796
|
+
const target = $chunk.serializeState;
|
|
1797
|
+
const scope = _scope_with_id(scopeId);
|
|
1798
|
+
const passive = target.passiveScopes ||= {};
|
|
1799
|
+
Object.assign(scope, partialScope);
|
|
1800
|
+
passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
|
|
1801
|
+
return scope;
|
|
1802
|
+
}
|
|
1803
|
+
function _show_start(display, mark) {
|
|
1804
|
+
if (display) {
|
|
1805
|
+
if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
1806
|
+
} else $chunk.writeHTML("<t hidden>");
|
|
1807
|
+
}
|
|
1808
|
+
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1809
|
+
const branchId = _scope_id();
|
|
1810
|
+
const wrap = !display;
|
|
1811
|
+
if (wrap) $chunk.writeHTML("</t>");
|
|
1812
|
+
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1819
1813
|
}
|
|
1820
1814
|
function _for_of(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1821
1815
|
forBranches(by, (each) => each ? forOf(list, (item, index) => {
|
|
@@ -1902,17 +1896,6 @@ function writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, p
|
|
|
1902
1896
|
} else $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
|
|
1903
1897
|
else $chunk.writeHTML(endTag);
|
|
1904
1898
|
}
|
|
1905
|
-
function _show_start(display, mark) {
|
|
1906
|
-
if (display) {
|
|
1907
|
-
if (mark) $chunk.writeHTML($chunk.boundary.state.mark("[", ""));
|
|
1908
|
-
} else $chunk.writeHTML("<t hidden>");
|
|
1909
|
-
}
|
|
1910
|
-
function _show_end(scopeId, accessor, display, serializeMarker, serializeStateful, parentEndTag, singleNode) {
|
|
1911
|
-
const branchId = _scope_id();
|
|
1912
|
-
const wrap = !display;
|
|
1913
|
-
if (wrap) $chunk.writeHTML("</t>");
|
|
1914
|
-
writeBranchEnd(scopeId, accessor, serializeStateful, serializeMarker, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
|
|
1915
|
-
}
|
|
1916
1899
|
let writeScope = (scopeId, partialScope) => {
|
|
1917
1900
|
const { state } = $chunk.boundary;
|
|
1918
1901
|
const target = $chunk.serializeState;
|
|
@@ -1942,8 +1925,47 @@ function scopeWithId(state, scopeId) {
|
|
|
1942
1925
|
if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
|
|
1943
1926
|
return scope;
|
|
1944
1927
|
}
|
|
1945
|
-
function
|
|
1946
|
-
|
|
1928
|
+
function _subscribe(subscribers, scope) {
|
|
1929
|
+
if (subscribers) {
|
|
1930
|
+
const { serializer } = $chunk.boundary.state;
|
|
1931
|
+
if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
|
|
1932
|
+
else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
|
|
1933
|
+
}
|
|
1934
|
+
return scope;
|
|
1935
|
+
}
|
|
1936
|
+
function _set_serialize_reason(reason) {
|
|
1937
|
+
$chunk.boundary.state.serializeReason = reason;
|
|
1938
|
+
}
|
|
1939
|
+
function _scope_reason() {
|
|
1940
|
+
const reason = $chunk.boundary.state.serializeReason;
|
|
1941
|
+
$chunk.boundary.state.serializeReason = void 0;
|
|
1942
|
+
return reason;
|
|
1943
|
+
}
|
|
1944
|
+
function _serialize_if(condition, key) {
|
|
1945
|
+
return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1946
|
+
}
|
|
1947
|
+
function _serialize_guard(condition, key) {
|
|
1948
|
+
return _serialize_if(condition, key) || 0;
|
|
1949
|
+
}
|
|
1950
|
+
function writeWaitReady(readyId, renderer, input) {
|
|
1951
|
+
const chunk = $chunk;
|
|
1952
|
+
const { boundary } = chunk;
|
|
1953
|
+
const body = new Chunk(boundary, null, chunk.context, {
|
|
1954
|
+
readyId,
|
|
1955
|
+
parent: chunk.serializeState,
|
|
1956
|
+
resumes: "",
|
|
1957
|
+
writeScopes: {},
|
|
1958
|
+
flushScopes: false
|
|
1959
|
+
});
|
|
1960
|
+
const bodyEnd = body.render(renderer, input);
|
|
1961
|
+
if (body === bodyEnd) {
|
|
1962
|
+
chunk.writeHTML(body.html);
|
|
1963
|
+
body.deferOwnReady();
|
|
1964
|
+
chunk.deferredReady = push(chunk.deferredReady, body);
|
|
1965
|
+
} else {
|
|
1966
|
+
bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
|
|
1967
|
+
chunk.next = body;
|
|
1968
|
+
}
|
|
1947
1969
|
}
|
|
1948
1970
|
function _await(scopeId, accessor, promise, content, serializeMarker) {
|
|
1949
1971
|
const resumeMarker = serializeMarker !== 0;
|
|
@@ -2067,6 +2089,7 @@ function tryCatch(content, catchContent) {
|
|
|
2067
2089
|
else boundary.onNext();
|
|
2068
2090
|
};
|
|
2069
2091
|
}
|
|
2092
|
+
const NOOP$2 = () => {};
|
|
2070
2093
|
var State = class {
|
|
2071
2094
|
$global;
|
|
2072
2095
|
tagId = 1;
|
|
@@ -2492,8 +2515,22 @@ function depsMarker(deps) {
|
|
|
2492
2515
|
}
|
|
2493
2516
|
return marker;
|
|
2494
2517
|
}
|
|
2495
|
-
function
|
|
2496
|
-
|
|
2518
|
+
function getFilteredGlobals($global) {
|
|
2519
|
+
if (!$global) return 0;
|
|
2520
|
+
const serializedGlobals = $global.serializedGlobals;
|
|
2521
|
+
if (!serializedGlobals) return 0;
|
|
2522
|
+
let filtered = 0;
|
|
2523
|
+
if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
|
|
2524
|
+
const value = $global[key];
|
|
2525
|
+
if (value !== void 0) if (filtered) filtered[key] = value;
|
|
2526
|
+
else filtered = { [key]: value };
|
|
2527
|
+
}
|
|
2528
|
+
else for (const key in serializedGlobals) if (serializedGlobals[key]) {
|
|
2529
|
+
const value = $global[key];
|
|
2530
|
+
if (value !== void 0) if (filtered) filtered[key] = value;
|
|
2531
|
+
else filtered = { [key]: value };
|
|
2532
|
+
}
|
|
2533
|
+
return filtered;
|
|
2497
2534
|
}
|
|
2498
2535
|
function concatEffects(a, b) {
|
|
2499
2536
|
return a ? b ? a + " " + b : a : b;
|
|
@@ -2521,31 +2558,6 @@ function flushTickQueue() {
|
|
|
2521
2558
|
tickQueue = void 0;
|
|
2522
2559
|
for (const cb of queue) cb(true);
|
|
2523
2560
|
}
|
|
2524
|
-
function getFilteredGlobals($global) {
|
|
2525
|
-
if (!$global) return 0;
|
|
2526
|
-
const serializedGlobals = $global.serializedGlobals;
|
|
2527
|
-
if (!serializedGlobals) return 0;
|
|
2528
|
-
let filtered = 0;
|
|
2529
|
-
if (Array.isArray(serializedGlobals)) for (const key of serializedGlobals) {
|
|
2530
|
-
const value = $global[key];
|
|
2531
|
-
if (value !== void 0) if (filtered) filtered[key] = value;
|
|
2532
|
-
else filtered = { [key]: value };
|
|
2533
|
-
}
|
|
2534
|
-
else for (const key in serializedGlobals) if (serializedGlobals[key]) {
|
|
2535
|
-
const value = $global[key];
|
|
2536
|
-
if (value !== void 0) if (filtered) filtered[key] = value;
|
|
2537
|
-
else filtered = { [key]: value };
|
|
2538
|
-
}
|
|
2539
|
-
return filtered;
|
|
2540
|
-
}
|
|
2541
|
-
function _subscribe(subscribers, scope) {
|
|
2542
|
-
if (subscribers) {
|
|
2543
|
-
const { serializer } = $chunk.boundary.state;
|
|
2544
|
-
if (!$chunk.serializeState.readyId && !serializer.written(subscribers)) subscribers.add(scope);
|
|
2545
|
-
else serializer.writeCall(scope, subscribers, "add", $chunk.serializeState);
|
|
2546
|
-
}
|
|
2547
|
-
return scope;
|
|
2548
|
-
}
|
|
2549
2561
|
//#endregion
|
|
2550
2562
|
//#region src/html/attrs.ts
|
|
2551
2563
|
function _attr_class(value) {
|
|
@@ -2754,7 +2766,7 @@ function normalizedValueMatches(a, b) {
|
|
|
2754
2766
|
return false;
|
|
2755
2767
|
}
|
|
2756
2768
|
function normalizeStrAttrValue(value) {
|
|
2757
|
-
return value && value !== true
|
|
2769
|
+
return isNotVoid(value) && value !== true ? value + "" : "";
|
|
2758
2770
|
}
|
|
2759
2771
|
//#endregion
|
|
2760
2772
|
//#region src/html/dynamic-tag.ts
|
|
@@ -2770,27 +2782,30 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2770
2782
|
assertValidTagName(renderer);
|
|
2771
2783
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
2772
2784
|
rendered = true;
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
if (
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
if (
|
|
2782
|
-
|
|
2783
|
-
|
|
2785
|
+
const renderNative = () => {
|
|
2786
|
+
_scope_id();
|
|
2787
|
+
_html(`<${renderer}${_attrs(input, `#${renderer}/0`, branchId, renderer)}>`);
|
|
2788
|
+
if (!voidElementsReg.test(renderer)) {
|
|
2789
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
2790
|
+
if (renderer === "textarea") {
|
|
2791
|
+
if (renderContent) throw new Error("A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead.");
|
|
2792
|
+
_html(_attr_textarea_value(branchId, `#${renderer}/0`, input.value, input.valueChange, 1));
|
|
2793
|
+
} else if (renderContent) {
|
|
2794
|
+
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2795
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, `#${renderer}/0`, input.value, input.valueChange, renderContent, 1);
|
|
2796
|
+
else _dynamic_tag(branchId, `#${renderer}/0`, renderContent, void 0, 0, void 0, serializeReason);
|
|
2797
|
+
}
|
|
2798
|
+
_html(`</${renderer}>`);
|
|
2799
|
+
} else if (content) throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2800
|
+
const childScope = getScopeById(branchId);
|
|
2801
|
+
const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
|
|
2802
|
+
if (needsScript) {
|
|
2803
|
+
writeScope(branchId, { ["#Renderer"]: renderer });
|
|
2804
|
+
_script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
|
|
2784
2805
|
}
|
|
2785
|
-
_html(
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
const needsScript = childScope && (childScope[`EventAttributes:#${renderer}/0`] || childScope[`ControlledHandler:#${renderer}/0`]);
|
|
2789
|
-
if (needsScript) {
|
|
2790
|
-
writeScope(branchId, { ["#Renderer"]: renderer });
|
|
2791
|
-
_script(branchId, DYNAMIC_TAG_SCRIPT_REGISTER_ID);
|
|
2792
|
-
}
|
|
2793
|
-
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2806
|
+
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2807
|
+
};
|
|
2808
|
+
renderNative();
|
|
2794
2809
|
} else {
|
|
2795
2810
|
if (shouldResume) _html(state.mark("[", ""));
|
|
2796
2811
|
const render = () => {
|
|
@@ -2830,6 +2845,7 @@ const patchDynamicTag = ((originalDynamicTag) => (patch) => {
|
|
|
2830
2845
|
})(_dynamic_tag);
|
|
2831
2846
|
//#endregion
|
|
2832
2847
|
//#region src/html/template.ts
|
|
2848
|
+
const CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result";
|
|
2833
2849
|
const _template = (templateId, renderer, page) => {
|
|
2834
2850
|
renderer.render = render;
|
|
2835
2851
|
renderer["embed"] = !page;
|
|
@@ -2992,7 +3008,7 @@ var ServerRendered = class {
|
|
|
2992
3008
|
return this.#cachedPromise ||= new Promise((resolve, reject) => {
|
|
2993
3009
|
const head = this.#head;
|
|
2994
3010
|
this.#head = null;
|
|
2995
|
-
if (!head) return reject(/* @__PURE__ */ new Error(
|
|
3011
|
+
if (!head) return reject(/* @__PURE__ */ new Error(CONSUMED_RESULT_MESSAGE));
|
|
2996
3012
|
const { boundary } = head;
|
|
2997
3013
|
(boundary.onNext = () => {
|
|
2998
3014
|
switch (!boundary.count && boundary.flush()) {
|
|
@@ -3000,9 +3016,11 @@ var ServerRendered = class {
|
|
|
3000
3016
|
boundary.onNext = NOOP$1;
|
|
3001
3017
|
reject(boundary.signal.reason);
|
|
3002
3018
|
break;
|
|
3003
|
-
case 0:
|
|
3004
|
-
|
|
3019
|
+
case 0: {
|
|
3020
|
+
const consumed = head.consume();
|
|
3021
|
+
if (!boundary.signal.aborted) resolve(consumed.flushHTML());
|
|
3005
3022
|
break;
|
|
3023
|
+
}
|
|
3006
3024
|
}
|
|
3007
3025
|
})();
|
|
3008
3026
|
});
|
|
@@ -3012,7 +3030,7 @@ var ServerRendered = class {
|
|
|
3012
3030
|
let head = this.#head;
|
|
3013
3031
|
this.#head = null;
|
|
3014
3032
|
if (!head) {
|
|
3015
|
-
onAbort(/* @__PURE__ */ new Error(
|
|
3033
|
+
onAbort(/* @__PURE__ */ new Error(CONSUMED_RESULT_MESSAGE));
|
|
3016
3034
|
return;
|
|
3017
3035
|
}
|
|
3018
3036
|
const { boundary } = head;
|
|
@@ -3042,7 +3060,7 @@ var ServerRendered = class {
|
|
|
3042
3060
|
toString() {
|
|
3043
3061
|
const head = this.#head;
|
|
3044
3062
|
this.#head = null;
|
|
3045
|
-
if (!head) throw new Error(
|
|
3063
|
+
if (!head) throw new Error(CONSUMED_RESULT_MESSAGE);
|
|
3046
3064
|
const { boundary } = head;
|
|
3047
3065
|
switch (boundary.flush()) {
|
|
3048
3066
|
case 2: throw boundary.signal.reason;
|