@marko/runtime-tags 6.0.149 → 6.0.150

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.
@@ -684,6 +684,7 @@ var State = class {
684
684
  flushed = false;
685
685
  wroteUndefined = false;
686
686
  buf = [];
687
+ strs = /* @__PURE__ */ new Map();
687
688
  refs = /* @__PURE__ */ new WeakMap();
688
689
  assigned = /* @__PURE__ */ new Set();
689
690
  registered = [];
@@ -888,7 +889,7 @@ function writeAssigned(state) {
888
889
  function writeProp(state, val, parent, accessor) {
889
890
  switch (typeof val) {
890
891
  case "string":
891
- return writeString(state, val);
892
+ return writeString(state, val, parent, accessor);
892
893
  case "number":
893
894
  return writeNumber(state, val);
894
895
  case "boolean":
@@ -955,8 +956,21 @@ function writeRegistered(state, val, parent, accessor, registered) {
955
956
  }
956
957
  return true;
957
958
  }
958
- function writeString(state, val) {
959
- state.buf.push(quote(val, 0));
959
+ function writeString(state, val, parent, accessor) {
960
+ if (val.length > 30) {
961
+ const ref = state.strs.get(val);
962
+ if (ref) {
963
+ state.buf.push(ensureId(state, ref));
964
+ } else {
965
+ state.strs.set(
966
+ val,
967
+ new Reference(parent, accessor, state.flush, state.buf.length)
968
+ );
969
+ state.buf.push(quote(val, 0));
970
+ }
971
+ } else {
972
+ state.buf.push(quote(val, 0));
973
+ }
960
974
  return true;
961
975
  }
962
976
  function writeNumber(state, val) {
@@ -591,6 +591,7 @@ var State = class {
591
591
  flushed = false;
592
592
  wroteUndefined = false;
593
593
  buf = [];
594
+ strs = /* @__PURE__ */ new Map();
594
595
  refs = /* @__PURE__ */ new WeakMap();
595
596
  assigned = /* @__PURE__ */ new Set();
596
597
  registered = [];
@@ -795,7 +796,7 @@ function writeAssigned(state) {
795
796
  function writeProp(state, val, parent, accessor) {
796
797
  switch (typeof val) {
797
798
  case "string":
798
- return writeString(state, val);
799
+ return writeString(state, val, parent, accessor);
799
800
  case "number":
800
801
  return writeNumber(state, val);
801
802
  case "boolean":
@@ -862,8 +863,21 @@ function writeRegistered(state, val, parent, accessor, registered) {
862
863
  }
863
864
  return true;
864
865
  }
865
- function writeString(state, val) {
866
- state.buf.push(quote(val, 0));
866
+ function writeString(state, val, parent, accessor) {
867
+ if (val.length > 30) {
868
+ const ref = state.strs.get(val);
869
+ if (ref) {
870
+ state.buf.push(ensureId(state, ref));
871
+ } else {
872
+ state.strs.set(
873
+ val,
874
+ new Reference(parent, accessor, state.flush, state.buf.length)
875
+ );
876
+ state.buf.push(quote(val, 0));
877
+ }
878
+ } else {
879
+ state.buf.push(quote(val, 0));
880
+ }
867
881
  return true;
868
882
  }
869
883
  function writeNumber(state, val) {
package/dist/html.js CHANGED
@@ -463,6 +463,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
463
463
  flushed = !1;
464
464
  wroteUndefined = !1;
465
465
  buf = [];
466
+ strs = /* @__PURE__ */ new Map();
466
467
  refs = /* @__PURE__ */ new WeakMap();
467
468
  assigned = /* @__PURE__ */ new Set();
468
469
  registered = [];
@@ -601,7 +602,7 @@ function writeAssigned(state) {
601
602
  function writeProp(state, val, parent, accessor) {
602
603
  switch (typeof val) {
603
604
  case "string":
604
- return writeString(state, val);
605
+ return writeString(state, val, parent, accessor);
605
606
  case "number":
606
607
  return writeNumber(state, val);
607
608
  case "boolean":
@@ -648,8 +649,16 @@ function writeRegistered(state, val, parent, accessor, registered) {
648
649
  state.buf.push(registered.access);
649
650
  return !0;
650
651
  }
651
- function writeString(state, val) {
652
- return state.buf.push(quote(val, 0)), !0;
652
+ function writeString(state, val, parent, accessor) {
653
+ if (val.length > 30) {
654
+ let ref = state.strs.get(val);
655
+ ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(
656
+ val,
657
+ new Reference(parent, accessor, state.flush, state.buf.length)
658
+ ), state.buf.push(quote(val, 0)));
659
+ } else
660
+ state.buf.push(quote(val, 0));
661
+ return !0;
653
662
  }
654
663
  function writeNumber(state, val) {
655
664
  return state.buf.push(val + ""), !0;
package/dist/html.mjs CHANGED
@@ -373,6 +373,7 @@ var REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
373
373
  flushed = !1;
374
374
  wroteUndefined = !1;
375
375
  buf = [];
376
+ strs = /* @__PURE__ */ new Map();
376
377
  refs = /* @__PURE__ */ new WeakMap();
377
378
  assigned = /* @__PURE__ */ new Set();
378
379
  registered = [];
@@ -511,7 +512,7 @@ function writeAssigned(state) {
511
512
  function writeProp(state, val, parent, accessor) {
512
513
  switch (typeof val) {
513
514
  case "string":
514
- return writeString(state, val);
515
+ return writeString(state, val, parent, accessor);
515
516
  case "number":
516
517
  return writeNumber(state, val);
517
518
  case "boolean":
@@ -558,8 +559,16 @@ function writeRegistered(state, val, parent, accessor, registered) {
558
559
  state.buf.push(registered.access);
559
560
  return !0;
560
561
  }
561
- function writeString(state, val) {
562
- return state.buf.push(quote(val, 0)), !0;
562
+ function writeString(state, val, parent, accessor) {
563
+ if (val.length > 30) {
564
+ let ref = state.strs.get(val);
565
+ ref ? state.buf.push(ensureId(state, ref)) : (state.strs.set(
566
+ val,
567
+ new Reference(parent, accessor, state.flush, state.buf.length)
568
+ ), state.buf.push(quote(val, 0)));
569
+ } else
570
+ state.buf.push(quote(val, 0));
571
+ return !0;
563
572
  }
564
573
  function writeNumber(state, val) {
565
574
  return state.buf.push(val + ""), !0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/runtime-tags",
3
- "version": "6.0.149",
3
+ "version": "6.0.150",
4
4
  "description": "Optimized runtime for Marko templates.",
5
5
  "keywords": [
6
6
  "api",