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