@absolutejs/absolute 0.19.0-beta.1073 → 0.19.0-beta.1074

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.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-j8fXB2/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-qrTyUD/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-j8fXB2/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-qrTyUD/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-j8fXB2/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-qrTyUD/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -2471,6 +2471,41 @@ var init_devRouteRegistrationCallsite = __esm(() => {
2471
2471
  pageHandlerWrappers = new WeakMap;
2472
2472
  });
2473
2473
 
2474
+ // src/core/pageResponseCache.ts
2475
+ import { createHash as createHash2 } from "crypto";
2476
+ var STREAMING_PAGE_HEADER = "x-absolute-stream", HTML_CONTENT_TYPE = "text/html", streamingPageHeaders = (extra) => {
2477
+ const headers = new Headers(extra);
2478
+ headers.set("content-type", HTML_CONTENT_TYPE);
2479
+ headers.set(STREAMING_PAGE_HEADER, "1");
2480
+ return headers;
2481
+ }, computeEtag = (html) => `W/"${createHash2("sha1").update(html).digest("base64url")}"`, withPageCacheHeaders = async (response, request) => {
2482
+ const contentType = response.headers.get("content-type") ?? "";
2483
+ if (!contentType.includes(HTML_CONTENT_TYPE))
2484
+ return response;
2485
+ if (response.headers.get(STREAMING_PAGE_HEADER) === "1" || !response.body) {
2486
+ response.headers.delete(STREAMING_PAGE_HEADER);
2487
+ response.headers.set("cache-control", "no-cache");
2488
+ return response;
2489
+ }
2490
+ const html = await response.text();
2491
+ const etag = computeEtag(html);
2492
+ if (request?.headers.get("if-none-match") === etag) {
2493
+ return new Response(null, {
2494
+ headers: { "cache-control": "no-cache", etag },
2495
+ status: 304
2496
+ });
2497
+ }
2498
+ const headers = new Headers(response.headers);
2499
+ headers.set("cache-control", "no-cache");
2500
+ headers.set("etag", etag);
2501
+ return new Response(html, {
2502
+ headers,
2503
+ status: response.status,
2504
+ statusText: response.statusText
2505
+ });
2506
+ };
2507
+ var init_pageResponseCache = () => {};
2508
+
2474
2509
  // src/client/streamSwap.ts
2475
2510
  var streamSwapRuntime = () => {
2476
2511
  const absoluteWindow = window;
@@ -15025,8 +15060,12 @@ var resetSsrSanitizer = () => {
15025
15060
  ssrSanitizer = null;
15026
15061
  };
15027
15062
 
15063
+ // src/angular/pageHandler.ts
15064
+ init_pageResponseCache();
15065
+
15028
15066
  // src/core/responseEnhancers.ts
15029
15067
  init_streamingSlots();
15068
+ init_pageResponseCache();
15030
15069
  var toResponse = async (responseLike) => responseLike;
15031
15070
  var cloneHeaders = (response) => {
15032
15071
  const headers = new Headers(response.headers);
@@ -15050,8 +15089,10 @@ var enhanceHtmlResponseWithStreamingSlots = (response, {
15050
15089
  runtimePlacement,
15051
15090
  runtimePreludeScript
15052
15091
  });
15092
+ const headers = cloneHeaders(response);
15093
+ headers.set(STREAMING_PAGE_HEADER, "1");
15053
15094
  return new Response(body, {
15054
- headers: cloneHeaders(response),
15095
+ headers,
15055
15096
  status: response.status,
15056
15097
  statusText: response.statusText
15057
15098
  });
@@ -15312,17 +15353,19 @@ var handleAngularPageRequest = async (input) => {
15312
15353
  const html = injectIslandPageContext(injectSsrScripts(htmlWithLoweredIslands, requestId, resolvedIndexPath, maybeRequestContext), { hasIslands: shouldProcessIslands });
15313
15354
  return new Response(html, withHtmlContentType(responseInit));
15314
15355
  };
15315
- return await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
15356
+ const pageResponse = await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
15357
+ return withPageCacheHeaders(pageResponse, input.request);
15316
15358
  } catch (error) {
15317
15359
  console.error("[SSR] Angular render error:", error);
15318
15360
  const pageName = derivePageName(resolvedPagePath);
15319
15361
  const conventionResponse = await renderConventionError("angular", pageName, error);
15320
- if (conventionResponse)
15321
- return conventionResponse;
15322
- return new Response(ssrErrorPage("angular", error), {
15362
+ if (conventionResponse) {
15363
+ return withPageCacheHeaders(conventionResponse, input.request);
15364
+ }
15365
+ return withPageCacheHeaders(new Response(ssrErrorPage("angular", error), {
15323
15366
  headers: { "Content-Type": "text/html" },
15324
15367
  status: 500
15325
- });
15368
+ }), input.request);
15326
15369
  }
15327
15370
  });
15328
15371
  };
@@ -15843,5 +15886,5 @@ export {
15843
15886
  ABSOLUTE_HTTP_TRANSFER_CACHE_SKIP_HEADER
15844
15887
  };
15845
15888
 
15846
- //# debugId=43D2C664F9CF0BA364756E2164756E21
15889
+ //# debugId=4CE7D8C0E75D262C64756E2164756E21
15847
15890
  //# sourceMappingURL=index.js.map