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/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,
@@ -93,39 +93,30 @@ function* attrTagIterator() {
93
93
  }
94
94
 
95
95
  // src/common/helpers.ts
96
- function classValue(value) {
97
- return toDelimitedString(value, " ", stringifyClassObject);
96
+ function classValue(classValue2) {
97
+ return toDelimitedString(classValue2, " ", stringifyClassObject);
98
98
  }
99
99
  function stringifyClassObject(name, value) {
100
100
  return value ? name : "";
101
101
  }
102
- function styleValue(value) {
103
- return toDelimitedString(value, ";", stringifyStyleObject);
102
+ function styleValue(styleValue2) {
103
+ return toDelimitedString(styleValue2, ";", stringifyStyleObject);
104
104
  }
105
105
  function stringifyStyleObject(name, value) {
106
- return value || value === 0 ? `${name}:${typeof value == "number" && value && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value + "px" : value}` : "";
106
+ 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}` : "";
107
107
  }
108
108
  function toDelimitedString(val, delimiter, stringify) {
109
- switch (typeof val) {
110
- case "string":
111
- return val;
112
- case "object":
113
- if (val !== null) {
114
- let result = "", curDelimiter = "";
115
- if (Array.isArray(val))
116
- for (let v of val) {
117
- let part = toDelimitedString(v, delimiter, stringify);
118
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
119
- }
120
- else
121
- for (let name in val) {
122
- let v = val[name], part = stringify(name, v);
123
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
124
- }
125
- return result;
126
- }
127
- }
128
- return "";
109
+ let str = "", sep = "", part;
110
+ if (val)
111
+ if (typeof val != "object")
112
+ str += val;
113
+ else if (Array.isArray(val))
114
+ for (let v of val)
115
+ part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
116
+ else
117
+ for (let name in val)
118
+ part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
119
+ return str;
129
120
  }
130
121
  function isEventHandler(name) {
131
122
  return /^on[A-Z-]/.test(name);
@@ -178,6 +169,17 @@ function forTo(to, from, step, cb) {
178
169
  cb(start + i * delta);
179
170
  }
180
171
 
172
+ // src/html/for.ts
173
+ function forOfBy(by, item, index) {
174
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
175
+ }
176
+ function forInBy(by, name, value) {
177
+ return by ? by(name, value) : name;
178
+ }
179
+ function forToBy(by, index) {
180
+ return by ? by(index) : index;
181
+ }
182
+
181
183
  // src/html/inlined-runtimes.ts
182
184
  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
185
 
@@ -1170,161 +1172,166 @@ var branchIdKey = Symbol();
1170
1172
  function withBranchId(branchId, cb) {
1171
1173
  return withContext(branchIdKey, branchId, cb);
1172
1174
  }
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, {}));
1175
+ function resumeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1176
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1177
+ if (resumeBranch) {
1178
+ let loopScopes = /* @__PURE__ */ new Map();
1179
+ forOf(list, (item, index) => {
1180
+ let branchId = peekNextScopeId();
1181
+ resumeMarker && $chunk.writeHTML(
1182
+ $chunk.boundary.state.mark(
1183
+ "[" /* BranchStart */,
1184
+ branchId + (index ? " " : "")
1185
+ )
1186
+ ), withBranchId(branchId, () => {
1187
+ cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1188
+ });
1189
+ }), loopScopes.size && writeScope(scopeId, {
1190
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1186
1191
  });
1187
- }), loopScopes.size && writeScope(scopeId, {
1188
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1189
- }), $chunk.writeHTML(
1192
+ } else
1193
+ forOf(list, cb);
1194
+ resumeMarker && $chunk.writeHTML(
1190
1195
  $chunk.boundary.state.mark(
1191
1196
  "]" /* BranchEnd */,
1192
1197
  scopeId + " " + accessor
1193
1198
  )
1194
1199
  );
1195
1200
  }
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, {}));
1201
+ function resumeSingleNodeForOf(list, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1202
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1203
+ if (resumeBranch) {
1204
+ let loopScopes = /* @__PURE__ */ new Map();
1205
+ forOf(list, (item, index) => {
1206
+ let branchId = peekNextScopeId();
1207
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1208
+ cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
1209
+ });
1210
+ }), loopScopes.size && writeScope(scopeId, {
1211
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1204
1212
  });
1205
- }), loopScopes.size && writeScope(scopeId, {
1206
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1207
- }), $chunk.writeHTML(
1213
+ } else
1214
+ forOf(list, cb);
1215
+ resumeMarker && $chunk.writeHTML(
1208
1216
  $chunk.boundary.state.mark(
1209
1217
  onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1210
1218
  scopeId + " " + accessor + branchIds
1211
1219
  )
1212
1220
  );
1213
1221
  }
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, {}));
1222
+ function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1223
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1224
+ if (resumeBranch) {
1225
+ let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1226
+ forIn(obj, (key, value) => {
1227
+ let branchId = peekNextScopeId();
1228
+ resumeMarker && ($chunk.writeHTML(
1229
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1230
+ ), sep = " "), withBranchId(branchId, () => {
1231
+ cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1232
+ });
1233
+ }), loopScopes.size && writeScope(scopeId, {
1234
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1227
1235
  });
1228
- }), loopScopes.size && writeScope(scopeId, {
1229
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1230
- }), $chunk.writeHTML(
1236
+ } else
1237
+ forIn(obj, cb);
1238
+ resumeMarker && $chunk.writeHTML(
1231
1239
  $chunk.boundary.state.mark(
1232
1240
  "]" /* BranchEnd */,
1233
1241
  scopeId + " " + accessor
1234
1242
  )
1235
1243
  );
1236
1244
  }
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, {}));
1245
+ function resumeSingleNodeForIn(obj, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1246
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1247
+ if (resumeBranch) {
1248
+ let loopScopes = /* @__PURE__ */ new Map();
1249
+ forIn(obj, (key, value) => {
1250
+ let branchId = peekNextScopeId();
1251
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1252
+ cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
1253
+ });
1254
+ }), loopScopes.size && writeScope(scopeId, {
1255
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1245
1256
  });
1246
- }), loopScopes.size && writeScope(scopeId, {
1247
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1248
- }), $chunk.writeHTML(
1257
+ } else
1258
+ forIn(obj, cb);
1259
+ resumeMarker && $chunk.writeHTML(
1249
1260
  $chunk.boundary.state.mark(
1250
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1261
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1251
1262
  scopeId + " " + accessor + branchIds
1252
1263
  )
1253
1264
  );
1254
1265
  }
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, {}));
1266
+ function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker) {
1267
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0;
1268
+ if (resumeBranch) {
1269
+ let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1270
+ forTo(to, from, step, (i) => {
1271
+ let branchId = peekNextScopeId();
1272
+ resumeMarker && ($chunk.writeHTML(
1273
+ $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1274
+ ), sep = " "), withBranchId(branchId, () => {
1275
+ cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1276
+ });
1277
+ }), loopScopes.size && writeScope(scopeId, {
1278
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1268
1279
  });
1269
- }), loopScopes.size && writeScope(scopeId, {
1270
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1271
- }), $chunk.writeHTML(
1280
+ } else
1281
+ forTo(to, from, step, cb);
1282
+ resumeMarker && $chunk.writeHTML(
1272
1283
  $chunk.boundary.state.mark(
1273
1284
  "]" /* BranchEnd */,
1274
1285
  scopeId + " " + accessor
1275
1286
  )
1276
1287
  );
1277
1288
  }
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, {}));
1289
+ function resumeSingleNodeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1290
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchIds = "";
1291
+ if (resumeBranch) {
1292
+ let loopScopes = /* @__PURE__ */ new Map();
1293
+ forTo(to, from, step, (i) => {
1294
+ let branchId = peekNextScopeId();
1295
+ resumeMarker && (branchIds = " " + branchId + branchIds), withBranchId(branchId, () => {
1296
+ cb(i), loopScopes.set(forToBy(by, i), writeScope(branchId, {}));
1297
+ });
1298
+ }), loopScopes.size && writeScope(scopeId, {
1299
+ ["m" /* LoopScopeMap */ + accessor]: loopScopes
1286
1300
  });
1287
- }), loopScopes.size && writeScope(scopeId, {
1288
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1289
- }), $chunk.writeHTML(
1301
+ } else
1302
+ forTo(to, from, step, cb);
1303
+ resumeMarker && $chunk.writeHTML(
1290
1304
  $chunk.boundary.state.mark(
1291
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1305
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1292
1306
  scopeId + " " + accessor + branchIds
1293
1307
  )
1294
1308
  );
1295
1309
  }
1296
- function forToBy(by, index) {
1297
- return by ? by(index) : index;
1298
- }
1299
1310
  function resumeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker) {
1300
- if (serializeBranch === 0)
1301
- return cb();
1302
- let branchId = peekNextScopeId();
1303
- serializeMarker && $chunk.writeHTML(
1311
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId();
1312
+ resumeMarker && resumeBranch && $chunk.writeHTML(
1304
1313
  $chunk.boundary.state.mark("[" /* BranchStart */, branchId + "")
1305
1314
  );
1306
- let branchIndex = withBranchId(branchId, cb);
1307
- branchIndex !== void 0 ? writeScope(scopeId, {
1308
- ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
1315
+ let branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb();
1316
+ resumeBranch && branchIndex !== void 0 && writeScope(scopeId, {
1317
+ ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1309
1318
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1310
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1319
+ }), resumeMarker && $chunk.writeHTML(
1311
1320
  $chunk.boundary.state.mark(
1312
1321
  "]" /* BranchEnd */,
1313
1322
  scopeId + " " + accessor
1314
1323
  )
1315
1324
  );
1316
1325
  }
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,
1326
+ function resumeSingleNodeConditional(cb, scopeId, accessor, serializeBranch, serializeMarker, onlyChildInParent) {
1327
+ let resumeBranch = serializeBranch !== 0, resumeMarker = serializeMarker !== 0, branchId = peekNextScopeId(), branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1328
+ shouldWriteBranch && writeScope(scopeId, {
1329
+ ["c" /* ConditionalRenderer */ + accessor]: resumeMarker ? branchIndex : void 0,
1323
1330
  ["d" /* ConditionalScope */ + accessor]: writeScope(branchId, {})
1324
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1331
+ }), resumeMarker && $chunk.writeHTML(
1325
1332
  $chunk.boundary.state.mark(
1326
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1327
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
1333
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1334
+ scopeId + " " + accessor + (shouldWriteBranch ? " " + branchId : "")
1328
1335
  )
1329
1336
  );
1330
1337
  }
@@ -2025,8 +2032,8 @@ function NOOP2() {
2025
2032
  }
2026
2033
 
2027
2034
  // 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;
2035
+ 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) => {
2036
+ let shouldResume = serializeReason !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = peekNextScopeId(), result;
2030
2037
  if (typeof renderer == "string") {
2031
2038
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
2032
2039
  if (nextScopeId(), write(`<${renderer}${attrs(input, accessor, scopeId, renderer)}>`), !voidElementsReg.test(renderer)) {
@@ -2062,7 +2069,7 @@ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|p
2062
2069
  let input = inputIsArgs ? inputOrArgs[0] : inputOrArgs;
2063
2070
  return renderer(
2064
2071
  content ? { ...input, content } : input,
2065
- shouldResume
2072
+ shouldResume ? 1 : 0
2066
2073
  );
2067
2074
  }
2068
2075
  return inputIsArgs ? renderer(...inputOrArgs) : renderer(
@@ -2171,17 +2178,6 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
2171
2178
  register(RENDER_BODY_ID, fn);
2172
2179
  }
2173
2180
  };
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
2181
  // Annotate the CommonJS export names for ESM import in node:
2186
2182
  0 && (module.exports = {
2187
2183
  $global,