marko 6.0.3 → 6.0.5
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/helpers.d.ts +2 -2
- package/dist/debug/dom.js +138 -136
- package/dist/debug/dom.mjs +138 -136
- package/dist/debug/html.js +250 -237
- package/dist/debug/html.mjs +250 -237
- package/dist/dom/dom.d.ts +5 -0
- package/dist/dom/queue.d.ts +1 -0
- package/dist/dom/scope.d.ts +0 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +85 -90
- package/dist/dom.mjs +85 -90
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/writer.d.ts +8 -8
- package/dist/html.js +141 -145
- package/dist/html.mjs +141 -145
- package/dist/translator/index.js +677 -420
- package/dist/translator/util/css-px-props.d.ts +2 -0
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/visitors/program/html.d.ts +1 -1
- package/dist/translator/visitors/tag/native-tag.d.ts +2 -2
- package/package.json +2 -2
package/dist/html.mjs
CHANGED
@@ -11,39 +11,30 @@ function* attrTagIterator() {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
// src/common/helpers.ts
|
14
|
-
function classValue(
|
15
|
-
return toDelimitedString(
|
14
|
+
function classValue(classValue2) {
|
15
|
+
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
16
16
|
}
|
17
17
|
function stringifyClassObject(name, value) {
|
18
18
|
return value ? name : "";
|
19
19
|
}
|
20
|
-
function styleValue(
|
21
|
-
return toDelimitedString(
|
20
|
+
function styleValue(styleValue2) {
|
21
|
+
return toDelimitedString(styleValue2, ";", stringifyStyleObject);
|
22
22
|
}
|
23
23
|
function stringifyStyleObject(name, value) {
|
24
|
-
return value || value === 0 ? `${name}:${typeof value == "number" &&
|
24
|
+
return value || value === 0 ? `${name}:${value && typeof value == "number" && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value + "px" : value}` : "";
|
25
25
|
}
|
26
26
|
function toDelimitedString(val, delimiter, stringify) {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
for (let name in val) {
|
40
|
-
let v = val[name], part = stringify(name, v);
|
41
|
-
part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
|
42
|
-
}
|
43
|
-
return result;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
return "";
|
27
|
+
let str = "", sep = "", part;
|
28
|
+
if (val)
|
29
|
+
if (typeof val != "object")
|
30
|
+
str += val;
|
31
|
+
else if (Array.isArray(val))
|
32
|
+
for (let v of val)
|
33
|
+
part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
34
|
+
else
|
35
|
+
for (let name in val)
|
36
|
+
part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
37
|
+
return str;
|
47
38
|
}
|
48
39
|
function isEventHandler(name) {
|
49
40
|
return /^on[A-Z-]/.test(name);
|
@@ -96,6 +87,17 @@ function forTo(to, from, step, cb) {
|
|
96
87
|
cb(start + i * delta);
|
97
88
|
}
|
98
89
|
|
90
|
+
// src/html/for.ts
|
91
|
+
function forOfBy(by, item, index) {
|
92
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
93
|
+
}
|
94
|
+
function forInBy(by, name, value) {
|
95
|
+
return by ? by(name, value) : name;
|
96
|
+
}
|
97
|
+
function forToBy(by, index) {
|
98
|
+
return by ? by(index) : index;
|
99
|
+
}
|
100
|
+
|
99
101
|
// src/html/inlined-runtimes.ts
|
100
102
|
var WALKER_RUNTIME_CODE = '(e=>(self[e]=(l,t=e+l,d=t.length,f={},s=[],x=document,a=x.createTreeWalker(x,129))=>self[e][l]={i:t,d:x,l:f,v:s,x(){},w(e,l,x){for(;e=a.nextNode();)this.x(l=(l=e.data)&&!l.indexOf(t)&&(f[x=l.slice(d+1)]=e,l[d]),x,e),l>"#"&&s.push(e)}},self[e]))', REORDER_RUNTIME_CODE = '(e=>{let i,l,t,r={},c=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(d,o,n,a,g)=>{"#"==d?(r[o]=l).i++:n==t&&i(),"T"==n.tagName&&(o=n.getAttribute(e.i))&&((a=e.l["^"+o])&&(r[o]={i:1,c(i=e.l[o]||n){for(;(t=i.previousSibling||a).remove(),a!=t;);c(i,n)}}),t=n.nextSibling,l=r[o],i=()=>{a||c(e.l[o],n),--l.i||l.c()},(d=e.j[o])&&(g=l.c,l.c=()=>g()+d(e.r)))}})';
|
101
103
|
|
@@ -1088,161 +1090,166 @@ var branchIdKey = Symbol();
|
|
1088
1090
|
function withBranchId(branchId, cb) {
|
1089
1091
|
return withContext(branchIdKey, branchId, cb);
|
1090
1092
|
}
|
1091
|
-
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1093
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1094
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1095
|
+
if (resumeBranch) {
|
1096
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1097
|
+
forOf(list, (item, index) => {
|
1098
|
+
let branchId = peekNextScopeId();
|
1099
|
+
resumeMarker && $chunk.writeHTML(
|
1100
|
+
$chunk.boundary.state.mark(
|
1101
|
+
"[" /* BranchStart */,
|
1102
|
+
branchId + (index ? " " : "")
|
1103
|
+
)
|
1104
|
+
), withBranchId(branchId, () => {
|
1105
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1106
|
+
});
|
1107
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1108
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1104
1109
|
});
|
1105
|
-
}
|
1106
|
-
|
1107
|
-
|
1110
|
+
} else
|
1111
|
+
forOf(list, cb);
|
1112
|
+
resumeMarker && $chunk.writeHTML(
|
1108
1113
|
$chunk.boundary.state.mark(
|
1109
1114
|
"]" /* BranchEnd */,
|
1110
1115
|
scopeId + " " + accessor
|
1111
1116
|
)
|
1112
1117
|
);
|
1113
1118
|
}
|
1114
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1119
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1120
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1121
|
+
if (resumeBranch) {
|
1122
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1123
|
+
forOf(list, (item, index) => {
|
1124
|
+
let branchId = peekNextScopeId();
|
1125
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1126
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1127
|
+
});
|
1128
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1129
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1122
1130
|
});
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
|
1131
|
+
} else
|
1132
|
+
forOf(list, cb);
|
1133
|
+
resumeMarker && $chunk.writeHTML(
|
1126
1134
|
$chunk.boundary.state.mark(
|
1127
1135
|
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1128
1136
|
scopeId + " " + accessor + branchIds
|
1129
1137
|
)
|
1130
1138
|
);
|
1131
1139
|
}
|
1132
|
-
function
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
),
|
1144
|
-
|
1140
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1141
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1142
|
+
if (resumeBranch) {
|
1143
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1144
|
+
forIn(obj, (key, value) => {
|
1145
|
+
let branchId = peekNextScopeId();
|
1146
|
+
resumeMarker && ($chunk.writeHTML(
|
1147
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1148
|
+
), sep = " "), withBranchId(branchId, () => {
|
1149
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1150
|
+
});
|
1151
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1152
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1145
1153
|
});
|
1146
|
-
}
|
1147
|
-
|
1148
|
-
|
1154
|
+
} else
|
1155
|
+
forIn(obj, cb);
|
1156
|
+
resumeMarker && $chunk.writeHTML(
|
1149
1157
|
$chunk.boundary.state.mark(
|
1150
1158
|
"]" /* BranchEnd */,
|
1151
1159
|
scopeId + " " + accessor
|
1152
1160
|
)
|
1153
1161
|
);
|
1154
1162
|
}
|
1155
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch,
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1164
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1165
|
+
if (resumeBranch) {
|
1166
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1167
|
+
forIn(obj, (key, value) => {
|
1168
|
+
let branchId = peekNextScopeId();
|
1169
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1170
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1171
|
+
});
|
1172
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1173
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1163
1174
|
});
|
1164
|
-
}
|
1165
|
-
|
1166
|
-
|
1175
|
+
} else
|
1176
|
+
forIn(obj, cb);
|
1177
|
+
resumeMarker && $chunk.writeHTML(
|
1167
1178
|
$chunk.boundary.state.mark(
|
1168
|
-
|
1179
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1169
1180
|
scopeId + " " + accessor + branchIds
|
1170
1181
|
)
|
1171
1182
|
);
|
1172
1183
|
}
|
1173
|
-
function
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
),
|
1185
|
-
|
1184
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1185
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1186
|
+
if (resumeBranch) {
|
1187
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1188
|
+
forTo(to, from, step, (i) => {
|
1189
|
+
let branchId = peekNextScopeId();
|
1190
|
+
resumeMarker && ($chunk.writeHTML(
|
1191
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1192
|
+
), sep = " "), withBranchId(branchId, () => {
|
1193
|
+
cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
|
1194
|
+
});
|
1195
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1196
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1186
1197
|
});
|
1187
|
-
}
|
1188
|
-
|
1189
|
-
|
1198
|
+
} else
|
1199
|
+
forTo(to, from, step, cb);
|
1200
|
+
resumeMarker && $chunk.writeHTML(
|
1190
1201
|
$chunk.boundary.state.mark(
|
1191
1202
|
"]" /* BranchEnd */,
|
1192
1203
|
scopeId + " " + accessor
|
1193
1204
|
)
|
1194
1205
|
);
|
1195
1206
|
}
|
1196
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch,
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1207
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1208
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1209
|
+
if (resumeBranch) {
|
1210
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1211
|
+
forTo(to, from, step, (i) => {
|
1212
|
+
let branchId = peekNextScopeId();
|
1213
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1214
|
+
cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
|
1215
|
+
});
|
1216
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1217
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1204
1218
|
});
|
1205
|
-
}
|
1206
|
-
|
1207
|
-
|
1219
|
+
} else
|
1220
|
+
forTo(to, from, step, cb);
|
1221
|
+
resumeMarker && $chunk.writeHTML(
|
1208
1222
|
$chunk.boundary.state.mark(
|
1209
|
-
|
1223
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1210
1224
|
scopeId + " " + accessor + branchIds
|
1211
1225
|
)
|
1212
1226
|
);
|
1213
1227
|
}
|
1214
|
-
function forToBy(by, index) {
|
1215
|
-
return by ? by(index) : index;
|
1216
|
-
}
|
1217
1228
|
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1218
|
-
|
1219
|
-
|
1220
|
-
let branchId = peekNextScopeId();
|
1221
|
-
serializeMarker && $chunk.writeHTML(
|
1229
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId();
|
1230
|
+
resumeMarker && resumeBranch && $chunk.writeHTML(
|
1222
1231
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1223
1232
|
);
|
1224
|
-
let branchIndex = withBranchId(branchId, cb);
|
1225
|
-
branchIndex !== void 0
|
1226
|
-
["c" /* ConditionalRenderer */ + accessor]:
|
1233
|
+
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
1234
|
+
resumeBranch && branchIndex !== void 0 && writeScope(scopeId, {
|
1235
|
+
["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
|
1227
1236
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1228
|
-
})
|
1237
|
+
}), resumeMarker && $chunk.writeHTML(
|
1229
1238
|
$chunk.boundary.state.mark(
|
1230
1239
|
"]" /* BranchEnd */,
|
1231
1240
|
scopeId + " " + accessor
|
1232
1241
|
)
|
1233
1242
|
);
|
1234
1243
|
}
|
1235
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker,
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
rendered ? writeScope(scopeId, {
|
1240
|
-
["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1244
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1245
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId(), branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
1246
|
+
shouldWriteBranch && writeScope(scopeId, {
|
1247
|
+
["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
|
1241
1248
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1242
|
-
})
|
1249
|
+
}), resumeMarker && $chunk.writeHTML(
|
1243
1250
|
$chunk.boundary.state.mark(
|
1244
|
-
|
1245
|
-
scopeId + " " + accessor + (
|
1251
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1252
|
+
scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
|
1246
1253
|
)
|
1247
1254
|
);
|
1248
1255
|
}
|
@@ -1943,8 +1950,8 @@ function NOOP2() {
|
|
1943
1950
|
}
|
1944
1951
|
|
1945
1952
|
// src/html/dynamic-tag.ts
|
1946
|
-
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,
|
1947
|
-
let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
|
1953
|
+
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, serializeReason) => {
|
1954
|
+
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
|
1948
1955
|
if (typeof renderer == "string") {
|
1949
1956
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1950
1957
|
if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
@@ -1980,7 +1987,7 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
|
|
1980
1987
|
let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
|
1981
1988
|
return renderer(
|
1982
1989
|
content ? { ...input, content } : input,
|
1983
|
-
shouldResume
|
1990
|
+
shouldResume ? 1 : 0
|
1984
1991
|
);
|
1985
1992
|
}
|
1986
1993
|
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
@@ -2089,17 +2096,6 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
2089
2096
|
register(RENDER_BODY_ID, fn);
|
2090
2097
|
}
|
2091
2098
|
};
|
2092
|
-
|
2093
|
-
// src/html/for.ts
|
2094
|
-
function forOfBy2(by, item, index) {
|
2095
|
-
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
2096
|
-
}
|
2097
|
-
function forInBy2(by, name, value) {
|
2098
|
-
return by ? by(name, value) : name;
|
2099
|
-
}
|
2100
|
-
function forToBy2(by, index) {
|
2101
|
-
return by ? by(index) : index;
|
2102
|
-
}
|
2103
2099
|
export {
|
2104
2100
|
$global,
|
2105
2101
|
attr,
|
@@ -2123,11 +2119,11 @@ export {
|
|
2123
2119
|
escapeStyle,
|
2124
2120
|
escapeXML,
|
2125
2121
|
forIn,
|
2126
|
-
|
2122
|
+
forInBy,
|
2127
2123
|
forOf,
|
2128
|
-
|
2124
|
+
forOfBy,
|
2129
2125
|
forTo,
|
2130
|
-
|
2126
|
+
forToBy,
|
2131
2127
|
fork,
|
2132
2128
|
getScopeById,
|
2133
2129
|
hoist,
|