@solidjs/start 1.0.2 → 1.0.3

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.
package/config/index.js CHANGED
@@ -252,6 +252,7 @@ export function defineConfig(baseConfig = {}) {
252
252
  fileURLToPath(new URL("../dist/runtime/server-fns-runtime.js", import.meta.url))
253
253
  )
254
254
  }),
255
+ start.experimental.islands ? serverComponents.server() : null,
255
256
  solid({ ...start.solid, ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
256
257
  config("app-server", {
257
258
  resolve: {
@@ -12,6 +12,7 @@ export function createServerReference(fn, id, name) {
12
12
  }
13
13
  if (prop === "GET")
14
14
  return receiver;
15
+ return target[prop];
15
16
  },
16
17
  apply(target, thisArg, args) {
17
18
  const ogEvt = getRequestEvent();
@@ -96,18 +96,24 @@ async function handleServerFunction(h3Event) {
96
96
  }
97
97
  if (h3Event.method === "POST") {
98
98
  const contentType = request.headers.get("content-type");
99
+ const h3EventBody = h3Event.node.req;
100
+ const isH3EventBodyStreamLocked = h3EventBody instanceof ReadableStream && h3EventBody.locked;
99
101
  if (contentType?.startsWith("multipart/form-data") ||
100
102
  contentType?.startsWith("application/x-www-form-urlencoded")) {
101
103
  // workaround for https://github.com/unjs/nitro/issues/1721
102
104
  // (issue only in edge runtimes)
103
- parsed.push(await new Request(request, { ...request, body: h3Event.node.req.body }).formData());
105
+ parsed.push(await (isH3EventBodyStreamLocked
106
+ ? request
107
+ : new Request(request, { ...request, body: h3EventBody })).formData());
104
108
  // what should work when #1721 is fixed
105
109
  // parsed.push(await request.formData);
106
110
  }
107
111
  else if (contentType?.startsWith("application/json")) {
108
112
  // workaround for https://github.com/unjs/nitro/issues/1721
109
113
  // (issue only in edge runtimes)
110
- const tmpReq = new Request(request, { ...request, body: h3Event.node.req.body });
114
+ const tmpReq = isH3EventBodyStreamLocked
115
+ ? request
116
+ : new Request(request, { ...request, body: h3EventBody });
111
117
  // what should work when #1721 is fixed
112
118
  // just use request.json() here
113
119
  parsed = fromJSON(await tmpReq.json(), {
@@ -119,11 +119,17 @@ async function fetchServerFunction(base, id, options, args) {
119
119
  ? createRequest(base, id, instance, options)
120
120
  : args.length === 1 && args[0] instanceof FormData
121
121
  ? createRequest(base, id, instance, { ...options, body: args[0] })
122
- : createRequest(base, id, instance, {
123
- ...options,
124
- body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
125
- headers: { ...options.headers, "Content-Type": "application/json" }
126
- }));
122
+ : args.length === 1 && args[0] instanceof URLSearchParams
123
+ ? createRequest(base, id, instance, {
124
+ ...options,
125
+ body: args[0],
126
+ headers: { ...options.headers, "Content-Type": "application/x-www-form-urlencoded" }
127
+ })
128
+ : createRequest(base, id, instance, {
129
+ ...options,
130
+ body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
131
+ headers: { ...options.headers, "Content-Type": "application/json" }
132
+ }));
127
133
  if (response.headers.get("Location") ||
128
134
  response.headers.get("X-Revalidate") ||
129
135
  response.headers.get("X-Single-Flight")) {
@@ -167,13 +173,17 @@ export function createServerReference(fn, id, name) {
167
173
  const fn = async (...args) => {
168
174
  const encodeArgs = options.method && options.method.toUpperCase() === "GET";
169
175
  return fetchServerFunction(encodeArgs
170
- ? url + (args.length ? `&args=${encodeURIComponent(JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))))}` : "")
176
+ ? url +
177
+ (args.length
178
+ ? `&args=${encodeURIComponent(JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))))}`
179
+ : "")
171
180
  : `${baseURL}/_server`, `${id}#${name}`, options, encodeArgs ? [] : args);
172
181
  };
173
182
  fn.url = url;
174
183
  return fn;
175
184
  };
176
185
  }
186
+ return target[prop];
177
187
  },
178
188
  apply(target, thisArg, args) {
179
189
  return fetchServerFunction(`${baseURL}/_server`, `${id}#${name}`, {}, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidjs/start",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "type": "module",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
@@ -55,14 +55,14 @@
55
55
  }
56
56
  },
57
57
  "devDependencies": {
58
- "solid-js": "^1.8.17",
59
- "vinxi": "^0.3.12",
58
+ "solid-js": "^1.8.18",
59
+ "vinxi": "^0.3.14",
60
60
  "typescript": "^5.4.2"
61
61
  },
62
62
  "dependencies": {
63
63
  "@vinxi/plugin-directives": "^0.3.1",
64
64
  "@vinxi/server-components": "^0.3.3",
65
- "@vinxi/server-functions": "^0.3.2",
65
+ "@vinxi/server-functions": "^0.3.3",
66
66
  "defu": "^6.1.2",
67
67
  "error-stack-parser": "^2.1.4",
68
68
  "glob": "^10.3.10",