@absolutejs/absolute 0.19.0-beta.1000 → 0.19.0-beta.1002

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.
@@ -0,0 +1,4 @@
1
+ export declare const readSiblingCss: (siblingJsPath: string | undefined) => Promise<string>;
2
+ /** Splice an inline <style> block before `</head>` in the user's
3
+ * headTag. No-op when the css string is empty. */
4
+ export declare const injectInlineCss: <T extends string>(headTag: T, css: string) => T;
@@ -3454,6 +3454,34 @@ var captureStreamingSlotWarningCallsite = () => {
3454
3454
  return extractCallsiteFromStack(stack);
3455
3455
  };
3456
3456
  var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
3457
+
3458
+ // src/utils/inlinePageCss.ts
3459
+ var siblingCssCache = new Map;
3460
+ var readSiblingCss = async (siblingJsPath) => {
3461
+ if (!siblingJsPath)
3462
+ return "";
3463
+ const cssPath = siblingJsPath.replace(/\.js$/, ".css");
3464
+ if (cssPath === siblingJsPath)
3465
+ return "";
3466
+ const cached = siblingCssCache.get(cssPath);
3467
+ if (cached !== undefined)
3468
+ return cached;
3469
+ const { readFile: readFile2 } = await import("fs/promises");
3470
+ try {
3471
+ const css = await readFile2(cssPath, "utf-8");
3472
+ siblingCssCache.set(cssPath, css);
3473
+ return css;
3474
+ } catch {
3475
+ siblingCssCache.set(cssPath, "");
3476
+ return "";
3477
+ }
3478
+ };
3479
+ var injectInlineCss = (headTag, css) => {
3480
+ if (!css)
3481
+ return headTag;
3482
+ const styleBlock = `<style data-absolute-page-css>${css}</style>`;
3483
+ return headTag.replace("</head>", `${styleBlock}</head>`);
3484
+ };
3457
3485
  // src/utils/resolveConvention.ts
3458
3486
  import { basename as basename2 } from "path";
3459
3487
  var CONVENTIONS_KEY = "__absoluteConventions";
@@ -3831,10 +3859,13 @@ var handleSveltePageRequest = async (input) => {
3831
3859
  };
3832
3860
  const { renderToReadableStream: renderToReadableStream2 } = await Promise.resolve().then(() => (init_renderToReadableStream(), exports_renderToReadableStream));
3833
3861
  const resolvedPage = await resolvePageComponent();
3862
+ const siblingCss = await readSiblingCss(resolvedPagePath);
3863
+ const cssBlock = siblingCss ? `<style data-absolute-page-css>${siblingCss}</style>` : "";
3864
+ const composedHeadContent = `${cssBlock}${resolvedOptions?.headContent ?? ""}`;
3834
3865
  const stream = await renderToReadableStream2(resolvedPage.component, resolvedProps, {
3835
3866
  bodyContent: resolvedOptions?.bodyContent,
3836
3867
  bootstrapScriptContent: `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(resolvedProps)};${resolvedIndexPath ? `import(${JSON.stringify(resolvedIndexPath)});` : ""}`,
3837
- headContent: resolvedOptions?.headContent
3868
+ headContent: composedHeadContent
3838
3869
  });
3839
3870
  const htmlStream = injectIslandPageContextStream(stream, {
3840
3871
  hasIslands: resolvedPage.hasIslands ? true : undefined
@@ -4001,5 +4032,5 @@ export {
4001
4032
  createTypedIsland
4002
4033
  };
4003
4034
 
4004
- //# debugId=1EB769EB23D636D964756E2164756E21
4035
+ //# debugId=A165999686274D4064756E2164756E21
4005
4036
  //# sourceMappingURL=index.js.map