marko 6.0.3 → 6.0.4
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/html.js +223 -206
- package/dist/debug/html.mjs +223 -206
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/writer.d.ts +8 -8
- package/dist/html.js +125 -120
- package/dist/html.mjs +125 -120
- package/dist/translator/index.js +104 -81
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/visitors/program/html.d.ts +1 -1
- package/package.json +2 -2
package/dist/html.mjs
CHANGED
@@ -96,6 +96,17 @@ function forTo(to, from, step, cb) {
|
|
96
96
|
cb(start + i * delta);
|
97
97
|
}
|
98
98
|
|
99
|
+
// src/html/for.ts
|
100
|
+
function forOfBy(by, item, index) {
|
101
|
+
return by ? typeof by == "string" ? item[by] : by(item, index) : index;
|
102
|
+
}
|
103
|
+
function forInBy(by, name, value) {
|
104
|
+
return by ? by(name, value) : name;
|
105
|
+
}
|
106
|
+
function forToBy(by, index) {
|
107
|
+
return by ? by(index) : index;
|
108
|
+
}
|
109
|
+
|
99
110
|
// src/html/inlined-runtimes.ts
|
100
111
|
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
112
|
|
@@ -1088,161 +1099,166 @@ var branchIdKey = Symbol();
|
|
1088
1099
|
function withBranchId(branchId, cb) {
|
1089
1100
|
return withContext(branchIdKey, branchId, cb);
|
1090
1101
|
}
|
1091
|
-
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1102
|
+
function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1103
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1104
|
+
if (resumeBranch) {
|
1105
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1106
|
+
forOf(list, (item, index) => {
|
1107
|
+
let branchId = peekNextScopeId();
|
1108
|
+
resumeMarker && $chunk.writeHTML(
|
1109
|
+
$chunk.boundary.state.mark(
|
1110
|
+
"[" /* BranchStart */,
|
1111
|
+
branchId + (index ? " " : "")
|
1112
|
+
)
|
1113
|
+
), withBranchId(branchId, () => {
|
1114
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1115
|
+
});
|
1116
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1117
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1104
1118
|
});
|
1105
|
-
}
|
1106
|
-
|
1107
|
-
|
1119
|
+
} else
|
1120
|
+
forOf(list, cb);
|
1121
|
+
resumeMarker && $chunk.writeHTML(
|
1108
1122
|
$chunk.boundary.state.mark(
|
1109
1123
|
"]" /* BranchEnd */,
|
1110
1124
|
scopeId + " " + accessor
|
1111
1125
|
)
|
1112
1126
|
);
|
1113
1127
|
}
|
1114
|
-
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1128
|
+
function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1129
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1130
|
+
if (resumeBranch) {
|
1131
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1132
|
+
forOf(list, (item, index) => {
|
1133
|
+
let branchId = peekNextScopeId();
|
1134
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1135
|
+
cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
|
1136
|
+
});
|
1137
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1138
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1122
1139
|
});
|
1123
|
-
}
|
1124
|
-
|
1125
|
-
|
1140
|
+
} else
|
1141
|
+
forOf(list, cb);
|
1142
|
+
resumeMarker && $chunk.writeHTML(
|
1126
1143
|
$chunk.boundary.state.mark(
|
1127
1144
|
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1128
1145
|
scopeId + " " + accessor + branchIds
|
1129
1146
|
)
|
1130
1147
|
);
|
1131
1148
|
}
|
1132
|
-
function
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
),
|
1144
|
-
|
1149
|
+
function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1150
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1151
|
+
if (resumeBranch) {
|
1152
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1153
|
+
forIn(obj, (key, value) => {
|
1154
|
+
let branchId = peekNextScopeId();
|
1155
|
+
resumeMarker && ($chunk.writeHTML(
|
1156
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1157
|
+
), sep = " "), withBranchId(branchId, () => {
|
1158
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1159
|
+
});
|
1160
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1161
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1145
1162
|
});
|
1146
|
-
}
|
1147
|
-
|
1148
|
-
|
1163
|
+
} else
|
1164
|
+
forIn(obj, cb);
|
1165
|
+
resumeMarker && $chunk.writeHTML(
|
1149
1166
|
$chunk.boundary.state.mark(
|
1150
1167
|
"]" /* BranchEnd */,
|
1151
1168
|
scopeId + " " + accessor
|
1152
1169
|
)
|
1153
1170
|
);
|
1154
1171
|
}
|
1155
|
-
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch,
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1172
|
+
function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1173
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1174
|
+
if (resumeBranch) {
|
1175
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1176
|
+
forIn(obj, (key, value) => {
|
1177
|
+
let branchId = peekNextScopeId();
|
1178
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1179
|
+
cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
|
1180
|
+
});
|
1181
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1182
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1163
1183
|
});
|
1164
|
-
}
|
1165
|
-
|
1166
|
-
|
1184
|
+
} else
|
1185
|
+
forIn(obj, cb);
|
1186
|
+
resumeMarker && $chunk.writeHTML(
|
1167
1187
|
$chunk.boundary.state.mark(
|
1168
|
-
|
1188
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1169
1189
|
scopeId + " " + accessor + branchIds
|
1170
1190
|
)
|
1171
1191
|
);
|
1172
1192
|
}
|
1173
|
-
function
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
),
|
1185
|
-
|
1193
|
+
function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
|
1194
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
|
1195
|
+
if (resumeBranch) {
|
1196
|
+
let loopScopes = /* @__PURE__ */ new Map(), sep = "";
|
1197
|
+
forTo(to, from, step, (i) => {
|
1198
|
+
let branchId = peekNextScopeId();
|
1199
|
+
resumeMarker && ($chunk.writeHTML(
|
1200
|
+
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
|
1201
|
+
), sep = " "), withBranchId(branchId, () => {
|
1202
|
+
cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
|
1203
|
+
});
|
1204
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1205
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1186
1206
|
});
|
1187
|
-
}
|
1188
|
-
|
1189
|
-
|
1207
|
+
} else
|
1208
|
+
forTo(to, from, step, cb);
|
1209
|
+
resumeMarker && $chunk.writeHTML(
|
1190
1210
|
$chunk.boundary.state.mark(
|
1191
1211
|
"]" /* BranchEnd */,
|
1192
1212
|
scopeId + " " + accessor
|
1193
1213
|
)
|
1194
1214
|
);
|
1195
1215
|
}
|
1196
|
-
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch,
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1216
|
+
function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1217
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
|
1218
|
+
if (resumeBranch) {
|
1219
|
+
let loopScopes = /* @__PURE__ */ new Map();
|
1220
|
+
forTo(to, from, step, (i) => {
|
1221
|
+
let branchId = peekNextScopeId();
|
1222
|
+
resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
|
1223
|
+
cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
|
1224
|
+
});
|
1225
|
+
}), loopScopes.size && writeScope(scopeId, {
|
1226
|
+
["m" /* LoopScopeMap */ + accessor]: loopScopes
|
1204
1227
|
});
|
1205
|
-
}
|
1206
|
-
|
1207
|
-
|
1228
|
+
} else
|
1229
|
+
forTo(to, from, step, cb);
|
1230
|
+
resumeMarker && $chunk.writeHTML(
|
1208
1231
|
$chunk.boundary.state.mark(
|
1209
|
-
|
1232
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1210
1233
|
scopeId + " " + accessor + branchIds
|
1211
1234
|
)
|
1212
1235
|
);
|
1213
1236
|
}
|
1214
|
-
function forToBy(by, index) {
|
1215
|
-
return by ? by(index) : index;
|
1216
|
-
}
|
1217
1237
|
function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
|
1218
|
-
|
1219
|
-
|
1220
|
-
let branchId = peekNextScopeId();
|
1221
|
-
serializeMarker && $chunk.writeHTML(
|
1238
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId();
|
1239
|
+
resumeMarker && resumeBranch && $chunk.writeHTML(
|
1222
1240
|
$chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
|
1223
1241
|
);
|
1224
|
-
let branchIndex = withBranchId(branchId, cb);
|
1225
|
-
branchIndex !== void 0
|
1226
|
-
["c" /* ConditionalRenderer */ + accessor]:
|
1242
|
+
let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
|
1243
|
+
resumeBranch && branchIndex !== void 0 && writeScope(scopeId, {
|
1244
|
+
["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
|
1227
1245
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1228
|
-
})
|
1246
|
+
}), resumeMarker && $chunk.writeHTML(
|
1229
1247
|
$chunk.boundary.state.mark(
|
1230
1248
|
"]" /* BranchEnd */,
|
1231
1249
|
scopeId + " " + accessor
|
1232
1250
|
)
|
1233
1251
|
);
|
1234
1252
|
}
|
1235
|
-
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker,
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
rendered ? writeScope(scopeId, {
|
1240
|
-
["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
|
1253
|
+
function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
|
1254
|
+
let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId(), branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
|
1255
|
+
shouldWriteBranch && writeScope(scopeId, {
|
1256
|
+
["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
|
1241
1257
|
["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
|
1242
|
-
})
|
1258
|
+
}), resumeMarker && $chunk.writeHTML(
|
1243
1259
|
$chunk.boundary.state.mark(
|
1244
|
-
|
1245
|
-
scopeId + " " + accessor + (
|
1260
|
+
onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
|
1261
|
+
scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
|
1246
1262
|
)
|
1247
1263
|
);
|
1248
1264
|
}
|
@@ -1943,8 +1959,8 @@ function NOOP2() {
|
|
1943
1959
|
}
|
1944
1960
|
|
1945
1961
|
// 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;
|
1962
|
+
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) => {
|
1963
|
+
let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
|
1948
1964
|
if (typeof renderer == "string") {
|
1949
1965
|
let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
1950
1966
|
if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
|
@@ -1980,7 +1996,7 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
|
|
1980
1996
|
let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
|
1981
1997
|
return renderer(
|
1982
1998
|
content ? { ...input, content } : input,
|
1983
|
-
shouldResume
|
1999
|
+
shouldResume ? 1 : 0
|
1984
2000
|
);
|
1985
2001
|
}
|
1986
2002
|
return inputIsArgs ? renderer(...inputOrArgs) : renderer(
|
@@ -2089,17 +2105,6 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
|
|
2089
2105
|
register(RENDER_BODY_ID, fn);
|
2090
2106
|
}
|
2091
2107
|
};
|
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
2108
|
export {
|
2104
2109
|
$global,
|
2105
2110
|
attr,
|
@@ -2123,11 +2128,11 @@ export {
|
|
2123
2128
|
escapeStyle,
|
2124
2129
|
escapeXML,
|
2125
2130
|
forIn,
|
2126
|
-
|
2131
|
+
forInBy,
|
2127
2132
|
forOf,
|
2128
|
-
|
2133
|
+
forOfBy,
|
2129
2134
|
forTo,
|
2130
|
-
|
2135
|
+
forToBy,
|
2131
2136
|
fork,
|
2132
2137
|
getScopeById,
|
2133
2138
|
hoist,
|