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.mjs CHANGED
@@ -11,39 +11,30 @@ function* attrTagIterator() {
11
11
  }
12
12
 
13
13
  // src/common/helpers.ts
14
- function classValue(value) {
15
- return toDelimitedString(value, " ", stringifyClassObject);
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(value) {
21
- return toDelimitedString(value, ";", stringifyStyleObject);
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" && value && !/^(--|ta|or|li|z)|cou|nk|it|ag|we|do|w$/.test(name) ? value + "px" : value}` : "";
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
- switch (typeof val) {
28
- case "string":
29
- return val;
30
- case "object":
31
- if (val !== null) {
32
- let result = "", curDelimiter = "";
33
- if (Array.isArray(val))
34
- for (let v of val) {
35
- let part = toDelimitedString(v, delimiter, stringify);
36
- part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
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
- if (serializeBranch === 0)
1093
- return forOf(list, cb);
1094
- let loopScopes = /* @__PURE__ */ new Map();
1095
- forOf(list, (item, index) => {
1096
- let branchId = peekNextScopeId();
1097
- $chunk.writeHTML(
1098
- $chunk.boundary.state.mark(
1099
- "[" /* BranchStart */,
1100
- branchId + (index ? " " : "")
1101
- )
1102
- ), withBranchId(branchId, () => {
1103
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1106
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1107
- }), $chunk.writeHTML(
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
- if (serializeBranch === 0)
1116
- return forOf(list, cb);
1117
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1118
- forOf(list, (item, index) => {
1119
- let branchId = peekNextScopeId();
1120
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1121
- cb(item, index), loopScopes.set(forOfBy(by, item, index), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1124
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1125
- }), $chunk.writeHTML(
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 forOfBy(by, item, index) {
1133
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1134
- }
1135
- function resumeForIn(obj, cb, by, scopeId, accessor, serializeBranch) {
1136
- if (serializeBranch === 0)
1137
- return forIn(obj, cb);
1138
- let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1139
- forIn(obj, (key, value) => {
1140
- let branchId = peekNextScopeId();
1141
- $chunk.writeHTML(
1142
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1143
- ), sep = " ", withBranchId(branchId, () => {
1144
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1147
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1148
- }), $chunk.writeHTML(
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, onlyChild) {
1156
- if (serializeBranch === 0)
1157
- return forIn(obj, cb);
1158
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1159
- forIn(obj, (key, value) => {
1160
- let branchId = peekNextScopeId();
1161
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1162
- cb(key, value), loopScopes.set(forInBy(by, key, value), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1165
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1166
- }), $chunk.writeHTML(
1175
+ } else
1176
+ forIn(obj, cb);
1177
+ resumeMarker && $chunk.writeHTML(
1167
1178
  $chunk.boundary.state.mark(
1168
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1179
+ onlyChildInParent ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1169
1180
  scopeId + " " + accessor + branchIds
1170
1181
  )
1171
1182
  );
1172
1183
  }
1173
- function forInBy(by, name, value) {
1174
- return by ? by(name, value) : name;
1175
- }
1176
- function resumeForTo(to, from, step, cb, by, scopeId, accessor, serializeBranch) {
1177
- if (serializeBranch === 0)
1178
- return forTo(to, from, step, cb);
1179
- let loopScopes = /* @__PURE__ */ new Map(), sep = "";
1180
- forTo(to, from, step, (index) => {
1181
- let branchId = peekNextScopeId();
1182
- $chunk.writeHTML(
1183
- $chunk.boundary.state.mark("[" /* BranchStart */, branchId + sep)
1184
- ), sep = " ", withBranchId(branchId, () => {
1185
- cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1188
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1189
- }), $chunk.writeHTML(
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, onlyChild) {
1197
- if (serializeBranch === 0)
1198
- return forTo(to, from, step, cb);
1199
- let loopScopes = /* @__PURE__ */ new Map(), branchIds = "";
1200
- forTo(to, from, step, (index) => {
1201
- let branchId = peekNextScopeId();
1202
- branchIds = " " + branchId + branchIds, withBranchId(branchId, () => {
1203
- cb(index), loopScopes.set(forToBy(by, index), writeScope(branchId, {}));
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
- }), loopScopes.size && writeScope(scopeId, {
1206
- ["m" /* LoopScopeMap */ + accessor]: loopScopes
1207
- }), $chunk.writeHTML(
1219
+ } else
1220
+ forTo(to, from, step, cb);
1221
+ resumeMarker && $chunk.writeHTML(
1208
1222
  $chunk.boundary.state.mark(
1209
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
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
- if (serializeBranch === 0)
1219
- return cb();
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 ? writeScope(scopeId, {
1226
- ["c" /* ConditionalRenderer */ + accessor]: serializeMarker ? branchIndex : void 0,
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
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
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, onlyChild) {
1236
- if (serializeBranch === 0)
1237
- return cb();
1238
- let branchId = peekNextScopeId(), branchIndex = withBranchId(branchId, cb), rendered = branchIndex !== void 0;
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
- }) : nextScopeId(), serializeMarker && $chunk.writeHTML(
1249
+ }), resumeMarker && $chunk.writeHTML(
1243
1250
  $chunk.boundary.state.mark(
1244
- onlyChild ? "=" /* BranchSingleNodeOnlyChildInParent */ : "|" /* BranchSingleNode */,
1245
- scopeId + " " + accessor + (rendered ? " " + branchId : "")
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, shouldResume) => {
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
- forInBy2 as forInBy,
2122
+ forInBy,
2127
2123
  forOf,
2128
- forOfBy2 as forOfBy,
2124
+ forOfBy,
2129
2125
  forTo,
2130
- forToBy2 as forToBy,
2126
+ forToBy,
2131
2127
  fork,
2132
2128
  getScopeById,
2133
2129
  hoist,