marko 6.0.0-3.12 → 6.0.0-3.14
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 +24 -17
- package/dist/debug/dom.mjs +24 -17
- package/dist/debug/html.js +36 -31
- package/dist/debug/html.mjs +36 -31
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/renderer.d.ts +1 -1
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom.js +20 -15
- package/dist/dom.mjs +20 -15
- package/dist/html/attrs.d.ts +1 -1
- package/dist/html/dynamic-tag.d.ts +4 -4
- package/dist/html/writer.d.ts +5 -5
- package/dist/html.js +28 -23
- package/dist/html.mjs +28 -23
- package/dist/translator/index.d.ts +2 -0
- package/dist/translator/index.js +98 -63
- package/dist/translator/util/entry-builder.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/translate-attrs.d.ts +5 -3
- package/index.d.ts +4 -4
- package/package.json +2 -2
- package/tags-html.d.ts +1 -1
package/dist/debug/dom.js
CHANGED
@@ -615,8 +615,8 @@ function setTagVarChange(scope, changeHandler) {
|
|
615
615
|
scope["@" /* TagVariableChange */] = changeHandler;
|
616
616
|
}
|
617
617
|
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
618
|
-
var
|
619
|
-
const signals =
|
618
|
+
var contentClosures = (content, childScope, op) => {
|
619
|
+
const signals = content?.___closureSignals;
|
620
620
|
if (signals) {
|
621
621
|
for (const signal of signals) {
|
622
622
|
signal(childScope, op);
|
@@ -787,7 +787,7 @@ function getEventHandlerName(name) {
|
|
787
787
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
788
788
|
}
|
789
789
|
function normalizeDynamicRenderer(value2) {
|
790
|
-
if (value2) return value2.
|
790
|
+
if (value2) return value2.content || value2.default || value2;
|
791
791
|
}
|
792
792
|
|
793
793
|
// src/dom/reconcile.ts
|
@@ -1439,7 +1439,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1439
1439
|
case "style":
|
1440
1440
|
styleAttr(el, value2);
|
1441
1441
|
break;
|
1442
|
-
case "
|
1442
|
+
case "content":
|
1443
1443
|
break;
|
1444
1444
|
default: {
|
1445
1445
|
if (isEventHandler(name)) {
|
@@ -1644,7 +1644,7 @@ function initRenderer(renderer, scope) {
|
|
1644
1644
|
}
|
1645
1645
|
return dom;
|
1646
1646
|
}
|
1647
|
-
function dynamicTagAttrs(nodeAccessor,
|
1647
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1648
1648
|
return (scope, attrsOrOp) => {
|
1649
1649
|
const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1650
1650
|
if (!renderer || attrsOrOp === DIRTY) {
|
@@ -1654,24 +1654,24 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
1654
1654
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
|
1655
1655
|
return renderer.___args?.(childScope, attrsOrOp);
|
1656
1656
|
}
|
1657
|
-
const
|
1657
|
+
const content = getContent?.(scope);
|
1658
1658
|
if (typeof renderer === "string") {
|
1659
1659
|
const nodeAccessor2 = true ? `#${renderer}/0` : 0;
|
1660
|
-
if (renderer === "textarea" &&
|
1660
|
+
if (renderer === "textarea" && content) {
|
1661
1661
|
throw new Error(
|
1662
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
1662
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1663
1663
|
);
|
1664
1664
|
}
|
1665
|
-
setConditionalRendererOnlyChild(childScope, nodeAccessor2,
|
1665
|
+
setConditionalRendererOnlyChild(childScope, nodeAccessor2, content);
|
1666
1666
|
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1667
1667
|
} else if (renderer.___args) {
|
1668
1668
|
const attributes = attrsOrOp();
|
1669
1669
|
renderer.___args(
|
1670
1670
|
childScope,
|
1671
1671
|
inputIsArgs ? attributes : [
|
1672
|
-
|
1672
|
+
content ? {
|
1673
1673
|
...attributes,
|
1674
|
-
|
1674
|
+
content
|
1675
1675
|
} : attributes
|
1676
1676
|
]
|
1677
1677
|
);
|
@@ -1741,7 +1741,7 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1741
1741
|
}
|
1742
1742
|
}
|
1743
1743
|
intersection2?.(scope, op);
|
1744
|
-
|
1744
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1745
1745
|
};
|
1746
1746
|
};
|
1747
1747
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1802,7 +1802,7 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1802
1802
|
}
|
1803
1803
|
}
|
1804
1804
|
intersection2?.(scope, op);
|
1805
|
-
|
1805
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1806
1806
|
};
|
1807
1807
|
};
|
1808
1808
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -2006,7 +2006,7 @@ var compat = {
|
|
2006
2006
|
renderer.___clone = clone;
|
2007
2007
|
return renderer;
|
2008
2008
|
},
|
2009
|
-
render(out, component, renderer,
|
2009
|
+
render(out, component, renderer, args) {
|
2010
2010
|
let scope = component.scope;
|
2011
2011
|
if (!scope) {
|
2012
2012
|
scope = classIdToScope.get(component.id);
|
@@ -2015,8 +2015,15 @@ var compat = {
|
|
2015
2015
|
classIdToScope.delete(component.id);
|
2016
2016
|
}
|
2017
2017
|
}
|
2018
|
-
const
|
2018
|
+
const applyArgs = renderer.___args || noop;
|
2019
2019
|
let existing = false;
|
2020
|
+
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
2021
|
+
const input = args[0];
|
2022
|
+
const normalizedInput = args[0] = {};
|
2023
|
+
for (const key in input) {
|
2024
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2025
|
+
}
|
2026
|
+
}
|
2020
2027
|
component.effects = prepareEffects(() => {
|
2021
2028
|
if (!scope) {
|
2022
2029
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
@@ -2027,10 +2034,10 @@ var compat = {
|
|
2027
2034
|
}
|
2028
2035
|
}
|
2029
2036
|
} else {
|
2030
|
-
|
2037
|
+
applyArgs(scope, MARK);
|
2031
2038
|
existing = true;
|
2032
2039
|
}
|
2033
|
-
|
2040
|
+
applyArgs(scope, args);
|
2034
2041
|
});
|
2035
2042
|
if (!existing) {
|
2036
2043
|
return scope.___startNode === scope.___endNode ? scope.___startNode : scope.___startNode.parentNode;
|
package/dist/debug/dom.mjs
CHANGED
@@ -525,8 +525,8 @@ function setTagVarChange(scope, changeHandler) {
|
|
525
525
|
scope["@" /* TagVariableChange */] = changeHandler;
|
526
526
|
}
|
527
527
|
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
528
|
-
var
|
529
|
-
const signals =
|
528
|
+
var contentClosures = (content, childScope, op) => {
|
529
|
+
const signals = content?.___closureSignals;
|
530
530
|
if (signals) {
|
531
531
|
for (const signal of signals) {
|
532
532
|
signal(childScope, op);
|
@@ -697,7 +697,7 @@ function getEventHandlerName(name) {
|
|
697
697
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
698
698
|
}
|
699
699
|
function normalizeDynamicRenderer(value2) {
|
700
|
-
if (value2) return value2.
|
700
|
+
if (value2) return value2.content || value2.default || value2;
|
701
701
|
}
|
702
702
|
|
703
703
|
// src/dom/reconcile.ts
|
@@ -1349,7 +1349,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1349
1349
|
case "style":
|
1350
1350
|
styleAttr(el, value2);
|
1351
1351
|
break;
|
1352
|
-
case "
|
1352
|
+
case "content":
|
1353
1353
|
break;
|
1354
1354
|
default: {
|
1355
1355
|
if (isEventHandler(name)) {
|
@@ -1554,7 +1554,7 @@ function initRenderer(renderer, scope) {
|
|
1554
1554
|
}
|
1555
1555
|
return dom;
|
1556
1556
|
}
|
1557
|
-
function dynamicTagAttrs(nodeAccessor,
|
1557
|
+
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
1558
1558
|
return (scope, attrsOrOp) => {
|
1559
1559
|
const renderer = scope[nodeAccessor + "(" /* ConditionalRenderer */];
|
1560
1560
|
if (!renderer || attrsOrOp === DIRTY) {
|
@@ -1564,24 +1564,24 @@ function dynamicTagAttrs(nodeAccessor, getRenderBody, inputIsArgs) {
|
|
1564
1564
|
if (attrsOrOp === MARK || attrsOrOp === CLEAN) {
|
1565
1565
|
return renderer.___args?.(childScope, attrsOrOp);
|
1566
1566
|
}
|
1567
|
-
const
|
1567
|
+
const content = getContent?.(scope);
|
1568
1568
|
if (typeof renderer === "string") {
|
1569
1569
|
const nodeAccessor2 = true ? `#${renderer}/0` : 0;
|
1570
|
-
if (renderer === "textarea" &&
|
1570
|
+
if (renderer === "textarea" && content) {
|
1571
1571
|
throw new Error(
|
1572
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
1572
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
1573
1573
|
);
|
1574
1574
|
}
|
1575
|
-
setConditionalRendererOnlyChild(childScope, nodeAccessor2,
|
1575
|
+
setConditionalRendererOnlyChild(childScope, nodeAccessor2, content);
|
1576
1576
|
attrs(childScope, nodeAccessor2, attrsOrOp());
|
1577
1577
|
} else if (renderer.___args) {
|
1578
1578
|
const attributes = attrsOrOp();
|
1579
1579
|
renderer.___args(
|
1580
1580
|
childScope,
|
1581
1581
|
inputIsArgs ? attributes : [
|
1582
|
-
|
1582
|
+
content ? {
|
1583
1583
|
...attributes,
|
1584
|
-
|
1584
|
+
content
|
1585
1585
|
} : attributes
|
1586
1586
|
]
|
1587
1587
|
);
|
@@ -1651,7 +1651,7 @@ var conditional = function conditional2(nodeAccessor, fn, getIntersection) {
|
|
1651
1651
|
}
|
1652
1652
|
}
|
1653
1653
|
intersection2?.(scope, op);
|
1654
|
-
|
1654
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1655
1655
|
};
|
1656
1656
|
};
|
1657
1657
|
function inConditionalScope(signal, nodeAccessor) {
|
@@ -1712,7 +1712,7 @@ var conditionalOnlyChild = function conditional3(nodeAccessor, fn, getIntersecti
|
|
1712
1712
|
}
|
1713
1713
|
}
|
1714
1714
|
intersection2?.(scope, op);
|
1715
|
-
|
1715
|
+
contentClosures(currentRenderer, scope[childScopeAccessor], op);
|
1716
1716
|
};
|
1717
1717
|
};
|
1718
1718
|
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
@@ -1916,7 +1916,7 @@ var compat = {
|
|
1916
1916
|
renderer.___clone = clone;
|
1917
1917
|
return renderer;
|
1918
1918
|
},
|
1919
|
-
render(out, component, renderer,
|
1919
|
+
render(out, component, renderer, args) {
|
1920
1920
|
let scope = component.scope;
|
1921
1921
|
if (!scope) {
|
1922
1922
|
scope = classIdToScope.get(component.id);
|
@@ -1925,8 +1925,15 @@ var compat = {
|
|
1925
1925
|
classIdToScope.delete(component.id);
|
1926
1926
|
}
|
1927
1927
|
}
|
1928
|
-
const
|
1928
|
+
const applyArgs = renderer.___args || noop;
|
1929
1929
|
let existing = false;
|
1930
|
+
if (typeof args[0] === "object" && "renderBody" in args[0]) {
|
1931
|
+
const input = args[0];
|
1932
|
+
const normalizedInput = args[0] = {};
|
1933
|
+
for (const key in input) {
|
1934
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1935
|
+
}
|
1936
|
+
}
|
1930
1937
|
component.effects = prepareEffects(() => {
|
1931
1938
|
if (!scope) {
|
1932
1939
|
scope = component.scope = createScopeWithRenderer(renderer, out.global);
|
@@ -1937,10 +1944,10 @@ var compat = {
|
|
1937
1944
|
}
|
1938
1945
|
}
|
1939
1946
|
} else {
|
1940
|
-
|
1947
|
+
applyArgs(scope, MARK);
|
1941
1948
|
existing = true;
|
1942
1949
|
}
|
1943
|
-
|
1950
|
+
applyArgs(scope, args);
|
1944
1951
|
});
|
1945
1952
|
if (!existing) {
|
1946
1953
|
return scope.___startNode === scope.___endNode ? scope.___startNode : scope.___startNode.parentNode;
|
package/dist/debug/html.js
CHANGED
@@ -153,7 +153,7 @@ function isVoid(value) {
|
|
153
153
|
return value == null || value === false;
|
154
154
|
}
|
155
155
|
function normalizeDynamicRenderer(value) {
|
156
|
-
if (value) return value.
|
156
|
+
if (value) return value.content || value.default || value;
|
157
157
|
}
|
158
158
|
|
159
159
|
// src/html/content.ts
|
@@ -1548,9 +1548,9 @@ function ensureScopeWithId(scopeId) {
|
|
1548
1548
|
function $global() {
|
1549
1549
|
return $chunk.boundary.state.$global;
|
1550
1550
|
}
|
1551
|
-
function fork(promise,
|
1551
|
+
function fork(promise, content) {
|
1552
1552
|
if (!isPromise(promise)) {
|
1553
|
-
|
1553
|
+
content(promise);
|
1554
1554
|
return;
|
1555
1555
|
}
|
1556
1556
|
const chunk = $chunk;
|
@@ -1566,7 +1566,7 @@ function fork(promise, renderBody) {
|
|
1566
1566
|
if (chunk.async) {
|
1567
1567
|
chunk.async = false;
|
1568
1568
|
if (!boundary.signal.aborted) {
|
1569
|
-
chunk.render(
|
1569
|
+
chunk.render(content, value);
|
1570
1570
|
boundary.endAsync(chunk);
|
1571
1571
|
}
|
1572
1572
|
}
|
@@ -1577,27 +1577,27 @@ function fork(promise, renderBody) {
|
|
1577
1577
|
}
|
1578
1578
|
);
|
1579
1579
|
}
|
1580
|
-
function tryPlaceholder(
|
1580
|
+
function tryPlaceholder(content, placeholder) {
|
1581
1581
|
const chunk = $chunk;
|
1582
1582
|
const { boundary } = chunk;
|
1583
1583
|
const body = new Chunk(boundary, null, chunk.context);
|
1584
|
-
if (body === body.render(
|
1584
|
+
if (body === body.render(content)) {
|
1585
1585
|
chunk.append(body);
|
1586
1586
|
return;
|
1587
1587
|
}
|
1588
1588
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
|
1589
1589
|
chunk.placeholderBody = body;
|
1590
|
-
chunk.placeholderRender =
|
1590
|
+
chunk.placeholderRender = placeholder;
|
1591
1591
|
}
|
1592
|
-
function tryCatch(
|
1592
|
+
function tryCatch(content, catchContent) {
|
1593
1593
|
const chunk = $chunk;
|
1594
1594
|
const { boundary } = chunk;
|
1595
1595
|
const { state } = boundary;
|
1596
1596
|
const catchBoundary = new Boundary(state);
|
1597
1597
|
const body = new Chunk(catchBoundary, null, chunk.context);
|
1598
|
-
const bodyEnd = body.render(
|
1598
|
+
const bodyEnd = body.render(content);
|
1599
1599
|
if (catchBoundary.signal.aborted) {
|
1600
|
-
|
1600
|
+
catchContent(catchBoundary.signal.reason);
|
1601
1601
|
return;
|
1602
1602
|
}
|
1603
1603
|
if (body === bodyEnd) {
|
@@ -1635,7 +1635,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1635
1635
|
}
|
1636
1636
|
const catchChunk = new Chunk(boundary, null, chunk.context);
|
1637
1637
|
catchChunk.reorderId = reorderId;
|
1638
|
-
catchChunk.render(
|
1638
|
+
catchChunk.render(catchContent, catchBoundary.signal.reason);
|
1639
1639
|
state.reorder(catchChunk);
|
1640
1640
|
boundary.endAsync();
|
1641
1641
|
} else if (catchBoundary.done) {
|
@@ -1818,11 +1818,11 @@ var Chunk = class {
|
|
1818
1818
|
}
|
1819
1819
|
return cur;
|
1820
1820
|
}
|
1821
|
-
render(
|
1821
|
+
render(content, val) {
|
1822
1822
|
const prev = $chunk;
|
1823
1823
|
$chunk = this;
|
1824
1824
|
try {
|
1825
|
-
|
1825
|
+
content(val);
|
1826
1826
|
return $chunk;
|
1827
1827
|
} catch (err) {
|
1828
1828
|
this.boundary.abort(err);
|
@@ -2035,7 +2035,7 @@ function optionValueAttr(value) {
|
|
2035
2035
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
|
2036
2036
|
}
|
2037
2037
|
var kSelectedValue = Symbol("selectedValue");
|
2038
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
2038
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
2039
2039
|
if (valueChange) {
|
2040
2040
|
writeControlledScope(
|
2041
2041
|
3 /* SelectValue */,
|
@@ -2045,8 +2045,8 @@ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, re
|
|
2045
2045
|
valueChange
|
2046
2046
|
);
|
2047
2047
|
}
|
2048
|
-
if (
|
2049
|
-
withContext(kSelectedValue, value,
|
2048
|
+
if (content) {
|
2049
|
+
withContext(kSelectedValue, value, content);
|
2050
2050
|
}
|
2051
2051
|
}
|
2052
2052
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
@@ -2182,7 +2182,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2182
2182
|
result += styleAttr(val);
|
2183
2183
|
break;
|
2184
2184
|
case "":
|
2185
|
-
case "
|
2185
|
+
case "content":
|
2186
2186
|
break;
|
2187
2187
|
default:
|
2188
2188
|
if (!isVoid(val)) {
|
@@ -2260,13 +2260,13 @@ var DEFAULT_RENDER_ID = "_";
|
|
2260
2260
|
|
2261
2261
|
// src/html/dynamic-tag.ts
|
2262
2262
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2263
|
-
function dynamicTagInput(scope, tag, input,
|
2264
|
-
if (!tag && !
|
2263
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
2264
|
+
if (!tag && !content) return void 0;
|
2265
2265
|
const scopeId = getScopeId(scope);
|
2266
2266
|
write(`${markResumeScopeStart(scopeId)}`);
|
2267
2267
|
writeScope(scopeId, scope);
|
2268
2268
|
if (!tag) {
|
2269
|
-
return
|
2269
|
+
return content();
|
2270
2270
|
}
|
2271
2271
|
if (typeof tag === "string") {
|
2272
2272
|
nextScopeId();
|
@@ -2275,9 +2275,9 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2275
2275
|
);
|
2276
2276
|
if (!voidElementsReg.test(tag)) {
|
2277
2277
|
if (tag === "textarea") {
|
2278
|
-
if (
|
2278
|
+
if (content) {
|
2279
2279
|
throw new Error(
|
2280
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
2280
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2281
2281
|
);
|
2282
2282
|
}
|
2283
2283
|
write(
|
@@ -2288,24 +2288,22 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2288
2288
|
input.valueChange
|
2289
2289
|
)
|
2290
2290
|
);
|
2291
|
-
} else if (
|
2291
|
+
} else if (content) {
|
2292
2292
|
if (tag === "select" && ("value" in input || "valueChange" in input)) {
|
2293
2293
|
controllable_select_value(
|
2294
2294
|
scopeId,
|
2295
2295
|
true ? `#${tag}/0` : 0,
|
2296
2296
|
input.value,
|
2297
2297
|
input.valueChange,
|
2298
|
-
|
2298
|
+
content
|
2299
2299
|
);
|
2300
2300
|
} else {
|
2301
|
-
|
2301
|
+
content();
|
2302
2302
|
}
|
2303
2303
|
}
|
2304
2304
|
write(`</${tag}>`);
|
2305
|
-
} else if (
|
2306
|
-
throw new Error(
|
2307
|
-
`A renderBody was provided for a "${tag}" tag, which cannot have children.`
|
2308
|
-
);
|
2305
|
+
} else if (content) {
|
2306
|
+
throw new Error(`Body content is not supported for a "${tag}" tag.`);
|
2309
2307
|
}
|
2310
2308
|
return null;
|
2311
2309
|
}
|
@@ -2315,7 +2313,7 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2315
2313
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
2316
2314
|
}
|
2317
2315
|
}
|
2318
|
-
return renderer(
|
2316
|
+
return renderer(content ? { ...input, content } : input, tagVar);
|
2319
2317
|
}
|
2320
2318
|
function dynamicTagArgs(scope, tag, args) {
|
2321
2319
|
if (!tag) return void 0;
|
@@ -2392,13 +2390,20 @@ var compat = {
|
|
2392
2390
|
null,
|
2393
2391
|
null
|
2394
2392
|
);
|
2393
|
+
let normalizedInput = input;
|
2394
|
+
if ("renderBody" in input) {
|
2395
|
+
normalizedInput = {};
|
2396
|
+
for (const key in input) {
|
2397
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2398
|
+
}
|
2399
|
+
}
|
2395
2400
|
head.render(() => {
|
2396
2401
|
if (willRerender) {
|
2397
2402
|
const scopeId = peekNextScopeId();
|
2398
2403
|
writeScope(scopeId, { m5c: component.id });
|
2399
2404
|
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2400
2405
|
}
|
2401
|
-
renderer(
|
2406
|
+
renderer(normalizedInput);
|
2402
2407
|
});
|
2403
2408
|
const asyncOut = classAPIOut.beginAsync();
|
2404
2409
|
(boundary.onNext = () => {
|
package/dist/debug/html.mjs
CHANGED
@@ -77,7 +77,7 @@ function isVoid(value) {
|
|
77
77
|
return value == null || value === false;
|
78
78
|
}
|
79
79
|
function normalizeDynamicRenderer(value) {
|
80
|
-
if (value) return value.
|
80
|
+
if (value) return value.content || value.default || value;
|
81
81
|
}
|
82
82
|
|
83
83
|
// src/html/content.ts
|
@@ -1472,9 +1472,9 @@ function ensureScopeWithId(scopeId) {
|
|
1472
1472
|
function $global() {
|
1473
1473
|
return $chunk.boundary.state.$global;
|
1474
1474
|
}
|
1475
|
-
function fork(promise,
|
1475
|
+
function fork(promise, content) {
|
1476
1476
|
if (!isPromise(promise)) {
|
1477
|
-
|
1477
|
+
content(promise);
|
1478
1478
|
return;
|
1479
1479
|
}
|
1480
1480
|
const chunk = $chunk;
|
@@ -1490,7 +1490,7 @@ function fork(promise, renderBody) {
|
|
1490
1490
|
if (chunk.async) {
|
1491
1491
|
chunk.async = false;
|
1492
1492
|
if (!boundary.signal.aborted) {
|
1493
|
-
chunk.render(
|
1493
|
+
chunk.render(content, value);
|
1494
1494
|
boundary.endAsync(chunk);
|
1495
1495
|
}
|
1496
1496
|
}
|
@@ -1501,27 +1501,27 @@ function fork(promise, renderBody) {
|
|
1501
1501
|
}
|
1502
1502
|
);
|
1503
1503
|
}
|
1504
|
-
function tryPlaceholder(
|
1504
|
+
function tryPlaceholder(content, placeholder) {
|
1505
1505
|
const chunk = $chunk;
|
1506
1506
|
const { boundary } = chunk;
|
1507
1507
|
const body = new Chunk(boundary, null, chunk.context);
|
1508
|
-
if (body === body.render(
|
1508
|
+
if (body === body.render(content)) {
|
1509
1509
|
chunk.append(body);
|
1510
1510
|
return;
|
1511
1511
|
}
|
1512
1512
|
chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
|
1513
1513
|
chunk.placeholderBody = body;
|
1514
|
-
chunk.placeholderRender =
|
1514
|
+
chunk.placeholderRender = placeholder;
|
1515
1515
|
}
|
1516
|
-
function tryCatch(
|
1516
|
+
function tryCatch(content, catchContent) {
|
1517
1517
|
const chunk = $chunk;
|
1518
1518
|
const { boundary } = chunk;
|
1519
1519
|
const { state } = boundary;
|
1520
1520
|
const catchBoundary = new Boundary(state);
|
1521
1521
|
const body = new Chunk(catchBoundary, null, chunk.context);
|
1522
|
-
const bodyEnd = body.render(
|
1522
|
+
const bodyEnd = body.render(content);
|
1523
1523
|
if (catchBoundary.signal.aborted) {
|
1524
|
-
|
1524
|
+
catchContent(catchBoundary.signal.reason);
|
1525
1525
|
return;
|
1526
1526
|
}
|
1527
1527
|
if (body === bodyEnd) {
|
@@ -1559,7 +1559,7 @@ function tryCatch(renderBody, renderCatch) {
|
|
1559
1559
|
}
|
1560
1560
|
const catchChunk = new Chunk(boundary, null, chunk.context);
|
1561
1561
|
catchChunk.reorderId = reorderId;
|
1562
|
-
catchChunk.render(
|
1562
|
+
catchChunk.render(catchContent, catchBoundary.signal.reason);
|
1563
1563
|
state.reorder(catchChunk);
|
1564
1564
|
boundary.endAsync();
|
1565
1565
|
} else if (catchBoundary.done) {
|
@@ -1742,11 +1742,11 @@ var Chunk = class {
|
|
1742
1742
|
}
|
1743
1743
|
return cur;
|
1744
1744
|
}
|
1745
|
-
render(
|
1745
|
+
render(content, val) {
|
1746
1746
|
const prev = $chunk;
|
1747
1747
|
$chunk = this;
|
1748
1748
|
try {
|
1749
|
-
|
1749
|
+
content(val);
|
1750
1750
|
return $chunk;
|
1751
1751
|
} catch (err) {
|
1752
1752
|
this.boundary.abort(err);
|
@@ -1959,7 +1959,7 @@ function optionValueAttr(value) {
|
|
1959
1959
|
return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
|
1960
1960
|
}
|
1961
1961
|
var kSelectedValue = Symbol("selectedValue");
|
1962
|
-
function controllable_select_value(scopeId, nodeAccessor, value, valueChange,
|
1962
|
+
function controllable_select_value(scopeId, nodeAccessor, value, valueChange, content) {
|
1963
1963
|
if (valueChange) {
|
1964
1964
|
writeControlledScope(
|
1965
1965
|
3 /* SelectValue */,
|
@@ -1969,8 +1969,8 @@ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, re
|
|
1969
1969
|
valueChange
|
1970
1970
|
);
|
1971
1971
|
}
|
1972
|
-
if (
|
1973
|
-
withContext(kSelectedValue, value,
|
1972
|
+
if (content) {
|
1973
|
+
withContext(kSelectedValue, value, content);
|
1974
1974
|
}
|
1975
1975
|
}
|
1976
1976
|
function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
|
@@ -2106,7 +2106,7 @@ function attrs(data, nodeAccessor, scopeId, tagName) {
|
|
2106
2106
|
result += styleAttr(val);
|
2107
2107
|
break;
|
2108
2108
|
case "":
|
2109
|
-
case "
|
2109
|
+
case "content":
|
2110
2110
|
break;
|
2111
2111
|
default:
|
2112
2112
|
if (!isVoid(val)) {
|
@@ -2184,13 +2184,13 @@ var DEFAULT_RENDER_ID = "_";
|
|
2184
2184
|
|
2185
2185
|
// src/html/dynamic-tag.ts
|
2186
2186
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
2187
|
-
function dynamicTagInput(scope, tag, input,
|
2188
|
-
if (!tag && !
|
2187
|
+
function dynamicTagInput(scope, tag, input, content, tagVar) {
|
2188
|
+
if (!tag && !content) return void 0;
|
2189
2189
|
const scopeId = getScopeId(scope);
|
2190
2190
|
write(`${markResumeScopeStart(scopeId)}`);
|
2191
2191
|
writeScope(scopeId, scope);
|
2192
2192
|
if (!tag) {
|
2193
|
-
return
|
2193
|
+
return content();
|
2194
2194
|
}
|
2195
2195
|
if (typeof tag === "string") {
|
2196
2196
|
nextScopeId();
|
@@ -2199,9 +2199,9 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2199
2199
|
);
|
2200
2200
|
if (!voidElementsReg.test(tag)) {
|
2201
2201
|
if (tag === "textarea") {
|
2202
|
-
if (
|
2202
|
+
if (content) {
|
2203
2203
|
throw new Error(
|
2204
|
-
"A dynamic tag rendering a `<textarea>` cannot have
|
2204
|
+
"A dynamic tag rendering a `<textarea>` cannot have `content` and must use the `value` attribute instead."
|
2205
2205
|
);
|
2206
2206
|
}
|
2207
2207
|
write(
|
@@ -2212,24 +2212,22 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2212
2212
|
input.valueChange
|
2213
2213
|
)
|
2214
2214
|
);
|
2215
|
-
} else if (
|
2215
|
+
} else if (content) {
|
2216
2216
|
if (tag === "select" && ("value" in input || "valueChange" in input)) {
|
2217
2217
|
controllable_select_value(
|
2218
2218
|
scopeId,
|
2219
2219
|
true ? `#${tag}/0` : 0,
|
2220
2220
|
input.value,
|
2221
2221
|
input.valueChange,
|
2222
|
-
|
2222
|
+
content
|
2223
2223
|
);
|
2224
2224
|
} else {
|
2225
|
-
|
2225
|
+
content();
|
2226
2226
|
}
|
2227
2227
|
}
|
2228
2228
|
write(`</${tag}>`);
|
2229
|
-
} else if (
|
2230
|
-
throw new Error(
|
2231
|
-
`A renderBody was provided for a "${tag}" tag, which cannot have children.`
|
2232
|
-
);
|
2229
|
+
} else if (content) {
|
2230
|
+
throw new Error(`Body content is not supported for a "${tag}" tag.`);
|
2233
2231
|
}
|
2234
2232
|
return null;
|
2235
2233
|
}
|
@@ -2239,7 +2237,7 @@ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
|
|
2239
2237
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
2240
2238
|
}
|
2241
2239
|
}
|
2242
|
-
return renderer(
|
2240
|
+
return renderer(content ? { ...input, content } : input, tagVar);
|
2243
2241
|
}
|
2244
2242
|
function dynamicTagArgs(scope, tag, args) {
|
2245
2243
|
if (!tag) return void 0;
|
@@ -2316,13 +2314,20 @@ var compat = {
|
|
2316
2314
|
null,
|
2317
2315
|
null
|
2318
2316
|
);
|
2317
|
+
let normalizedInput = input;
|
2318
|
+
if ("renderBody" in input) {
|
2319
|
+
normalizedInput = {};
|
2320
|
+
for (const key in input) {
|
2321
|
+
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
2322
|
+
}
|
2323
|
+
}
|
2319
2324
|
head.render(() => {
|
2320
2325
|
if (willRerender) {
|
2321
2326
|
const scopeId = peekNextScopeId();
|
2322
2327
|
writeScope(scopeId, { m5c: component.id });
|
2323
2328
|
writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
|
2324
2329
|
}
|
2325
|
-
renderer(
|
2330
|
+
renderer(normalizedInput);
|
2326
2331
|
});
|
2327
2332
|
const asyncOut = classAPIOut.beginAsync();
|
2328
2333
|
(boundary.onNext = () => {
|
package/dist/dom/compat.d.ts
CHANGED
@@ -16,5 +16,5 @@ export declare const compat: {
|
|
16
16
|
componentIdPrefix: string;
|
17
17
|
}): any;
|
18
18
|
createRenderer(setup: Renderer["___setup"], clone: Renderer["___clone"], args: Renderer["___args"]): Renderer;
|
19
|
-
render(out: any, component: any, renderer: Renderer,
|
19
|
+
render(out: any, component: any, renderer: Renderer, args: any): (Node & ChildNode) | ParentNode | null | undefined;
|
20
20
|
};
|
package/dist/dom/renderer.d.ts
CHANGED
@@ -15,7 +15,7 @@ type SetupFn = (scope: Scope) => void;
|
|
15
15
|
export declare function createScopeWithRenderer(renderer: Renderer, $global: Scope["___global"], ownerScope?: Scope): Scope;
|
16
16
|
export declare function createScopeWithTagNameOrRenderer(tagNameOrRenderer: Renderer | string, $global: Scope["___global"], ownerScope?: Scope): Scope;
|
17
17
|
export declare function initRenderer(renderer: Renderer, scope: Scope): Node;
|
18
|
-
export declare function dynamicTagAttrs(nodeAccessor: Accessor,
|
18
|
+
export declare function dynamicTagAttrs(nodeAccessor: Accessor, getContent?: (scope: Scope) => Renderer, inputIsArgs?: boolean): (scope: Scope, attrsOrOp: (() => Record<string, unknown>) | SignalOp) => void;
|
19
19
|
export declare function createRendererWithOwner(template: string, rawWalks?: string, setup?: SetupFn, getClosureSignals?: () => IntersectionSignal[], getArgs?: () => ValueSignal): (owner?: Scope) => Renderer;
|
20
20
|
export declare function createRenderer(template: string, walks?: string, setup?: SetupFn, getClosureSignals?: () => IntersectionSignal[], getArgs?: () => ValueSignal): Renderer;
|
21
21
|
export {};
|
package/dist/dom/signals.d.ts
CHANGED
@@ -31,7 +31,7 @@ export declare function setTagVar(scope: Scope, childAccessor: Accessor, tagVarS
|
|
31
31
|
export declare const tagVarSignal: (scope: Scope, valueOrOp: unknown | SignalOp) => any;
|
32
32
|
export declare function setTagVarChange(scope: Scope, changeHandler: (value: unknown) => void): void;
|
33
33
|
export declare const tagVarSignalChange: (scope: Scope, value: unknown) => any;
|
34
|
-
export declare const
|
34
|
+
export declare const contentClosures: (content: Renderer | string | undefined, childScope: Scope, op: SignalOp) => void;
|
35
35
|
export declare const inMany: (scopes: Scope[], op: SignalOp, signal: IntersectionSignal) => void;
|
36
36
|
export declare function nextTagId({ $global }: Scope): string;
|
37
37
|
export declare function inChild(childAccessor: Accessor, signal: ValueSignal): (scope: Scope, valueOrOp: unknown | SignalOp) => void;
|