@marko/runtime-tags 6.0.113 → 6.0.115
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/accessor.d.ts +2 -2
- package/dist/common/accessor.debug.d.ts +2 -2
- package/dist/common/types.d.ts +6 -1
- package/dist/debug/dom.js +140 -92
- package/dist/debug/dom.mjs +140 -92
- package/dist/debug/html.js +34 -24
- package/dist/debug/html.mjs +34 -24
- package/dist/dom/control-flow.d.ts +2 -1
- package/dist/dom/queue.d.ts +1 -1
- package/dist/dom/resume.d.ts +21 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +121 -96
- package/dist/dom.mjs +121 -96
- package/dist/html/writer.d.ts +2 -0
- package/dist/html.js +28 -24
- package/dist/html.mjs +28 -24
- package/dist/translator/index.js +36 -14
- package/dist/translator/util/sections.d.ts +1 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export declare enum AccessorProp {
|
|
|
18
18
|
Owner = "_",
|
|
19
19
|
AbortControllers = "A",
|
|
20
20
|
AbortScopes = "B",
|
|
21
|
+
AwaitCounter = "O",
|
|
21
22
|
BranchAccessor = "C",
|
|
22
23
|
BranchScopes = "D",
|
|
23
24
|
CatchContent = "E",
|
|
@@ -25,12 +26,11 @@ export declare enum AccessorProp {
|
|
|
25
26
|
ClosestBranchId = "G",
|
|
26
27
|
Creating = "H",
|
|
27
28
|
Destroyed = "I",
|
|
28
|
-
PendingEffects = "J",
|
|
29
29
|
EndNode = "K",
|
|
30
30
|
Id = "L",
|
|
31
31
|
LoopKey = "M",
|
|
32
32
|
ParentBranch = "N",
|
|
33
|
-
|
|
33
|
+
PendingEffects = "J",
|
|
34
34
|
PlaceholderBranch = "P",
|
|
35
35
|
PlaceholderContent = "Q",
|
|
36
36
|
Renderer = "R",
|
|
@@ -18,6 +18,7 @@ export declare enum AccessorProp {
|
|
|
18
18
|
Owner = "_",
|
|
19
19
|
AbortControllers = "#AbortControllers",
|
|
20
20
|
AbortScopes = "#AbortScopes",
|
|
21
|
+
AwaitCounter = "#AwaitCounter",
|
|
21
22
|
BranchAccessor = "#BranchAccessor",
|
|
22
23
|
BranchScopes = "#BranchScopes",
|
|
23
24
|
CatchContent = "#CatchContent",
|
|
@@ -25,12 +26,11 @@ export declare enum AccessorProp {
|
|
|
25
26
|
ClosestBranchId = "#ClosestBranchId",
|
|
26
27
|
Creating = "#Creating",
|
|
27
28
|
Destroyed = "#Destroyed",
|
|
28
|
-
PendingEffects = "#PendingEffects",
|
|
29
29
|
EndNode = "#EndNode",
|
|
30
30
|
Id = "#Id",
|
|
31
31
|
LoopKey = "#LoopKey",
|
|
32
32
|
ParentBranch = "#ParentBranch",
|
|
33
|
-
|
|
33
|
+
PendingEffects = "#PendingEffects",
|
|
34
34
|
PlaceholderBranch = "#PlaceholderBranch",
|
|
35
35
|
PlaceholderContent = "#PlaceholderContent",
|
|
36
36
|
Renderer = "#Renderer",
|
package/dist/common/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface BranchScope extends Scope {
|
|
|
10
10
|
[AccessorProp.AbortScopes]: Set<Scope> | undefined;
|
|
11
11
|
[AccessorProp.BranchScopes]: Set<BranchScope> | undefined;
|
|
12
12
|
[AccessorProp.Renderer]: ClientRenderer | string;
|
|
13
|
-
[AccessorProp.
|
|
13
|
+
[AccessorProp.AwaitCounter]: AwaitCounter | undefined;
|
|
14
14
|
[AccessorProp.PendingEffects]: unknown[] | undefined;
|
|
15
15
|
}
|
|
16
16
|
export interface Scope {
|
|
@@ -33,6 +33,11 @@ export declare enum ResumeSymbol {
|
|
|
33
33
|
BranchEndOnlyChildInParent = ")",
|
|
34
34
|
BranchEndSingleNodeOnlyChildInParent = "}"
|
|
35
35
|
}
|
|
36
|
+
export interface AwaitCounter {
|
|
37
|
+
d?: 1;
|
|
38
|
+
i: number;
|
|
39
|
+
c: () => void;
|
|
40
|
+
}
|
|
36
41
|
export { AccessorPrefix, AccessorProp } from "./accessor.debug";
|
|
37
42
|
export declare enum NodeType {
|
|
38
43
|
Element = 1,
|
package/dist/debug/dom.js
CHANGED
|
@@ -50,7 +50,8 @@ __export(dom_exports, {
|
|
|
50
50
|
_attrs_partial: () => _attrs_partial,
|
|
51
51
|
_attrs_partial_content: () => _attrs_partial_content,
|
|
52
52
|
_attrs_script: () => _attrs_script,
|
|
53
|
-
|
|
53
|
+
_await_content: () => _await_content,
|
|
54
|
+
_await_promise: () => _await_promise,
|
|
54
55
|
_call: () => _call,
|
|
55
56
|
_child_setup: () => _child_setup,
|
|
56
57
|
_closure: () => _closure,
|
|
@@ -511,7 +512,6 @@ function getDebugKey(index, node) {
|
|
|
511
512
|
// src/dom/resume.ts
|
|
512
513
|
var registeredValues = {};
|
|
513
514
|
var branchesEnabled;
|
|
514
|
-
var isInit;
|
|
515
515
|
function enableBranches() {
|
|
516
516
|
branchesEnabled = 1;
|
|
517
517
|
}
|
|
@@ -616,60 +616,64 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
616
616
|
let lastScopeId = 0;
|
|
617
617
|
const nextToken = () => lastToken = visitText.slice(
|
|
618
618
|
lastTokenIndex,
|
|
619
|
-
|
|
620
|
-
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1) ? lastTokenIndex - 1 : visitText.length
|
|
619
|
+
(lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1
|
|
621
620
|
);
|
|
622
|
-
render.
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
[
|
|
634
|
-
|
|
635
|
-
);
|
|
636
|
-
} else {
|
|
637
|
-
for (const scope of serialized(serializeContext)) {
|
|
638
|
-
if (!$global) {
|
|
639
|
-
$global = scope || {};
|
|
640
|
-
$global.runtimeId = runtimeId;
|
|
641
|
-
$global.renderId = renderId;
|
|
642
|
-
} else if (typeof scope === "number") {
|
|
643
|
-
lastScopeId += scope;
|
|
644
|
-
} else {
|
|
645
|
-
scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
|
|
646
|
-
scope["$global" /* Global */] = $global;
|
|
647
|
-
if (branchesEnabled) {
|
|
648
|
-
scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */]];
|
|
621
|
+
render.m = (effects = []) => {
|
|
622
|
+
for (const serialized of resumes = render.r || []) {
|
|
623
|
+
if (typeof serialized === "string") {
|
|
624
|
+
lastTokenIndex = 0;
|
|
625
|
+
visitText = serialized;
|
|
626
|
+
while (nextToken()) {
|
|
627
|
+
if (/\D/.test(lastToken)) {
|
|
628
|
+
lastEffect = registeredValues[lastToken];
|
|
629
|
+
} else {
|
|
630
|
+
effects.push(
|
|
631
|
+
lastEffect,
|
|
632
|
+
scopeLookup[lastToken] ||= {
|
|
633
|
+
["#Id" /* Id */]: +lastToken
|
|
649
634
|
}
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
} else {
|
|
639
|
+
for (const scope of serialized(serializeContext)) {
|
|
640
|
+
if (!$global) {
|
|
641
|
+
$global = scope || {};
|
|
642
|
+
$global.runtimeId = runtimeId;
|
|
643
|
+
$global.renderId = renderId;
|
|
644
|
+
} else if (typeof scope === "number") {
|
|
645
|
+
lastScopeId += scope;
|
|
646
|
+
} else {
|
|
647
|
+
scopeLookup[scope["#Id" /* Id */] = ++lastScopeId] = scope;
|
|
648
|
+
scope["$global" /* Global */] = $global;
|
|
649
|
+
if (branchesEnabled) {
|
|
650
|
+
scope["#ClosestBranch" /* ClosestBranch */] = scopeLookup[scope["#ClosestBranchId" /* ClosestBranchId */]];
|
|
650
651
|
}
|
|
651
652
|
}
|
|
652
653
|
}
|
|
653
654
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
655
|
+
}
|
|
656
|
+
for (visit of visits = render.v) {
|
|
657
|
+
lastTokenIndex = render.i.length;
|
|
658
|
+
visitText = visit.data;
|
|
659
|
+
visitType = visitText[lastTokenIndex++];
|
|
660
|
+
visitScope = scopeLookup[+nextToken(
|
|
661
|
+
/* read scope id */
|
|
662
|
+
)] ||= {
|
|
663
|
+
["#Id" /* Id */]: +lastToken
|
|
664
|
+
};
|
|
665
|
+
if (visitType === "*" /* Node */) {
|
|
666
|
+
visitScope["Getter:" /* Getter */ + nextToken()] = /* @__PURE__ */ ((node) => () => node)(visitScope[lastToken] = visit.previousSibling);
|
|
667
|
+
} else if (branchesEnabled) {
|
|
668
|
+
visitBranches();
|
|
668
669
|
}
|
|
669
|
-
runEffects(effects);
|
|
670
|
-
} finally {
|
|
671
|
-
isInit = isResuming = visits.length = resumes.length = 0;
|
|
672
670
|
}
|
|
671
|
+
visits.length = resumes.length = 0;
|
|
672
|
+
return effects;
|
|
673
|
+
};
|
|
674
|
+
render.w = () => {
|
|
675
|
+
walk2();
|
|
676
|
+
runResumeEffects(render);
|
|
673
677
|
};
|
|
674
678
|
return render;
|
|
675
679
|
})
|
|
@@ -678,8 +682,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
678
682
|
if (renders) {
|
|
679
683
|
initRuntime(renders);
|
|
680
684
|
for (const renderId in renders) {
|
|
681
|
-
|
|
682
|
-
resumeRender(renderId).w();
|
|
685
|
+
runResumeEffects(resumeRender(renderId));
|
|
683
686
|
}
|
|
684
687
|
} else {
|
|
685
688
|
defineRuntime({
|
|
@@ -689,6 +692,14 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
|
689
692
|
}
|
|
690
693
|
}
|
|
691
694
|
var isResuming;
|
|
695
|
+
function runResumeEffects(render) {
|
|
696
|
+
try {
|
|
697
|
+
isResuming = 1;
|
|
698
|
+
runEffects(render.m(), 1);
|
|
699
|
+
} finally {
|
|
700
|
+
isResuming = 0;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
692
703
|
function getRegisteredWithScope(id, scope) {
|
|
693
704
|
const val = registeredValues[id];
|
|
694
705
|
return scope ? val(scope) : val;
|
|
@@ -1775,24 +1786,52 @@ function longestIncreasingSubsequence(a) {
|
|
|
1775
1786
|
}
|
|
1776
1787
|
|
|
1777
1788
|
// src/dom/control-flow.ts
|
|
1778
|
-
function
|
|
1789
|
+
function _await_promise(nodeAccessor, params) {
|
|
1779
1790
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1780
1791
|
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
|
1781
1792
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
1782
|
-
const
|
|
1783
|
-
|
|
1793
|
+
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
|
1794
|
+
_enable_catch();
|
|
1784
1795
|
return (scope, promise) => {
|
|
1785
|
-
|
|
1796
|
+
let awaitCounter;
|
|
1797
|
+
let renderData;
|
|
1786
1798
|
const tryWithPlaceholder = findBranchWithKey(
|
|
1787
1799
|
scope,
|
|
1788
1800
|
"#PlaceholderContent" /* PlaceholderContent */
|
|
1789
1801
|
);
|
|
1790
|
-
let awaitBranch = scope[branchAccessor];
|
|
1791
1802
|
if (tryWithPlaceholder) {
|
|
1803
|
+
renderData = self[tryWithPlaceholder["$global" /* Global */].runtimeId]?.[tryWithPlaceholder["$global" /* Global */].renderId];
|
|
1804
|
+
awaitCounter = tryWithPlaceholder["#AwaitCounter" /* AwaitCounter */] ||= renderData?.p?.[tryWithPlaceholder["#Id" /* Id */]];
|
|
1805
|
+
if (!awaitCounter?.i) {
|
|
1806
|
+
awaitCounter = tryWithPlaceholder["#AwaitCounter" /* AwaitCounter */] = {
|
|
1807
|
+
d: 1,
|
|
1808
|
+
i: 0,
|
|
1809
|
+
c() {
|
|
1810
|
+
if (!--awaitCounter.i) {
|
|
1811
|
+
const placeholderBranch = tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */];
|
|
1812
|
+
tryWithPlaceholder["#PlaceholderBranch" /* PlaceholderBranch */] = 0;
|
|
1813
|
+
if (placeholderBranch) {
|
|
1814
|
+
placeholderBranch["#StartNode" /* StartNode */].parentNode.insertBefore(
|
|
1815
|
+
tryWithPlaceholder["#StartNode" /* StartNode */].parentNode,
|
|
1816
|
+
placeholderBranch["#StartNode" /* StartNode */]
|
|
1817
|
+
);
|
|
1818
|
+
removeAndDestroyBranch(placeholderBranch);
|
|
1819
|
+
}
|
|
1820
|
+
queueEffect(tryWithPlaceholder, (scope2) => {
|
|
1821
|
+
const pendingEffects2 = scope2["#PendingEffects" /* PendingEffects */];
|
|
1822
|
+
if (pendingEffects2) {
|
|
1823
|
+
scope2["#PendingEffects" /* PendingEffects */] = [];
|
|
1824
|
+
runEffects(pendingEffects2, true);
|
|
1825
|
+
}
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1792
1831
|
placeholderShown.add(pendingEffects);
|
|
1793
|
-
if (!scope[promiseAccessor] &&
|
|
1832
|
+
if (!scope[promiseAccessor] && !awaitCounter.i++) {
|
|
1794
1833
|
requestAnimationFrame(
|
|
1795
|
-
() =>
|
|
1834
|
+
() => awaitCounter.i && runEffects(
|
|
1796
1835
|
prepareEffects(
|
|
1797
1836
|
() => queueRender(
|
|
1798
1837
|
tryWithPlaceholder,
|
|
@@ -1815,12 +1854,12 @@ function _await(nodeAccessor, template, walks, setup, params) {
|
|
|
1815
1854
|
)
|
|
1816
1855
|
);
|
|
1817
1856
|
}
|
|
1818
|
-
} else if (
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1857
|
+
} else if (scope[branchAccessor] && !scope[promiseAccessor]) {
|
|
1858
|
+
scope[branchAccessor]["#StartNode" /* StartNode */].parentNode.insertBefore(
|
|
1859
|
+
scope[nodeAccessor],
|
|
1860
|
+
scope[branchAccessor]["#StartNode" /* StartNode */]
|
|
1822
1861
|
);
|
|
1823
|
-
tempDetachBranch(
|
|
1862
|
+
tempDetachBranch(scope[branchAccessor]);
|
|
1824
1863
|
}
|
|
1825
1864
|
const thisPromise = scope[promiseAccessor] = promise.then(
|
|
1826
1865
|
(data) => {
|
|
@@ -1830,45 +1869,47 @@ function _await(nodeAccessor, template, walks, setup, params) {
|
|
|
1830
1869
|
queueRender(
|
|
1831
1870
|
scope,
|
|
1832
1871
|
() => {
|
|
1833
|
-
if (
|
|
1872
|
+
if (scope[branchAccessor]) {
|
|
1834
1873
|
if (!tryWithPlaceholder) {
|
|
1835
|
-
|
|
1836
|
-
|
|
1874
|
+
scope[nodeAccessor].replaceWith(
|
|
1875
|
+
scope[branchAccessor]["#StartNode" /* StartNode */].parentNode
|
|
1837
1876
|
);
|
|
1838
1877
|
}
|
|
1839
1878
|
} else {
|
|
1840
1879
|
insertBranchBefore(
|
|
1841
|
-
|
|
1880
|
+
scope[branchAccessor] = createAndSetupBranch(
|
|
1842
1881
|
scope["$global" /* Global */],
|
|
1843
|
-
|
|
1882
|
+
scope[rendererAccessor],
|
|
1844
1883
|
scope,
|
|
1845
|
-
|
|
1884
|
+
scope[nodeAccessor].parentNode
|
|
1846
1885
|
),
|
|
1847
|
-
|
|
1848
|
-
|
|
1886
|
+
scope[nodeAccessor].parentNode,
|
|
1887
|
+
scope[nodeAccessor]
|
|
1849
1888
|
);
|
|
1850
|
-
|
|
1889
|
+
scope[nodeAccessor].remove();
|
|
1851
1890
|
}
|
|
1852
|
-
params?.(
|
|
1853
|
-
if (
|
|
1891
|
+
params?.(scope[branchAccessor], [data]);
|
|
1892
|
+
if (awaitCounter) {
|
|
1854
1893
|
placeholderShown.add(pendingEffects);
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
)
|
|
1863
|
-
|
|
1894
|
+
awaitCounter.c();
|
|
1895
|
+
if (!awaitCounter.d) {
|
|
1896
|
+
const fnScopes = /* @__PURE__ */ new Map();
|
|
1897
|
+
const effects = renderData.m();
|
|
1898
|
+
for (let i = 0; i < pendingEffects.length; ) {
|
|
1899
|
+
const fn = pendingEffects[i++];
|
|
1900
|
+
let scopes = fnScopes.get(fn);
|
|
1901
|
+
if (!scopes) {
|
|
1902
|
+
fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1903
|
+
}
|
|
1904
|
+
scopes.add(pendingEffects[i++]);
|
|
1864
1905
|
}
|
|
1865
|
-
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1906
|
+
for (let i = 0; i < effects.length; ) {
|
|
1907
|
+
const fn = effects[i++];
|
|
1908
|
+
const scope2 = effects[i++];
|
|
1909
|
+
if (!fnScopes.get(fn)?.has(scope2)) {
|
|
1910
|
+
queueEffect(scope2, fn);
|
|
1870
1911
|
}
|
|
1871
|
-
}
|
|
1912
|
+
}
|
|
1872
1913
|
}
|
|
1873
1914
|
}
|
|
1874
1915
|
},
|
|
@@ -1878,8 +1919,7 @@ function _await(nodeAccessor, template, walks, setup, params) {
|
|
|
1878
1919
|
},
|
|
1879
1920
|
(error) => {
|
|
1880
1921
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1881
|
-
if (
|
|
1882
|
-
tryWithPlaceholder["#PendingAsyncCount" /* PendingAsyncCount */] = 0;
|
|
1922
|
+
if (awaitCounter) awaitCounter.i = 0;
|
|
1883
1923
|
scope[promiseAccessor] = 0;
|
|
1884
1924
|
schedule();
|
|
1885
1925
|
queueRender(scope, renderCatch, -1, error);
|
|
@@ -1888,6 +1928,13 @@ function _await(nodeAccessor, template, walks, setup, params) {
|
|
|
1888
1928
|
);
|
|
1889
1929
|
};
|
|
1890
1930
|
}
|
|
1931
|
+
function _await_content(nodeAccessor, template, walks, setup) {
|
|
1932
|
+
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + (true ? nodeAccessor : decodeAccessor4(nodeAccessor));
|
|
1933
|
+
const renderer = _content("", template, walks, setup)();
|
|
1934
|
+
return (scope) => {
|
|
1935
|
+
scope[rendererAccessor] = renderer;
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1891
1938
|
function _try(nodeAccessor, template, walks, setup) {
|
|
1892
1939
|
if (false) nodeAccessor = decodeAccessor4(nodeAccessor);
|
|
1893
1940
|
const branchAccessor = "BranchScopes:" /* BranchScopes */ + nodeAccessor;
|
|
@@ -1919,7 +1966,8 @@ function renderCatch(scope, error) {
|
|
|
1919
1966
|
const owner = tryWithCatch["_" /* Owner */];
|
|
1920
1967
|
const placeholderBranch = tryWithCatch["#PlaceholderBranch" /* PlaceholderBranch */];
|
|
1921
1968
|
if (placeholderBranch) {
|
|
1922
|
-
tryWithCatch["#
|
|
1969
|
+
if (tryWithCatch["#AwaitCounter" /* AwaitCounter */])
|
|
1970
|
+
tryWithCatch["#AwaitCounter" /* AwaitCounter */].i = 0;
|
|
1923
1971
|
owner["BranchScopes:" /* BranchScopes */ + tryWithCatch["#BranchAccessor" /* BranchAccessor */]] = placeholderBranch;
|
|
1924
1972
|
destroyBranch(tryWithCatch);
|
|
1925
1973
|
}
|
|
@@ -2296,7 +2344,7 @@ var _enable_catch = () => {
|
|
|
2296
2344
|
enableBranches();
|
|
2297
2345
|
const handlePendingTry = (fn, scope, branch) => {
|
|
2298
2346
|
while (branch) {
|
|
2299
|
-
if (branch["#
|
|
2347
|
+
if (branch["#AwaitCounter" /* AwaitCounter */]?.i) {
|
|
2300
2348
|
return (branch["#PendingEffects" /* PendingEffects */] ||= []).push(fn, scope);
|
|
2301
2349
|
}
|
|
2302
2350
|
branch = branch["#ParentBranch" /* ParentBranch */];
|