@torpor/view 0.4.12 → 0.4.14

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.
Files changed (90) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{Cleanup-BGQ5zaxE.d.cts → Cleanup-CYsytTEc.d.cts} +1 -1
  3. package/dist/Cleanup-CYsytTEc.d.cts.map +1 -0
  4. package/dist/{Cleanup-Ca8IspaG.d.ts → Cleanup-CgjyN0lW.d.mts} +1 -1
  5. package/dist/Cleanup-CgjyN0lW.d.mts.map +1 -0
  6. package/dist/{Component-BDUCwkBQ.d.cts → Component-DmWGMgak.d.mts} +1 -1
  7. package/dist/{Component-BDUCwkBQ.d.cts.map → Component-DmWGMgak.d.mts.map} +1 -1
  8. package/dist/{Component-JVwSemf-.d.ts → Component-kGLRFYg2.d.cts} +1 -1
  9. package/dist/Component-kGLRFYg2.d.cts.map +1 -0
  10. package/dist/{Region-BrsZLZUe.d.ts → Region-Bb6HAb-F.d.cts} +2 -2
  11. package/dist/{Region-Cf7OeBIQ.d.cts.map → Region-Bb6HAb-F.d.cts.map} +1 -1
  12. package/dist/{Region-Cf7OeBIQ.d.cts → Region-CTchywkr.d.mts} +2 -2
  13. package/dist/Region-CTchywkr.d.mts.map +1 -0
  14. package/dist/compile.cjs +239 -71
  15. package/dist/compile.d.cts +1 -1
  16. package/dist/{compile.d.ts → compile.d.mts} +2 -2
  17. package/dist/compile.d.mts.map +1 -0
  18. package/dist/{compile.js → compile.mjs} +239 -70
  19. package/dist/compile.mjs.map +1 -0
  20. package/dist/dev.cjs +1 -2
  21. package/dist/dev.d.cts +2 -2
  22. package/dist/{dev.d.ts → dev.d.mts} +3 -3
  23. package/dist/dev.d.mts.map +1 -0
  24. package/dist/{dev.js → dev.mjs} +2 -2
  25. package/dist/{dev.cjs.map → dev.mjs.map} +1 -1
  26. package/dist/devContext-B3yskfhA.cjs +1 -2
  27. package/dist/{devContext-CevrTlUO.js → devContext-CQ8RhBX-.mjs} +1 -1
  28. package/dist/{devContext-B3yskfhA.cjs.map → devContext-CQ8RhBX-.mjs.map} +1 -1
  29. package/dist/{formatText-Ck04q8_X.cjs → formatText--9zsK5Nq.cjs} +4 -4
  30. package/dist/{formatText-OyD8MNAM.js → formatText-B8u71S_K.mjs} +4 -3
  31. package/dist/formatText-B8u71S_K.mjs.map +1 -0
  32. package/dist/formatText-BNP3P38F.d.cts +17 -0
  33. package/dist/formatText-BNP3P38F.d.cts.map +1 -0
  34. package/dist/formatText-D6Ov8Ub0.d.mts +17 -0
  35. package/dist/formatText-D6Ov8Ub0.d.mts.map +1 -0
  36. package/dist/index.cjs +2 -3
  37. package/dist/index.d.cts +5 -5
  38. package/dist/{index.d.ts → index.d.mts} +6 -6
  39. package/dist/index.d.mts.map +1 -0
  40. package/dist/{index.js → index.mjs} +3 -3
  41. package/dist/{index.cjs.map → index.mjs.map} +1 -1
  42. package/dist/ssr.cjs +2 -3
  43. package/dist/ssr.d.cts +2 -2
  44. package/dist/{ssr.d.ts → ssr.d.mts} +3 -3
  45. package/dist/ssr.d.mts.map +1 -0
  46. package/dist/{ssr.js → ssr.mjs} +2 -2
  47. package/dist/{ssr.cjs.map → ssr.mjs.map} +1 -1
  48. package/package.json +17 -17
  49. package/scripts/copyToRepl.ts +6 -6
  50. package/src/compile/build/client/addMappedTextWithOffsets.ts +31 -0
  51. package/src/compile/build/client/buildAddFragment.ts +11 -11
  52. package/src/compile/build/client/buildComponentNode.ts +123 -29
  53. package/src/compile/build/client/buildElementNode.ts +65 -8
  54. package/src/compile/build/client/buildIfNode.ts +1 -1
  55. package/src/compile/build/client/buildSwitchNode.ts +1 -1
  56. package/src/compile/build/client/buildTextNode.ts +13 -6
  57. package/src/compile/build/client/getAttributeOffsets.ts +90 -0
  58. package/src/compile/build/client/stashRunWithOffsets.ts +7 -1
  59. package/src/compile/build/server/buildServerElementNode.ts +1 -1
  60. package/src/compile/parse/parseTag.ts +1 -7
  61. package/src/compile/parse/parseText.ts +1 -1
  62. package/src/index.ts +3 -1
  63. package/src/render/buildClasses.ts +4 -17
  64. package/src/render/buildStyles.ts +6 -4
  65. package/src/types/ClassValue.ts +8 -0
  66. package/src/types/StyleValue.ts +8 -0
  67. package/test/source-maps/interpolated.test.ts +88 -0
  68. package/test/source-maps/parse.test.ts +1 -1
  69. package/tsdown.config.ts +2 -9
  70. package/vitest.config.ts +3 -3
  71. package/dist/Cleanup-BGQ5zaxE.d.cts.map +0 -1
  72. package/dist/Cleanup-Ca8IspaG.d.ts.map +0 -1
  73. package/dist/Component-JVwSemf-.d.ts.map +0 -1
  74. package/dist/Region-BrsZLZUe.d.ts.map +0 -1
  75. package/dist/compile.cjs.map +0 -1
  76. package/dist/compile.d.ts.map +0 -1
  77. package/dist/compile.js.map +0 -1
  78. package/dist/dev.d.ts.map +0 -1
  79. package/dist/dev.js.map +0 -1
  80. package/dist/devContext-CevrTlUO.js.map +0 -1
  81. package/dist/formatText-A8G0kbCI.d.ts +0 -11
  82. package/dist/formatText-A8G0kbCI.d.ts.map +0 -1
  83. package/dist/formatText-Ck04q8_X.cjs.map +0 -1
  84. package/dist/formatText-DNPkZ1xY.d.cts +0 -11
  85. package/dist/formatText-DNPkZ1xY.d.cts.map +0 -1
  86. package/dist/formatText-OyD8MNAM.js.map +0 -1
  87. package/dist/index.d.ts.map +0 -1
  88. package/dist/index.js.map +0 -1
  89. package/dist/ssr.d.ts.map +0 -1
  90. package/dist/ssr.js.map +0 -1
@@ -299,6 +299,28 @@ function nextVarName(name, status) {
299
299
  return varName;
300
300
  }
301
301
 
302
+ //#endregion
303
+ //#region src/compile/build/client/addMappedTextWithOffsets.ts
304
+ function addMappedTextWithOffsets(preText, text, postText, spans, offsets, lengths, status, b) {
305
+ if (status.options.mapped === true) {
306
+ let mappedStart = b.toString().length + preText.length;
307
+ let functionBody = preText + text + postText;
308
+ b.append(functionBody);
309
+ for (let i = 0; i < spans.length; i++) {
310
+ let start = mappedStart + offsets[i];
311
+ let end = start + lengths[i];
312
+ status.map.push({
313
+ script: functionBody,
314
+ source: spans[i],
315
+ compiled: {
316
+ start,
317
+ end
318
+ }
319
+ });
320
+ }
321
+ } else b.append(preText + text + postText);
322
+ }
323
+
302
324
  //#endregion
303
325
  //#region src/compile/build/client/buildAddFragment.ts
304
326
  function buildAddFragment(node, status, b, parentName, anchorName) {
@@ -309,19 +331,7 @@ function buildAddFragment(node, status, b, parentName, anchorName) {
309
331
  if (fragment.effects.length > 0) {
310
332
  status.imports.add("$run");
311
333
  b.append("$run(() => {");
312
- if (status.options.mapped === true) for (let effect of fragment.effects) for (let i = 0; i < effect.spans.length; i++) {
313
- let start = b.toString().length + effect.offsets[i];
314
- b.append(effect.functionBody);
315
- let end = start + effect.lengths[i];
316
- status.map.push({
317
- script: effect.functionBody,
318
- source: effect.spans[i],
319
- compiled: {
320
- start,
321
- end
322
- }
323
- });
324
- }
334
+ if (status.options.mapped === true) for (let effect of fragment.effects) addMappedTextWithOffsets("", effect.functionBody, "", effect.spans, effect.offsets, effect.lengths, status, b);
325
335
  else b.append(fragment.effects.map((e) => e.functionBody).join("\n"));
326
336
  b.append(`}${status.options.dev === true ? `, "setAttributes"` : ""});`);
327
337
  }
@@ -704,6 +714,81 @@ function buildRun(functionName, functionBody, status, b) {
704
714
  addPopDevBoundary(status, b);
705
715
  }
706
716
 
717
+ //#endregion
718
+ //#region src/compile/utils/endOfString.ts
719
+ function endOfString(char, content, start) {
720
+ for (let j = start + 1; j < content.length; j++) if (content[j] === char && content[j - 1] !== "\\") return j;
721
+ return content.length;
722
+ }
723
+
724
+ //#endregion
725
+ //#region src/compile/build/client/getAttributeOffsets.ts
726
+ function getAttributeOffsets(value, span) {
727
+ value = trimQuotes(value);
728
+ let spans = [];
729
+ let offsets = [];
730
+ let lengths = [];
731
+ let textContent = "";
732
+ let reactiveStart = 0;
733
+ let level = 0;
734
+ for (let i = 0; i < value.length; i++) {
735
+ const char = value[i];
736
+ const nextChar = value[i + 1];
737
+ if (char === "{") {
738
+ level++;
739
+ if (level === 1) {
740
+ textContent += "${";
741
+ reactiveStart = textContent.length;
742
+ spans.push({
743
+ start: span.start + i + 2,
744
+ end: -1
745
+ });
746
+ offsets.push(reactiveStart + 1);
747
+ continue;
748
+ }
749
+ } else if (char === "}") {
750
+ level--;
751
+ if (level === 0) {
752
+ spans.at(-1).end = span.start + i + 2;
753
+ lengths.push(textContent.length - reactiveStart);
754
+ textContent += "}";
755
+ continue;
756
+ }
757
+ } else if (char === "`" && level === 0) textContent += "\\";
758
+ else if (level > 0) {
759
+ if (char === "/" && nextChar === "/") {
760
+ let start = i;
761
+ i = value.indexOf("\n", i);
762
+ textContent += value.substring(start, i + 1);
763
+ continue;
764
+ } else if (char === "/" && nextChar === "*") {
765
+ let start = i;
766
+ i = value.indexOf("*/", i) + 1;
767
+ textContent += value.substring(start, i + 1);
768
+ continue;
769
+ } else if (char === "\"" || char === "'") {
770
+ let start = i;
771
+ i = endOfString(char, value, i);
772
+ textContent += value.substring(start, i + 1);
773
+ continue;
774
+ } else if (char === "`") {
775
+ let start = i;
776
+ i = endOfTemplateString(value, i);
777
+ textContent += value.substring(start, i + 1);
778
+ continue;
779
+ }
780
+ }
781
+ textContent += value[i];
782
+ }
783
+ value = `\`${textContent}\``;
784
+ return {
785
+ newValue: value,
786
+ spans,
787
+ offsets,
788
+ lengths
789
+ };
790
+ }
791
+
707
792
  //#endregion
708
793
  //#region src/compile/build/client/buildComponentNode.ts
709
794
  function buildComponentNode(node, status, b, root = false) {
@@ -716,51 +801,123 @@ function buildComponentNode(node, status, b, root = false) {
716
801
  let props = [];
717
802
  let runs = [];
718
803
  let bindingRuns = [];
719
- for (let { name, value, reactive, fullyReactive, span } of node.attributes) if (name === "self" && node.tagName === "@component") {} else if (name.startsWith("&") && value != null && fullyReactive) {
804
+ for (let { name, value, reactive, fullyReactive, span } of node.attributes) if (name === "self" && node.tagName === "@component") {} else if (value != null && fullyReactive) if (name.startsWith("&")) {
720
805
  name = name.substring(1);
721
806
  props.push({
722
807
  name,
808
+ preText: "",
723
809
  value,
724
- span
810
+ postText: "",
811
+ spans: [span],
812
+ offsets: [],
813
+ lengths: []
725
814
  });
726
815
  runs.push(`${propsName}["${name}"] = ${value};`);
727
816
  bindingRuns.push(`${value} = ${propsName}["${name}"];`);
728
- } else if (name === "class" && value != null) {
817
+ } else if (name === "class") {
729
818
  status.imports.add("t_class");
730
819
  const params = [value];
731
820
  if (node.scopeStyles) params.push(`"torp-${status.styleHash}"`);
732
- value = `t_class(${params.join(", ")})`;
821
+ value = params.join(", ");
733
822
  props.push({
734
823
  name,
824
+ preText: "t_class(",
735
825
  value,
736
- span
826
+ postText: ")",
827
+ spans: [span],
828
+ offsets: [],
829
+ lengths: []
737
830
  });
738
- runs.push(`${propsName}["${name}"] = ${value};`);
739
- } else if (name === "style" && value != null) {
831
+ runs.push(`${propsName}["${name}"] = t_class(${value});`);
832
+ } else if (name === "style") {
740
833
  status.imports.add("t_style");
741
- value = `t_style(${value})`;
742
834
  props.push({
743
835
  name,
836
+ preText: "t_style(",
744
837
  value,
745
- span
838
+ postText: ")",
839
+ spans: [span],
840
+ offsets: [],
841
+ lengths: []
746
842
  });
747
- runs.push(`${propsName}["${name}"] = ${value};`);
748
- } else if (value != null) {
843
+ runs.push(`${propsName}["${name}"] = t_style(${value});`);
844
+ } else {
749
845
  props.push({
750
846
  name,
847
+ preText: "",
751
848
  value,
752
- span
849
+ postText: "",
850
+ spans: [span],
851
+ offsets: [],
852
+ lengths: []
753
853
  });
754
- if (reactive) runs.push(`${propsName}["${name}"] = ${value};`);
755
- } else props.push({
854
+ runs.push(`${propsName}["${name}"] = ${value};`);
855
+ }
856
+ else if (value != null && reactive) {
857
+ const { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);
858
+ value = newValue;
859
+ if (name === "class") {
860
+ status.imports.add("t_class");
861
+ const params = [value];
862
+ if (node.scopeStyles) params.push(`"torp-${status.styleHash}"`);
863
+ value = params.join(", ");
864
+ props.push({
865
+ name,
866
+ preText: "t_class(",
867
+ value,
868
+ postText: ")",
869
+ spans,
870
+ offsets,
871
+ lengths
872
+ });
873
+ runs.push(`${propsName}["${name}"] = t_class(${value});`);
874
+ } else if (name === "style") {
875
+ status.imports.add("t_style");
876
+ props.push({
877
+ name,
878
+ preText: "t_style(",
879
+ value,
880
+ postText: ")",
881
+ spans,
882
+ offsets,
883
+ lengths
884
+ });
885
+ runs.push(`${propsName}["${name}"] = t_style(${value});`);
886
+ } else {
887
+ props.push({
888
+ name,
889
+ preText: "",
890
+ value,
891
+ postText: "",
892
+ spans,
893
+ offsets,
894
+ lengths
895
+ });
896
+ runs.push(`${propsName}["${name}"] = ${value};`);
897
+ }
898
+ } else if (value != null) props.push({
899
+ name,
900
+ preText: "",
901
+ value,
902
+ postText: "",
903
+ spans: [span],
904
+ offsets: [],
905
+ lengths: []
906
+ });
907
+ else props.push({
756
908
  name,
909
+ preText: "",
757
910
  value: "true",
758
- span
911
+ postText: "",
912
+ spans: [span],
913
+ offsets: [],
914
+ lengths: []
759
915
  });
760
916
  b.append(`const ${propsName} = $watch({`);
761
917
  for (let p of props) {
762
918
  let value = replaceForVarNames(p.value, status);
763
- addMappedText(`${p.name}: `, value, ",", p.span, status, b);
919
+ if (p.spans.length === 1) addMappedText(`${p.name}: ` + p.preText, value, p.postText + ",", p.spans[0], status, b);
920
+ else addMappedTextWithOffsets(`${p.name}: ` + p.preText, value, p.postText + ",", p.spans, p.offsets, p.lengths, status, b);
764
921
  }
765
922
  b.append("});");
766
923
  if (runs.length) buildRun("setProps", replaceForVarNames(runs.join("\n"), status), status, b);
@@ -1099,7 +1256,7 @@ function buildIfNode(node, status, b) {
1099
1256
  b.append(`
1100
1257
  const ${regionName} = t_region(${status.options.dev === true ? `"if"` : ""});
1101
1258
  let ${indexName} = -1;
1102
- t_run_control(${regionName}, ${anchorName}, (t_before) => {`);
1259
+ t_run_control(${regionName}, ${anchorName}, (${status.inHead ? "" : "t_before"}) => {`);
1103
1260
  let index = 0;
1104
1261
  for (let branch of branches) buildIfBranch(branch, status, b, parentName, regionName, indexName, index++);
1105
1262
  b.append(`}${status.options.dev === true ? `, "runIf"` : ""});`);
@@ -1208,7 +1365,7 @@ function buildSwitchNode(node, status, b) {
1208
1365
  b.append(`
1209
1366
  const ${regionName} = t_region(${status.options.dev === true ? `"switch"` : ""});
1210
1367
  let ${indexName} = -1;
1211
- t_run_control(${regionName}, ${anchorName}, (t_before) => {`);
1368
+ t_run_control(${regionName}, ${anchorName}, (${status.inHead ? "" : "t_before"}) => {`);
1212
1369
  addMappedText("", `${replaceForVarNames(node.statement, status)}`, " {", node.span, status, b);
1213
1370
  let index = 0;
1214
1371
  for (let branch of branches) buildSwitchBranch(branch, status, b, parentName, regionName, indexName, index++);
@@ -1330,6 +1487,26 @@ function stashRun(fragment, functionStart, value, functionEnd, span, status) {
1330
1487
  });
1331
1488
  }
1332
1489
 
1490
+ //#endregion
1491
+ //#region src/compile/build/client/stashRunWithOffsets.ts
1492
+ function stashRunWithOffsets(fragment, functionStart, value, functionEnd, spans, offsets, lengths, status) {
1493
+ let functionBody = functionStart + value + functionEnd;
1494
+ for (let i = 0; i < offsets.length; i++) {
1495
+ offsets[i] += functionStart.length;
1496
+ const oldLength = functionBody.length;
1497
+ functionBody = functionBody.substring(0, offsets[i]) + replaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) + functionBody.substring(offsets[i] + lengths[i]);
1498
+ const changedLength = functionBody.length - oldLength;
1499
+ lengths[i] += changedLength;
1500
+ for (let j = i + 1; j < offsets.length; j++) offsets[j] += changedLength;
1501
+ }
1502
+ fragment.effects.push({
1503
+ functionBody,
1504
+ spans,
1505
+ offsets,
1506
+ lengths
1507
+ });
1508
+ }
1509
+
1333
1510
  //#endregion
1334
1511
  //#region src/compile/build/client/buildElementNode.ts
1335
1512
  function buildElementNode(node, status, b, parentName, root = false) {
@@ -1419,26 +1596,46 @@ function buildElementAttributes$1(node, varName, status, b) {
1419
1596
  let { value, fullyReactive } = refAttribute;
1420
1597
  if (value != null && fullyReactive) b.append(`${value} = ${varName};`);
1421
1598
  }
1422
- for (let { name, value, reactive, span: range } of node.attributes) if (name === "self" && node.tagName === "@element") {} else if (name === "&ref") {} else if (value != null && reactive) if (name === "&group") buildBindGroupAttribute(node, varName, value, status, b);
1599
+ for (let { name, value, reactive, fullyReactive, span } of node.attributes) if (name === "self" && node.tagName === "@element") {} else if (name === "&ref") {} else if (value != null && fullyReactive) if (name === "&group") buildBindGroupAttribute(node, varName, value, status, b);
1423
1600
  else if (name === "&value" || name === "&checked") buildBindAttribute(node, varName, name, value, status, b);
1424
1601
  else if (name === "onmount") buildMount("elMount", `return (${trimEnd(value.trim(), ";")})(${varName});`, status, b);
1425
- else if (name.startsWith("on")) buildEventAttribute(varName, name, value, range, status, b);
1602
+ else if (name.startsWith("on")) buildEventAttribute(varName, name, value, span, status, b);
1426
1603
  else if (name.startsWith("transition")) buildTransitionAttribute(node, varName, name, value, status, b);
1427
1604
  else if (name === "class") {
1428
1605
  status.imports.add("t_class");
1429
1606
  const params = [value];
1430
1607
  if (node.scopeStyles) params.push(`"torp-${status.styleHash}"`);
1431
1608
  const propName = status.ns ? "className.baseVal" : "className";
1432
- stashRun(fragment, `${status.ns ? "// @ts-ignore\n" : ""}${varName}.${propName} = t_class(`, params.join(", "), ");", range, status);
1609
+ stashRun(fragment, `${status.ns ? "// @ts-ignore\n" : ""}${varName}.${propName} = t_class(`, params.join(", "), ");", span, status);
1433
1610
  } else if (name === "style") {
1434
1611
  status.imports.add("t_style");
1435
- stashRun(fragment, `${varName}.setAttribute("style", t_style(`, value, "));", range, status);
1612
+ stashRun(fragment, `${varName}.setAttribute("style", t_style(`, value, "));", span, status);
1436
1613
  } else if (name.includes("-")) {
1437
1614
  status.imports.add("t_attribute");
1438
- stashRun(fragment, `t_attribute(${varName}, "${name}", `, value, ");", range, status);
1615
+ stashRun(fragment, `t_attribute(${varName}, "${name}", `, value, ");", span, status);
1439
1616
  } else {
1440
1617
  status.imports.add("t_attribute");
1441
- stashRun(fragment, `t_attribute(${varName}, "${name}", `, value, ");", range, status);
1618
+ stashRun(fragment, `t_attribute(${varName}, "${name}", `, value, ");", span, status);
1619
+ }
1620
+ else if (value != null && reactive) {
1621
+ const { newValue, spans, offsets, lengths } = getAttributeOffsets(value, span);
1622
+ value = newValue;
1623
+ if (name === "class") {
1624
+ status.imports.add("t_class");
1625
+ const params = [value];
1626
+ if (node.scopeStyles) params.push(`"torp-${status.styleHash}"`);
1627
+ const propName = status.ns ? "className.baseVal" : "className";
1628
+ stashRunWithOffsets(fragment, `${status.ns ? "// @ts-ignore\n" : ""}${varName}.${propName} = t_class(`, params.join(", "), ");", spans, offsets, lengths, status);
1629
+ } else if (name === "style") {
1630
+ status.imports.add("t_style");
1631
+ stashRunWithOffsets(fragment, `${varName}.setAttribute("style", t_style(`, value, "));", spans, offsets, lengths, status);
1632
+ } else if (name.includes("-")) {
1633
+ status.imports.add("t_attribute");
1634
+ stashRunWithOffsets(fragment, `t_attribute(${varName}, "${name}", `, value, ");", spans, offsets, lengths, status);
1635
+ } else {
1636
+ status.imports.add("t_attribute");
1637
+ stashRunWithOffsets(fragment, `t_attribute(${varName}, "${name}", `, value, ");", spans, offsets, lengths, status);
1638
+ }
1442
1639
  }
1443
1640
  }
1444
1641
  function buildBindGroupAttribute(node, varName, value, status, b) {
@@ -1602,31 +1799,6 @@ function buildSpecialNode(node, status, b, parentName, root = false) {
1602
1799
  return "";
1603
1800
  }
1604
1801
 
1605
- //#endregion
1606
- //#region src/compile/utils/endOfString.ts
1607
- function endOfString(char, content, start) {
1608
- for (let j = start + 1; j < content.length; j++) if (content[j] === char && content[j - 1] !== "\\") return j;
1609
- return content.length;
1610
- }
1611
-
1612
- //#endregion
1613
- //#region src/compile/build/client/stashRunWithOffsets.ts
1614
- function stashRunWithOffsets(fragment, functionBody, spans, offsets, lengths, status) {
1615
- for (let i = 0; i < offsets.length; i++) {
1616
- const oldLength = functionBody.length;
1617
- functionBody = functionBody.substring(0, offsets[i]) + replaceForVarNames(functionBody.substring(offsets[i], offsets[i] + lengths[i]), status) + functionBody.substring(offsets[i] + lengths[i]);
1618
- const changedLength = functionBody.length - oldLength;
1619
- lengths[i] += changedLength;
1620
- for (let j = i + 1; j < offsets.length; j++) offsets[j] += changedLength;
1621
- }
1622
- fragment.effects.push({
1623
- functionBody,
1624
- spans,
1625
- offsets,
1626
- lengths
1627
- });
1628
- }
1629
-
1630
1802
  //#endregion
1631
1803
  //#region src/compile/build/client/buildTextNode.ts
1632
1804
  function buildTextNode(node, status) {
@@ -1696,11 +1868,8 @@ function buildTextNode(node, status) {
1696
1868
  offsetChange = 1;
1697
1869
  }
1698
1870
  status.imports.add("t_fmt");
1699
- let functionBody = `${node.varName}.textContent = `;
1700
- offsetChange += functionBody.length;
1701
1871
  offsets.map((_, i) => offsets[i] += offsetChange);
1702
- functionBody += `${textContent};`;
1703
- stashRunWithOffsets(fragment, functionBody, node.spans, offsets, lengths, status);
1872
+ stashRunWithOffsets(fragment, `${node.varName}.textContent = `, textContent, ";", node.spans, offsets, lengths, status);
1704
1873
  }
1705
1874
  }
1706
1875
 
@@ -2268,7 +2437,7 @@ function buildElementAttributes(node, status) {
2268
2437
  }
2269
2438
  else if (value != null && reactive) {
2270
2439
  status.imports.add("t_attr");
2271
- attributes.push(`${name}="${trimQuotes(value).replaceAll("${", "${t_attr(").replaceAll("}", ")}")}"`);
2440
+ attributes.push(`${name}="${trimQuotes(value).replaceAll("{", "${t_attr(").replaceAll("}", ")}")}"`);
2272
2441
  } else if (name === "class" && node.scopeStyles) {
2273
2442
  value = value ? `"${trimQuotes(value)} torp-${status.styleHash}"` : `"torp-${status.styleHash}"`;
2274
2443
  attributes.push(`${name}="${trimQuotes(value).replaceAll("\"", "&quot;")}"`);
@@ -2718,7 +2887,7 @@ function parseTag(status) {
2718
2887
  accept("<", status);
2719
2888
  let closeTag = accept("/", status);
2720
2889
  consumeSpace(status);
2721
- let tagStart = status.i;
2890
+ let tagStart = status.i + 1;
2722
2891
  let snailed = accept("@", status);
2723
2892
  let tagName = consumeAlphaNumeric(status);
2724
2893
  let tagEnd = status.i;
@@ -2782,7 +2951,7 @@ function parseAttribute(status) {
2782
2951
  value = value.substring(1, value.length - 1);
2783
2952
  valueStart++;
2784
2953
  valueEnd--;
2785
- } else if (reactive) value = `\`${trimQuotes(value).replaceAll("{", "${")}\``;
2954
+ }
2786
2955
  } else if (name.startsWith("{") && name.endsWith("}")) {
2787
2956
  value = name.substring(1, name.length - 1);
2788
2957
  valueStart++;
@@ -3799,4 +3968,4 @@ function parse(source) {
3799
3968
 
3800
3969
  //#endregion
3801
3970
  export { build, buildType, parse };
3802
- //# sourceMappingURL=compile.js.map
3971
+ //# sourceMappingURL=compile.mjs.map