marko 6.0.0-next.3.22 → 6.0.0-next.3.24
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/for.d.ts +3 -4
- package/dist/common/types.d.ts +18 -17
- package/dist/debug/dom.js +717 -753
- package/dist/debug/dom.mjs +717 -753
- package/dist/debug/html.js +256 -99
- package/dist/debug/html.mjs +247 -95
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/compat.d.ts +1 -0
- package/dist/dom/control-flow.d.ts +6 -8
- package/dist/dom/parse-html.d.ts +1 -4
- package/dist/dom/queue.d.ts +4 -2
- package/dist/dom/reconcile.d.ts +2 -2
- package/dist/dom/renderer.d.ts +7 -8
- package/dist/dom/resume.d.ts +3 -3
- package/dist/dom/scope.d.ts +4 -4
- package/dist/dom/signals.d.ts +13 -26
- package/dist/dom/template.d.ts +2 -2
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +459 -494
- package/dist/dom.mjs +459 -494
- package/dist/html/dynamic-tag.d.ts +3 -3
- package/dist/html/writer.d.ts +12 -12
- package/dist/html.d.ts +1 -1
- package/dist/html.js +202 -65
- package/dist/html.mjs +193 -61
- package/dist/translator/core/for.d.ts +0 -2
- package/dist/translator/index.js +189 -224
- package/dist/translator/util/runtime.d.ts +1 -2
- package/dist/translator/util/sections.d.ts +2 -1
- package/dist/translator/util/signals.d.ts +2 -2
- package/package.json +2 -2
- package/tags-html.d.ts +152 -152
package/dist/html.mjs
CHANGED
@@ -79,6 +79,24 @@ function escapeStyle(val) {
|
|
79
79
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
80
80
|
}
|
81
81
|
|
82
|
+
// src/common/for.ts
|
83
|
+
function forIn(obj, cb) {
|
84
|
+
for (let key in obj)
|
85
|
+
cb(key, obj[key]);
|
86
|
+
}
|
87
|
+
function forOf(list, cb) {
|
88
|
+
if (list) {
|
89
|
+
let i = 0;
|
90
|
+
for (let item of list)
|
91
|
+
cb(item, i++);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
function forTo(to, from, step, cb) {
|
95
|
+
let start = from || 0, delta = step || 1;
|
96
|
+
for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
|
97
|
+
cb(start + i * delta);
|
98
|
+
}
|
99
|
+
|
82
100
|
// src/html/inlined-runtimes.ts
|
83
101
|
var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},s=[],f=document,i=f.createTreeWalker(f,129),n=self[e][l]={i:l=e+l,d:f,l:d,v:s,x(){},w(e){for(;e=i.nextNode();)this.x(n=(n=e.data)&&!n.indexOf(l)&&(d[t=n.slice(x+1)]=e,n[x]),t,e),n>"#"&&s.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l={},o=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,n,a,c,p)=>{"#"==d?(l[n]=t).i++:a==r&&i(),"T"==a.tagName&&(n=a.getAttribute(e.i))&&((c=e.l["^"+n])&&(l[n]={i:1,c(i=e.l[n]||a){for(;i.parentNode!==c.parentNode;)i=i.parentNode;for(;i!=r;(r=c.nextSibling).remove());o(c,a)}}),r=a.nextSibling,t=l[n],i=()=>{c||o(e.l[n],a),--t.i||t.c()},(d=e.j[n])&&(p=t.c,t.c=()=>p()+d(e)))}})';
|
84
102
|
|
@@ -935,23 +953,114 @@ function nodeRef(scopeId, id) {
|
|
935
953
|
};
|
936
954
|
return id ? register2(getter, id, scopeId) : getter;
|
937
955
|
}
|
938
|
-
function
|
939
|
-
|
940
|
-
|
941
|
-
|
956
|
+
function resumeClosestBranch(scopeId) {
|
957
|
+
let branchId = $chunk.context?.[branchIdKey];
|
958
|
+
branchId !== void 0 && branchId !== scopeId && $chunk.writeHTML(
|
959
|
+
$chunk.boundary.state.mark("$" /* ClosestBranch */, "" + scopeId)
|
960
|
+
);
|
961
|
+
}
|
962
|
+
var branchIdKey = Symbol();
|
963
|
+
function resumeForOf(list, cb, scopeId, accessor) {
|
964
|
+
forOf(list, (item, i) => {
|
965
|
+
let branchId = peekNextScopeId();
|
966
|
+
$chunk.writeHTML(
|
967
|
+
$chunk.boundary.state.mark(
|
968
|
+
"[" /* BranchStart */,
|
969
|
+
branchId + (i ? " " : "")
|
970
|
+
)
|
971
|
+
), withContext(branchIdKey, branchId, () => cb(item, i));
|
972
|
+
}), $chunk.writeHTML(
|
973
|
+
$chunk.boundary.state.mark(
|
974
|
+
"]" /* BranchEnd */,
|
975
|
+
scopeId + " " + accessor
|
976
|
+
)
|
977
|
+
);
|
978
|
+
}
|
979
|
+
function resumeSingleNodeForOf(list, cb, scopeId, accessor) {
|
980
|
+
let branchIds = "";
|
981
|
+
forOf(list, (item, index) => {
|
982
|
+
let branchId = peekNextScopeId();
|
983
|
+
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(item, index));
|
984
|
+
}), $chunk.writeHTML(
|
985
|
+
$chunk.boundary.state.mark(
|
986
|
+
"|" /* BranchSingleNode */,
|
987
|
+
scopeId + " " + accessor + branchIds
|
988
|
+
)
|
989
|
+
);
|
990
|
+
}
|
991
|
+
function resumeForIn(obj, cb, scopeId, accessor) {
|
992
|
+
let sep = "";
|
993
|
+
forIn(obj, (key, value) => {
|
994
|
+
let branchId = peekNextScopeId();
|
995
|
+
$chunk.writeHTML(
|
996
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
997
|
+
), sep = " ", withContext(branchIdKey, branchId, () => cb(key, value));
|
998
|
+
}), $chunk.writeHTML(
|
999
|
+
$chunk.boundary.state.mark(
|
1000
|
+
"]" /* BranchEnd */,
|
1001
|
+
scopeId + " " + accessor
|
1002
|
+
)
|
1003
|
+
);
|
1004
|
+
}
|
1005
|
+
function resumeSingleNodeForIn(obj, cb, scopeId, accessor) {
|
1006
|
+
let branchIds = "";
|
1007
|
+
forIn(obj, (key, value) => {
|
1008
|
+
let branchId = peekNextScopeId();
|
1009
|
+
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(key, value));
|
1010
|
+
}), $chunk.writeHTML(
|
1011
|
+
$chunk.boundary.state.mark(
|
1012
|
+
"|" /* BranchSingleNode */,
|
1013
|
+
scopeId + " " + accessor + branchIds
|
1014
|
+
)
|
1015
|
+
);
|
1016
|
+
}
|
1017
|
+
function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
1018
|
+
let sep = "";
|
1019
|
+
forTo(to, from, step, (index) => {
|
1020
|
+
let branchId = peekNextScopeId();
|
1021
|
+
$chunk.writeHTML(
|
1022
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1023
|
+
), sep = " ", withContext(branchIdKey, branchId, () => cb(index));
|
1024
|
+
}), $chunk.writeHTML(
|
1025
|
+
$chunk.boundary.state.mark(
|
1026
|
+
"]" /* BranchEnd */,
|
1027
|
+
scopeId + " " + accessor
|
1028
|
+
)
|
942
1029
|
);
|
943
1030
|
}
|
944
|
-
function
|
945
|
-
|
1031
|
+
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor) {
|
1032
|
+
let branchIds = "";
|
1033
|
+
forTo(to, from, step, (index) => {
|
1034
|
+
let branchId = peekNextScopeId();
|
1035
|
+
branchIds = " " + branchId + branchIds, withContext(branchIdKey, branchId, () => cb(index));
|
1036
|
+
}), $chunk.writeHTML(
|
1037
|
+
$chunk.boundary.state.mark(
|
1038
|
+
"|" /* BranchSingleNode */,
|
1039
|
+
scopeId + " " + accessor + branchIds
|
1040
|
+
)
|
1041
|
+
);
|
946
1042
|
}
|
947
|
-
function
|
948
|
-
|
949
|
-
|
950
|
-
|
1043
|
+
function resumeConditional(cb, scopeId, accessor) {
|
1044
|
+
let branchId = peekNextScopeId();
|
1045
|
+
$chunk.writeHTML(
|
1046
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1047
|
+
), withContext(branchIdKey, branchId, cb), peekNextScopeId() !== branchId ? writeScope(branchId, {}) : nextScopeId(), $chunk.writeHTML(
|
1048
|
+
$chunk.boundary.state.mark(
|
1049
|
+
"]" /* BranchEnd */,
|
1050
|
+
scopeId + " " + accessor
|
1051
|
+
)
|
951
1052
|
);
|
952
1053
|
}
|
953
|
-
function
|
954
|
-
|
1054
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor) {
|
1055
|
+
let branchId = peekNextScopeId();
|
1056
|
+
withContext(branchIdKey, branchId, cb);
|
1057
|
+
let rendered = peekNextScopeId() !== branchId;
|
1058
|
+
rendered ? writeScope(branchId, {}) : nextScopeId(), $chunk.writeHTML(
|
1059
|
+
$chunk.boundary.state.mark(
|
1060
|
+
"|" /* BranchSingleNode */,
|
1061
|
+
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
1062
|
+
)
|
1063
|
+
);
|
955
1064
|
}
|
956
1065
|
function writeScope(scopeId, partialScope) {
|
957
1066
|
let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
|
@@ -1139,7 +1248,7 @@ var State2 = class {
|
|
1139
1248
|
if (cur.next && !cur.async) {
|
1140
1249
|
let html = "", effects = "", scripts = "";
|
1141
1250
|
do
|
1142
|
-
cur.flushPlaceholder(), html += cur.html, effects
|
1251
|
+
cur.flushPlaceholder(), html += cur.html, effects = concatEffects(effects, cur.effects), scripts = concatScripts(scripts, cur.scripts), cur.consumed = !0, cur = cur.next;
|
1143
1252
|
while (cur.next && !cur.async);
|
1144
1253
|
cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts);
|
1145
1254
|
}
|
@@ -1439,36 +1548,72 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
1439
1548
|
|
1440
1549
|
// src/html/dynamic-tag.ts
|
1441
1550
|
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
|
1442
|
-
function dynamicTagInput(
|
1443
|
-
if (!tag && !content)
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1551
|
+
function dynamicTagInput(scopeId, accessor, tag, input, content, tagVar) {
|
1552
|
+
if (!tag && !content) {
|
1553
|
+
nextScopeId();
|
1554
|
+
return;
|
1555
|
+
}
|
1556
|
+
if (!tag) {
|
1557
|
+
resumeConditional(content, scopeId, accessor);
|
1558
|
+
return;
|
1559
|
+
}
|
1560
|
+
if (typeof tag == "string") {
|
1561
|
+
resumeSingleNodeConditional(
|
1562
|
+
() => {
|
1563
|
+
nextScopeId(), write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`), voidElementsReg.test(tag) || (tag === "textarea" ? write(
|
1564
|
+
controllable_textarea_value(
|
1565
|
+
scopeId,
|
1566
|
+
accessor,
|
1567
|
+
input.value,
|
1568
|
+
input.valueChange
|
1569
|
+
)
|
1570
|
+
) : content && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1571
|
+
scopeId,
|
1572
|
+
accessor,
|
1573
|
+
input.value,
|
1574
|
+
input.valueChange,
|
1575
|
+
content
|
1576
|
+
) : content()), write(`</${tag}>`));
|
1577
|
+
},
|
1449
1578
|
scopeId,
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1579
|
+
accessor
|
1580
|
+
);
|
1581
|
+
return;
|
1582
|
+
}
|
1583
|
+
let renderer = getDynamicRenderer(tag), result;
|
1584
|
+
return resumeConditional(
|
1585
|
+
() => {
|
1586
|
+
result = renderer(content ? { ...input, content } : input, tagVar);
|
1587
|
+
},
|
1455
1588
|
scopeId,
|
1456
|
-
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1589
|
+
accessor
|
1590
|
+
), result;
|
1591
|
+
}
|
1592
|
+
function dynamicTagArgs(scopeId, accessor, tag, args) {
|
1593
|
+
if (!tag) {
|
1594
|
+
nextScopeId();
|
1595
|
+
return;
|
1596
|
+
}
|
1597
|
+
if (typeof tag == "string") {
|
1598
|
+
resumeSingleNodeConditional(
|
1599
|
+
() => {
|
1600
|
+
nextScopeId(), write(
|
1601
|
+
`<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
|
1602
|
+
), voidElementsReg.test(tag) || write(`</${tag}>`);
|
1603
|
+
},
|
1604
|
+
scopeId,
|
1605
|
+
accessor
|
1606
|
+
);
|
1469
1607
|
return;
|
1470
1608
|
}
|
1471
|
-
|
1609
|
+
let renderer = getDynamicRenderer(tag), result;
|
1610
|
+
return resumeConditional(
|
1611
|
+
() => {
|
1612
|
+
result = renderer(...args);
|
1613
|
+
},
|
1614
|
+
scopeId,
|
1615
|
+
accessor
|
1616
|
+
), result;
|
1472
1617
|
}
|
1473
1618
|
var getDynamicRenderer = normalizeDynamicRenderer, createRenderer = (fn) => fn;
|
1474
1619
|
function patchDynamicTag(newGetDynamicRenderer, newCreateRenderer) {
|
@@ -1538,24 +1683,6 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1538
1683
|
}
|
1539
1684
|
};
|
1540
1685
|
|
1541
|
-
// src/common/for.ts
|
1542
|
-
function forIn(obj, cb) {
|
1543
|
-
for (let key in obj)
|
1544
|
-
cb(key, obj[key]);
|
1545
|
-
}
|
1546
|
-
function forOf(list, cb) {
|
1547
|
-
if (list) {
|
1548
|
-
let i = 0;
|
1549
|
-
for (let item of list)
|
1550
|
-
cb(item, i++);
|
1551
|
-
}
|
1552
|
-
}
|
1553
|
-
function forTo(to, from, step, cb) {
|
1554
|
-
let start = from || 0, delta = step || 1;
|
1555
|
-
for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
|
1556
|
-
cb(start + i * delta);
|
1557
|
-
}
|
1558
|
-
|
1559
1686
|
// src/html/for.ts
|
1560
1687
|
function forOfBy(by, item, index) {
|
1561
1688
|
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
@@ -1739,11 +1866,7 @@ export {
|
|
1739
1866
|
forToBy,
|
1740
1867
|
fork,
|
1741
1868
|
getScopeById,
|
1742
|
-
markResumeCleanup,
|
1743
|
-
markResumeControlEnd,
|
1744
|
-
markResumeControlSingleNodeEnd,
|
1745
1869
|
markResumeNode,
|
1746
|
-
markResumeScopeStart,
|
1747
1870
|
nextScopeId,
|
1748
1871
|
nextTagId,
|
1749
1872
|
nodeRef,
|
@@ -1752,6 +1875,15 @@ export {
|
|
1752
1875
|
partialAttrs,
|
1753
1876
|
peekNextScope,
|
1754
1877
|
register2 as register,
|
1878
|
+
resumeClosestBranch,
|
1879
|
+
resumeConditional,
|
1880
|
+
resumeForIn,
|
1881
|
+
resumeForOf,
|
1882
|
+
resumeForTo,
|
1883
|
+
resumeSingleNodeConditional,
|
1884
|
+
resumeSingleNodeForIn,
|
1885
|
+
resumeSingleNodeForOf,
|
1886
|
+
resumeSingleNodeForTo,
|
1755
1887
|
styleAttr,
|
1756
1888
|
toString,
|
1757
1889
|
tryContent,
|
@@ -2,12 +2,10 @@ import { types as t } from "@marko/compiler";
|
|
2
2
|
import { type Binding } from "../util/references";
|
3
3
|
type ForType = "in" | "of" | "to";
|
4
4
|
declare const kForMarkerBinding: unique symbol;
|
5
|
-
declare const kForScopeStartIndex: unique symbol;
|
6
5
|
declare const kOnlyChildInParent: unique symbol;
|
7
6
|
declare module "@marko/compiler/dist/types" {
|
8
7
|
interface NodeExtra {
|
9
8
|
[kForMarkerBinding]?: Binding;
|
10
|
-
[kForScopeStartIndex]?: t.Identifier;
|
11
9
|
[kOnlyChildInParent]?: boolean;
|
12
10
|
}
|
13
11
|
}
|