@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.
@@ -1814,6 +1814,240 @@ var init_islandSsr = __esm(() => {
1814
1814
  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;
1815
1815
  });
1816
1816
 
1817
+ // src/build/maskLiterals.ts
1818
+ var SENTINEL, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
1819
+ const n = src.length;
1820
+ const pieces = [];
1821
+ let out = "";
1822
+ let i = 0;
1823
+ let prevChar = "";
1824
+ let prevWord = "";
1825
+ let prevWasSpace = false;
1826
+ let wordBeforeParen = "";
1827
+ const mask = (text) => {
1828
+ out += SENTINEL + pieces.length + SENTINEL;
1829
+ pieces.push(text);
1830
+ prevChar = ")";
1831
+ prevWord = "";
1832
+ prevWasSpace = false;
1833
+ };
1834
+ const endOfString = (start) => {
1835
+ const q = src[start];
1836
+ let j = start + 1;
1837
+ while (j < n) {
1838
+ const c = src[j];
1839
+ if (c === "\\") {
1840
+ j += 2;
1841
+ continue;
1842
+ }
1843
+ if (c === q)
1844
+ return j + 1;
1845
+ if (c === `
1846
+ `)
1847
+ return j;
1848
+ j++;
1849
+ }
1850
+ return j;
1851
+ };
1852
+ const endOfInterp = (start) => {
1853
+ let j = start;
1854
+ let depth = 1;
1855
+ while (j < n && depth > 0) {
1856
+ const c = src[j];
1857
+ if (c === "\\") {
1858
+ j += 2;
1859
+ continue;
1860
+ }
1861
+ if (c === "`") {
1862
+ j = endOfTemplate(j);
1863
+ continue;
1864
+ }
1865
+ if (c === '"' || c === "'") {
1866
+ j = endOfString(j);
1867
+ continue;
1868
+ }
1869
+ if (c === "/" && src[j + 1] === "/") {
1870
+ const nl = src.indexOf(`
1871
+ `, j);
1872
+ j = nl < 0 ? n : nl;
1873
+ continue;
1874
+ }
1875
+ if (c === "/" && src[j + 1] === "*") {
1876
+ const e = src.indexOf("*/", j + 2);
1877
+ j = e < 0 ? n : e + 2;
1878
+ continue;
1879
+ }
1880
+ if (c === "{")
1881
+ depth++;
1882
+ else if (c === "}")
1883
+ depth--;
1884
+ j++;
1885
+ }
1886
+ return j;
1887
+ };
1888
+ function endOfTemplate(start) {
1889
+ let j = start + 1;
1890
+ while (j < n) {
1891
+ const c = src[j];
1892
+ if (c === "\\") {
1893
+ j += 2;
1894
+ continue;
1895
+ }
1896
+ if (c === "`")
1897
+ return j + 1;
1898
+ if (c === "$" && src[j + 1] === "{") {
1899
+ j = endOfInterp(j + 2);
1900
+ continue;
1901
+ }
1902
+ j++;
1903
+ }
1904
+ return j;
1905
+ }
1906
+ const endOfRegex = (start) => {
1907
+ let j = start + 1;
1908
+ let inClass = false;
1909
+ while (j < n) {
1910
+ const c = src[j];
1911
+ if (c === "\\") {
1912
+ j += 2;
1913
+ continue;
1914
+ }
1915
+ if (c === `
1916
+ `)
1917
+ return -1;
1918
+ if (c === "[")
1919
+ inClass = true;
1920
+ else if (c === "]")
1921
+ inClass = false;
1922
+ else if (c === "/" && !inClass) {
1923
+ j++;
1924
+ break;
1925
+ }
1926
+ j++;
1927
+ }
1928
+ while (j < n && /[a-z]/i.test(src[j] ?? ""))
1929
+ j++;
1930
+ return j;
1931
+ };
1932
+ while (i < n) {
1933
+ const c = src[i];
1934
+ const c2 = src[i + 1];
1935
+ if (c === "/" && c2 === "/") {
1936
+ out += "//";
1937
+ i += 2;
1938
+ const s = i;
1939
+ while (i < n && src[i] !== `
1940
+ `)
1941
+ i++;
1942
+ mask(src.slice(s, i));
1943
+ continue;
1944
+ }
1945
+ if (c === "/" && c2 === "*") {
1946
+ out += "/*";
1947
+ i += 2;
1948
+ const e = src.indexOf("*/", i);
1949
+ const end = e < 0 ? n : e;
1950
+ mask(src.slice(i, end));
1951
+ i = end < n ? end + 2 : n;
1952
+ if (end < n)
1953
+ out += "*/";
1954
+ continue;
1955
+ }
1956
+ if (c === "`") {
1957
+ const end = endOfTemplate(i);
1958
+ mask(src.slice(i, end));
1959
+ i = end;
1960
+ continue;
1961
+ }
1962
+ if (c === '"' || c === "'") {
1963
+ const end = endOfString(i);
1964
+ const isSpecifier = prevWord === "from" || prevWord === "import" || prevChar === "(" && (wordBeforeParen === "import" || wordBeforeParen === "require");
1965
+ if (isSpecifier) {
1966
+ out += src.slice(i, end);
1967
+ prevChar = '"';
1968
+ prevWord = "";
1969
+ prevWasSpace = false;
1970
+ } else {
1971
+ mask(src.slice(i, end));
1972
+ }
1973
+ i = end;
1974
+ continue;
1975
+ }
1976
+ if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
1977
+ const end = endOfRegex(i);
1978
+ if (end > 0) {
1979
+ out += src.slice(i, end);
1980
+ i = end;
1981
+ prevChar = ")";
1982
+ prevWord = "";
1983
+ prevWasSpace = false;
1984
+ continue;
1985
+ }
1986
+ }
1987
+ out += c;
1988
+ i++;
1989
+ if (c === " " || c === "\t" || c === "\r" || c === `
1990
+ `) {
1991
+ prevWasSpace = true;
1992
+ continue;
1993
+ }
1994
+ if (isIdentChar(c)) {
1995
+ const contiguous = isIdentChar(prevChar) && !prevWasSpace;
1996
+ prevWord = contiguous ? prevWord + c : c;
1997
+ } else {
1998
+ if (c === "(")
1999
+ wordBeforeParen = prevWord;
2000
+ prevWord = "";
2001
+ }
2002
+ prevChar = c;
2003
+ prevWasSpace = false;
2004
+ }
2005
+ const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
2006
+ const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
2007
+ return { masked: out, restore };
2008
+ };
2009
+ var init_maskLiterals = __esm(() => {
2010
+ SENTINEL = String.fromCharCode(57344);
2011
+ REGEX_OK_AFTER_CHAR = new Set([
2012
+ "(",
2013
+ ",",
2014
+ "=",
2015
+ ":",
2016
+ "[",
2017
+ "!",
2018
+ "&",
2019
+ "|",
2020
+ "?",
2021
+ "{",
2022
+ "}",
2023
+ ";",
2024
+ "+",
2025
+ "-",
2026
+ "*",
2027
+ "/",
2028
+ "%",
2029
+ "^",
2030
+ "~",
2031
+ "<",
2032
+ ">"
2033
+ ]);
2034
+ REGEX_OK_AFTER_WORD = new Set([
2035
+ "return",
2036
+ "typeof",
2037
+ "instanceof",
2038
+ "in",
2039
+ "of",
2040
+ "new",
2041
+ "delete",
2042
+ "void",
2043
+ "do",
2044
+ "else",
2045
+ "yield",
2046
+ "await",
2047
+ "case"
2048
+ ]);
2049
+ });
2050
+
1817
2051
  // src/build/nativeRewrite.ts
1818
2052
  import { dlopen, FFIType, ptr } from "bun:ffi";
1819
2053
  import { platform, arch } from "os";
@@ -1904,8 +2138,9 @@ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewrite
1904
2138
  if (Object.keys(vendorPaths).length === 0)
1905
2139
  return content;
1906
2140
  const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
1907
- const native = nativeRewriteImports(content, replacements);
1908
- return native ?? jsRewriteImports(content, replacements);
2141
+ const { masked, restore } = maskLiterals(content);
2142
+ const native = nativeRewriteImports(masked, replacements);
2143
+ return restore(native ?? jsRewriteImports(masked, replacements));
1909
2144
  }, fixMissingReExportNamespacesInContent = (content) => {
1910
2145
  const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
1911
2146
  REEXPORT_PATTERN.lastIndex = 0;
@@ -2051,6 +2286,7 @@ ${content}`;
2051
2286
  return result;
2052
2287
  };
2053
2288
  var init_rewriteImportsPlugin = __esm(() => {
2289
+ init_maskLiterals();
2054
2290
  init_nativeRewrite();
2055
2291
  });
2056
2292
 
@@ -4300,5 +4536,5 @@ export {
4300
4536
  Island
4301
4537
  };
4302
4538
 
4303
- //# debugId=B7935F7DE166BD6B64756E2164756E21
4539
+ //# debugId=5D057DA7E1D729CF64756E2164756E21
4304
4540
  //# sourceMappingURL=index.js.map