@absolutejs/absolute 0.19.0-beta.1077 → 0.19.0-beta.1079

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.
@@ -739,6 +739,240 @@ var init_islandSsr = __esm(() => {
739
739
  LEADING_HOISTED_RESOURCE_RE = /^\s*(?:<link\b[^>]*\/?>|<meta\b[^>]*\/?>|<title\b[^>]*>[\s\S]*?<\/title>|<style\b[^>]*>[\s\S]*?<\/style>|<script\b[^>]*>[\s\S]*?<\/script>)/i;
740
740
  });
741
741
 
742
+ // src/build/maskLiterals.ts
743
+ var SENTINEL, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
744
+ const n = src.length;
745
+ const pieces = [];
746
+ let out = "";
747
+ let i = 0;
748
+ let prevChar = "";
749
+ let prevWord = "";
750
+ let prevWasSpace = false;
751
+ let wordBeforeParen = "";
752
+ const mask = (text) => {
753
+ out += SENTINEL + pieces.length + SENTINEL;
754
+ pieces.push(text);
755
+ prevChar = ")";
756
+ prevWord = "";
757
+ prevWasSpace = false;
758
+ };
759
+ const endOfString = (start) => {
760
+ const q = src[start];
761
+ let j = start + 1;
762
+ while (j < n) {
763
+ const c = src[j];
764
+ if (c === "\\") {
765
+ j += 2;
766
+ continue;
767
+ }
768
+ if (c === q)
769
+ return j + 1;
770
+ if (c === `
771
+ `)
772
+ return j;
773
+ j++;
774
+ }
775
+ return j;
776
+ };
777
+ const endOfInterp = (start) => {
778
+ let j = start;
779
+ let depth = 1;
780
+ while (j < n && depth > 0) {
781
+ const c = src[j];
782
+ if (c === "\\") {
783
+ j += 2;
784
+ continue;
785
+ }
786
+ if (c === "`") {
787
+ j = endOfTemplate(j);
788
+ continue;
789
+ }
790
+ if (c === '"' || c === "'") {
791
+ j = endOfString(j);
792
+ continue;
793
+ }
794
+ if (c === "/" && src[j + 1] === "/") {
795
+ const nl = src.indexOf(`
796
+ `, j);
797
+ j = nl < 0 ? n : nl;
798
+ continue;
799
+ }
800
+ if (c === "/" && src[j + 1] === "*") {
801
+ const e = src.indexOf("*/", j + 2);
802
+ j = e < 0 ? n : e + 2;
803
+ continue;
804
+ }
805
+ if (c === "{")
806
+ depth++;
807
+ else if (c === "}")
808
+ depth--;
809
+ j++;
810
+ }
811
+ return j;
812
+ };
813
+ function endOfTemplate(start) {
814
+ let j = start + 1;
815
+ while (j < n) {
816
+ const c = src[j];
817
+ if (c === "\\") {
818
+ j += 2;
819
+ continue;
820
+ }
821
+ if (c === "`")
822
+ return j + 1;
823
+ if (c === "$" && src[j + 1] === "{") {
824
+ j = endOfInterp(j + 2);
825
+ continue;
826
+ }
827
+ j++;
828
+ }
829
+ return j;
830
+ }
831
+ const endOfRegex = (start) => {
832
+ let j = start + 1;
833
+ let inClass = false;
834
+ while (j < n) {
835
+ const c = src[j];
836
+ if (c === "\\") {
837
+ j += 2;
838
+ continue;
839
+ }
840
+ if (c === `
841
+ `)
842
+ return -1;
843
+ if (c === "[")
844
+ inClass = true;
845
+ else if (c === "]")
846
+ inClass = false;
847
+ else if (c === "/" && !inClass) {
848
+ j++;
849
+ break;
850
+ }
851
+ j++;
852
+ }
853
+ while (j < n && /[a-z]/i.test(src[j] ?? ""))
854
+ j++;
855
+ return j;
856
+ };
857
+ while (i < n) {
858
+ const c = src[i];
859
+ const c2 = src[i + 1];
860
+ if (c === "/" && c2 === "/") {
861
+ out += "//";
862
+ i += 2;
863
+ const s = i;
864
+ while (i < n && src[i] !== `
865
+ `)
866
+ i++;
867
+ mask(src.slice(s, i));
868
+ continue;
869
+ }
870
+ if (c === "/" && c2 === "*") {
871
+ out += "/*";
872
+ i += 2;
873
+ const e = src.indexOf("*/", i);
874
+ const end = e < 0 ? n : e;
875
+ mask(src.slice(i, end));
876
+ i = end < n ? end + 2 : n;
877
+ if (end < n)
878
+ out += "*/";
879
+ continue;
880
+ }
881
+ if (c === "`") {
882
+ const end = endOfTemplate(i);
883
+ mask(src.slice(i, end));
884
+ i = end;
885
+ continue;
886
+ }
887
+ if (c === '"' || c === "'") {
888
+ const end = endOfString(i);
889
+ const isSpecifier = prevWord === "from" || prevWord === "import" || prevChar === "(" && (wordBeforeParen === "import" || wordBeforeParen === "require");
890
+ if (isSpecifier) {
891
+ out += src.slice(i, end);
892
+ prevChar = '"';
893
+ prevWord = "";
894
+ prevWasSpace = false;
895
+ } else {
896
+ mask(src.slice(i, end));
897
+ }
898
+ i = end;
899
+ continue;
900
+ }
901
+ if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
902
+ const end = endOfRegex(i);
903
+ if (end > 0) {
904
+ out += src.slice(i, end);
905
+ i = end;
906
+ prevChar = ")";
907
+ prevWord = "";
908
+ prevWasSpace = false;
909
+ continue;
910
+ }
911
+ }
912
+ out += c;
913
+ i++;
914
+ if (c === " " || c === "\t" || c === "\r" || c === `
915
+ `) {
916
+ prevWasSpace = true;
917
+ continue;
918
+ }
919
+ if (isIdentChar(c)) {
920
+ const contiguous = isIdentChar(prevChar) && !prevWasSpace;
921
+ prevWord = contiguous ? prevWord + c : c;
922
+ } else {
923
+ if (c === "(")
924
+ wordBeforeParen = prevWord;
925
+ prevWord = "";
926
+ }
927
+ prevChar = c;
928
+ prevWasSpace = false;
929
+ }
930
+ const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
931
+ const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
932
+ return { masked: out, restore };
933
+ };
934
+ var init_maskLiterals = __esm(() => {
935
+ SENTINEL = String.fromCharCode(57344);
936
+ REGEX_OK_AFTER_CHAR = new Set([
937
+ "(",
938
+ ",",
939
+ "=",
940
+ ":",
941
+ "[",
942
+ "!",
943
+ "&",
944
+ "|",
945
+ "?",
946
+ "{",
947
+ "}",
948
+ ";",
949
+ "+",
950
+ "-",
951
+ "*",
952
+ "/",
953
+ "%",
954
+ "^",
955
+ "~",
956
+ "<",
957
+ ">"
958
+ ]);
959
+ REGEX_OK_AFTER_WORD = new Set([
960
+ "return",
961
+ "typeof",
962
+ "instanceof",
963
+ "in",
964
+ "of",
965
+ "new",
966
+ "delete",
967
+ "void",
968
+ "do",
969
+ "else",
970
+ "yield",
971
+ "await",
972
+ "case"
973
+ ]);
974
+ });
975
+
742
976
  // src/build/nativeRewrite.ts
743
977
  import { dlopen, FFIType, ptr } from "bun:ffi";
744
978
  import { platform, arch } from "os";
@@ -829,8 +1063,9 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewrite
829
1063
  if (Object.keys(vendorPaths).length === 0)
830
1064
  return content;
831
1065
  const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
832
- const native = nativeRewriteImports(content, replacements);
833
- return native ?? jsRewriteImports(content, replacements);
1066
+ const { masked, restore } = maskLiterals(content);
1067
+ const native = nativeRewriteImports(masked, replacements);
1068
+ return restore(native ?? jsRewriteImports(masked, replacements));
834
1069
  }, fixMissingReExportNamespacesInContent = (content) => {
835
1070
  const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
836
1071
  REEXPORT_PATTERN.lastIndex = 0;
@@ -976,6 +1211,7 @@ ${content}`;
976
1211
  return result;
977
1212
  };
978
1213
  var init_rewriteImportsPlugin = __esm(() => {
1214
+ init_maskLiterals();
979
1215
  init_nativeRewrite();
980
1216
  });
981
1217
 
@@ -2412,5 +2648,5 @@ export {
2412
2648
  createIslandStore
2413
2649
  };
2414
2650
 
2415
- //# debugId=2BDA41BFE8300F5F64756E2164756E21
2651
+ //# debugId=A4E68C081DF3970564756E2164756E21
2416
2652
  //# sourceMappingURL=index.js.map