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/html.js
CHANGED
@@ -568,7 +568,7 @@ var State = class {
|
|
568
568
|
refs = /* @__PURE__ */ new WeakMap();
|
569
569
|
assigned = /* @__PURE__ */ new Set();
|
570
570
|
boundary = void 0;
|
571
|
-
|
571
|
+
mutations = [];
|
572
572
|
};
|
573
573
|
var Reference = class {
|
574
574
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
@@ -617,9 +617,25 @@ var Serializer = class {
|
|
617
617
|
this.#state.refs.set(symbol, new Reference(null, null, 0, null, id));
|
618
618
|
return symbol;
|
619
619
|
}
|
620
|
-
writeCall(value, object,
|
620
|
+
writeCall(value, object, property, spread) {
|
621
621
|
const state = this.#state;
|
622
|
-
state.
|
622
|
+
state.mutations.push({
|
623
|
+
type: 0 /* call */,
|
624
|
+
value,
|
625
|
+
object,
|
626
|
+
property,
|
627
|
+
spread
|
628
|
+
});
|
629
|
+
state.flushed = true;
|
630
|
+
}
|
631
|
+
writeAssign(value, object, property) {
|
632
|
+
const state = this.#state;
|
633
|
+
state.mutations.push({
|
634
|
+
type: 1 /* assign */,
|
635
|
+
value,
|
636
|
+
object,
|
637
|
+
property
|
638
|
+
});
|
623
639
|
state.flushed = true;
|
624
640
|
}
|
625
641
|
};
|
@@ -642,7 +658,7 @@ function getRegistered(val) {
|
|
642
658
|
}
|
643
659
|
}
|
644
660
|
function writeRoot(state, root) {
|
645
|
-
const { buf, assigned,
|
661
|
+
const { buf, assigned, mutations } = state;
|
646
662
|
const hadBuf = buf.length !== 0;
|
647
663
|
let result = "";
|
648
664
|
if (hadBuf) {
|
@@ -652,7 +668,7 @@ function writeRoot(state, root) {
|
|
652
668
|
const rootRef = state.refs.get(root);
|
653
669
|
if (rootRef) {
|
654
670
|
const rootId = ensureId(state, rootRef);
|
655
|
-
if (assigned.size ||
|
671
|
+
if (assigned.size || mutations.length) {
|
656
672
|
assigned.delete(rootRef);
|
657
673
|
writeAssigned(state);
|
658
674
|
buf.push(
|
@@ -693,13 +709,13 @@ function writeAssigned(state) {
|
|
693
709
|
}
|
694
710
|
state.assigned = /* @__PURE__ */ new Set();
|
695
711
|
}
|
696
|
-
if (state.
|
697
|
-
for (const
|
712
|
+
if (state.mutations.length) {
|
713
|
+
for (const mutation of state.mutations) {
|
698
714
|
const objectStartIndex = state.buf.push(
|
699
715
|
state.buf.length === 0 ? "(" : ",("
|
700
716
|
);
|
701
|
-
if (writeProp(state, object, null, "")) {
|
702
|
-
const objectRef = state.refs.get(object);
|
717
|
+
if (writeProp(state, mutation.object, null, "")) {
|
718
|
+
const objectRef = state.refs.get(mutation.object);
|
703
719
|
if (objectRef && !objectRef.id) {
|
704
720
|
objectRef.id = nextRefAccess(state);
|
705
721
|
state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex];
|
@@ -708,10 +724,10 @@ function writeAssigned(state) {
|
|
708
724
|
state.buf.push("void 0");
|
709
725
|
}
|
710
726
|
const valueStartIndex = state.buf.push(
|
711
|
-
")" + (
|
727
|
+
mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
|
712
728
|
);
|
713
|
-
if (writeProp(state, value, null, "")) {
|
714
|
-
const valueRef = state.refs.get(value);
|
729
|
+
if (writeProp(state, mutation.value, null, "")) {
|
730
|
+
const valueRef = state.refs.get(mutation.value);
|
715
731
|
if (valueRef && !valueRef.id) {
|
716
732
|
valueRef.id = nextRefAccess(state);
|
717
733
|
state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
|
@@ -721,7 +737,7 @@ function writeAssigned(state) {
|
|
721
737
|
}
|
722
738
|
state.buf.push(")");
|
723
739
|
}
|
724
|
-
state.
|
740
|
+
state.mutations = [];
|
725
741
|
if (state.assigned.size) {
|
726
742
|
writeAssigned(state);
|
727
743
|
}
|
@@ -1865,9 +1881,22 @@ function ensureScopeWithId(scopeId) {
|
|
1865
1881
|
function $global() {
|
1866
1882
|
return $chunk.boundary.state.$global;
|
1867
1883
|
}
|
1868
|
-
function fork(promise, content) {
|
1884
|
+
function fork(scopeId, accessor, promise, content) {
|
1869
1885
|
if (!isPromise(promise)) {
|
1886
|
+
const branchId = peekNextScopeId();
|
1887
|
+
$chunk.writeHTML(
|
1888
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1889
|
+
);
|
1870
1890
|
content(promise);
|
1891
|
+
writeScope(scopeId, {
|
1892
|
+
[accessor + "!" /* ConditionalScope */]: writeScope(branchId, {})
|
1893
|
+
});
|
1894
|
+
$chunk.writeHTML(
|
1895
|
+
$chunk.boundary.state.mark(
|
1896
|
+
"]" /* BranchEnd */,
|
1897
|
+
scopeId + " " + accessor
|
1898
|
+
)
|
1899
|
+
);
|
1871
1900
|
return;
|
1872
1901
|
}
|
1873
1902
|
const chunk = $chunk;
|
@@ -1883,7 +1912,27 @@ function fork(promise, content) {
|
|
1883
1912
|
if (chunk.async) {
|
1884
1913
|
chunk.async = false;
|
1885
1914
|
if (!boundary.signal.aborted) {
|
1886
|
-
chunk.render(
|
1915
|
+
chunk.render(() => {
|
1916
|
+
const branchId = peekNextScopeId();
|
1917
|
+
$chunk.writeHTML(
|
1918
|
+
$chunk.boundary.state.mark(
|
1919
|
+
"[" /* BranchStart */,
|
1920
|
+
branchId + ""
|
1921
|
+
)
|
1922
|
+
);
|
1923
|
+
content(value);
|
1924
|
+
boundary.state.serializer.writeAssign(
|
1925
|
+
writeScope(branchId, {}),
|
1926
|
+
ensureScopeWithId(scopeId),
|
1927
|
+
accessor + "!" /* ConditionalScope */
|
1928
|
+
);
|
1929
|
+
$chunk.writeHTML(
|
1930
|
+
$chunk.boundary.state.mark(
|
1931
|
+
"]" /* BranchEnd */,
|
1932
|
+
scopeId + " " + accessor
|
1933
|
+
)
|
1934
|
+
);
|
1935
|
+
});
|
1887
1936
|
boundary.endAsync(chunk);
|
1888
1937
|
}
|
1889
1938
|
}
|
@@ -1894,22 +1943,37 @@ function fork(promise, content) {
|
|
1894
1943
|
}
|
1895
1944
|
);
|
1896
1945
|
}
|
1897
|
-
function tryContent(input) {
|
1898
|
-
const
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
)
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1946
|
+
function tryContent(scopeId, accessor, content, input) {
|
1947
|
+
const branchId = peekNextScopeId();
|
1948
|
+
$chunk.writeHTML(
|
1949
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1950
|
+
);
|
1951
|
+
const catchContent = normalizeDynamicRenderer(input.catch);
|
1952
|
+
const placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
1953
|
+
if (catchContent) {
|
1954
|
+
tryCatch(
|
1955
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1956
|
+
catchContent
|
1957
|
+
);
|
1958
|
+
} else if (placeholderContent) {
|
1959
|
+
tryPlaceholder(content, placeholderContent);
|
1960
|
+
} else {
|
1961
|
+
content();
|
1912
1962
|
}
|
1963
|
+
writeScope(branchId, {
|
1964
|
+
["*" /* BranchAccessor */]: accessor,
|
1965
|
+
["^" /* CatchContent */]: catchContent,
|
1966
|
+
["%" /* PlaceholderContent */]: placeholderContent
|
1967
|
+
});
|
1968
|
+
writeScope(scopeId, {
|
1969
|
+
[accessor + "!" /* ConditionalScope */]: getScopeById(branchId)
|
1970
|
+
});
|
1971
|
+
$chunk.writeHTML(
|
1972
|
+
$chunk.boundary.state.mark(
|
1973
|
+
"]" /* BranchEnd */,
|
1974
|
+
scopeId + " " + accessor
|
1975
|
+
)
|
1976
|
+
);
|
1913
1977
|
}
|
1914
1978
|
function tryPlaceholder(content, placeholder) {
|
1915
1979
|
const chunk = $chunk;
|
@@ -2613,7 +2677,7 @@ function dynamicTagId(tagName) {
|
|
2613
2677
|
const normalizedRenderer = normalizeDynamicRenderer(tagName);
|
2614
2678
|
return normalizedRenderer?.___id || normalizedRenderer;
|
2615
2679
|
}
|
2616
|
-
|
2680
|
+
var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
|
2617
2681
|
if (!tag && !content) {
|
2618
2682
|
nextScopeId();
|
2619
2683
|
return;
|
@@ -2665,7 +2729,9 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
2665
2729
|
);
|
2666
2730
|
return;
|
2667
2731
|
}
|
2668
|
-
const renderer =
|
2732
|
+
const renderer = normalizeDynamicRenderer(
|
2733
|
+
tag
|
2734
|
+
);
|
2669
2735
|
if (true) {
|
2670
2736
|
if (typeof renderer !== "function") {
|
2671
2737
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
@@ -2680,8 +2746,8 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
2680
2746
|
accessor
|
2681
2747
|
);
|
2682
2748
|
return result;
|
2683
|
-
}
|
2684
|
-
|
2749
|
+
};
|
2750
|
+
var dynamicTagArgs = (scopeId, accessor, tag, args) => {
|
2685
2751
|
if (!tag) {
|
2686
2752
|
nextScopeId();
|
2687
2753
|
return;
|
@@ -2702,7 +2768,9 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
2702
2768
|
);
|
2703
2769
|
return;
|
2704
2770
|
}
|
2705
|
-
const renderer =
|
2771
|
+
const renderer = normalizeDynamicRenderer(
|
2772
|
+
tag
|
2773
|
+
);
|
2706
2774
|
if (true) {
|
2707
2775
|
if (typeof renderer !== "function") {
|
2708
2776
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
@@ -2717,7 +2785,7 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
2717
2785
|
accessor
|
2718
2786
|
);
|
2719
2787
|
return result;
|
2720
|
-
}
|
2788
|
+
};
|
2721
2789
|
function createContent(id, fn) {
|
2722
2790
|
fn.___id = id;
|
2723
2791
|
return fn;
|
@@ -2725,9 +2793,20 @@ function createContent(id, fn) {
|
|
2725
2793
|
function registerContent(id, fn, scopeId) {
|
2726
2794
|
return register2(createContent(id, fn), id, scopeId);
|
2727
2795
|
}
|
2728
|
-
|
2729
|
-
|
2730
|
-
|
2796
|
+
function patchDynamicTag(patch) {
|
2797
|
+
dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
|
2798
|
+
scopeId,
|
2799
|
+
accessor,
|
2800
|
+
patch(scopeId, accessor, tag),
|
2801
|
+
input,
|
2802
|
+
content
|
2803
|
+
))(dynamicTagInput);
|
2804
|
+
dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
|
2805
|
+
scopeId,
|
2806
|
+
accessor,
|
2807
|
+
patch(scopeId, accessor, tag),
|
2808
|
+
args
|
2809
|
+
))(dynamicTagArgs);
|
2731
2810
|
}
|
2732
2811
|
|
2733
2812
|
// src/html/compat.ts
|
package/dist/debug/html.mjs
CHANGED
@@ -484,7 +484,7 @@ var State = class {
|
|
484
484
|
refs = /* @__PURE__ */ new WeakMap();
|
485
485
|
assigned = /* @__PURE__ */ new Set();
|
486
486
|
boundary = void 0;
|
487
|
-
|
487
|
+
mutations = [];
|
488
488
|
};
|
489
489
|
var Reference = class {
|
490
490
|
constructor(parent, accessor, flush, pos = null, id = null) {
|
@@ -533,9 +533,25 @@ var Serializer = class {
|
|
533
533
|
this.#state.refs.set(symbol, new Reference(null, null, 0, null, id));
|
534
534
|
return symbol;
|
535
535
|
}
|
536
|
-
writeCall(value, object,
|
536
|
+
writeCall(value, object, property, spread) {
|
537
537
|
const state = this.#state;
|
538
|
-
state.
|
538
|
+
state.mutations.push({
|
539
|
+
type: 0 /* call */,
|
540
|
+
value,
|
541
|
+
object,
|
542
|
+
property,
|
543
|
+
spread
|
544
|
+
});
|
545
|
+
state.flushed = true;
|
546
|
+
}
|
547
|
+
writeAssign(value, object, property) {
|
548
|
+
const state = this.#state;
|
549
|
+
state.mutations.push({
|
550
|
+
type: 1 /* assign */,
|
551
|
+
value,
|
552
|
+
object,
|
553
|
+
property
|
554
|
+
});
|
539
555
|
state.flushed = true;
|
540
556
|
}
|
541
557
|
};
|
@@ -558,7 +574,7 @@ function getRegistered(val) {
|
|
558
574
|
}
|
559
575
|
}
|
560
576
|
function writeRoot(state, root) {
|
561
|
-
const { buf, assigned,
|
577
|
+
const { buf, assigned, mutations } = state;
|
562
578
|
const hadBuf = buf.length !== 0;
|
563
579
|
let result = "";
|
564
580
|
if (hadBuf) {
|
@@ -568,7 +584,7 @@ function writeRoot(state, root) {
|
|
568
584
|
const rootRef = state.refs.get(root);
|
569
585
|
if (rootRef) {
|
570
586
|
const rootId = ensureId(state, rootRef);
|
571
|
-
if (assigned.size ||
|
587
|
+
if (assigned.size || mutations.length) {
|
572
588
|
assigned.delete(rootRef);
|
573
589
|
writeAssigned(state);
|
574
590
|
buf.push(
|
@@ -609,13 +625,13 @@ function writeAssigned(state) {
|
|
609
625
|
}
|
610
626
|
state.assigned = /* @__PURE__ */ new Set();
|
611
627
|
}
|
612
|
-
if (state.
|
613
|
-
for (const
|
628
|
+
if (state.mutations.length) {
|
629
|
+
for (const mutation of state.mutations) {
|
614
630
|
const objectStartIndex = state.buf.push(
|
615
631
|
state.buf.length === 0 ? "(" : ",("
|
616
632
|
);
|
617
|
-
if (writeProp(state, object, null, "")) {
|
618
|
-
const objectRef = state.refs.get(object);
|
633
|
+
if (writeProp(state, mutation.object, null, "")) {
|
634
|
+
const objectRef = state.refs.get(mutation.object);
|
619
635
|
if (objectRef && !objectRef.id) {
|
620
636
|
objectRef.id = nextRefAccess(state);
|
621
637
|
state.buf[objectStartIndex] = objectRef.id + "=" + state.buf[objectStartIndex];
|
@@ -624,10 +640,10 @@ function writeAssigned(state) {
|
|
624
640
|
state.buf.push("void 0");
|
625
641
|
}
|
626
642
|
const valueStartIndex = state.buf.push(
|
627
|
-
")" + (
|
643
|
+
mutation.type === 0 /* call */ ? ")" + (mutation.property === void 0 ? "" : toAccess(toObjectKey(mutation.property))) + "(" + (mutation.spread ? "..." : "") : toAccess(toObjectKey(mutation.property)) + "="
|
628
644
|
);
|
629
|
-
if (writeProp(state, value, null, "")) {
|
630
|
-
const valueRef = state.refs.get(value);
|
645
|
+
if (writeProp(state, mutation.value, null, "")) {
|
646
|
+
const valueRef = state.refs.get(mutation.value);
|
631
647
|
if (valueRef && !valueRef.id) {
|
632
648
|
valueRef.id = nextRefAccess(state);
|
633
649
|
state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
|
@@ -637,7 +653,7 @@ function writeAssigned(state) {
|
|
637
653
|
}
|
638
654
|
state.buf.push(")");
|
639
655
|
}
|
640
|
-
state.
|
656
|
+
state.mutations = [];
|
641
657
|
if (state.assigned.size) {
|
642
658
|
writeAssigned(state);
|
643
659
|
}
|
@@ -1781,9 +1797,22 @@ function ensureScopeWithId(scopeId) {
|
|
1781
1797
|
function $global() {
|
1782
1798
|
return $chunk.boundary.state.$global;
|
1783
1799
|
}
|
1784
|
-
function fork(promise, content) {
|
1800
|
+
function fork(scopeId, accessor, promise, content) {
|
1785
1801
|
if (!isPromise(promise)) {
|
1802
|
+
const branchId = peekNextScopeId();
|
1803
|
+
$chunk.writeHTML(
|
1804
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1805
|
+
);
|
1786
1806
|
content(promise);
|
1807
|
+
writeScope(scopeId, {
|
1808
|
+
[accessor + "!" /* ConditionalScope */]: writeScope(branchId, {})
|
1809
|
+
});
|
1810
|
+
$chunk.writeHTML(
|
1811
|
+
$chunk.boundary.state.mark(
|
1812
|
+
"]" /* BranchEnd */,
|
1813
|
+
scopeId + " " + accessor
|
1814
|
+
)
|
1815
|
+
);
|
1787
1816
|
return;
|
1788
1817
|
}
|
1789
1818
|
const chunk = $chunk;
|
@@ -1799,7 +1828,27 @@ function fork(promise, content) {
|
|
1799
1828
|
if (chunk.async) {
|
1800
1829
|
chunk.async = false;
|
1801
1830
|
if (!boundary.signal.aborted) {
|
1802
|
-
chunk.render(
|
1831
|
+
chunk.render(() => {
|
1832
|
+
const branchId = peekNextScopeId();
|
1833
|
+
$chunk.writeHTML(
|
1834
|
+
$chunk.boundary.state.mark(
|
1835
|
+
"[" /* BranchStart */,
|
1836
|
+
branchId + ""
|
1837
|
+
)
|
1838
|
+
);
|
1839
|
+
content(value);
|
1840
|
+
boundary.state.serializer.writeAssign(
|
1841
|
+
writeScope(branchId, {}),
|
1842
|
+
ensureScopeWithId(scopeId),
|
1843
|
+
accessor + "!" /* ConditionalScope */
|
1844
|
+
);
|
1845
|
+
$chunk.writeHTML(
|
1846
|
+
$chunk.boundary.state.mark(
|
1847
|
+
"]" /* BranchEnd */,
|
1848
|
+
scopeId + " " + accessor
|
1849
|
+
)
|
1850
|
+
);
|
1851
|
+
});
|
1803
1852
|
boundary.endAsync(chunk);
|
1804
1853
|
}
|
1805
1854
|
}
|
@@ -1810,22 +1859,37 @@ function fork(promise, content) {
|
|
1810
1859
|
}
|
1811
1860
|
);
|
1812
1861
|
}
|
1813
|
-
function tryContent(input) {
|
1814
|
-
const
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
)
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1862
|
+
function tryContent(scopeId, accessor, content, input) {
|
1863
|
+
const branchId = peekNextScopeId();
|
1864
|
+
$chunk.writeHTML(
|
1865
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1866
|
+
);
|
1867
|
+
const catchContent = normalizeDynamicRenderer(input.catch);
|
1868
|
+
const placeholderContent = normalizeDynamicRenderer(input.placeholder);
|
1869
|
+
if (catchContent) {
|
1870
|
+
tryCatch(
|
1871
|
+
placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
|
1872
|
+
catchContent
|
1873
|
+
);
|
1874
|
+
} else if (placeholderContent) {
|
1875
|
+
tryPlaceholder(content, placeholderContent);
|
1876
|
+
} else {
|
1877
|
+
content();
|
1828
1878
|
}
|
1879
|
+
writeScope(branchId, {
|
1880
|
+
["*" /* BranchAccessor */]: accessor,
|
1881
|
+
["^" /* CatchContent */]: catchContent,
|
1882
|
+
["%" /* PlaceholderContent */]: placeholderContent
|
1883
|
+
});
|
1884
|
+
writeScope(scopeId, {
|
1885
|
+
[accessor + "!" /* ConditionalScope */]: getScopeById(branchId)
|
1886
|
+
});
|
1887
|
+
$chunk.writeHTML(
|
1888
|
+
$chunk.boundary.state.mark(
|
1889
|
+
"]" /* BranchEnd */,
|
1890
|
+
scopeId + " " + accessor
|
1891
|
+
)
|
1892
|
+
);
|
1829
1893
|
}
|
1830
1894
|
function tryPlaceholder(content, placeholder) {
|
1831
1895
|
const chunk = $chunk;
|
@@ -2529,7 +2593,7 @@ function dynamicTagId(tagName) {
|
|
2529
2593
|
const normalizedRenderer = normalizeDynamicRenderer(tagName);
|
2530
2594
|
return normalizedRenderer?.___id || normalizedRenderer;
|
2531
2595
|
}
|
2532
|
-
|
2596
|
+
var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
|
2533
2597
|
if (!tag && !content) {
|
2534
2598
|
nextScopeId();
|
2535
2599
|
return;
|
@@ -2581,7 +2645,9 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
2581
2645
|
);
|
2582
2646
|
return;
|
2583
2647
|
}
|
2584
|
-
const renderer =
|
2648
|
+
const renderer = normalizeDynamicRenderer(
|
2649
|
+
tag
|
2650
|
+
);
|
2585
2651
|
if (true) {
|
2586
2652
|
if (typeof renderer !== "function") {
|
2587
2653
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
@@ -2596,8 +2662,8 @@ function dynamicTagInput(scopeId, accessor, tag, input, content) {
|
|
2596
2662
|
accessor
|
2597
2663
|
);
|
2598
2664
|
return result;
|
2599
|
-
}
|
2600
|
-
|
2665
|
+
};
|
2666
|
+
var dynamicTagArgs = (scopeId, accessor, tag, args) => {
|
2601
2667
|
if (!tag) {
|
2602
2668
|
nextScopeId();
|
2603
2669
|
return;
|
@@ -2618,7 +2684,9 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
2618
2684
|
);
|
2619
2685
|
return;
|
2620
2686
|
}
|
2621
|
-
const renderer =
|
2687
|
+
const renderer = normalizeDynamicRenderer(
|
2688
|
+
tag
|
2689
|
+
);
|
2622
2690
|
if (true) {
|
2623
2691
|
if (typeof renderer !== "function") {
|
2624
2692
|
throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
|
@@ -2633,7 +2701,7 @@ function dynamicTagArgs(scopeId, accessor, tag, args) {
|
|
2633
2701
|
accessor
|
2634
2702
|
);
|
2635
2703
|
return result;
|
2636
|
-
}
|
2704
|
+
};
|
2637
2705
|
function createContent(id, fn) {
|
2638
2706
|
fn.___id = id;
|
2639
2707
|
return fn;
|
@@ -2641,9 +2709,20 @@ function createContent(id, fn) {
|
|
2641
2709
|
function registerContent(id, fn, scopeId) {
|
2642
2710
|
return register2(createContent(id, fn), id, scopeId);
|
2643
2711
|
}
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2712
|
+
function patchDynamicTag(patch) {
|
2713
|
+
dynamicTagInput = /* @__PURE__ */ ((originalDynamicTagInput) => (scopeId, accessor, tag, input, content) => originalDynamicTagInput(
|
2714
|
+
scopeId,
|
2715
|
+
accessor,
|
2716
|
+
patch(scopeId, accessor, tag),
|
2717
|
+
input,
|
2718
|
+
content
|
2719
|
+
))(dynamicTagInput);
|
2720
|
+
dynamicTagArgs = /* @__PURE__ */ ((originalDynamicTagArgs) => (scopeId, accessor, tag, args) => originalDynamicTagArgs(
|
2721
|
+
scopeId,
|
2722
|
+
accessor,
|
2723
|
+
patch(scopeId, accessor, tag),
|
2724
|
+
args
|
2725
|
+
))(dynamicTagArgs);
|
2647
2726
|
}
|
2648
2727
|
|
2649
2728
|
// src/html/compat.ts
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import { type Accessor, type BranchScope, type Scope } from "../common/types";
|
2
2
|
import { type Renderer } from "./renderer";
|
3
3
|
import { type Signal } from "./signals";
|
4
|
+
export declare function awaitTag(nodeAccessor: Accessor, renderer: Renderer): (scope: Scope, promise: Promise<unknown>) => void;
|
5
|
+
export declare function createTry(nodeAccessor: Accessor, tryContent: Renderer): (scope: Scope, input: {
|
6
|
+
catch: unknown;
|
7
|
+
placeholder: unknown;
|
8
|
+
}) => void;
|
4
9
|
export declare function conditional(nodeAccessor: Accessor, ...branches: Renderer[]): (scope: Scope, newBranch: number) => void;
|
5
10
|
export declare function patchDynamicTag(fn: <T extends typeof dynamicTag>(cond: T) => T): void;
|
6
11
|
export declare let dynamicTag: (nodeAccessor: Accessor, getContent?: ((scope: Scope) => Renderer) | 0, getTagVar?: (() => Signal<unknown>) | 0, inputIsArgs?: 1) => Signal<Renderer | string | undefined>;
|
package/dist/dom/queue.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type
|
1
|
+
import { type Scope } from "../common/types";
|
2
2
|
import type { Signal } from "./signals";
|
3
3
|
type ExecFn<S extends Scope = Scope> = (scope: S, arg?: any) => void;
|
4
4
|
export declare let pendingEffects: unknown[];
|
@@ -8,4 +8,5 @@ export declare function queueEffect<S extends Scope, T extends ExecFn<S>>(scope:
|
|
8
8
|
export declare function run(): void;
|
9
9
|
export declare function prepareEffects(fn: () => void): unknown[];
|
10
10
|
export declare function runEffects(effects: unknown[]): void;
|
11
|
+
export declare let enableCatch: () => void;
|
11
12
|
export {};
|
package/dist/dom/scope.d.ts
CHANGED
@@ -5,3 +5,4 @@ export declare function finishPendingScopes(): void;
|
|
5
5
|
export declare function destroyBranch(branch: BranchScope): void;
|
6
6
|
export declare function removeAndDestroyBranch(branch: BranchScope): void;
|
7
7
|
export declare function insertBranchBefore(branch: BranchScope, parentNode: ParentNode, nextSibling: Node | null): void;
|
8
|
+
export declare function tempDetatchBranch(branch: BranchScope): void;
|
package/dist/dom.d.ts
CHANGED
@@ -2,11 +2,11 @@ export { attrTag, attrTags } from "./common/attr-tag";
|
|
2
2
|
export { forIn, forOf, forTo } from "./common/for";
|
3
3
|
export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
|
4
4
|
export { compat } from "./dom/compat";
|
5
|
-
export { conditional, dynamicTag, loopIn, loopOf, loopTo, } from "./dom/control-flow";
|
5
|
+
export { awaitTag, conditional, createTry, dynamicTag, loopIn, loopOf, loopTo, } from "./dom/control-flow";
|
6
6
|
export { controllable_detailsOrDialog_open, controllable_detailsOrDialog_open_effect, controllable_input_checked, controllable_input_checked_effect, controllable_input_checkedValue, controllable_input_checkedValue_effect, controllable_input_value, controllable_input_value_effect, controllable_select_value, controllable_select_value_effect, controllable_textarea_value, controllable_textarea_value_effect, } from "./dom/controllable";
|
7
7
|
export { attr, attrs, attrsEvents, classAttr, data, html, lifecycle, partialAttrs, props, styleAttr, textContent, } from "./dom/dom";
|
8
8
|
export { on } from "./dom/event";
|
9
|
-
export { run } from "./dom/queue";
|
9
|
+
export { enableCatch, run } from "./dom/queue";
|
10
10
|
export { createContent, createRenderer, registerContent } from "./dom/renderer";
|
11
11
|
export { init, nodeRef, register, registerBoundSignal } from "./dom/resume";
|
12
12
|
export { conditionalClosure, dynamicClosure, dynamicClosureRead, effect, hoist, intersection, loopClosure, nextTagId, setTagVar, setTagVarChange, state, tagVarSignal, tagVarSignalChange, value, } from "./dom/signals";
|