@maintainer-pro/ai-bridge 0.1.33 → 0.1.36

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.
@@ -140,7 +140,9 @@ export function shouldRewriteBody(headers) {
140
140
  }
141
141
 
142
142
  /** Redirects have no Content-Type, but Location still has to stay under the share prefix. */
143
- export function shouldProcessShareResponse(headers) {
143
+ export function shouldProcessShareResponse(headers, path = "") {
144
+ // Widget bundle is self-contained — rewriting it as text blocks the bridge.
145
+ if (isLongCacheScriptPath(path)) return false;
144
146
  if (headerGet(headers, "location")) return true;
145
147
  if (shouldRewriteBody(headers)) return true;
146
148
  const ct = headerGet(headers, "content-type").toLowerCase();
@@ -1656,6 +1658,22 @@ export function processShareHttpResponse(opts) {
1656
1658
 
1657
1659
  rewriteHeaderUrls(headers, publicBase, port, portUrls);
1658
1660
 
1661
+ if (isLongCacheScriptPath(path)) {
1662
+ delete headers.etag;
1663
+ delete headers["last-modified"];
1664
+ const mode = applyShareCacheHeaders(headers, path);
1665
+ const etag = etagFor(payload);
1666
+ if (mode !== "no-store") headers.etag = etag;
1667
+ const cachedKey = rewriteCacheKey(publicBase, path);
1668
+ if (cachedKey) rememberRewrite(cachedKey, payload, status, headers, etag);
1669
+ if (mode !== "no-store" && etagMatches(ifNoneMatch, etag)) {
1670
+ return notModifiedResult(headers, etag);
1671
+ }
1672
+ payload = gzipIfRequested(payload, headers, acceptEncoding);
1673
+ headers["content-length"] = String(payload.length);
1674
+ return { status, headers, body: payload };
1675
+ }
1676
+
1659
1677
  const cachedKey = rewriteCacheKey(publicBase, path);
1660
1678
  const hit =
1661
1679
  cachedKey && Date.now() - (rewriteCache.get(cachedKey)?.at || 0) < REWRITE_CACHE_MS