marko 6.0.0-next.3.59 → 6.0.0-next.3.60
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 +7 -1
- package/dist/debug/dom.js +291 -126
- package/dist/debug/dom.mjs +291 -126
- package/dist/debug/html.js +118 -39
- package/dist/debug/html.mjs +118 -39
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +253 -130
- package/dist/dom.mjs +253 -130
- package/dist/html/dynamic-tag.d.ts +3 -4
- package/dist/html/serializer.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -3
- package/dist/html.js +103 -35
- package/dist/html.mjs +103 -35
- package/dist/translator/core/await.d.ts +7 -0
- package/dist/translator/core/try.d.ts +7 -0
- package/dist/translator/index.js +140 -27
- package/package.json +1 -1
package/dist/debug/dom.mjs
CHANGED
@@ -943,134 +943,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
943
943
|
branch.___endNode
|
944
944
|
);
|
945
945
|
}
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
954
|
-
const key = scopeKey * scopeKeyOffset + signalKey;
|
955
|
-
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
956
|
-
if (existingRender) {
|
957
|
-
existingRender.___value = value2;
|
958
|
-
} else {
|
959
|
-
const render = {
|
960
|
-
___key: key,
|
961
|
-
___scope: scope,
|
962
|
-
___signal: signal,
|
963
|
-
___value: value2
|
964
|
-
};
|
965
|
-
let i = pendingRenders.push(render) - 1;
|
966
|
-
while (i) {
|
967
|
-
const parentIndex = i - 1 >> 1;
|
968
|
-
const parent = pendingRenders[parentIndex];
|
969
|
-
if (key - parent.___key >= 0) break;
|
970
|
-
pendingRenders[i] = parent;
|
971
|
-
i = parentIndex;
|
972
|
-
}
|
973
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
974
|
-
pendingRenders[i] = render;
|
975
|
-
}
|
976
|
-
}
|
977
|
-
function queueEffect(scope, fn) {
|
978
|
-
pendingEffects.push(fn, scope);
|
979
|
-
}
|
980
|
-
function run() {
|
981
|
-
const effects = pendingEffects;
|
982
|
-
try {
|
983
|
-
rendering = true;
|
984
|
-
runRenders();
|
985
|
-
} finally {
|
986
|
-
pendingRenders = [];
|
987
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
988
|
-
pendingEffects = [];
|
989
|
-
rendering = false;
|
990
|
-
}
|
991
|
-
runEffects(effects);
|
992
|
-
}
|
993
|
-
function prepareEffects(fn) {
|
994
|
-
const prevRenders = pendingRenders;
|
995
|
-
const prevRendersLookup = pendingRendersLookup;
|
996
|
-
const prevEffects = pendingEffects;
|
997
|
-
const preparedEffects = pendingEffects = [];
|
998
|
-
pendingRenders = [];
|
999
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1000
|
-
try {
|
1001
|
-
rendering = true;
|
1002
|
-
fn();
|
1003
|
-
runRenders();
|
1004
|
-
} finally {
|
1005
|
-
rendering = false;
|
1006
|
-
pendingRenders = prevRenders;
|
1007
|
-
pendingRendersLookup = prevRendersLookup;
|
1008
|
-
pendingEffects = prevEffects;
|
1009
|
-
}
|
1010
|
-
return preparedEffects;
|
1011
|
-
}
|
1012
|
-
function runEffects(effects) {
|
1013
|
-
for (let i = 0, scope; i < effects.length; ) {
|
1014
|
-
effects[i++](
|
1015
|
-
scope = effects[i++],
|
1016
|
-
scope
|
1017
|
-
);
|
1018
|
-
}
|
1019
|
-
}
|
1020
|
-
function runRenders() {
|
1021
|
-
while (pendingRenders.length) {
|
1022
|
-
const render = pendingRenders[0];
|
1023
|
-
const item = pendingRenders.pop();
|
1024
|
-
if (render !== item) {
|
1025
|
-
let i = 0;
|
1026
|
-
const mid = pendingRenders.length >> 1;
|
1027
|
-
const key = (pendingRenders[0] = item).___key;
|
1028
|
-
while (i < mid) {
|
1029
|
-
let bestChild = (i << 1) + 1;
|
1030
|
-
const right = bestChild + 1;
|
1031
|
-
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
1032
|
-
bestChild = right;
|
1033
|
-
}
|
1034
|
-
if (pendingRenders[bestChild].___key - key >= 0) {
|
1035
|
-
break;
|
1036
|
-
} else {
|
1037
|
-
pendingRenders[i] = pendingRenders[bestChild];
|
1038
|
-
i = bestChild;
|
1039
|
-
}
|
1040
|
-
}
|
1041
|
-
pendingRenders[i] = item;
|
1042
|
-
}
|
1043
|
-
if (!render.___scope.___closestBranch?.___destroyed) {
|
1044
|
-
render.___signal(render.___scope, render.___value);
|
1045
|
-
}
|
1046
|
-
}
|
1047
|
-
finishPendingScopes();
|
1048
|
-
}
|
1049
|
-
|
1050
|
-
// src/dom/abort-signal.ts
|
1051
|
-
function resetAbortSignal(scope, id) {
|
1052
|
-
const ctrl = scope.___abortControllers?.[id];
|
1053
|
-
if (ctrl) {
|
1054
|
-
queueEffect(ctrl, abort);
|
1055
|
-
scope.___abortControllers[id] = void 0;
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
function getAbortSignal(scope, id) {
|
1059
|
-
if (scope.___closestBranch) {
|
1060
|
-
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1061
|
-
}
|
1062
|
-
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1063
|
-
}
|
1064
|
-
function abort(ctrl) {
|
1065
|
-
ctrl.abort();
|
946
|
+
function tempDetatchBranch(branch) {
|
947
|
+
insertChildNodes(
|
948
|
+
branch.___startNode.ownerDocument.createDocumentFragment(),
|
949
|
+
null,
|
950
|
+
branch.___startNode,
|
951
|
+
branch.___endNode
|
952
|
+
);
|
1066
953
|
}
|
1067
954
|
|
1068
|
-
// src/common/compat-meta.ts
|
1069
|
-
var prefix = true ? "$compat_" : "$C_";
|
1070
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1071
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1072
|
-
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1073
|
-
|
1074
955
|
// src/dom/reconcile.ts
|
1075
956
|
var WRONG_POS = 2147483647;
|
1076
957
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -1647,6 +1528,132 @@ function hoist(...path) {
|
|
1647
1528
|
}
|
1648
1529
|
|
1649
1530
|
// src/dom/control-flow.ts
|
1531
|
+
function awaitTag(nodeAccessor, renderer) {
|
1532
|
+
const promiseAccessor = nodeAccessor + "?" /* Promise */;
|
1533
|
+
const branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1534
|
+
return (scope, promise) => {
|
1535
|
+
let tryBranch = scope.___closestBranch;
|
1536
|
+
let awaitBranch = scope[branchAccessor];
|
1537
|
+
const referenceNode = scope[nodeAccessor];
|
1538
|
+
const namespaceNode = (awaitBranch?.___startNode ?? referenceNode).parentNode;
|
1539
|
+
while (tryBranch && !tryBranch["%" /* PlaceholderContent */]) {
|
1540
|
+
tryBranch = tryBranch.___parentBranch;
|
1541
|
+
}
|
1542
|
+
const thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1543
|
+
if (scope.___closestBranch?.___destroyed || scope[promiseAccessor] !== thisPromise) {
|
1544
|
+
return;
|
1545
|
+
}
|
1546
|
+
scope[promiseAccessor] = void 0;
|
1547
|
+
const effects = prepareEffects(() => {
|
1548
|
+
if (!awaitBranch || !tryBranch) {
|
1549
|
+
insertBranchBefore(
|
1550
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1551
|
+
scope.$global,
|
1552
|
+
renderer,
|
1553
|
+
scope,
|
1554
|
+
namespaceNode
|
1555
|
+
),
|
1556
|
+
referenceNode.parentNode,
|
1557
|
+
referenceNode
|
1558
|
+
);
|
1559
|
+
referenceNode.remove();
|
1560
|
+
}
|
1561
|
+
renderer.___params?.(awaitBranch, [data2]);
|
1562
|
+
});
|
1563
|
+
if (tryBranch) {
|
1564
|
+
if (!--tryBranch["." /* PendingCount */]) {
|
1565
|
+
const placeholderBranch = tryBranch["#" /* PlaceholderBranch */];
|
1566
|
+
if (placeholderBranch) {
|
1567
|
+
insertBranchBefore(
|
1568
|
+
tryBranch,
|
1569
|
+
placeholderBranch.___startNode.parentNode,
|
1570
|
+
placeholderBranch.___startNode
|
1571
|
+
);
|
1572
|
+
removeAndDestroyBranch(placeholderBranch);
|
1573
|
+
} else {
|
1574
|
+
insertBranchBefore(
|
1575
|
+
tryBranch,
|
1576
|
+
referenceNode.parentNode,
|
1577
|
+
referenceNode
|
1578
|
+
);
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
} else {
|
1582
|
+
runEffects(effects);
|
1583
|
+
}
|
1584
|
+
}).catch((error) => {
|
1585
|
+
let tryBranch2 = scope.___closestBranch;
|
1586
|
+
while (tryBranch2 && !tryBranch2["^" /* CatchContent */]) {
|
1587
|
+
tryBranch2 = tryBranch2.___parentBranch;
|
1588
|
+
}
|
1589
|
+
if (!tryBranch2) {
|
1590
|
+
setTimeout(() => {
|
1591
|
+
throw error;
|
1592
|
+
});
|
1593
|
+
} else {
|
1594
|
+
setConditionalRenderer(
|
1595
|
+
tryBranch2._,
|
1596
|
+
tryBranch2["*" /* BranchAccessor */],
|
1597
|
+
tryBranch2["^" /* CatchContent */],
|
1598
|
+
createAndSetupBranch
|
1599
|
+
);
|
1600
|
+
tryBranch2["^" /* CatchContent */].___params?.(
|
1601
|
+
tryBranch2._[tryBranch2["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1602
|
+
[error]
|
1603
|
+
);
|
1604
|
+
}
|
1605
|
+
});
|
1606
|
+
if (tryBranch) {
|
1607
|
+
if (!tryBranch["." /* PendingCount */]) {
|
1608
|
+
tryBranch["." /* PendingCount */] = 0;
|
1609
|
+
requestAnimationFrame(() => {
|
1610
|
+
if (tryBranch["." /* PendingCount */] && !tryBranch.___destroyed) {
|
1611
|
+
const placeholderBranch = tryBranch["#" /* PlaceholderBranch */] = createAndSetupBranch(
|
1612
|
+
scope.$global,
|
1613
|
+
tryBranch["%" /* PlaceholderContent */],
|
1614
|
+
tryBranch._,
|
1615
|
+
tryBranch.___startNode.parentNode
|
1616
|
+
);
|
1617
|
+
insertBranchBefore(
|
1618
|
+
placeholderBranch,
|
1619
|
+
tryBranch.___startNode.parentNode,
|
1620
|
+
tryBranch.___startNode
|
1621
|
+
);
|
1622
|
+
tempDetatchBranch(tryBranch);
|
1623
|
+
}
|
1624
|
+
});
|
1625
|
+
}
|
1626
|
+
tryBranch["." /* PendingCount */]++;
|
1627
|
+
} else if (awaitBranch) {
|
1628
|
+
awaitBranch.___startNode.parentNode.insertBefore(
|
1629
|
+
referenceNode,
|
1630
|
+
awaitBranch.___startNode
|
1631
|
+
);
|
1632
|
+
tempDetatchBranch(awaitBranch);
|
1633
|
+
}
|
1634
|
+
};
|
1635
|
+
}
|
1636
|
+
function createTry(nodeAccessor, tryContent) {
|
1637
|
+
const branchAccessor = nodeAccessor + "!" /* ConditionalScope */;
|
1638
|
+
return (scope, input) => {
|
1639
|
+
if (!scope[branchAccessor]) {
|
1640
|
+
setConditionalRenderer(
|
1641
|
+
scope,
|
1642
|
+
nodeAccessor,
|
1643
|
+
tryContent,
|
1644
|
+
createAndSetupBranch
|
1645
|
+
);
|
1646
|
+
}
|
1647
|
+
const branch = scope[branchAccessor];
|
1648
|
+
if (branch) {
|
1649
|
+
branch["*" /* BranchAccessor */] = nodeAccessor;
|
1650
|
+
branch["^" /* CatchContent */] = normalizeDynamicRenderer(input.catch);
|
1651
|
+
branch["%" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
1652
|
+
input.placeholder
|
1653
|
+
);
|
1654
|
+
}
|
1655
|
+
};
|
1656
|
+
}
|
1650
1657
|
function conditional(nodeAccessor, ...branches) {
|
1651
1658
|
const branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
1652
1659
|
return (scope, newBranch) => {
|
@@ -1842,6 +1849,161 @@ function byFirstArg(name) {
|
|
1842
1849
|
return name;
|
1843
1850
|
}
|
1844
1851
|
|
1852
|
+
// src/dom/queue.ts
|
1853
|
+
var pendingRenders = [];
|
1854
|
+
var pendingRendersLookup = /* @__PURE__ */ new Map();
|
1855
|
+
var pendingEffects = [];
|
1856
|
+
var rendering = false;
|
1857
|
+
var scopeKeyOffset = 1e3;
|
1858
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
1859
|
+
const key = scopeKey * scopeKeyOffset + signalKey;
|
1860
|
+
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1861
|
+
if (existingRender) {
|
1862
|
+
existingRender.___value = value2;
|
1863
|
+
} else {
|
1864
|
+
const render = {
|
1865
|
+
___key: key,
|
1866
|
+
___scope: scope,
|
1867
|
+
___signal: signal,
|
1868
|
+
___value: value2
|
1869
|
+
};
|
1870
|
+
let i = pendingRenders.push(render) - 1;
|
1871
|
+
while (i) {
|
1872
|
+
const parentIndex = i - 1 >> 1;
|
1873
|
+
const parent = pendingRenders[parentIndex];
|
1874
|
+
if (key - parent.___key >= 0) break;
|
1875
|
+
pendingRenders[i] = parent;
|
1876
|
+
i = parentIndex;
|
1877
|
+
}
|
1878
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
1879
|
+
pendingRenders[i] = render;
|
1880
|
+
}
|
1881
|
+
}
|
1882
|
+
function queueEffect(scope, fn) {
|
1883
|
+
pendingEffects.push(fn, scope);
|
1884
|
+
}
|
1885
|
+
function run() {
|
1886
|
+
const effects = pendingEffects;
|
1887
|
+
try {
|
1888
|
+
rendering = true;
|
1889
|
+
runRenders();
|
1890
|
+
} finally {
|
1891
|
+
pendingRenders = [];
|
1892
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1893
|
+
pendingEffects = [];
|
1894
|
+
rendering = false;
|
1895
|
+
}
|
1896
|
+
runEffects(effects);
|
1897
|
+
}
|
1898
|
+
function prepareEffects(fn) {
|
1899
|
+
const prevRenders = pendingRenders;
|
1900
|
+
const prevRendersLookup = pendingRendersLookup;
|
1901
|
+
const prevEffects = pendingEffects;
|
1902
|
+
const preparedEffects = pendingEffects = [];
|
1903
|
+
pendingRenders = [];
|
1904
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1905
|
+
try {
|
1906
|
+
rendering = true;
|
1907
|
+
fn();
|
1908
|
+
runRenders();
|
1909
|
+
} finally {
|
1910
|
+
rendering = false;
|
1911
|
+
pendingRenders = prevRenders;
|
1912
|
+
pendingRendersLookup = prevRendersLookup;
|
1913
|
+
pendingEffects = prevEffects;
|
1914
|
+
}
|
1915
|
+
return preparedEffects;
|
1916
|
+
}
|
1917
|
+
function runEffects(effects) {
|
1918
|
+
for (let i = 0, scope; i < effects.length; ) {
|
1919
|
+
effects[i++](
|
1920
|
+
scope = effects[i++],
|
1921
|
+
scope
|
1922
|
+
);
|
1923
|
+
}
|
1924
|
+
}
|
1925
|
+
function runRenders() {
|
1926
|
+
while (pendingRenders.length) {
|
1927
|
+
const render = pendingRenders[0];
|
1928
|
+
const item = pendingRenders.pop();
|
1929
|
+
if (render !== item) {
|
1930
|
+
let i = 0;
|
1931
|
+
const mid = pendingRenders.length >> 1;
|
1932
|
+
const key = (pendingRenders[0] = item).___key;
|
1933
|
+
while (i < mid) {
|
1934
|
+
let bestChild = (i << 1) + 1;
|
1935
|
+
const right = bestChild + 1;
|
1936
|
+
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
1937
|
+
bestChild = right;
|
1938
|
+
}
|
1939
|
+
if (pendingRenders[bestChild].___key - key >= 0) {
|
1940
|
+
break;
|
1941
|
+
} else {
|
1942
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
1943
|
+
i = bestChild;
|
1944
|
+
}
|
1945
|
+
}
|
1946
|
+
pendingRenders[i] = item;
|
1947
|
+
}
|
1948
|
+
if (!render.___scope.___closestBranch?.___destroyed) {
|
1949
|
+
runRender(render);
|
1950
|
+
}
|
1951
|
+
}
|
1952
|
+
finishPendingScopes();
|
1953
|
+
}
|
1954
|
+
var runRender = (render) => render.___signal(render.___scope, render.___value);
|
1955
|
+
var enableCatch = () => {
|
1956
|
+
enableCatch = () => {
|
1957
|
+
};
|
1958
|
+
runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1959
|
+
try {
|
1960
|
+
runRender2(render);
|
1961
|
+
} catch (error) {
|
1962
|
+
let branch = render.___scope.___closestBranch;
|
1963
|
+
while (branch && !branch["^" /* CatchContent */])
|
1964
|
+
branch = branch.___parentBranch;
|
1965
|
+
if (!branch) {
|
1966
|
+
throw error;
|
1967
|
+
} else {
|
1968
|
+
setConditionalRenderer(
|
1969
|
+
branch._,
|
1970
|
+
branch["*" /* BranchAccessor */],
|
1971
|
+
branch["^" /* CatchContent */],
|
1972
|
+
createAndSetupBranch
|
1973
|
+
);
|
1974
|
+
branch["^" /* CatchContent */].___params?.(
|
1975
|
+
branch._[branch["*" /* BranchAccessor */] + "!" /* ConditionalScope */],
|
1976
|
+
[error]
|
1977
|
+
);
|
1978
|
+
}
|
1979
|
+
}
|
1980
|
+
})(runRender);
|
1981
|
+
};
|
1982
|
+
|
1983
|
+
// src/dom/abort-signal.ts
|
1984
|
+
function resetAbortSignal(scope, id) {
|
1985
|
+
const ctrl = scope.___abortControllers?.[id];
|
1986
|
+
if (ctrl) {
|
1987
|
+
queueEffect(ctrl, abort);
|
1988
|
+
scope.___abortControllers[id] = void 0;
|
1989
|
+
}
|
1990
|
+
}
|
1991
|
+
function getAbortSignal(scope, id) {
|
1992
|
+
if (scope.___closestBranch) {
|
1993
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1994
|
+
}
|
1995
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1996
|
+
}
|
1997
|
+
function abort(ctrl) {
|
1998
|
+
ctrl.abort();
|
1999
|
+
}
|
2000
|
+
|
2001
|
+
// src/common/compat-meta.ts
|
2002
|
+
var prefix = true ? "$compat_" : "$C_";
|
2003
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
2004
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
2005
|
+
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
2006
|
+
|
1845
2007
|
// src/dom/compat.ts
|
1846
2008
|
var classIdToBranch = /* @__PURE__ */ new Map();
|
1847
2009
|
var compat = {
|
@@ -2024,6 +2186,7 @@ export {
|
|
2024
2186
|
attrTags,
|
2025
2187
|
attrs,
|
2026
2188
|
attrsEvents,
|
2189
|
+
awaitTag,
|
2027
2190
|
classAttr,
|
2028
2191
|
compat,
|
2029
2192
|
conditional,
|
@@ -2043,11 +2206,13 @@ export {
|
|
2043
2206
|
createContent,
|
2044
2207
|
createRenderer,
|
2045
2208
|
createTemplate,
|
2209
|
+
createTry,
|
2046
2210
|
data,
|
2047
2211
|
dynamicClosure,
|
2048
2212
|
dynamicClosureRead,
|
2049
2213
|
dynamicTag,
|
2050
2214
|
effect,
|
2215
|
+
enableCatch,
|
2051
2216
|
forIn,
|
2052
2217
|
forOf,
|
2053
2218
|
forTo,
|