@solidjs/start 1.0.2 → 1.0.4
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: {
|
|
@@ -96,18 +96,28 @@ async function handleServerFunction(h3Event) {
|
|
|
96
96
|
}
|
|
97
97
|
if (h3Event.method === "POST") {
|
|
98
98
|
const contentType = request.headers.get("content-type");
|
|
99
|
+
const h3Request = h3Event.node.req;
|
|
100
|
+
// This should never be the case in "proper" Nitro presets since node.req has to be IncomingMessage,
|
|
101
|
+
// But the new azure-functions preset for some reason uses a ReadableStream in node.req (#1521)
|
|
102
|
+
const isReadableStream = h3Request instanceof ReadableStream;
|
|
103
|
+
const isH3EventBodyStreamLocked = isReadableStream && h3Request.locked;
|
|
104
|
+
const requestBody = isReadableStream ? h3Request : h3Request.body;
|
|
99
105
|
if (contentType?.startsWith("multipart/form-data") ||
|
|
100
106
|
contentType?.startsWith("application/x-www-form-urlencoded")) {
|
|
101
107
|
// workaround for https://github.com/unjs/nitro/issues/1721
|
|
102
108
|
// (issue only in edge runtimes)
|
|
103
|
-
parsed.push(await
|
|
109
|
+
parsed.push(await (isH3EventBodyStreamLocked
|
|
110
|
+
? request
|
|
111
|
+
: new Request(request, { ...request, body: requestBody })).formData());
|
|
104
112
|
// what should work when #1721 is fixed
|
|
105
113
|
// parsed.push(await request.formData);
|
|
106
114
|
}
|
|
107
115
|
else if (contentType?.startsWith("application/json")) {
|
|
108
116
|
// workaround for https://github.com/unjs/nitro/issues/1721
|
|
109
117
|
// (issue only in edge runtimes)
|
|
110
|
-
const tmpReq =
|
|
118
|
+
const tmpReq = isH3EventBodyStreamLocked
|
|
119
|
+
? request
|
|
120
|
+
: new Request(request, { ...request, body: requestBody });
|
|
111
121
|
// what should work when #1721 is fixed
|
|
112
122
|
// just use request.json() here
|
|
113
123
|
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
|
-
:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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 +
|
|
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.
|
|
3
|
+
"version": "1.0.4",
|
|
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.
|
|
59
|
-
"vinxi": "^0.3.
|
|
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.
|
|
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",
|