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/html.js CHANGED
@@ -39,11 +39,11 @@ __export(html_exports, {
39
39
  escapeStyle: () => escapeStyle,
40
40
  escapeXML: () => escapeXML,
41
41
  forIn: () => forIn,
42
- forInBy: () => forInBy2,
42
+ forInBy: () => forInBy,
43
43
  forOf: () => forOf,
44
- forOfBy: () => forOfBy2,
44
+ forOfBy: () => forOfBy,
45
45
  forTo: () => forTo,
46
- forToBy: () => forToBy2,
46
+ forToBy: () => forToBy,
47
47
  fork: () => fork,
48
48
  getScopeById: () => getScopeById,
49
49
  hoist: () => hoist,
@@ -178,6 +178,17 @@ function forTo(to, from, step, cb) {
178
178
  cb(start + i * delta);
179
179
  }
180
180
 
181
+ // src/html/for.ts
182
+ function forOfBy(by, item, index) {
183
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
184
+ }
185
+ function forInBy(by, name, value) {
186
+ return by ? by(name, value) : name;
187
+ }
188
+ function forToBy(by, index) {
189
+ return by ? by(index) : index;
190
+ }
191
+
181
192
  // src/html/inlined-runtimes.ts
182
193
  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)))}})';
183
194
 
@@ -1170,161 +1181,166 @@ var branchIdKey = Symbol();
1170
1181
  function withBranchId(branchId, cb) {
1171
1182
  return withContext(branchIdKey, branchId, cb);
1172
1183
  }
1173
- function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch) {
1174
- if (serializeBranch === 0)
1175
- return forOf(list, cb);
1176
- let loopScopes = /* @__PURE__ */ new Map();
1177
- forOf(list, (item, index) => {
1178
- let branchId = peekNextScopeId();
1179
- $chunk.writeHTML(
1180
- $chunk.boundary.state.mark(
1181
- "[" /* BranchStart */,
1182
- branchId + (index ? " " : "")
1183
- )
1184
- ), withBranchId(branchId, () => {
1185
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1184
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1185
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1186
+ if (resumeBranch) {
1187
+ let loopScopes = /* @__PURE__ */ new Map();
1188
+ forOf(list, (item, index) => {
1189
+ let branchId = peekNextScopeId();
1190
+ resumeMarker && $chunk.writeHTML(
1191
+ $chunk.boundary.state.mark(
1192
+ "[" /* BranchStart */,
1193
+ branchId + (index ? " " : "")
1194
+ )
1195
+ ), withBranchId(branchId, () => {
1196
+ cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1197
+ });
1198
+ }), loopScopes.size && writeScope(scopeId, {
1199
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1186
1200
  });
1187
- }), loopScopes.size && writeScope(scopeId, {
1188
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1189
- }), $chunk.writeHTML(
1201
+ } else
1202
+ forOf(list, cb);
1203
+ resumeMarker && $chunk.writeHTML(
1190
1204
  $chunk.boundary.state.mark(
1191
1205
  "]" /* BranchEnd */,
1192
1206
  scopeId + " " + accessor
1193
1207
  )
1194
1208
  );
1195
1209
  }
1196
- function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, onlyChildInParent) {
1197
- if (serializeBranch === 0)
1198
- return forOf(list, cb);
1199
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1200
- forOf(list, (item, index) => {
1201
- let branchId = peekNextScopeId();
1202
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1203
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1210
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1211
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1212
+ if (resumeBranch) {
1213
+ let loopScopes = /* @__PURE__ */ new Map();
1214
+ forOf(list, (item, index) => {
1215
+ let branchId = peekNextScopeId();
1216
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1217
+ cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1218
+ });
1219
+ }), loopScopes.size && writeScope(scopeId, {
1220
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1204
1221
  });
1205
- }), loopScopes.size && writeScope(scopeId, {
1206
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1207
- }), $chunk.writeHTML(
1222
+ } else
1223
+ forOf(list, cb);
1224
+ resumeMarker && $chunk.writeHTML(
1208
1225
  $chunk.boundary.state.mark(
1209
1226
  onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1210
1227
  scopeId + " " + accessor + branchIds
1211
1228
  )
1212
1229
  );
1213
1230
  }
1214
- function forOfBy(by, item, index) {
1215
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1216
- }
1217
- function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1218
- if (serializeBranch === 0)
1219
- return forIn(obj, cb);
1220
- let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1221
- forIn(obj, (key, value) => {
1222
- let branchId = peekNextScopeId();
1223
- $chunk.writeHTML(
1224
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1225
- ), sep = " ", withBranchId(branchId, () => {
1226
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1231
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1232
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1233
+ if (resumeBranch) {
1234
+ let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1235
+ forIn(obj, (key, value) => {
1236
+ let branchId = peekNextScopeId();
1237
+ resumeMarker && ($chunk.writeHTML(
1238
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1239
+ ), sep = " "), withBranchId(branchId, () => {
1240
+ cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1241
+ });
1242
+ }), loopScopes.size && writeScope(scopeId, {
1243
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1227
1244
  });
1228
- }), loopScopes.size && writeScope(scopeId, {
1229
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1230
- }), $chunk.writeHTML(
1245
+ } else
1246
+ forIn(obj, cb);
1247
+ resumeMarker && $chunk.writeHTML(
1231
1248
  $chunk.boundary.state.mark(
1232
1249
  "]" /* BranchEnd */,
1233
1250
  scopeId + " " + accessor
1234
1251
  )
1235
1252
  );
1236
1253
  }
1237
- function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1238
- if (serializeBranch === 0)
1239
- return forIn(obj, cb);
1240
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1241
- forIn(obj, (key, value) => {
1242
- let branchId = peekNextScopeId();
1243
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1244
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1254
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1255
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1256
+ if (resumeBranch) {
1257
+ let loopScopes = /* @__PURE__ */ new Map();
1258
+ forIn(obj, (key, value) => {
1259
+ let branchId = peekNextScopeId();
1260
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1261
+ cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1262
+ });
1263
+ }), loopScopes.size && writeScope(scopeId, {
1264
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1245
1265
  });
1246
- }), loopScopes.size && writeScope(scopeId, {
1247
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1248
- }), $chunk.writeHTML(
1266
+ } else
1267
+ forIn(obj, cb);
1268
+ resumeMarker && $chunk.writeHTML(
1249
1269
  $chunk.boundary.state.mark(
1250
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1270
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1251
1271
  scopeId + " " + accessor + branchIds
1252
1272
  )
1253
1273
  );
1254
1274
  }
1255
- function forInBy(by, name, value) {
1256
- return by ? by(name, value) : name;
1257
- }
1258
- function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1259
- if (serializeBranch === 0)
1260
- return forTo(to, from, step, cb);
1261
- let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1262
- forTo(to, from, step, (index) => {
1263
- let branchId = peekNextScopeId();
1264
- $chunk.writeHTML(
1265
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1266
- ), sep = " ", withBranchId(branchId, () => {
1267
- cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1275
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1276
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1277
+ if (resumeBranch) {
1278
+ let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1279
+ forTo(to, from, step, (i) => {
1280
+ let branchId = peekNextScopeId();
1281
+ resumeMarker && ($chunk.writeHTML(
1282
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1283
+ ), sep = " "), withBranchId(branchId, () => {
1284
+ cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1285
+ });
1286
+ }), loopScopes.size && writeScope(scopeId, {
1287
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1268
1288
  });
1269
- }), loopScopes.size && writeScope(scopeId, {
1270
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1271
- }), $chunk.writeHTML(
1289
+ } else
1290
+ forTo(to, from, step, cb);
1291
+ resumeMarker && $chunk.writeHTML(
1272
1292
  $chunk.boundary.state.mark(
1273
1293
  "]" /* BranchEnd */,
1274
1294
  scopeId + " " + accessor
1275
1295
  )
1276
1296
  );
1277
1297
  }
1278
- function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, onlyChild) {
1279
- if (serializeBranch === 0)
1280
- return forTo(to, from, step, cb);
1281
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1282
- forTo(to, from, step, (index) => {
1283
- let branchId = peekNextScopeId();
1284
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1285
- cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
1298
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1299
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1300
+ if (resumeBranch) {
1301
+ let loopScopes = /* @__PURE__ */ new Map();
1302
+ forTo(to, from, step, (i) => {
1303
+ let branchId = peekNextScopeId();
1304
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1305
+ cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1306
+ });
1307
+ }), loopScopes.size && writeScope(scopeId, {
1308
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1286
1309
  });
1287
- }), loopScopes.size && writeScope(scopeId, {
1288
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1289
- }), $chunk.writeHTML(
1310
+ } else
1311
+ forTo(to, from, step, cb);
1312
+ resumeMarker && $chunk.writeHTML(
1290
1313
  $chunk.boundary.state.mark(
1291
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1314
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1292
1315
  scopeId + " " + accessor + branchIds
1293
1316
  )
1294
1317
  );
1295
1318
  }
1296
- function forToBy(by, index) {
1297
- return by ? by(index) : index;
1298
- }
1299
1319
  function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1300
- if (serializeBranch === 0)
1301
- return cb();
1302
- let branchId = peekNextScopeId();
1303
- serializeMarker && $chunk.writeHTML(
1320
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId();
1321
+ resumeMarker && resumeBranch && $chunk.writeHTML(
1304
1322
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1305
1323
  );
1306
- let branchIndex = withBranchId(branchId, cb);
1307
- branchIndex !== void 0 ? writeScope(scopeId, {
1308
- ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1324
+ let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1325
+ resumeBranch && branchIndex !== void 0 && writeScope(scopeId, {
1326
+ ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1309
1327
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1310
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1328
+ }), resumeMarker && $chunk.writeHTML(
1311
1329
  $chunk.boundary.state.mark(
1312
1330
  "]" /* BranchEnd */,
1313
1331
  scopeId + " " + accessor
1314
1332
  )
1315
1333
  );
1316
1334
  }
1317
- function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChild) {
1318
- if (serializeBranch === 0)
1319
- return cb();
1320
- let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
1321
- rendered ? writeScope(scopeId, {
1322
- ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1335
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1336
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId(), branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1337
+ shouldWriteBranch && writeScope(scopeId, {
1338
+ ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1323
1339
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1324
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1340
+ }), resumeMarker && $chunk.writeHTML(
1325
1341
  $chunk.boundary.state.mark(
1326
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1327
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
1342
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1343
+ scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1328
1344
  )
1329
1345
  );
1330
1346
  }
@@ -2025,8 +2041,8 @@ function NOOP2() {
2025
2041
  }
2026
2042
 
2027
2043
  // src/html/dynamic-tag.ts
2028
- 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, shouldResume) => {
2029
- let renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
2044
+ 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) => {
2045
+ let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
2030
2046
  if (typeof renderer == "string") {
2031
2047
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2032
2048
  if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
@@ -2062,7 +2078,7 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
2062
2078
  let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
2063
2079
  return renderer(
2064
2080
  content ? { ...input, content } : input,
2065
- shouldResume
2081
+ shouldResume ? 1 : 0
2066
2082
  );
2067
2083
  }
2068
2084
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
@@ -2171,17 +2187,6 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2171
2187
  register(RENDER_BODY_ID, fn);
2172
2188
  }
2173
2189
  };
2174
-
2175
- // src/html/for.ts
2176
- function forOfBy2(by, item, index) {
2177
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
2178
- }
2179
- function forInBy2(by, name, value) {
2180
- return by ? by(name, value) : name;
2181
- }
2182
- function forToBy2(by, index) {
2183
- return by ? by(index) : index;
2184
- }
2185
2190
  // Annotate the CommonJS export names for ESM import in node:
2186
2191
  0 && (module.exports = {
2187
2192
  $global,