marko 6.0.0-next.3.68 → 6.0.0-next.3.69
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/debug/dom.js +1 -1
- package/dist/debug/dom.mjs +1 -1
- package/dist/debug/html.js +234 -178
- package/dist/debug/html.mjs +233 -175
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/html/dynamic-tag.d.ts +2 -4
- package/dist/html/writer.d.ts +10 -9
- package/dist/html.d.ts +1 -1
- package/dist/html.js +134 -129
- package/dist/html.mjs +133 -126
- package/dist/translator/index.js +49 -211
- package/package.json +1 -1
package/dist/html.mjs
CHANGED
@@ -411,10 +411,7 @@ function register(id, val, scope) {
|
|
411
411
|
function getRegistered(val) {
|
412
412
|
let registered = REGISTRY.get(val);
|
413
413
|
if (registered)
|
414
|
-
return {
|
415
|
-
id: registered.id,
|
416
|
-
scope: registered.scope
|
417
|
-
};
|
414
|
+
return { id: registered.id, scope: registered.scope };
|
418
415
|
}
|
419
416
|
function writeRoot(state, root) {
|
420
417
|
let { buf, assigned, mutations } = state, hadBuf = buf.length !== 0, result = "";
|
@@ -510,7 +507,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
|
|
510
507
|
return newScopeRef && ensureId(state, newScopeRef), !0;
|
511
508
|
}
|
512
509
|
if (scopeRef) {
|
513
|
-
if (isCircular(parent, scopeRef))
|
510
|
+
if (parent && (state.assigned.has(scopeRef) || isCircular(parent, scopeRef)))
|
514
511
|
return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
|
515
512
|
state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
|
516
513
|
} else {
|
@@ -1012,7 +1009,7 @@ function withContext(key, value, cb) {
|
|
1012
1009
|
let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
|
1013
1010
|
ctx[kPendingContexts]++, ctx[key] = value;
|
1014
1011
|
try {
|
1015
|
-
cb();
|
1012
|
+
return cb();
|
1016
1013
|
} finally {
|
1017
1014
|
ctx[kPendingContexts]--, ctx[key] = prev;
|
1018
1015
|
}
|
@@ -1060,20 +1057,26 @@ function hoist(scopeId, id) {
|
|
1060
1057
|
}
|
1061
1058
|
function resumeClosestBranch(scopeId) {
|
1062
1059
|
let branchId = $chunk.context?.[branchIdKey];
|
1063
|
-
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, {
|
1064
|
-
g: branchId
|
1065
|
-
});
|
1060
|
+
branchId !== void 0 && branchId !== scopeId && writeScope(scopeId, { g: branchId });
|
1066
1061
|
}
|
1067
1062
|
var branchIdKey = Symbol();
|
1068
|
-
function
|
1069
|
-
|
1063
|
+
function withBranchId(branchId, cb) {
|
1064
|
+
return withContext(branchIdKey, branchId, cb);
|
1065
|
+
}
|
1066
|
+
function resumeForOf(list, cb, by, scopeId, accessor) {
|
1067
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1068
|
+
forOf(list, (item, index) => {
|
1070
1069
|
let branchId = peekNextScopeId();
|
1071
1070
|
$chunk.writeHTML(
|
1072
1071
|
$chunk.boundary.state.mark(
|
1073
1072
|
"[" /* BranchStart */,
|
1074
|
-
branchId + (
|
1073
|
+
branchId + (index ? " " : "")
|
1075
1074
|
)
|
1076
|
-
),
|
1075
|
+
), withBranchId(branchId, () => {
|
1076
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1077
|
+
});
|
1078
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1079
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1077
1080
|
}), $chunk.writeHTML(
|
1078
1081
|
$chunk.boundary.state.mark(
|
1079
1082
|
"]" /* BranchEnd */,
|
@@ -1081,11 +1084,15 @@ function resumeForOf(list, cb, scopeId, accessor) {
|
|
1081
1084
|
)
|
1082
1085
|
);
|
1083
1086
|
}
|
1084
|
-
function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
1085
|
-
let branchIds = "";
|
1087
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, onlyChildInParent) {
|
1088
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1086
1089
|
forOf(list, (item, index) => {
|
1087
1090
|
let branchId = peekNextScopeId();
|
1088
|
-
branchIds = " " + branchId + branchIds,
|
1091
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1092
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1093
|
+
});
|
1094
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1095
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1089
1096
|
}), $chunk.writeHTML(
|
1090
1097
|
$chunk.boundary.state.mark(
|
1091
1098
|
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1093,13 +1100,20 @@ function resumeSingleNodeForOf(list, cb, scopeId, accessor, onlyChildInParent) {
|
|
1093
1100
|
)
|
1094
1101
|
);
|
1095
1102
|
}
|
1096
|
-
function
|
1097
|
-
|
1103
|
+
function forOfBy(by, item, index) {
|
1104
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1105
|
+
}
|
1106
|
+
function resumeForIn(obj, cb, by, scopeId, accessor) {
|
1107
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1098
1108
|
forIn(obj, (key, value) => {
|
1099
1109
|
let branchId = peekNextScopeId();
|
1100
1110
|
$chunk.writeHTML(
|
1101
1111
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1102
|
-
), sep = " ",
|
1112
|
+
), sep = " ", withBranchId(branchId, () => {
|
1113
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1114
|
+
});
|
1115
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1116
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1103
1117
|
}), $chunk.writeHTML(
|
1104
1118
|
$chunk.boundary.state.mark(
|
1105
1119
|
"]" /* BranchEnd */,
|
@@ -1107,11 +1121,15 @@ function resumeForIn(obj, cb, scopeId, accessor) {
|
|
1107
1121
|
)
|
1108
1122
|
);
|
1109
1123
|
}
|
1110
|
-
function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
1111
|
-
let branchIds = "";
|
1124
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, onlyChild) {
|
1125
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1112
1126
|
forIn(obj, (key, value) => {
|
1113
1127
|
let branchId = peekNextScopeId();
|
1114
|
-
branchIds = " " + branchId + branchIds,
|
1128
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1129
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1130
|
+
});
|
1131
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1132
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1115
1133
|
}), $chunk.writeHTML(
|
1116
1134
|
$chunk.boundary.state.mark(
|
1117
1135
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1119,13 +1137,20 @@ function resumeSingleNodeForIn(obj, cb, scopeId, accessor, onlyChild) {
|
|
1119
1137
|
)
|
1120
1138
|
);
|
1121
1139
|
}
|
1122
|
-
function
|
1123
|
-
|
1140
|
+
function forInBy(by, name, value) {
|
1141
|
+
return by ? by(name, value) : name;
|
1142
|
+
}
|
1143
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor) {
|
1144
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1124
1145
|
forTo(to, from, step, (index) => {
|
1125
1146
|
let branchId = peekNextScopeId();
|
1126
1147
|
$chunk.writeHTML(
|
1127
1148
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1128
|
-
), sep = " ",
|
1149
|
+
), sep = " ", withBranchId(branchId, () => {
|
1150
|
+
cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
|
1151
|
+
});
|
1152
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1153
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1129
1154
|
}), $chunk.writeHTML(
|
1130
1155
|
$chunk.boundary.state.mark(
|
1131
1156
|
"]" /* BranchEnd */,
|
@@ -1133,11 +1158,15 @@ function resumeForTo(to, from, step, cb, scopeId, accessor) {
|
|
1133
1158
|
)
|
1134
1159
|
);
|
1135
1160
|
}
|
1136
|
-
function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild) {
|
1137
|
-
let branchIds = "";
|
1161
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, onlyChild) {
|
1162
|
+
let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
|
1138
1163
|
forTo(to, from, step, (index) => {
|
1139
1164
|
let branchId = peekNextScopeId();
|
1140
|
-
branchIds = " " + branchId + branchIds,
|
1165
|
+
branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
|
1166
|
+
cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
|
1167
|
+
});
|
1168
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1169
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1141
1170
|
}), $chunk.writeHTML(
|
1142
1171
|
$chunk.boundary.state.mark(
|
1143
1172
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
@@ -1145,22 +1174,31 @@ function resumeSingleNodeForTo(to, from, step, cb, scopeId, accessor, onlyChild)
|
|
1145
1174
|
)
|
1146
1175
|
);
|
1147
1176
|
}
|
1148
|
-
function
|
1177
|
+
function forToBy(by, index) {
|
1178
|
+
return by ? by(index) : index;
|
1179
|
+
}
|
1180
|
+
function resumeConditional(cb, scopeId, accessor, dynamic) {
|
1149
1181
|
let branchId = peekNextScopeId();
|
1150
|
-
$chunk.writeHTML(
|
1182
|
+
dynamic && $chunk.writeHTML(
|
1151
1183
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1152
|
-
)
|
1184
|
+
);
|
1185
|
+
let branchIndex = withBranchId(branchId, cb);
|
1186
|
+
branchIndex !== void 0 ? writeScope(scopeId, {
|
1187
|
+
["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
|
1188
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1189
|
+
}) : nextScopeId(), dynamic && $chunk.writeHTML(
|
1153
1190
|
$chunk.boundary.state.mark(
|
1154
1191
|
"]" /* BranchEnd */,
|
1155
1192
|
scopeId + " " + accessor
|
1156
1193
|
)
|
1157
1194
|
);
|
1158
1195
|
}
|
1159
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor, onlyChild) {
|
1160
|
-
let branchId = peekNextScopeId();
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1196
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, dynamic, onlyChild) {
|
1197
|
+
let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
|
1198
|
+
rendered ? writeScope(scopeId, {
|
1199
|
+
["c" /* ConditionalRenderer */ + accessor]: dynamic ? branchIndex : void 0,
|
1200
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1201
|
+
}) : nextScopeId(), dynamic && $chunk.writeHTML(
|
1164
1202
|
$chunk.boundary.state.mark(
|
1165
1203
|
onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1166
1204
|
scopeId + " " + accessor + (rendered ? " " + branchId : "")
|
@@ -1713,80 +1751,51 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1713
1751
|
var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
1714
1752
|
|
1715
1753
|
// src/html/dynamic-tag.ts
|
1716
|
-
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
}
|
1721
|
-
|
1722
|
-
|
1723
|
-
nextScopeId();
|
1724
|
-
return;
|
1725
|
-
}
|
1726
|
-
if (!tag) {
|
1727
|
-
resumeConditional(content, scopeId, accessor);
|
1728
|
-
return;
|
1729
|
-
}
|
1730
|
-
if (typeof tag == "string") {
|
1731
|
-
resumeSingleNodeConditional(
|
1732
|
-
() => {
|
1733
|
-
nextScopeId(), write(`<${tag}${attrs(input, accessor, scopeId, tag)}>`), voidElementsReg.test(tag) || (tag === "textarea" ? write(
|
1734
|
-
controllable_textarea_value(
|
1735
|
-
scopeId,
|
1736
|
-
accessor,
|
1737
|
-
input.value,
|
1738
|
-
input.valueChange
|
1739
|
-
)
|
1740
|
-
) : content && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1754
|
+
var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, dynamicTag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, resume) => {
|
1755
|
+
let renderer = normalizeDynamicRenderer(tag), chunk = getChunk(), branchId = peekNextScopeId(), result;
|
1756
|
+
if (typeof renderer == "string") {
|
1757
|
+
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1758
|
+
nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), voidElementsReg.test(renderer) || (withBranchId(branchId, () => {
|
1759
|
+
renderer === "textarea" ? write(
|
1760
|
+
controllable_textarea_value(
|
1741
1761
|
scopeId,
|
1742
1762
|
accessor,
|
1743
1763
|
input.value,
|
1744
|
-
input.valueChange
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1764
|
+
input.valueChange
|
1765
|
+
)
|
1766
|
+
) : content && (renderer === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
|
1767
|
+
scopeId,
|
1768
|
+
accessor,
|
1769
|
+
input.value,
|
1770
|
+
input.valueChange,
|
1771
|
+
content
|
1772
|
+
) : content());
|
1773
|
+
}), write(`</${renderer}>`)), resume && chunk.writeHTML(
|
1774
|
+
chunk.boundary.state.mark(
|
1775
|
+
"|" /* BranchSingleNode */,
|
1776
|
+
scopeId + " " + accessor + " " + branchId
|
1777
|
+
)
|
1750
1778
|
);
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
return;
|
1767
|
-
}
|
1768
|
-
if (typeof tag == "string") {
|
1769
|
-
resumeSingleNodeConditional(
|
1770
|
-
() => {
|
1771
|
-
nextScopeId(), write(
|
1772
|
-
`<${tag}${attrs(args[0], accessor, scopeId, tag)}>`
|
1773
|
-
), voidElementsReg.test(tag) || write(`</${tag}>`);
|
1774
|
-
},
|
1775
|
-
scopeId,
|
1776
|
-
accessor
|
1779
|
+
} else
|
1780
|
+
resume && chunk.writeHTML(
|
1781
|
+
chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1782
|
+
), result = withBranchId(branchId, () => {
|
1783
|
+
if (renderer)
|
1784
|
+
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
1785
|
+
content ? { ...inputOrArgs, content } : inputOrArgs
|
1786
|
+
);
|
1787
|
+
if (content)
|
1788
|
+
return content();
|
1789
|
+
}), resume && chunk.writeHTML(
|
1790
|
+
chunk.boundary.state.mark(
|
1791
|
+
"]" /* BranchEnd */,
|
1792
|
+
scopeId + " " + accessor
|
1793
|
+
)
|
1777
1794
|
);
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
), result;
|
1783
|
-
return resumeConditional(
|
1784
|
-
() => {
|
1785
|
-
result = renderer(...args);
|
1786
|
-
},
|
1787
|
-
scopeId,
|
1788
|
-
accessor
|
1789
|
-
), result;
|
1795
|
+
return peekNextScopeId() !== branchId ? resume && writeScope(scopeId, {
|
1796
|
+
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {}),
|
1797
|
+
["c" /* ConditionalRenderer */ + accessor]: renderer?.h || renderer
|
1798
|
+
}) : nextScopeId(), result;
|
1790
1799
|
};
|
1791
1800
|
function createContent(id, fn) {
|
1792
1801
|
return fn.h = id, fn;
|
@@ -1795,18 +1804,18 @@ function registerContent(id, fn, scopeId) {
|
|
1795
1804
|
return register2(createContent(id, fn), id, scopeId);
|
1796
1805
|
}
|
1797
1806
|
function patchDynamicTag(patch) {
|
1798
|
-
|
1799
|
-
scopeId,
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
)
|
1807
|
+
dynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (scopeId, accessor, tag, input, content, inputIsArgs, resume) => {
|
1808
|
+
let patched = patch(scopeId, accessor, tag);
|
1809
|
+
return patched.h = tag, originalDynamicTag(
|
1810
|
+
scopeId,
|
1811
|
+
accessor,
|
1812
|
+
patched,
|
1813
|
+
input,
|
1814
|
+
content,
|
1815
|
+
inputIsArgs,
|
1816
|
+
resume
|
1817
|
+
);
|
1818
|
+
})(dynamicTag);
|
1810
1819
|
}
|
1811
1820
|
|
1812
1821
|
// src/html/compat.ts
|
@@ -1881,13 +1890,13 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
1881
1890
|
};
|
1882
1891
|
|
1883
1892
|
// src/html/for.ts
|
1884
|
-
function
|
1893
|
+
function forOfBy2(by, item, index) {
|
1885
1894
|
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
1886
1895
|
}
|
1887
|
-
function
|
1896
|
+
function forInBy2(by, name, value) {
|
1888
1897
|
return by ? by(name, value) : name;
|
1889
1898
|
}
|
1890
|
-
function
|
1899
|
+
function forToBy2(by, index) {
|
1891
1900
|
return by ? by(index) : index;
|
1892
1901
|
}
|
1893
1902
|
|
@@ -2047,19 +2056,17 @@ export {
|
|
2047
2056
|
controllable_textarea_value,
|
2048
2057
|
createContent,
|
2049
2058
|
createTemplate,
|
2050
|
-
|
2051
|
-
dynamicTagId,
|
2052
|
-
dynamicTagInput,
|
2059
|
+
dynamicTag,
|
2053
2060
|
ensureScopeWithId,
|
2054
2061
|
escapeScript,
|
2055
2062
|
escapeStyle,
|
2056
2063
|
escapeXML,
|
2057
2064
|
forIn,
|
2058
|
-
forInBy,
|
2065
|
+
forInBy2 as forInBy,
|
2059
2066
|
forOf,
|
2060
|
-
forOfBy,
|
2067
|
+
forOfBy2 as forOfBy,
|
2061
2068
|
forTo,
|
2062
|
-
forToBy,
|
2069
|
+
forToBy2 as forToBy,
|
2063
2070
|
fork,
|
2064
2071
|
getScopeById,
|
2065
2072
|
hoist,
|