@solidjs/start 0.5.7 → 0.5.9

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.
@@ -14,7 +14,7 @@ import {
14
14
  URLSearchParamsPlugin
15
15
  } from "seroval-plugins/web";
16
16
  import { sharedConfig } from "solid-js";
17
- import { renderToStream } from "solid-js/web";
17
+ import { renderToString } from "solid-js/web";
18
18
  import { provideRequestEvent } from "solid-js/web/storage";
19
19
  import { eventHandler, setHeader, setResponseStatus, type H3Event } from "vinxi/http";
20
20
  import invariant from "vinxi/lib/invariant";
@@ -105,7 +105,7 @@ async function handleServerFunction(h3Event: H3Event) {
105
105
  );
106
106
  // what should work when #1721 is fixed
107
107
  // parsed.push(await request.formData);
108
- } else {
108
+ } else if (contentType?.startsWith("application/json")) {
109
109
  // workaround for https://github.com/unjs/nitro/issues/1721
110
110
  // (issue only in edge runtimes)
111
111
  const tmpReq = new Request(request, { ...request, body: (h3Event.node.req as any).body });
@@ -176,7 +176,7 @@ async function handleServerFunction(h3Event: H3Event) {
176
176
  // forward headers
177
177
  if (x.headers) mergeResponseHeaders(h3Event, x.headers);
178
178
  if ((x as any).customBody) {
179
- x = await (x as any).customBody();
179
+ x = (x as any).customBody();
180
180
  } else if (x.body == undefined) x = null;
181
181
  }
182
182
  return x;
@@ -203,17 +203,16 @@ async function handleSingleFlight(sourceEvent: FetchEvent, result: any) {
203
203
  event.router.dataOnly = revalidate || true;
204
204
  /* @ts-ignore */
205
205
  event.router.previousUrl = sourceEvent.request.headers.get("referer");
206
- (async () => {
207
- try {
208
- await renderToStream(() => {
209
- /* @ts-ignore */
210
- sharedConfig.context.event = event;
211
- App();
212
- });
213
- } catch (e) {
214
- console.log(e);
215
- }
216
- })();
206
+ try {
207
+ renderToString(() => {
208
+ /* @ts-ignore */
209
+ sharedConfig.context.event = event;
210
+ App();
211
+ });
212
+ } catch (e) {
213
+ console.log(e);
214
+ }
215
+
217
216
  /* @ts-ignore */
218
217
  const body = event.router.data;
219
218
  if (!body) return result;
@@ -226,6 +225,8 @@ async function handleSingleFlight(sourceEvent: FetchEvent, result: any) {
226
225
  if (!(result instanceof Response)) {
227
226
  body["_$value"] = result;
228
227
  result = new Response(null, { status: 200 });
228
+ } else if ((result as any).customBody) {
229
+ body["_$value"] = (result as any).customBody();
229
230
  }
230
231
  result.customBody = () => body;
231
232
  result.headers.set("X-Single-Flight", "true");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "publishConfig": {
@@ -42,7 +42,7 @@
42
42
  }
43
43
  },
44
44
  "devDependencies": {
45
- "solid-js": "^1.8.14",
45
+ "solid-js": "^1.8.15",
46
46
  "vinxi": "^0.2.1"
47
47
  },
48
48
  "dependencies": {
@@ -8,20 +8,19 @@ import {
8
8
  getResponseHeaders,
9
9
  getResponseStatus,
10
10
  getResponseStatusText,
11
+ getWebRequest,
11
12
  removeResponseHeader,
12
13
  setHeader,
13
14
  setResponseHeader,
14
15
  setResponseStatus,
15
- toWebRequest
16
16
  } from "vinxi/http";
17
17
  import type { FetchEvent, ResponseStub } from "./types";
18
18
 
19
19
  const fetchEventSymbol = Symbol("fetchEvent");
20
20
 
21
21
  export function createFetchEvent(event: H3Event): FetchEvent {
22
- const request = toWebRequest(event);
23
22
  return {
24
- request: request,
23
+ request: getWebRequest(event),
25
24
  response: createResponseStub(event),
26
25
  clientAddress: getRequestIP(event),
27
26
  locals: {},