rasengan 1.0.0-beta.33 → 1.0.0-beta.34

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.
@@ -55,12 +55,12 @@ import { fileTypeFromBuffer } from "file-type";
55
55
  // // @ts-ignore
56
56
  // import type { Context } from "@netlify/functions"
57
57
  export default (function (req, context) { return __awaiter(void 0, void 0, void 0, function () {
58
- var url, host, appPath, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler, fetchRequest, context_1, status_1, redirect, helmetContext, router, rendered, html, e_1;
58
+ var url, host, appPath, err_1, segments, segmentsWithoutOrigin, _i, segments_1, segment, filePath, file, otherFile, result, mimeType, file, file, res, buffer, mimeType, templateHtml, serverFilePath, bootstrapDirPath, entry, bootstrap, styles, render, staticRoutes, loadTemplateHtml, handler, fetchRequest, context_1, status_1, redirect, helmetContext, router, rendered, html, e_1;
59
59
  var _a;
60
60
  return __generator(this, function (_b) {
61
61
  switch (_b.label) {
62
62
  case 0:
63
- _b.trys.push([0, 14, , 15]);
63
+ _b.trys.push([0, 19, , 20]);
64
64
  url = req.url;
65
65
  host = req.headers.get("host");
66
66
  appPath = process.cwd();
@@ -131,11 +131,37 @@ export default (function (req, context) { return __awaiter(void 0, void 0, void
131
131
  },
132
132
  })];
133
133
  case 10:
134
+ if (!(url.endsWith(".ttf") || url.endsWith(".woff") || url.endsWith(".woff2") || url.endsWith(".eot") || url.endsWith(".otf"))) return [3 /*break*/, 12];
135
+ return [4 /*yield*/, fs.readFile(url, "utf-8")];
136
+ case 11:
137
+ file = _b.sent();
138
+ return [2 /*return*/, new Response(file, {
139
+ headers: {
140
+ "Content-Type": "font/".concat(url.split(".").pop()),
141
+ "Cache-Control": "max-age=31536000",
142
+ },
143
+ })];
144
+ case 12:
145
+ if (!url.includes('/.netlify/images')) return [3 /*break*/, 15];
146
+ return [4 /*yield*/, fetch(url)];
147
+ case 13:
148
+ res = _b.sent();
149
+ return [4 /*yield*/, res.arrayBuffer()];
150
+ case 14:
151
+ buffer = _b.sent();
152
+ mimeType = res.headers.get("Content-Type") || "application/octet-stream";
153
+ return [2 /*return*/, new Response(buffer, {
154
+ headers: {
155
+ "Content-Type": mimeType,
156
+ "Cache-Control": "max-age=31536000",
157
+ },
158
+ })];
159
+ case 15:
134
160
  templateHtml = "";
135
161
  serverFilePath = join(appPath, "dist/server/entry-server.js");
136
162
  bootstrapDirPath = join(appPath, "dist/client/assets");
137
163
  return [4 /*yield*/, import(serverFilePath)];
138
- case 11:
164
+ case 16:
139
165
  entry = _b.sent();
140
166
  bootstrap = "/assets/" +
141
167
  fsSync
@@ -149,7 +175,7 @@ export default (function (req, context) { return __awaiter(void 0, void 0, void
149
175
  handler = createStaticHandler(staticRoutes);
150
176
  fetchRequest = createFetchRequest(req, host);
151
177
  return [4 /*yield*/, handler.query(fetchRequest)];
152
- case 12:
178
+ case 17:
153
179
  context_1 = _b.sent();
154
180
  status_1 = context_1.status;
155
181
  if (status_1 === 302) {
@@ -161,7 +187,7 @@ export default (function (req, context) { return __awaiter(void 0, void 0, void
161
187
  helmetContext = {};
162
188
  router = createStaticRouter(handler.dataRoutes, context_1);
163
189
  return [4 /*yield*/, render(router, context_1, helmetContext)];
164
- case 13:
190
+ case 18:
165
191
  rendered = _b.sent();
166
192
  // Load template html
167
193
  if (!templateHtml) {
@@ -176,13 +202,13 @@ export default (function (req, context) { return __awaiter(void 0, void 0, void
176
202
  "Cache-Control": "max-age=31536000",
177
203
  },
178
204
  })];
179
- case 14:
205
+ case 19:
180
206
  e_1 = _b.sent();
181
207
  console.log(e_1.stack);
182
208
  return [2 /*return*/, new Response(e_1.stack, {
183
209
  status: 500,
184
210
  })];
185
- case 15: return [2 /*return*/];
211
+ case 20: return [2 /*return*/];
186
212
  }
187
213
  });
188
214
  }); });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rasengan",
3
3
  "private": false,
4
- "version": "1.0.0-beta.33",
4
+ "version": "1.0.0-beta.34",
5
5
  "description": "The modern frontend framework for React",
6
6
  "type": "module",
7
7
  "main": "lib/esm/index.js",