marko 6.0.0-next.3.61 → 6.0.0-next.3.63

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
@@ -424,6 +424,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
424
424
  ids = 0;
425
425
  flush = 0;
426
426
  flushed = !1;
427
+ wroteUndefined = !1;
427
428
  buf = [];
428
429
  refs = /* @__PURE__ */ new WeakMap();
429
430
  assigned = /* @__PURE__ */ new Set();
@@ -511,7 +512,7 @@ function writeRoot(state, root) {
511
512
  hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
512
513
  for (let chunk of buf)
513
514
  result += chunk;
514
- return "_=>" + result;
515
+ return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
515
516
  }
516
517
  function writeAssigned(state) {
517
518
  if (state.assigned.size) {
@@ -711,10 +712,12 @@ function writePlainObject(state, val, ref) {
711
712
  return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
712
713
  }
713
714
  function writeArray(state, val, ref) {
714
- state.buf.push("["), writeProp(state, val[0], ref, "0");
715
- for (let i = 1; i < val.length; i++)
716
- state.buf.push(","), writeProp(state, val[i], ref, "" + i);
717
- return state.buf.push("]"), !0;
715
+ let sep = "[";
716
+ for (let i = 0; i < val.length; i++) {
717
+ let item = val[i];
718
+ state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
719
+ }
720
+ return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
718
721
  }
719
722
  function writeDate(state, val) {
720
723
  return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
@@ -734,26 +737,38 @@ function writePromise(state, val, ref) {
734
737
  function writeMap(state, val, ref) {
735
738
  if (!val.size)
736
739
  return state.buf.push("new Map"), !0;
737
- let items = [], assigns;
738
- for (let [itemKey, itemValue] of val)
739
- itemKey === val && (itemKey = void 0, (assigns ||= []).push("i[" + items.length + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("i[" + items.length + "][1]")), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
740
740
  let arrayRef = new Reference(
741
741
  ref,
742
742
  null,
743
743
  state.flush,
744
744
  null,
745
745
  nextRefAccess(state)
746
- );
747
- return state.buf.push(
748
- (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
749
- ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
746
+ ), items = [], assigns, i = 0;
747
+ if (val.size < 25) {
748
+ for (let [itemKey, itemValue] of val)
749
+ itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(
750
+ itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]
751
+ );
752
+ assigns ? state.buf.push(
753
+ "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "="
754
+ ) : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
755
+ } else {
756
+ for (let [itemKey, itemValue] of val)
757
+ itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
758
+ assigns ? state.buf.push(
759
+ "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "="
760
+ ) : state.buf.push(
761
+ "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="
762
+ ), writeArray(state, items, arrayRef), state.buf.push(")");
763
+ }
764
+ return !0;
750
765
  }
751
766
  function writeSet(state, val, ref) {
752
767
  if (!val.size)
753
768
  return state.buf.push("new Set"), !0;
754
- let items = [], assigns;
769
+ let items = [], assigns, i = 0;
755
770
  for (let item of val)
756
- item === val && (item = void 0, (assigns ||= []).push("i[" + items.length + "]")), items.push(item);
771
+ item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
757
772
  let arrayRef = new Reference(
758
773
  ref,
759
774
  null,
@@ -806,9 +821,9 @@ function writeHeaders(state, val) {
806
821
  function writeFormData(state, val) {
807
822
  let sep = "[", valStr = "";
808
823
  for (let [key, value] of val)
809
- typeof value == "string" && (valStr += sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]", sep = ",");
824
+ typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
810
825
  return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
811
- "((f,i)=>(f,i.forEach(i=>f.append(i[0],i[1])),f))(new FormData," + valStr + "])"
826
+ valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"
812
827
  ), !0;
813
828
  }
814
829
  function writeRequest(state, val, ref) {
@@ -1084,7 +1099,7 @@ function withContext(key, value, cb) {
1084
1099
  }
1085
1100
  }
1086
1101
  function setTagVar(parentScopeId, scopeOffsetAccessor, childScope, registryId) {
1087
- ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), childScope["/" /* TagVariable */] = register2(
1102
+ ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), childScope.e = register2(
1088
1103
  {},
1089
1104
  registryId,
1090
1105
  parentScopeId
@@ -1302,9 +1317,9 @@ function tryContent(scopeId, accessor, content, input) {
1302
1317
  placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
1303
1318
  catchContent
1304
1319
  ) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content(), writeScope(branchId, {
1305
- "*": accessor,
1306
- "^": catchContent,
1307
- "%": placeholderContent
1320
+ a: accessor,
1321
+ b: catchContent,
1322
+ d: placeholderContent
1308
1323
  }), writeScope(scopeId, {
1309
1324
  ["d" /* ConditionalScope */ + accessor]: getScopeById(branchId)
1310
1325
  }), $chunk.writeHTML(
@@ -1774,7 +1789,7 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1774
1789
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
1775
1790
  function dynamicTagId(tagName) {
1776
1791
  let normalizedRenderer = normalizeDynamicRenderer(tagName);
1777
- return normalizedRenderer?.a || normalizedRenderer;
1792
+ return normalizedRenderer?.g || normalizedRenderer;
1778
1793
  }
1779
1794
  var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
1780
1795
  if (!tag && !content) {
@@ -1847,7 +1862,7 @@ var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
1847
1862
  ), result;
1848
1863
  };
1849
1864
  function createContent(id, fn) {
1850
- return fn.a = id, fn;
1865
+ return fn.g = id, fn;
1851
1866
  }
1852
1867
  function registerContent(id, fn, scopeId) {
1853
1868
  return register2(createContent(id, fn), id, scopeId);
@@ -1874,7 +1889,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
1874
1889
  writeScript,
1875
1890
  nextScopeId,
1876
1891
  isTagsAPI(fn) {
1877
- return !!fn.a;
1892
+ return !!fn.g;
1878
1893
  },
1879
1894
  patchDynamicTag,
1880
1895
  writeSetScopeForComponent(m5c) {
package/dist/html.mjs CHANGED
@@ -343,6 +343,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
343
343
  ids = 0;
344
344
  flush = 0;
345
345
  flushed = !1;
346
+ wroteUndefined = !1;
346
347
  buf = [];
347
348
  refs = /* @__PURE__ */ new WeakMap();
348
349
  assigned = /* @__PURE__ */ new Set();
@@ -430,7 +431,7 @@ function writeRoot(state, root) {
430
431
  hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
431
432
  for (let chunk of buf)
432
433
  result += chunk;
433
- return "_=>" + result;
434
+ return state.wroteUndefined ? (state.wroteUndefined = !1, "(_,$)=>" + result) : "_=>" + result;
434
435
  }
435
436
  function writeAssigned(state) {
436
437
  if (state.assigned.size) {
@@ -630,10 +631,12 @@ function writePlainObject(state, val, ref) {
630
631
  return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
631
632
  }
632
633
  function writeArray(state, val, ref) {
633
- state.buf.push("["), writeProp(state, val[0], ref, "0");
634
- for (let i = 1; i < val.length; i++)
635
- state.buf.push(","), writeProp(state, val[i], ref, "" + i);
636
- return state.buf.push("]"), !0;
634
+ let sep = "[";
635
+ for (let i = 0; i < val.length; i++) {
636
+ let item = val[i];
637
+ state.buf.push(sep), sep = ",", item === void 0 ? (state.wroteUndefined = !0, state.buf.push("$")) : writeProp(state, item, ref, "" + i);
638
+ }
639
+ return sep === "[" ? state.buf.push("[]") : state.buf.push("]"), !0;
637
640
  }
638
641
  function writeDate(state, val) {
639
642
  return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
@@ -653,26 +656,38 @@ function writePromise(state, val, ref) {
653
656
  function writeMap(state, val, ref) {
654
657
  if (!val.size)
655
658
  return state.buf.push("new Map"), !0;
656
- let items = [], assigns;
657
- for (let [itemKey, itemValue] of val)
658
- itemKey === val && (itemKey = void 0, (assigns ||= []).push("i[" + items.length + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("i[" + items.length + "][1]")), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
659
659
  let arrayRef = new Reference(
660
660
  ref,
661
661
  null,
662
662
  state.flush,
663
663
  null,
664
664
  nextRefAccess(state)
665
- );
666
- return state.buf.push(
667
- (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
668
- ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
665
+ ), items = [], assigns, i = 0;
666
+ if (val.size < 25) {
667
+ for (let [itemKey, itemValue] of val)
668
+ itemKey === val && (itemKey = void 0, (assigns ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assigns ||= []).push("a[" + i + "][1]")), i = items.push(
669
+ itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]
670
+ );
671
+ assigns ? state.buf.push(
672
+ "((m,a)=>(" + assignsToString(assigns, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map," + arrayRef.id + "="
673
+ ) : state.buf.push("new Map(" + arrayRef.id + "="), writeArray(state, items, arrayRef), state.buf.push(")");
674
+ } else {
675
+ for (let [itemKey, itemValue] of val)
676
+ itemKey === val && (itemKey = 0, (assigns ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assigns ||= []).push("a[" + (i + 1) + "]")), i = items.push(itemKey, itemValue);
677
+ assigns ? state.buf.push(
678
+ "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignsToString(assigns, "new Map") + "))(" + arrayRef.id + "="
679
+ ) : state.buf.push(
680
+ "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(" + arrayRef.id + "="
681
+ ), writeArray(state, items, arrayRef), state.buf.push(")");
682
+ }
683
+ return !0;
669
684
  }
670
685
  function writeSet(state, val, ref) {
671
686
  if (!val.size)
672
687
  return state.buf.push("new Set"), !0;
673
- let items = [], assigns;
688
+ let items = [], assigns, i = 0;
674
689
  for (let item of val)
675
- item === val && (item = void 0, (assigns ||= []).push("i[" + items.length + "]")), items.push(item);
690
+ item === val && (item = 0, (assigns ||= []).push("i[" + i + "]")), i = items.push(item);
676
691
  let arrayRef = new Reference(
677
692
  ref,
678
693
  null,
@@ -725,9 +740,9 @@ function writeHeaders(state, val) {
725
740
  function writeFormData(state, val) {
726
741
  let sep = "[", valStr = "";
727
742
  for (let [key, value] of val)
728
- typeof value == "string" && (valStr += sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]", sep = ",");
743
+ typeof value == "string" && (valStr += sep + quote(key, 0) + "," + quote(value, 0), sep = ",");
729
744
  return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
730
- "((f,i)=>(f,i.forEach(i=>f.append(i[0],i[1])),f))(new FormData," + valStr + "])"
745
+ valStr + "].reduce((f,v,i,a)=>i%2&&f.append(v,a[i+1])||f,new FormData)"
731
746
  ), !0;
732
747
  }
733
748
  function writeRequest(state, val, ref) {
@@ -1003,7 +1018,7 @@ function withContext(key, value, cb) {
1003
1018
  }
1004
1019
  }
1005
1020
  function setTagVar(parentScopeId, scopeOffsetAccessor, childScope, registryId) {
1006
- ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), childScope["/" /* TagVariable */] = register2(
1021
+ ensureScopeWithId(parentScopeId)[scopeOffsetAccessor] = nextScopeId(), childScope.e = register2(
1007
1022
  {},
1008
1023
  registryId,
1009
1024
  parentScopeId
@@ -1221,9 +1236,9 @@ function tryContent(scopeId, accessor, content, input) {
1221
1236
  placeholderContent ? () => tryPlaceholder(content, placeholderContent) : content,
1222
1237
  catchContent
1223
1238
  ) : placeholderContent ? tryPlaceholder(content, placeholderContent) : content(), writeScope(branchId, {
1224
- "*": accessor,
1225
- "^": catchContent,
1226
- "%": placeholderContent
1239
+ a: accessor,
1240
+ b: catchContent,
1241
+ d: placeholderContent
1227
1242
  }), writeScope(scopeId, {
1228
1243
  ["d" /* ConditionalScope */ + accessor]: getScopeById(branchId)
1229
1244
  }), $chunk.writeHTML(
@@ -1693,7 +1708,7 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1693
1708
  var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
1694
1709
  function dynamicTagId(tagName) {
1695
1710
  let normalizedRenderer = normalizeDynamicRenderer(tagName);
1696
- return normalizedRenderer?.a || normalizedRenderer;
1711
+ return normalizedRenderer?.g || normalizedRenderer;
1697
1712
  }
1698
1713
  var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
1699
1714
  if (!tag && !content) {
@@ -1766,7 +1781,7 @@ var dynamicTagInput = (scopeId, accessor, tag, input, content) => {
1766
1781
  ), result;
1767
1782
  };
1768
1783
  function createContent(id, fn) {
1769
- return fn.a = id, fn;
1784
+ return fn.g = id, fn;
1770
1785
  }
1771
1786
  function registerContent(id, fn, scopeId) {
1772
1787
  return register2(createContent(id, fn), id, scopeId);
@@ -1793,7 +1808,7 @@ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap()
1793
1808
  writeScript,
1794
1809
  nextScopeId,
1795
1810
  isTagsAPI(fn) {
1796
- return !!fn.a;
1811
+ return !!fn.g;
1797
1812
  },
1798
1813
  patchDynamicTag,
1799
1814
  writeSetScopeForComponent(m5c) {
@@ -128,15 +128,16 @@ var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix3) => {
128
128
  AccessorPrefix3["LoopScopeArray"] = "LoopScopeArray:";
129
129
  AccessorPrefix3["LoopScopeMap"] = "LoopScopeMap:";
130
130
  AccessorPrefix3["Promise"] = "Promise:";
131
+ AccessorPrefix3["TagVariableChange"] = "TagVariableChange:";
131
132
  return AccessorPrefix3;
132
133
  })(AccessorPrefix || {});
133
134
  var AccessorProp = /* @__PURE__ */ ((AccessorProp3) => {
134
- AccessorProp3["BranchAccessor"] = "*BranchAccessor";
135
- AccessorProp3["CatchContent"] = "^CatchContent";
135
+ AccessorProp3["BranchAccessor"] = "#BranchAccessor";
136
+ AccessorProp3["CatchContent"] = "#CatchContent";
136
137
  AccessorProp3["PlaceholderBranch"] = "#PlaceholderBranch";
137
- AccessorProp3["PlaceholderContent"] = "%PlaceholderContent";
138
- AccessorProp3["TagVariable"] = "/TagVariable";
139
- AccessorProp3["TagVariableChange"] = "@TagVariableChange";
138
+ AccessorProp3["PlaceholderContent"] = "#PlaceholderContent";
139
+ AccessorProp3["TagVariable"] = "#TagVariable";
140
+ AccessorProp3["TagVariableChange"] = "#TagVariableChange";
140
141
  return AccessorProp3;
141
142
  })(AccessorProp || {});
142
143
 
@@ -1441,15 +1442,16 @@ var AccessorPrefix2 = /* @__PURE__ */ ((AccessorPrefix3) => {
1441
1442
  AccessorPrefix3["LoopScopeArray"] = "l";
1442
1443
  AccessorPrefix3["LoopScopeMap"] = "m";
1443
1444
  AccessorPrefix3["Promise"] = "n";
1445
+ AccessorPrefix3["TagVariableChange"] = "o";
1444
1446
  return AccessorPrefix3;
1445
1447
  })(AccessorPrefix2 || {});
1446
1448
  var AccessorProp2 = /* @__PURE__ */ ((AccessorProp3) => {
1447
- AccessorProp3["BranchAccessor"] = "*";
1448
- AccessorProp3["CatchContent"] = "^";
1449
- AccessorProp3["PlaceholderBranch"] = "#";
1450
- AccessorProp3["PlaceholderContent"] = "%";
1451
- AccessorProp3["TagVariable"] = "/";
1452
- AccessorProp3["TagVariableChange"] = "@";
1449
+ AccessorProp3["BranchAccessor"] = "a";
1450
+ AccessorProp3["CatchContent"] = "b";
1451
+ AccessorProp3["PlaceholderBranch"] = "c";
1452
+ AccessorProp3["PlaceholderContent"] = "d";
1453
+ AccessorProp3["TagVariable"] = "e";
1454
+ AccessorProp3["TagVariableChange"] = "f";
1453
1455
  return AccessorProp3;
1454
1456
  })(AccessorProp2 || {});
1455
1457
 
@@ -7873,7 +7875,7 @@ var let_default = {
7873
7875
  if (valueChangeAttr) {
7874
7876
  setSerializedProperty(
7875
7877
  section,
7876
- getAccessorProp().TagVariableChange + getScopeAccessor(binding),
7878
+ getAccessorPrefix().TagVariableChange + getScopeAccessor(binding),
7877
7879
  valueChangeAttr.value
7878
7880
  );
7879
7881
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.61",
3
+ "version": "6.0.0-next.3.63",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",