rasengan 1.0.0-beta.44 → 1.0.0-beta.46

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.
@@ -67,7 +67,7 @@ var RenderApp = function (_a) {
67
67
  } }) }) }));
68
68
  };
69
69
  export default function renderStream(router_1, context_1) {
70
- return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
70
+ return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res, env) {
71
71
  if (helmetContext === void 0) { helmetContext = {}; }
72
72
  return __generator(this, function (_a) {
73
73
  return [2 /*return*/, new Promise(function (resolve, reject) {
@@ -76,10 +76,18 @@ export default function renderStream(router_1, context_1) {
76
76
  var _a = renderToPipeableStream(_jsx(RenderApp, { router: router, context: context, helmetContext: helmetContext, bootstrap: bootstrap, styles: styles }), {
77
77
  onShellReady: function () {
78
78
  shellRendered = true;
79
- res.status(responseStatusCode).set({
80
- "Content-Type": "text/html",
81
- "Cache-Control": "max-age=31536000",
82
- });
79
+ if (env === "vercel") {
80
+ res
81
+ .status(responseStatusCode)
82
+ .setHeader("Content-Type", "text/html")
83
+ .setHeader("Cache-Control", "max-age=31536000");
84
+ }
85
+ else {
86
+ res.status(responseStatusCode).set({
87
+ "Content-Type": "text/html",
88
+ "Cache-Control": "max-age=31536000",
89
+ });
90
+ }
83
91
  resolve(res);
84
92
  pipe(res);
85
93
  },
@@ -77,7 +77,7 @@ var TemplateHtml = function (_a) {
77
77
  * @returns
78
78
  */
79
79
  export function render(router_1, context_1) {
80
- return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res) {
80
+ return __awaiter(this, arguments, void 0, function (router, context, helmetContext, bootstrap, styles, res, env) {
81
81
  if (helmetContext === void 0) { helmetContext = {}; }
82
82
  if (bootstrap === void 0) { bootstrap = ""; }
83
83
  if (styles === void 0) { styles = ""; }
@@ -86,7 +86,7 @@ export function render(router_1, context_1) {
86
86
  case 0:
87
87
  if (!res)
88
88
  return [2 /*return*/];
89
- return [4 /*yield*/, renderStream(router, context, helmetContext, bootstrap, styles, res)];
89
+ return [4 /*yield*/, renderStream(router, context, helmetContext, bootstrap, styles, res, env)];
90
90
  case 1: return [2 /*return*/, _a.sent()];
91
91
  }
92
92
  });
@@ -176,7 +176,7 @@ export default function handler(req, res) {
176
176
  }
177
177
  helmetContext = {};
178
178
  router = createStaticRouter(handler_1.dataRoutes, context);
179
- return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res)];
179
+ return [4 /*yield*/, render(router, context, helmetContext, bootstrap, styles, res, "vercel")];
180
180
  case 15:
181
181
  // If stream mode enabled, render the page as a plain text
182
182
  return [2 /*return*/, _a.sent()];
@@ -1,4 +1,4 @@
1
1
  import { Response } from "express";
2
2
  import { type Router } from "@remix-run/router";
3
3
  import { StaticHandlerContext } from "react-router-dom/server";
4
- export default function renderStream(router: Router, context: StaticHandlerContext, helmetContext: any, bootstrap: string, styles: string, res: Response): Promise<unknown>;
4
+ export default function renderStream(router: Router, context: StaticHandlerContext, helmetContext: any, bootstrap: string, styles: string, res: Response, env?: "vercel" | "netlify" | "cloudflare" | "other"): Promise<unknown>;
@@ -8,6 +8,6 @@ import { Response } from "express";
8
8
  * @param helmetContext
9
9
  * @returns
10
10
  */
11
- export declare function render(router: Router, context: StaticHandlerContext, helmetContext?: any, bootstrap?: string, styles?: string, res?: Response): Promise<unknown>;
11
+ export declare function render(router: Router, context: StaticHandlerContext, helmetContext?: any, bootstrap?: string, styles?: string, res?: Response, env?: "vercel" | "netlify" | "cloudflare" | "other"): Promise<unknown>;
12
12
  export declare const staticRoutes: any;
13
13
  export declare const loadTemplateHtml: (helmetContext: any, bootstrap: string, styles: string) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.44",
4
+ "version": "1.0.0-beta.46",
5
5
  "description": "The modern frontend framework for React",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",