@absolutejs/absolute 0.19.0-beta.1076 → 0.19.0-beta.1078

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