marko 6.0.0-next.3.47 → 6.0.0-next.3.48

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.
@@ -584,7 +584,7 @@ var Reference = class {
584
584
  this.id = id;
585
585
  }
586
586
  init = "";
587
- assigns = "";
587
+ assigns = null;
588
588
  };
589
589
  var DEBUG = /* @__PURE__ */ new WeakMap();
590
590
  function setDebugInfo(obj, file, loc, vars) {
@@ -655,7 +655,9 @@ function writeRoot(state, root) {
655
655
  if (assigned.size || calls.length) {
656
656
  assigned.delete(rootRef);
657
657
  writeAssigned(state);
658
- buf.push("," + rootRef.assigns + rootId);
658
+ buf.push(
659
+ "," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
660
+ );
659
661
  }
660
662
  }
661
663
  result = "(";
@@ -676,9 +678,17 @@ function writeRoot(state, root) {
676
678
  function writeAssigned(state) {
677
679
  if (state.assigned.size) {
678
680
  for (const valueRef of state.assigned) {
679
- if (valueRef.assigns || valueRef.init) {
680
- state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id));
681
+ if (valueRef.init) {
682
+ if (valueRef.assigns) {
683
+ state.buf.push(
684
+ "," + assignsToString(valueRef.assigns, valueRef.init)
685
+ );
686
+ } else {
687
+ state.buf.push("," + valueRef.init);
688
+ }
681
689
  valueRef.init = "";
690
+ } else if (valueRef.assigns) {
691
+ state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
682
692
  }
683
693
  }
684
694
  state.assigned = /* @__PURE__ */ new Set();
@@ -742,7 +752,7 @@ function writeReferenceOr(state, write2, val, parent, accessor) {
742
752
  let ref = state.refs.get(val);
743
753
  if (ref) {
744
754
  if (ref.init) {
745
- ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
755
+ addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
746
756
  return false;
747
757
  }
748
758
  if (isCircular(parent, ref)) {
@@ -750,7 +760,7 @@ function writeReferenceOr(state, write2, val, parent, accessor) {
750
760
  ensureId(state, ref);
751
761
  state.assigned.add(ref);
752
762
  }
753
- ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
763
+ addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
754
764
  return false;
755
765
  }
756
766
  state.buf.push(ensureId(state, ref));
@@ -797,7 +807,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
797
807
  state.assigned.add(parent);
798
808
  state.assigned.add(fnRef);
799
809
  fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
800
- fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
810
+ addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
801
811
  return false;
802
812
  }
803
813
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
@@ -811,7 +821,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
811
821
  state.assigned.add(parent);
812
822
  state.assigned.add(fnRef);
813
823
  fnRef.init = access + "(" + scopeId + ")";
814
- fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
824
+ addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
815
825
  } else {
816
826
  state.buf[pos] = access + "(" + state.buf[pos];
817
827
  state.buf.push(")");
@@ -991,15 +1001,15 @@ function writeMap(state, val, ref) {
991
1001
  return true;
992
1002
  }
993
1003
  const items = [];
994
- let assigns = "";
1004
+ let assigns;
995
1005
  for (let [itemKey, itemValue] of val) {
996
1006
  if (itemKey === val) {
997
1007
  itemKey = void 0;
998
- assigns += "i[" + items.length + "][0]=";
1008
+ (assigns ||= []).push("i[" + items.length + "][0]");
999
1009
  }
1000
1010
  if (itemValue === val) {
1001
1011
  itemValue = void 0;
1002
- assigns += "i[" + items.length + "][1]=";
1012
+ (assigns ||= []).push("i[" + items.length + "][1]");
1003
1013
  }
1004
1014
  if (itemValue === void 0) {
1005
1015
  items.push([itemKey]);
@@ -1015,7 +1025,7 @@ function writeMap(state, val, ref) {
1015
1025
  nextRefAccess(state)
1016
1026
  );
1017
1027
  state.buf.push(
1018
- (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
1028
+ (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
1019
1029
  );
1020
1030
  writeArray(state, items, arrayRef);
1021
1031
  state.buf.push(")");
@@ -1027,11 +1037,11 @@ function writeSet(state, val, ref) {
1027
1037
  return true;
1028
1038
  }
1029
1039
  const items = [];
1030
- let assigns = "";
1040
+ let assigns;
1031
1041
  for (let item of val) {
1032
1042
  if (item === val) {
1033
1043
  item = void 0;
1034
- assigns += "i[" + items.length + "]=";
1044
+ (assigns ||= []).push("i[" + items.length + "]");
1035
1045
  }
1036
1046
  items.push(item);
1037
1047
  }
@@ -1043,7 +1053,7 @@ function writeSet(state, val, ref) {
1043
1053
  nextRefAccess(state)
1044
1054
  );
1045
1055
  state.buf.push(
1046
- (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
1056
+ (assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
1047
1057
  );
1048
1058
  writeArray(state, items, arrayRef);
1049
1059
  state.buf.push(")");
@@ -1513,6 +1523,19 @@ function assignId(state, ref) {
1513
1523
  } while (cur);
1514
1524
  return ref.id + "=" + accessPrevValue;
1515
1525
  }
1526
+ function assignsToString(assigns, value) {
1527
+ if (assigns.length > 100) {
1528
+ return "($=>(" + assigns.join("=$,") + "=$))(" + value + ")";
1529
+ }
1530
+ return assigns.join("=") + "=" + value;
1531
+ }
1532
+ function addAssignment(ref, assign) {
1533
+ if (ref.assigns) {
1534
+ ref.assigns.push(assign);
1535
+ } else {
1536
+ ref.assigns = [assign];
1537
+ }
1538
+ }
1516
1539
  function nextRefAccess(state) {
1517
1540
  return "_." + nextId(state);
1518
1541
  }
@@ -500,7 +500,7 @@ var Reference = class {
500
500
  this.id = id;
501
501
  }
502
502
  init = "";
503
- assigns = "";
503
+ assigns = null;
504
504
  };
505
505
  var DEBUG = /* @__PURE__ */ new WeakMap();
506
506
  function setDebugInfo(obj, file, loc, vars) {
@@ -571,7 +571,9 @@ function writeRoot(state, root) {
571
571
  if (assigned.size || calls.length) {
572
572
  assigned.delete(rootRef);
573
573
  writeAssigned(state);
574
- buf.push("," + rootRef.assigns + rootId);
574
+ buf.push(
575
+ "," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
576
+ );
575
577
  }
576
578
  }
577
579
  result = "(";
@@ -592,9 +594,17 @@ function writeRoot(state, root) {
592
594
  function writeAssigned(state) {
593
595
  if (state.assigned.size) {
594
596
  for (const valueRef of state.assigned) {
595
- if (valueRef.assigns || valueRef.init) {
596
- state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id));
597
+ if (valueRef.init) {
598
+ if (valueRef.assigns) {
599
+ state.buf.push(
600
+ "," + assignsToString(valueRef.assigns, valueRef.init)
601
+ );
602
+ } else {
603
+ state.buf.push("," + valueRef.init);
604
+ }
597
605
  valueRef.init = "";
606
+ } else if (valueRef.assigns) {
607
+ state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
598
608
  }
599
609
  }
600
610
  state.assigned = /* @__PURE__ */ new Set();
@@ -658,7 +668,7 @@ function writeReferenceOr(state, write2, val, parent, accessor) {
658
668
  let ref = state.refs.get(val);
659
669
  if (ref) {
660
670
  if (ref.init) {
661
- ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
671
+ addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
662
672
  return false;
663
673
  }
664
674
  if (isCircular(parent, ref)) {
@@ -666,7 +676,7 @@ function writeReferenceOr(state, write2, val, parent, accessor) {
666
676
  ensureId(state, ref);
667
677
  state.assigned.add(ref);
668
678
  }
669
- ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
679
+ addAssignment(ref, ensureId(state, parent) + toAccess(accessor));
670
680
  return false;
671
681
  }
672
682
  state.buf.push(ensureId(state, ref));
@@ -713,7 +723,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
713
723
  state.assigned.add(parent);
714
724
  state.assigned.add(fnRef);
715
725
  fnRef.init = access + "(" + ensureId(state, scopeRef) + ")";
716
- fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
726
+ addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
717
727
  return false;
718
728
  }
719
729
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
@@ -727,7 +737,7 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
727
737
  state.assigned.add(parent);
728
738
  state.assigned.add(fnRef);
729
739
  fnRef.init = access + "(" + scopeId + ")";
730
- fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
740
+ addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor));
731
741
  } else {
732
742
  state.buf[pos] = access + "(" + state.buf[pos];
733
743
  state.buf.push(")");
@@ -907,15 +917,15 @@ function writeMap(state, val, ref) {
907
917
  return true;
908
918
  }
909
919
  const items = [];
910
- let assigns = "";
920
+ let assigns;
911
921
  for (let [itemKey, itemValue] of val) {
912
922
  if (itemKey === val) {
913
923
  itemKey = void 0;
914
- assigns += "i[" + items.length + "][0]=";
924
+ (assigns ||= []).push("i[" + items.length + "][0]");
915
925
  }
916
926
  if (itemValue === val) {
917
927
  itemValue = void 0;
918
- assigns += "i[" + items.length + "][1]=";
928
+ (assigns ||= []).push("i[" + items.length + "][1]");
919
929
  }
920
930
  if (itemValue === void 0) {
921
931
  items.push([itemKey]);
@@ -931,7 +941,7 @@ function writeMap(state, val, ref) {
931
941
  nextRefAccess(state)
932
942
  );
933
943
  state.buf.push(
934
- (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
944
+ (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
935
945
  );
936
946
  writeArray(state, items, arrayRef);
937
947
  state.buf.push(")");
@@ -943,11 +953,11 @@ function writeSet(state, val, ref) {
943
953
  return true;
944
954
  }
945
955
  const items = [];
946
- let assigns = "";
956
+ let assigns;
947
957
  for (let item of val) {
948
958
  if (item === val) {
949
959
  item = void 0;
950
- assigns += "i[" + items.length + "]=";
960
+ (assigns ||= []).push("i[" + items.length + "]");
951
961
  }
952
962
  items.push(item);
953
963
  }
@@ -959,7 +969,7 @@ function writeSet(state, val, ref) {
959
969
  nextRefAccess(state)
960
970
  );
961
971
  state.buf.push(
962
- (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
972
+ (assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
963
973
  );
964
974
  writeArray(state, items, arrayRef);
965
975
  state.buf.push(")");
@@ -1429,6 +1439,19 @@ function assignId(state, ref) {
1429
1439
  } while (cur);
1430
1440
  return ref.id + "=" + accessPrevValue;
1431
1441
  }
1442
+ function assignsToString(assigns, value) {
1443
+ if (assigns.length > 100) {
1444
+ return "($=>(" + assigns.join("=$,") + "=$))(" + value + ")";
1445
+ }
1446
+ return assigns.join("=") + "=" + value;
1447
+ }
1448
+ function addAssignment(ref, assign) {
1449
+ if (ref.assigns) {
1450
+ ref.assigns.push(assign);
1451
+ } else {
1452
+ ref.assigns = [assign];
1453
+ }
1454
+ }
1432
1455
  function nextRefAccess(state) {
1433
1456
  return "_." + nextId(state);
1434
1457
  }
package/dist/html.js CHANGED
@@ -438,7 +438,7 @@ var { hasOwnProperty } = {}, Generator = function* () {
438
438
  this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
439
439
  }
440
440
  init = "";
441
- assigns = "";
441
+ assigns = null;
442
442
  };
443
443
  var Serializer = class {
444
444
  #state = new State();
@@ -486,7 +486,9 @@ function writeRoot(state, root) {
486
486
  let rootRef = state.refs.get(root);
487
487
  if (rootRef) {
488
488
  let rootId = ensureId(state, rootRef);
489
- (assigned.size || calls.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push("," + rootRef.assigns + rootId));
489
+ (assigned.size || calls.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push(
490
+ "," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
491
+ ));
490
492
  }
491
493
  result = "(", buf.push(")");
492
494
  } else
@@ -498,7 +500,9 @@ function writeRoot(state, root) {
498
500
  function writeAssigned(state) {
499
501
  if (state.assigned.size) {
500
502
  for (let valueRef of state.assigned)
501
- (valueRef.assigns || valueRef.init) && (state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id)), valueRef.init = "");
503
+ valueRef.init ? (valueRef.assigns ? state.buf.push(
504
+ "," + assignsToString(valueRef.assigns, valueRef.init)
505
+ ) : state.buf.push("," + valueRef.init), valueRef.init = "") : valueRef.assigns && state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
502
506
  state.assigned = /* @__PURE__ */ new Set();
503
507
  }
504
508
  if (state.calls.length) {
@@ -547,7 +551,7 @@ function writeProp(state, val, parent, accessor) {
547
551
  function writeReferenceOr(state, write2, val, parent, accessor) {
548
552
  let ref = state.refs.get(val);
549
553
  if (ref)
550
- return ref.init ? (ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : (state.buf.push(ensureId(state, ref)), !0);
554
+ return ref.init ? (addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1) : (state.buf.push(ensureId(state, ref)), !0);
551
555
  let registered = REGISTRY.get(val);
552
556
  return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
553
557
  val,
@@ -571,13 +575,13 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
571
575
  }
572
576
  if (scopeRef) {
573
577
  if (isCircular(parent, scopeRef))
574
- return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1;
578
+ return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
575
579
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
576
580
  } else {
577
581
  let pos = state.buf.push("") - 1, assigns = state.assigned.size;
578
582
  writeProp(state, scope, parent, "");
579
583
  let scopeRef2 = parent && state.refs.get(scope), scopeId = scopeRef2 && ensureId(state, scopeRef2);
580
- scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=") : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
584
+ scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor))) : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
581
585
  }
582
586
  } else
583
587
  state.buf.push(access);
@@ -714,9 +718,9 @@ function writePromise(state, val, ref) {
714
718
  function writeMap(state, val, ref) {
715
719
  if (!val.size)
716
720
  return state.buf.push("new Map"), !0;
717
- let items = [], assigns = "";
721
+ let items = [], assigns;
718
722
  for (let [itemKey, itemValue] of val)
719
- itemKey === val && (itemKey = void 0, assigns += "i[" + items.length + "][0]="), itemValue === val && (itemValue = void 0, assigns += "i[" + items.length + "][1]="), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
723
+ 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]);
720
724
  let arrayRef = new Reference(
721
725
  ref,
722
726
  null,
@@ -725,15 +729,15 @@ function writeMap(state, val, ref) {
725
729
  nextRefAccess(state)
726
730
  );
727
731
  return state.buf.push(
728
- (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
732
+ (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
729
733
  ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
730
734
  }
731
735
  function writeSet(state, val, ref) {
732
736
  if (!val.size)
733
737
  return state.buf.push("new Set"), !0;
734
- let items = [], assigns = "";
738
+ let items = [], assigns;
735
739
  for (let item of val)
736
- item === val && (item = void 0, assigns += "i[" + items.length + "]="), items.push(item);
740
+ item === val && (item = void 0, (assigns ||= []).push("i[" + items.length + "]")), items.push(item);
737
741
  let arrayRef = new Reference(
738
742
  ref,
739
743
  null,
@@ -742,7 +746,7 @@ function writeSet(state, val, ref) {
742
746
  nextRefAccess(state)
743
747
  );
744
748
  return state.buf.push(
745
- (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
749
+ (assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
746
750
  ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
747
751
  }
748
752
  function writeArrayBuffer(state, val) {
@@ -990,6 +994,12 @@ function assignId(state, ref) {
990
994
  } while (cur);
991
995
  return ref.id + "=" + accessPrevValue;
992
996
  }
997
+ function assignsToString(assigns, value) {
998
+ return assigns.length > 100 ? "($=>(" + assigns.join("=$,") + "=$))(" + value + ")" : assigns.join("=") + "=" + value;
999
+ }
1000
+ function addAssignment(ref, assign) {
1001
+ ref.assigns ? ref.assigns.push(assign) : ref.assigns = [assign];
1002
+ }
993
1003
  function nextRefAccess(state) {
994
1004
  return "_." + nextId(state);
995
1005
  }
package/dist/html.mjs CHANGED
@@ -357,7 +357,7 @@ var { hasOwnProperty } = {}, Generator = function* () {
357
357
  this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
358
358
  }
359
359
  init = "";
360
- assigns = "";
360
+ assigns = null;
361
361
  };
362
362
  var Serializer = class {
363
363
  #state = new State();
@@ -405,7 +405,9 @@ function writeRoot(state, root) {
405
405
  let rootRef = state.refs.get(root);
406
406
  if (rootRef) {
407
407
  let rootId = ensureId(state, rootRef);
408
- (assigned.size || calls.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push("," + rootRef.assigns + rootId));
408
+ (assigned.size || calls.length) && (assigned.delete(rootRef), writeAssigned(state), buf.push(
409
+ "," + (rootRef.assigns ? assignsToString(rootRef.assigns, rootId) : rootId)
410
+ ));
409
411
  }
410
412
  result = "(", buf.push(")");
411
413
  } else
@@ -417,7 +419,9 @@ function writeRoot(state, root) {
417
419
  function writeAssigned(state) {
418
420
  if (state.assigned.size) {
419
421
  for (let valueRef of state.assigned)
420
- (valueRef.assigns || valueRef.init) && (state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id)), valueRef.init = "");
422
+ valueRef.init ? (valueRef.assigns ? state.buf.push(
423
+ "," + assignsToString(valueRef.assigns, valueRef.init)
424
+ ) : state.buf.push("," + valueRef.init), valueRef.init = "") : valueRef.assigns && state.buf.push("," + assignsToString(valueRef.assigns, valueRef.id));
421
425
  state.assigned = /* @__PURE__ */ new Set();
422
426
  }
423
427
  if (state.calls.length) {
@@ -466,7 +470,7 @@ function writeProp(state, val, parent, accessor) {
466
470
  function writeReferenceOr(state, write2, val, parent, accessor) {
467
471
  let ref = state.refs.get(val);
468
472
  if (ref)
469
- return ref.init ? (ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : (state.buf.push(ensureId(state, ref)), !0);
473
+ return ref.init ? (addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), addAssignment(ref, ensureId(state, parent) + toAccess(accessor)), !1) : (state.buf.push(ensureId(state, ref)), !0);
470
474
  let registered = REGISTRY.get(val);
471
475
  return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
472
476
  val,
@@ -490,13 +494,13 @@ function writeRegistered(state, val, parent, accessor, { access, scope, getter }
490
494
  }
491
495
  if (scopeRef) {
492
496
  if (isCircular(parent, scopeRef))
493
- return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1;
497
+ return state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + ensureId(state, scopeRef) + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor)), !1;
494
498
  state.buf.push(access + "(" + ensureId(state, scopeRef) + ")");
495
499
  } else {
496
500
  let pos = state.buf.push("") - 1, assigns = state.assigned.size;
497
501
  writeProp(state, scope, parent, "");
498
502
  let scopeRef2 = parent && state.refs.get(scope), scopeId = scopeRef2 && ensureId(state, scopeRef2);
499
- scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=") : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
503
+ scopeId && assigns !== state.assigned.size ? (state.assigned.add(parent), state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", addAssignment(fnRef, ensureId(state, parent) + toAccess(accessor))) : (state.buf[pos] = access + "(" + state.buf[pos], state.buf.push(")"));
500
504
  }
501
505
  } else
502
506
  state.buf.push(access);
@@ -633,9 +637,9 @@ function writePromise(state, val, ref) {
633
637
  function writeMap(state, val, ref) {
634
638
  if (!val.size)
635
639
  return state.buf.push("new Map"), !0;
636
- let items = [], assigns = "";
640
+ let items = [], assigns;
637
641
  for (let [itemKey, itemValue] of val)
638
- itemKey === val && (itemKey = void 0, assigns += "i[" + items.length + "][0]="), itemValue === val && (itemValue = void 0, assigns += "i[" + items.length + "][1]="), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
642
+ 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]);
639
643
  let arrayRef = new Reference(
640
644
  ref,
641
645
  null,
@@ -644,15 +648,15 @@ function writeMap(state, val, ref) {
644
648
  nextRefAccess(state)
645
649
  );
646
650
  return state.buf.push(
647
- (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
651
+ (assigns ? "((m,i)=>(" + assignsToString(assigns, "m") + ",i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
648
652
  ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
649
653
  }
650
654
  function writeSet(state, val, ref) {
651
655
  if (!val.size)
652
656
  return state.buf.push("new Set"), !0;
653
- let items = [], assigns = "";
657
+ let items = [], assigns;
654
658
  for (let item of val)
655
- item === val && (item = void 0, assigns += "i[" + items.length + "]="), items.push(item);
659
+ item === val && (item = void 0, (assigns ||= []).push("i[" + items.length + "]")), items.push(item);
656
660
  let arrayRef = new Reference(
657
661
  ref,
658
662
  null,
@@ -661,7 +665,7 @@ function writeSet(state, val, ref) {
661
665
  nextRefAccess(state)
662
666
  );
663
667
  return state.buf.push(
664
- (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
668
+ (assigns ? "((s,i)=>(" + assignsToString(assigns, "s") + ",i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
665
669
  ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
666
670
  }
667
671
  function writeArrayBuffer(state, val) {
@@ -909,6 +913,12 @@ function assignId(state, ref) {
909
913
  } while (cur);
910
914
  return ref.id + "=" + accessPrevValue;
911
915
  }
916
+ function assignsToString(assigns, value) {
917
+ return assigns.length > 100 ? "($=>(" + assigns.join("=$,") + "=$))(" + value + ")" : assigns.join("=") + "=" + value;
918
+ }
919
+ function addAssignment(ref, assign) {
920
+ ref.assigns ? ref.assigns.push(assign) : ref.assigns = [assign];
921
+ }
912
922
  function nextRefAccess(state) {
913
923
  return "_." + nextId(state);
914
924
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "marko",
3
- "version": "6.0.0-next.3.47",
3
+ "version": "6.0.0-next.3.48",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",