@impakers/debug 1.3.11 → 1.3.12

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.
package/dist/react.mjs CHANGED
@@ -2087,30 +2087,51 @@ async function updateTaskStatus(endpoint, taskId, status) {
2087
2087
  import { AnyMap, originalPositionFor } from "@jridgewell/trace-mapping";
2088
2088
  var cache2 = /* @__PURE__ */ new Map();
2089
2089
  var failedUrls = /* @__PURE__ */ new Set();
2090
- function getSourceMapUrl(bundleUrl) {
2091
- if (bundleUrl.endsWith(".map")) return bundleUrl;
2092
- return `${bundleUrl}.map`;
2090
+ async function getSourceMapUrlFromBundle(bundleUrl) {
2091
+ try {
2092
+ const res = await fetch(bundleUrl, { cache: "force-cache" });
2093
+ if (!res.ok) return null;
2094
+ const text = await res.text();
2095
+ const match = text.match(/\/\/[#@]\s*sourceMappingURL\s*=\s*(\S+)\s*$/m);
2096
+ if (!match) return null;
2097
+ const mapRef = match[1];
2098
+ if (mapRef.startsWith("http")) return mapRef;
2099
+ const base = bundleUrl.substring(0, bundleUrl.lastIndexOf("/") + 1);
2100
+ return base + mapRef;
2101
+ } catch {
2102
+ return null;
2103
+ }
2093
2104
  }
2094
2105
  async function loadSourceMap(bundleUrl) {
2095
2106
  if (cache2.has(bundleUrl)) return cache2.get(bundleUrl) ?? null;
2096
2107
  if (failedUrls.has(bundleUrl)) return null;
2097
- const mapUrl = getSourceMapUrl(bundleUrl);
2108
+ const directMapUrl = bundleUrl.endsWith(".map") ? bundleUrl : `${bundleUrl}.map`;
2098
2109
  try {
2099
- const res = await fetch(mapUrl, { cache: "force-cache" });
2100
- if (!res.ok) {
2101
- failedUrls.add(bundleUrl);
2102
- cache2.set(bundleUrl, null);
2103
- return null;
2110
+ const res = await fetch(directMapUrl, { cache: "force-cache" });
2111
+ if (res.ok) {
2112
+ const rawMap = await res.json();
2113
+ const traceMap = new AnyMap(rawMap);
2114
+ cache2.set(bundleUrl, traceMap);
2115
+ return traceMap;
2104
2116
  }
2105
- const rawMap = await res.json();
2106
- const traceMap = new AnyMap(rawMap);
2107
- cache2.set(bundleUrl, traceMap);
2108
- return traceMap;
2109
2117
  } catch {
2110
- failedUrls.add(bundleUrl);
2111
- cache2.set(bundleUrl, null);
2112
- return null;
2113
2118
  }
2119
+ const actualMapUrl = await getSourceMapUrlFromBundle(bundleUrl);
2120
+ if (actualMapUrl) {
2121
+ try {
2122
+ const res = await fetch(actualMapUrl, { cache: "force-cache" });
2123
+ if (res.ok) {
2124
+ const rawMap = await res.json();
2125
+ const traceMap = new AnyMap(rawMap);
2126
+ cache2.set(bundleUrl, traceMap);
2127
+ return traceMap;
2128
+ }
2129
+ } catch {
2130
+ }
2131
+ }
2132
+ failedUrls.add(bundleUrl);
2133
+ cache2.set(bundleUrl, null);
2134
+ return null;
2114
2135
  }
2115
2136
  async function resolveSourcePosition(bundlePath, line, column) {
2116
2137
  let bundleUrl;