@marko/runtime-tags 0.3.45 → 0.3.46
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/types.d.ts +1 -1
- package/dist/debug/dom.js +75 -81
- package/dist/debug/dom.mjs +75 -81
- package/dist/dom/compat.d.ts +4 -1
- package/dist/dom/control-flow.d.ts +1 -1
- package/dist/dom/parse-html.d.ts +1 -4
- package/dist/dom/renderer.d.ts +7 -10
- package/dist/dom/template.d.ts +2 -2
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +75 -72
- package/dist/dom.mjs +75 -72
- package/dist/translator/index.js +21 -23
- package/dist/translator/util/signals.d.ts +1 -1
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/util/writer.d.ts +2 -2
- package/package.json +1 -1
package/dist/common/types.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ export interface BranchScope extends Scope {
|
|
|
9
9
|
___destroyed: 1 | undefined;
|
|
10
10
|
___abortScopes: Set<Scope> | undefined;
|
|
11
11
|
___branchScopes: Set<BranchScope> | undefined;
|
|
12
|
+
___renderer: ClientRenderer | string;
|
|
12
13
|
}
|
|
13
14
|
export interface Scope {
|
|
14
15
|
$global: Record<string, unknown>;
|
|
15
16
|
_: Scope | undefined;
|
|
16
17
|
___args: unknown;
|
|
17
18
|
___pending: 1 | 0 | undefined;
|
|
18
|
-
___renderer: ClientRenderer | undefined;
|
|
19
19
|
___abortControllers: Record<string | number, AbortController | void> | undefined;
|
|
20
20
|
___closestBranch: BranchScope | undefined;
|
|
21
21
|
[x: string | number]: any;
|
package/dist/debug/dom.js
CHANGED
|
@@ -41,8 +41,8 @@ __export(dom_exports, {
|
|
|
41
41
|
controllable_select_value_effect: () => controllable_select_value_effect,
|
|
42
42
|
controllable_textarea_value: () => controllable_input_value,
|
|
43
43
|
controllable_textarea_value_effect: () => controllable_input_value_effect,
|
|
44
|
+
createContent: () => createContent,
|
|
44
45
|
createRenderer: () => createRenderer,
|
|
45
|
-
createRendererWithOwner: () => createRendererWithOwner,
|
|
46
46
|
createTemplate: () => createTemplate,
|
|
47
47
|
data: () => data,
|
|
48
48
|
dynamicClosure: () => dynamicClosure,
|
|
@@ -69,6 +69,7 @@ __export(dom_exports, {
|
|
|
69
69
|
props: () => props,
|
|
70
70
|
register: () => register,
|
|
71
71
|
registerBoundSignal: () => registerBoundSignal,
|
|
72
|
+
registerContent: () => registerContent,
|
|
72
73
|
registerDynamicClosure: () => registerDynamicClosure,
|
|
73
74
|
resetAbortSignal: () => resetAbortSignal,
|
|
74
75
|
run: () => run,
|
|
@@ -735,9 +736,8 @@ function toValueProp(it) {
|
|
|
735
736
|
var parsers = {};
|
|
736
737
|
function parseHTML(html2, ns) {
|
|
737
738
|
const parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
return content;
|
|
739
|
+
parser.innerHTML = html2;
|
|
740
|
+
return parser.content || parser;
|
|
741
741
|
}
|
|
742
742
|
|
|
743
743
|
// src/dom/dom.ts
|
|
@@ -922,7 +922,7 @@ function html(scope, value2, accessor) {
|
|
|
922
922
|
insertChildNodes(
|
|
923
923
|
parentNode,
|
|
924
924
|
firstChild,
|
|
925
|
-
scope[accessor] = newContent.firstChild,
|
|
925
|
+
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
|
926
926
|
scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild
|
|
927
927
|
);
|
|
928
928
|
removeChildNodes(firstChild, lastChild);
|
|
@@ -1635,38 +1635,25 @@ function getDebugKey(index, node) {
|
|
|
1635
1635
|
}
|
|
1636
1636
|
|
|
1637
1637
|
// src/dom/renderer.ts
|
|
1638
|
-
function
|
|
1638
|
+
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
1639
1639
|
const branch = createBranch(
|
|
1640
1640
|
$global,
|
|
1641
|
-
|
|
1642
|
-
parentScope
|
|
1641
|
+
tagNameOrRenderer,
|
|
1642
|
+
parentScope,
|
|
1643
|
+
parentNode
|
|
1643
1644
|
);
|
|
1644
|
-
if (
|
|
1645
|
-
branch.
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
return branch;
|
|
1649
|
-
}
|
|
1650
|
-
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope, parentNode) {
|
|
1651
|
-
if (typeof tagNameOrRenderer !== "string") {
|
|
1652
|
-
return createBranchScopeWithRenderer(
|
|
1653
|
-
tagNameOrRenderer,
|
|
1654
|
-
$global,
|
|
1655
|
-
parentScope,
|
|
1656
|
-
parentNode
|
|
1645
|
+
if (typeof tagNameOrRenderer === "string") {
|
|
1646
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
|
1647
|
+
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
1648
|
+
tagNameOrRenderer
|
|
1657
1649
|
);
|
|
1658
1650
|
}
|
|
1659
|
-
const branch = createBranch($global, parentScope, parentScope);
|
|
1660
|
-
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
|
1661
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
1662
|
-
tagNameOrRenderer
|
|
1663
|
-
);
|
|
1664
1651
|
return branch;
|
|
1665
1652
|
}
|
|
1666
|
-
function createBranch($global,
|
|
1653
|
+
function createBranch($global, renderer, parentScope, parentNode) {
|
|
1667
1654
|
const branch = createScope($global);
|
|
1668
|
-
const parentBranch = parentScope
|
|
1669
|
-
branch._ =
|
|
1655
|
+
const parentBranch = parentScope?.___closestBranch;
|
|
1656
|
+
branch._ = renderer.___owner || parentScope;
|
|
1670
1657
|
branch.___closestBranch = branch;
|
|
1671
1658
|
if (parentBranch) {
|
|
1672
1659
|
branch.___branchDepth = parentBranch.___branchDepth + 1;
|
|
@@ -1675,34 +1662,32 @@ function createBranch($global, ownerScope, parentScope) {
|
|
|
1675
1662
|
} else {
|
|
1676
1663
|
branch.___branchDepth = 1;
|
|
1677
1664
|
}
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
function initBranch(renderer, branch, parentNode) {
|
|
1681
|
-
const clone = renderer.___clone(parentNode.namespaceURI);
|
|
1682
|
-
const cloneParent = clone.parentNode;
|
|
1683
|
-
if (cloneParent) {
|
|
1684
|
-
walk(cloneParent.firstChild, renderer.___walks, branch);
|
|
1685
|
-
branch.___startNode = cloneParent.firstChild;
|
|
1686
|
-
branch.___endNode = cloneParent.lastChild;
|
|
1687
|
-
} else {
|
|
1688
|
-
walk(clone, renderer.___walks, branch);
|
|
1689
|
-
branch.___startNode = branch.___endNode = clone;
|
|
1690
|
-
}
|
|
1691
|
-
if (renderer.___setup) {
|
|
1692
|
-
queueRender(branch, renderer.___setup);
|
|
1665
|
+
if (true) {
|
|
1666
|
+
branch.___renderer = renderer;
|
|
1693
1667
|
}
|
|
1668
|
+
renderer.___init?.(
|
|
1669
|
+
branch,
|
|
1670
|
+
parentNode.namespaceURI
|
|
1671
|
+
);
|
|
1672
|
+
return branch;
|
|
1694
1673
|
}
|
|
1695
|
-
function
|
|
1674
|
+
function createContent(id, template, rawWalks, setup, getArgs) {
|
|
1696
1675
|
let args;
|
|
1697
|
-
const
|
|
1698
|
-
const
|
|
1676
|
+
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : "";
|
|
1677
|
+
const init2 = template ? (branch, ns) => {
|
|
1678
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
|
|
1679
|
+
template,
|
|
1680
|
+
ns
|
|
1681
|
+
))(branch, walks);
|
|
1682
|
+
setup && queueRender(branch, setup);
|
|
1683
|
+
} : (branch) => {
|
|
1684
|
+
branch.___startNode = branch.___endNode = new Text();
|
|
1685
|
+
setup && queueRender(branch, setup);
|
|
1686
|
+
};
|
|
1699
1687
|
return (owner) => {
|
|
1700
1688
|
return {
|
|
1701
1689
|
___id: id,
|
|
1702
|
-
|
|
1703
|
-
___walks: walks,
|
|
1704
|
-
___setup: setup,
|
|
1705
|
-
___clone: _clone,
|
|
1690
|
+
___init: init2,
|
|
1706
1691
|
___owner: owner,
|
|
1707
1692
|
get ___args() {
|
|
1708
1693
|
return args ||= getArgs?.();
|
|
@@ -1710,21 +1695,29 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
|
1710
1695
|
};
|
|
1711
1696
|
};
|
|
1712
1697
|
}
|
|
1713
|
-
function
|
|
1714
|
-
return
|
|
1698
|
+
function registerContent(id, template, walks, setup, getArgs) {
|
|
1699
|
+
return register(id, createContent(id, template, walks, setup, getArgs));
|
|
1715
1700
|
}
|
|
1716
|
-
function
|
|
1717
|
-
return (
|
|
1718
|
-
this.___template,
|
|
1719
|
-
ns
|
|
1720
|
-
))();
|
|
1701
|
+
function createRenderer(template, walks, setup, getArgs) {
|
|
1702
|
+
return createContent("", template, walks, setup, getArgs)();
|
|
1721
1703
|
}
|
|
1722
1704
|
var cloneCache = {};
|
|
1723
1705
|
function createCloneableHTML(html2, ns) {
|
|
1724
1706
|
const { firstChild, lastChild } = parseHTML(html2, ns);
|
|
1725
1707
|
const parent = document.createElementNS(ns, "t");
|
|
1726
1708
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
1727
|
-
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (
|
|
1709
|
+
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
|
1710
|
+
walk(
|
|
1711
|
+
branch.___startNode = branch.___endNode = firstChild.cloneNode(true),
|
|
1712
|
+
walks,
|
|
1713
|
+
branch
|
|
1714
|
+
);
|
|
1715
|
+
} : (branch, walks) => {
|
|
1716
|
+
const clone = parent.cloneNode(true);
|
|
1717
|
+
walk(clone.firstChild, walks, branch);
|
|
1718
|
+
branch.___startNode = clone.firstChild;
|
|
1719
|
+
branch.___endNode = clone.lastChild;
|
|
1720
|
+
};
|
|
1728
1721
|
}
|
|
1729
1722
|
|
|
1730
1723
|
// src/dom/control-flow.ts
|
|
@@ -1736,7 +1729,7 @@ function conditional(nodeAccessor, ...branches) {
|
|
|
1736
1729
|
scope,
|
|
1737
1730
|
nodeAccessor,
|
|
1738
1731
|
branches[scope[branchAccessor] = newBranch],
|
|
1739
|
-
|
|
1732
|
+
createBranch
|
|
1740
1733
|
);
|
|
1741
1734
|
}
|
|
1742
1735
|
};
|
|
@@ -1762,7 +1755,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
|
1762
1755
|
scope,
|
|
1763
1756
|
nodeAccessor,
|
|
1764
1757
|
newRenderer || (getContent ? getContent(scope) : void 0),
|
|
1765
|
-
|
|
1758
|
+
createBranchWithTagNameOrRenderer
|
|
1766
1759
|
);
|
|
1767
1760
|
if (getTagVar) {
|
|
1768
1761
|
setTagVar(scope, childScopeAccessor, getTagVar());
|
|
@@ -1772,7 +1765,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
|
1772
1765
|
scope[childScopeAccessor],
|
|
1773
1766
|
true ? `#${newRenderer}/0` : 0,
|
|
1774
1767
|
getContent(scope),
|
|
1775
|
-
|
|
1768
|
+
createBranch
|
|
1776
1769
|
);
|
|
1777
1770
|
}
|
|
1778
1771
|
}
|
|
@@ -1803,7 +1796,7 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
1803
1796
|
const referenceNode = scope[nodeAccessor];
|
|
1804
1797
|
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
|
1805
1798
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
|
1806
|
-
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(
|
|
1799
|
+
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
|
1807
1800
|
if (referenceNode === parentNode) {
|
|
1808
1801
|
if (prevBranch) {
|
|
1809
1802
|
destroyBranch(prevBranch);
|
|
@@ -1875,12 +1868,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
|
1875
1868
|
const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
|
|
1876
1869
|
const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
|
1877
1870
|
forEach(valueOrOp, (key, args) => {
|
|
1878
|
-
const branch = oldMap?.get(key) ||
|
|
1879
|
-
renderer,
|
|
1880
|
-
scope.$global,
|
|
1881
|
-
scope,
|
|
1882
|
-
parentNode
|
|
1883
|
-
);
|
|
1871
|
+
const branch = oldMap?.get(key) || createBranch(scope.$global, renderer, scope, parentNode);
|
|
1884
1872
|
params?.(branch, args);
|
|
1885
1873
|
newMap.set(key, branch);
|
|
1886
1874
|
newArray.push(branch);
|
|
@@ -1908,7 +1896,7 @@ function byFirstArg(name) {
|
|
|
1908
1896
|
return name;
|
|
1909
1897
|
}
|
|
1910
1898
|
function isDifferentRenderer(a, b) {
|
|
1911
|
-
return a !== b
|
|
1899
|
+
return a !== b || a?.___id !== b?.___id;
|
|
1912
1900
|
}
|
|
1913
1901
|
|
|
1914
1902
|
// src/dom/compat.ts
|
|
@@ -1929,7 +1917,7 @@ var compat = {
|
|
|
1929
1917
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
|
1930
1918
|
},
|
|
1931
1919
|
isRenderer(renderer) {
|
|
1932
|
-
return renderer.
|
|
1920
|
+
return renderer.___init;
|
|
1933
1921
|
},
|
|
1934
1922
|
getStartNode(branch) {
|
|
1935
1923
|
return branch.___startNode;
|
|
@@ -1959,8 +1947,12 @@ var compat = {
|
|
|
1959
1947
|
return value2;
|
|
1960
1948
|
},
|
|
1961
1949
|
createRenderer(args, clone) {
|
|
1962
|
-
const renderer = createRenderer(
|
|
1963
|
-
renderer.
|
|
1950
|
+
const renderer = createRenderer(0, 0, 0, () => args);
|
|
1951
|
+
renderer.___init = (branch) => {
|
|
1952
|
+
const cloned = clone();
|
|
1953
|
+
branch.___startNode = cloned.startNode;
|
|
1954
|
+
branch.___endNode = cloned.endNode;
|
|
1955
|
+
};
|
|
1964
1956
|
return renderer;
|
|
1965
1957
|
},
|
|
1966
1958
|
render(out, component, renderer, args) {
|
|
@@ -1983,9 +1975,12 @@ var compat = {
|
|
|
1983
1975
|
}
|
|
1984
1976
|
component.effects = prepareEffects(() => {
|
|
1985
1977
|
if (!branch) {
|
|
1986
|
-
branch = component.scope =
|
|
1987
|
-
|
|
1988
|
-
|
|
1978
|
+
branch = component.scope = createBranch(
|
|
1979
|
+
out.global,
|
|
1980
|
+
renderer,
|
|
1981
|
+
renderer.___owner,
|
|
1982
|
+
document.body
|
|
1983
|
+
);
|
|
1989
1984
|
} else {
|
|
1990
1985
|
applyArgs(branch, MARK);
|
|
1991
1986
|
existing = true;
|
|
@@ -2001,8 +1996,8 @@ function noop() {
|
|
|
2001
1996
|
}
|
|
2002
1997
|
|
|
2003
1998
|
// src/dom/template.ts
|
|
2004
|
-
var createTemplate = (
|
|
2005
|
-
const renderer =
|
|
1999
|
+
var createTemplate = (...contentArgs) => {
|
|
2000
|
+
const renderer = createContent(...contentArgs)();
|
|
2006
2001
|
renderer.mount = mount;
|
|
2007
2002
|
renderer._ = renderer;
|
|
2008
2003
|
if (true) {
|
|
@@ -2012,7 +2007,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
|
2012
2007
|
);
|
|
2013
2008
|
};
|
|
2014
2009
|
}
|
|
2015
|
-
return register(
|
|
2010
|
+
return register(contentArgs[0], renderer);
|
|
2016
2011
|
};
|
|
2017
2012
|
function mount(input = {}, reference, position) {
|
|
2018
2013
|
let branch;
|
|
@@ -2047,8 +2042,7 @@ function mount(input = {}, reference, position) {
|
|
|
2047
2042
|
}
|
|
2048
2043
|
const args = this.___args;
|
|
2049
2044
|
const effects = prepareEffects(() => {
|
|
2050
|
-
branch =
|
|
2051
|
-
initBranch(this, branch, parentNode);
|
|
2045
|
+
branch = createBranch($global, this, void 0, parentNode);
|
|
2052
2046
|
args?.(branch, [input]);
|
|
2053
2047
|
});
|
|
2054
2048
|
insertChildNodes(
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -650,9 +650,8 @@ function toValueProp(it) {
|
|
|
650
650
|
var parsers = {};
|
|
651
651
|
function parseHTML(html2, ns) {
|
|
652
652
|
const parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return content;
|
|
653
|
+
parser.innerHTML = html2;
|
|
654
|
+
return parser.content || parser;
|
|
656
655
|
}
|
|
657
656
|
|
|
658
657
|
// src/dom/dom.ts
|
|
@@ -837,7 +836,7 @@ function html(scope, value2, accessor) {
|
|
|
837
836
|
insertChildNodes(
|
|
838
837
|
parentNode,
|
|
839
838
|
firstChild,
|
|
840
|
-
scope[accessor] = newContent.firstChild,
|
|
839
|
+
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
|
841
840
|
scope[accessor + "-" /* DynamicPlaceholderLastChild */] = newContent.lastChild
|
|
842
841
|
);
|
|
843
842
|
removeChildNodes(firstChild, lastChild);
|
|
@@ -1550,38 +1549,25 @@ function getDebugKey(index, node) {
|
|
|
1550
1549
|
}
|
|
1551
1550
|
|
|
1552
1551
|
// src/dom/renderer.ts
|
|
1553
|
-
function
|
|
1552
|
+
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
1554
1553
|
const branch = createBranch(
|
|
1555
1554
|
$global,
|
|
1556
|
-
|
|
1557
|
-
parentScope
|
|
1555
|
+
tagNameOrRenderer,
|
|
1556
|
+
parentScope,
|
|
1557
|
+
parentNode
|
|
1558
1558
|
);
|
|
1559
|
-
if (
|
|
1560
|
-
branch.
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
return branch;
|
|
1564
|
-
}
|
|
1565
|
-
function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, parentScope, parentNode) {
|
|
1566
|
-
if (typeof tagNameOrRenderer !== "string") {
|
|
1567
|
-
return createBranchScopeWithRenderer(
|
|
1568
|
-
tagNameOrRenderer,
|
|
1569
|
-
$global,
|
|
1570
|
-
parentScope,
|
|
1571
|
-
parentNode
|
|
1559
|
+
if (typeof tagNameOrRenderer === "string") {
|
|
1560
|
+
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
|
1561
|
+
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
1562
|
+
tagNameOrRenderer
|
|
1572
1563
|
);
|
|
1573
1564
|
}
|
|
1574
|
-
const branch = createBranch($global, parentScope, parentScope);
|
|
1575
|
-
branch[true ? `#${tagNameOrRenderer}/0` : 0] = branch.___startNode = branch.___endNode = document.createElementNS(
|
|
1576
|
-
tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI,
|
|
1577
|
-
tagNameOrRenderer
|
|
1578
|
-
);
|
|
1579
1565
|
return branch;
|
|
1580
1566
|
}
|
|
1581
|
-
function createBranch($global,
|
|
1567
|
+
function createBranch($global, renderer, parentScope, parentNode) {
|
|
1582
1568
|
const branch = createScope($global);
|
|
1583
|
-
const parentBranch = parentScope
|
|
1584
|
-
branch._ =
|
|
1569
|
+
const parentBranch = parentScope?.___closestBranch;
|
|
1570
|
+
branch._ = renderer.___owner || parentScope;
|
|
1585
1571
|
branch.___closestBranch = branch;
|
|
1586
1572
|
if (parentBranch) {
|
|
1587
1573
|
branch.___branchDepth = parentBranch.___branchDepth + 1;
|
|
@@ -1590,34 +1576,32 @@ function createBranch($global, ownerScope, parentScope) {
|
|
|
1590
1576
|
} else {
|
|
1591
1577
|
branch.___branchDepth = 1;
|
|
1592
1578
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
function initBranch(renderer, branch, parentNode) {
|
|
1596
|
-
const clone = renderer.___clone(parentNode.namespaceURI);
|
|
1597
|
-
const cloneParent = clone.parentNode;
|
|
1598
|
-
if (cloneParent) {
|
|
1599
|
-
walk(cloneParent.firstChild, renderer.___walks, branch);
|
|
1600
|
-
branch.___startNode = cloneParent.firstChild;
|
|
1601
|
-
branch.___endNode = cloneParent.lastChild;
|
|
1602
|
-
} else {
|
|
1603
|
-
walk(clone, renderer.___walks, branch);
|
|
1604
|
-
branch.___startNode = branch.___endNode = clone;
|
|
1605
|
-
}
|
|
1606
|
-
if (renderer.___setup) {
|
|
1607
|
-
queueRender(branch, renderer.___setup);
|
|
1579
|
+
if (true) {
|
|
1580
|
+
branch.___renderer = renderer;
|
|
1608
1581
|
}
|
|
1582
|
+
renderer.___init?.(
|
|
1583
|
+
branch,
|
|
1584
|
+
parentNode.namespaceURI
|
|
1585
|
+
);
|
|
1586
|
+
return branch;
|
|
1609
1587
|
}
|
|
1610
|
-
function
|
|
1588
|
+
function createContent(id, template, rawWalks, setup, getArgs) {
|
|
1611
1589
|
let args;
|
|
1612
|
-
const
|
|
1613
|
-
const
|
|
1590
|
+
const walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : "";
|
|
1591
|
+
const init2 = template ? (branch, ns) => {
|
|
1592
|
+
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(
|
|
1593
|
+
template,
|
|
1594
|
+
ns
|
|
1595
|
+
))(branch, walks);
|
|
1596
|
+
setup && queueRender(branch, setup);
|
|
1597
|
+
} : (branch) => {
|
|
1598
|
+
branch.___startNode = branch.___endNode = new Text();
|
|
1599
|
+
setup && queueRender(branch, setup);
|
|
1600
|
+
};
|
|
1614
1601
|
return (owner) => {
|
|
1615
1602
|
return {
|
|
1616
1603
|
___id: id,
|
|
1617
|
-
|
|
1618
|
-
___walks: walks,
|
|
1619
|
-
___setup: setup,
|
|
1620
|
-
___clone: _clone,
|
|
1604
|
+
___init: init2,
|
|
1621
1605
|
___owner: owner,
|
|
1622
1606
|
get ___args() {
|
|
1623
1607
|
return args ||= getArgs?.();
|
|
@@ -1625,21 +1609,29 @@ function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
|
|
1625
1609
|
};
|
|
1626
1610
|
};
|
|
1627
1611
|
}
|
|
1628
|
-
function
|
|
1629
|
-
return
|
|
1612
|
+
function registerContent(id, template, walks, setup, getArgs) {
|
|
1613
|
+
return register(id, createContent(id, template, walks, setup, getArgs));
|
|
1630
1614
|
}
|
|
1631
|
-
function
|
|
1632
|
-
return (
|
|
1633
|
-
this.___template,
|
|
1634
|
-
ns
|
|
1635
|
-
))();
|
|
1615
|
+
function createRenderer(template, walks, setup, getArgs) {
|
|
1616
|
+
return createContent("", template, walks, setup, getArgs)();
|
|
1636
1617
|
}
|
|
1637
1618
|
var cloneCache = {};
|
|
1638
1619
|
function createCloneableHTML(html2, ns) {
|
|
1639
1620
|
const { firstChild, lastChild } = parseHTML(html2, ns);
|
|
1640
1621
|
const parent = document.createElementNS(ns, "t");
|
|
1641
1622
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
1642
|
-
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (
|
|
1623
|
+
return firstChild === lastChild && firstChild.nodeType < 8 /* Comment */ ? (branch, walks) => {
|
|
1624
|
+
walk(
|
|
1625
|
+
branch.___startNode = branch.___endNode = firstChild.cloneNode(true),
|
|
1626
|
+
walks,
|
|
1627
|
+
branch
|
|
1628
|
+
);
|
|
1629
|
+
} : (branch, walks) => {
|
|
1630
|
+
const clone = parent.cloneNode(true);
|
|
1631
|
+
walk(clone.firstChild, walks, branch);
|
|
1632
|
+
branch.___startNode = clone.firstChild;
|
|
1633
|
+
branch.___endNode = clone.lastChild;
|
|
1634
|
+
};
|
|
1643
1635
|
}
|
|
1644
1636
|
|
|
1645
1637
|
// src/dom/control-flow.ts
|
|
@@ -1651,7 +1643,7 @@ function conditional(nodeAccessor, ...branches) {
|
|
|
1651
1643
|
scope,
|
|
1652
1644
|
nodeAccessor,
|
|
1653
1645
|
branches[scope[branchAccessor] = newBranch],
|
|
1654
|
-
|
|
1646
|
+
createBranch
|
|
1655
1647
|
);
|
|
1656
1648
|
}
|
|
1657
1649
|
};
|
|
@@ -1677,7 +1669,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
|
1677
1669
|
scope,
|
|
1678
1670
|
nodeAccessor,
|
|
1679
1671
|
newRenderer || (getContent ? getContent(scope) : void 0),
|
|
1680
|
-
|
|
1672
|
+
createBranchWithTagNameOrRenderer
|
|
1681
1673
|
);
|
|
1682
1674
|
if (getTagVar) {
|
|
1683
1675
|
setTagVar(scope, childScopeAccessor, getTagVar());
|
|
@@ -1687,7 +1679,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
|
1687
1679
|
scope[childScopeAccessor],
|
|
1688
1680
|
true ? `#${newRenderer}/0` : 0,
|
|
1689
1681
|
getContent(scope),
|
|
1690
|
-
|
|
1682
|
+
createBranch
|
|
1691
1683
|
);
|
|
1692
1684
|
}
|
|
1693
1685
|
}
|
|
@@ -1718,7 +1710,7 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2)
|
|
|
1718
1710
|
const referenceNode = scope[nodeAccessor];
|
|
1719
1711
|
const prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */];
|
|
1720
1712
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
|
1721
|
-
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(
|
|
1713
|
+
const newBranch = scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
|
1722
1714
|
if (referenceNode === parentNode) {
|
|
1723
1715
|
if (prevBranch) {
|
|
1724
1716
|
destroyBranch(prevBranch);
|
|
@@ -1790,12 +1782,7 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
|
1790
1782
|
const newMap = scope[nodeAccessor + "(" /* LoopScopeMap */] = /* @__PURE__ */ new Map();
|
|
1791
1783
|
const newArray = scope[nodeAccessor + "!" /* LoopScopeArray */] = [];
|
|
1792
1784
|
forEach(valueOrOp, (key, args) => {
|
|
1793
|
-
const branch = oldMap?.get(key) ||
|
|
1794
|
-
renderer,
|
|
1795
|
-
scope.$global,
|
|
1796
|
-
scope,
|
|
1797
|
-
parentNode
|
|
1798
|
-
);
|
|
1785
|
+
const branch = oldMap?.get(key) || createBranch(scope.$global, renderer, scope, parentNode);
|
|
1799
1786
|
params?.(branch, args);
|
|
1800
1787
|
newMap.set(key, branch);
|
|
1801
1788
|
newArray.push(branch);
|
|
@@ -1823,7 +1810,7 @@ function byFirstArg(name) {
|
|
|
1823
1810
|
return name;
|
|
1824
1811
|
}
|
|
1825
1812
|
function isDifferentRenderer(a, b) {
|
|
1826
|
-
return a !== b
|
|
1813
|
+
return a !== b || a?.___id !== b?.___id;
|
|
1827
1814
|
}
|
|
1828
1815
|
|
|
1829
1816
|
// src/dom/compat.ts
|
|
@@ -1844,7 +1831,7 @@ var compat = {
|
|
|
1844
1831
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
|
1845
1832
|
},
|
|
1846
1833
|
isRenderer(renderer) {
|
|
1847
|
-
return renderer.
|
|
1834
|
+
return renderer.___init;
|
|
1848
1835
|
},
|
|
1849
1836
|
getStartNode(branch) {
|
|
1850
1837
|
return branch.___startNode;
|
|
@@ -1874,8 +1861,12 @@ var compat = {
|
|
|
1874
1861
|
return value2;
|
|
1875
1862
|
},
|
|
1876
1863
|
createRenderer(args, clone) {
|
|
1877
|
-
const renderer = createRenderer(
|
|
1878
|
-
renderer.
|
|
1864
|
+
const renderer = createRenderer(0, 0, 0, () => args);
|
|
1865
|
+
renderer.___init = (branch) => {
|
|
1866
|
+
const cloned = clone();
|
|
1867
|
+
branch.___startNode = cloned.startNode;
|
|
1868
|
+
branch.___endNode = cloned.endNode;
|
|
1869
|
+
};
|
|
1879
1870
|
return renderer;
|
|
1880
1871
|
},
|
|
1881
1872
|
render(out, component, renderer, args) {
|
|
@@ -1898,9 +1889,12 @@ var compat = {
|
|
|
1898
1889
|
}
|
|
1899
1890
|
component.effects = prepareEffects(() => {
|
|
1900
1891
|
if (!branch) {
|
|
1901
|
-
branch = component.scope =
|
|
1902
|
-
|
|
1903
|
-
|
|
1892
|
+
branch = component.scope = createBranch(
|
|
1893
|
+
out.global,
|
|
1894
|
+
renderer,
|
|
1895
|
+
renderer.___owner,
|
|
1896
|
+
document.body
|
|
1897
|
+
);
|
|
1904
1898
|
} else {
|
|
1905
1899
|
applyArgs(branch, MARK);
|
|
1906
1900
|
existing = true;
|
|
@@ -1916,8 +1910,8 @@ function noop() {
|
|
|
1916
1910
|
}
|
|
1917
1911
|
|
|
1918
1912
|
// src/dom/template.ts
|
|
1919
|
-
var createTemplate = (
|
|
1920
|
-
const renderer =
|
|
1913
|
+
var createTemplate = (...contentArgs) => {
|
|
1914
|
+
const renderer = createContent(...contentArgs)();
|
|
1921
1915
|
renderer.mount = mount;
|
|
1922
1916
|
renderer._ = renderer;
|
|
1923
1917
|
if (true) {
|
|
@@ -1927,7 +1921,7 @@ var createTemplate = (templateId, ...rendererArgs) => {
|
|
|
1927
1921
|
);
|
|
1928
1922
|
};
|
|
1929
1923
|
}
|
|
1930
|
-
return register(
|
|
1924
|
+
return register(contentArgs[0], renderer);
|
|
1931
1925
|
};
|
|
1932
1926
|
function mount(input = {}, reference, position) {
|
|
1933
1927
|
let branch;
|
|
@@ -1962,8 +1956,7 @@ function mount(input = {}, reference, position) {
|
|
|
1962
1956
|
}
|
|
1963
1957
|
const args = this.___args;
|
|
1964
1958
|
const effects = prepareEffects(() => {
|
|
1965
|
-
branch =
|
|
1966
|
-
initBranch(this, branch, parentNode);
|
|
1959
|
+
branch = createBranch($global, this, void 0, parentNode);
|
|
1967
1960
|
args?.(branch, [input]);
|
|
1968
1961
|
});
|
|
1969
1962
|
insertChildNodes(
|
|
@@ -2011,8 +2004,8 @@ export {
|
|
|
2011
2004
|
controllable_select_value_effect,
|
|
2012
2005
|
controllable_input_value as controllable_textarea_value,
|
|
2013
2006
|
controllable_input_value_effect as controllable_textarea_value_effect,
|
|
2007
|
+
createContent,
|
|
2014
2008
|
createRenderer,
|
|
2015
|
-
createRendererWithOwner,
|
|
2016
2009
|
createTemplate,
|
|
2017
2010
|
data,
|
|
2018
2011
|
dynamicClosure,
|
|
@@ -2039,6 +2032,7 @@ export {
|
|
|
2039
2032
|
props,
|
|
2040
2033
|
register,
|
|
2041
2034
|
registerBoundSignal,
|
|
2035
|
+
registerContent,
|
|
2042
2036
|
registerDynamicClosure,
|
|
2043
2037
|
resetAbortSignal,
|
|
2044
2038
|
run,
|
package/dist/dom/compat.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export declare const compat: {
|
|
|
16
16
|
runtimeId: string;
|
|
17
17
|
componentIdPrefix: string;
|
|
18
18
|
}): any;
|
|
19
|
-
createRenderer(args: NonNullable<Renderer["___args"]>, clone:
|
|
19
|
+
createRenderer(args: NonNullable<Renderer["___args"]>, clone: () => {
|
|
20
|
+
startNode: ChildNode;
|
|
21
|
+
endNode: ChildNode;
|
|
22
|
+
}): Renderer;
|
|
20
23
|
render(out: any, component: any, renderer: Renderer, args: any): Node | undefined;
|
|
21
24
|
};
|
|
@@ -4,7 +4,7 @@ import { type Signal, type SignalOp } from "./signals";
|
|
|
4
4
|
export declare function conditional(nodeAccessor: Accessor, ...branches: Renderer[]): (scope: Scope, newBranch: number) => void;
|
|
5
5
|
export declare function patchDynamicTag(fn: <T extends typeof dynamicTag>(cond: T) => T): void;
|
|
6
6
|
export declare let dynamicTag: (nodeAccessor: Accessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
|
|
7
|
-
export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: (
|
|
7
|
+
export declare function setConditionalRenderer<T>(scope: Scope, nodeAccessor: Accessor, newRenderer: T, createBranch: ($global: Scope["$global"], renderer: NonNullable<T>, parentScope: Scope, parentNode: ParentNode) => BranchScope): void;
|
|
8
8
|
export declare function loopOf(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [all: unknown[], by?: ((item: unknown, index: number) => unknown) | undefined]) => void;
|
|
9
9
|
export declare function loopIn(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [obj: {}, by?: ((key: string, v: unknown) => unknown) | undefined]) => void;
|
|
10
10
|
export declare function loopTo(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, valueOrOp: SignalOp | [to: number, from: number, step: number, by?: ((v: number) => unknown) | undefined]) => void;
|
package/dist/dom/parse-html.d.ts
CHANGED