@solidjs/start 0.7.6 → 1.0.0-rc.0
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/dist/router/routes.js
CHANGED
|
@@ -7,7 +7,7 @@ function defineRoutes(fileRoutes) {
|
|
|
7
7
|
return id.startsWith(o.id + "/");
|
|
8
8
|
});
|
|
9
9
|
if (!parentRoute) {
|
|
10
|
-
routes.push({ ...route, id, path: id.replace(/\/\([^)/]+\)/g, "").replace(
|
|
10
|
+
routes.push({ ...route, id, path: id.replace(/\/\([^)/]+\)/g, "").replace(/\([^)/]+\)/g, "") });
|
|
11
11
|
return routes;
|
|
12
12
|
}
|
|
13
13
|
processRoute(parentRoute.children || (parentRoute.children = []), route, id.slice(parentRoute.id.length), full);
|
|
@@ -38,7 +38,7 @@ const router = createRouter({
|
|
|
38
38
|
routes: fileRoutes.reduce((memo, route) => {
|
|
39
39
|
if (!containsHTTP(route))
|
|
40
40
|
return memo;
|
|
41
|
-
let path = route.path.replace(/\(
|
|
41
|
+
let path = route.path.replace(/\([^)/]+\)/g, "").replace(/\*([^/]*)/g, (_, m) => `**:${m}`);
|
|
42
42
|
if (/:[^/]*\?/g.test(path)) {
|
|
43
43
|
throw new Error(`Optional parameters are not supported in API routes: ${path}`);
|
|
44
44
|
}
|
|
@@ -68,8 +68,25 @@ async function handleServerFunction(h3Event) {
|
|
|
68
68
|
// grab bound arguments from url when no JS
|
|
69
69
|
if (!instance || h3Event.method === "GET") {
|
|
70
70
|
const args = url.searchParams.get("args");
|
|
71
|
-
if (args)
|
|
72
|
-
JSON.parse(args)
|
|
71
|
+
if (args) {
|
|
72
|
+
const json = JSON.parse(args);
|
|
73
|
+
(json.t
|
|
74
|
+
? fromJSON(json, {
|
|
75
|
+
plugins: [
|
|
76
|
+
CustomEventPlugin,
|
|
77
|
+
DOMExceptionPlugin,
|
|
78
|
+
EventPlugin,
|
|
79
|
+
FormDataPlugin,
|
|
80
|
+
HeadersPlugin,
|
|
81
|
+
ReadableStreamPlugin,
|
|
82
|
+
RequestPlugin,
|
|
83
|
+
ResponsePlugin,
|
|
84
|
+
URLSearchParamsPlugin,
|
|
85
|
+
URLPlugin
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
: json).forEach((arg) => parsed.push(arg));
|
|
89
|
+
}
|
|
73
90
|
}
|
|
74
91
|
if (h3Event.method === "POST") {
|
|
75
92
|
const contentType = request.headers.get("content-type");
|
|
@@ -108,7 +125,7 @@ async function handleServerFunction(h3Event) {
|
|
|
108
125
|
/* @ts-ignore */
|
|
109
126
|
sharedConfig.context = { event };
|
|
110
127
|
event.locals.serverFunctionMeta = {
|
|
111
|
-
id: filepath + "#" + name
|
|
128
|
+
id: filepath + "#" + name
|
|
112
129
|
};
|
|
113
130
|
return serverFunction(...parsed);
|
|
114
131
|
});
|
|
@@ -97,6 +97,18 @@ function createRequest(base, id, instance, options) {
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
+
const plugins = [
|
|
101
|
+
CustomEventPlugin,
|
|
102
|
+
DOMExceptionPlugin,
|
|
103
|
+
EventPlugin,
|
|
104
|
+
FormDataPlugin,
|
|
105
|
+
HeadersPlugin,
|
|
106
|
+
ReadableStreamPlugin,
|
|
107
|
+
RequestPlugin,
|
|
108
|
+
ResponsePlugin,
|
|
109
|
+
URLSearchParamsPlugin,
|
|
110
|
+
URLPlugin
|
|
111
|
+
];
|
|
100
112
|
async function fetchServerFunction(base, id, options, args) {
|
|
101
113
|
const instance = `server-fn:${INSTANCE++}`;
|
|
102
114
|
const response = await (args.length === 0
|
|
@@ -105,20 +117,7 @@ async function fetchServerFunction(base, id, options, args) {
|
|
|
105
117
|
? createRequest(base, id, instance, { ...options, body: args[0] })
|
|
106
118
|
: createRequest(base, id, instance, {
|
|
107
119
|
...options,
|
|
108
|
-
body: JSON.stringify(await Promise.resolve(toJSONAsync(args, {
|
|
109
|
-
plugins: [
|
|
110
|
-
CustomEventPlugin,
|
|
111
|
-
DOMExceptionPlugin,
|
|
112
|
-
EventPlugin,
|
|
113
|
-
FormDataPlugin,
|
|
114
|
-
HeadersPlugin,
|
|
115
|
-
ReadableStreamPlugin,
|
|
116
|
-
RequestPlugin,
|
|
117
|
-
ResponsePlugin,
|
|
118
|
-
URLSearchParamsPlugin,
|
|
119
|
-
URLPlugin
|
|
120
|
-
]
|
|
121
|
-
}))),
|
|
120
|
+
body: JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins }))),
|
|
122
121
|
headers: { ...options.headers, "Content-Type": "application/json" }
|
|
123
122
|
}));
|
|
124
123
|
if (response.headers.get("Location") ||
|
|
@@ -161,10 +160,10 @@ export function createServerReference(fn, id, name) {
|
|
|
161
160
|
if (prop === "withOptions") {
|
|
162
161
|
const url = `${baseURL}/_server/?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
|
|
163
162
|
return (options) => {
|
|
164
|
-
const fn = (...args) => {
|
|
163
|
+
const fn = async (...args) => {
|
|
165
164
|
const encodeArgs = options.method && options.method.toUpperCase() === "GET";
|
|
166
165
|
return fetchServerFunction(encodeArgs
|
|
167
|
-
? url + (args.length ? `&args=${JSON.stringify(args)}` : "")
|
|
166
|
+
? url + (args.length ? `&args=${JSON.stringify(await Promise.resolve(toJSONAsync(args, { plugins })))}` : "")
|
|
168
167
|
: `${baseURL}/_server`, `${id}#${name}`, options, encodeArgs ? [] : args);
|
|
169
168
|
};
|
|
170
169
|
fn.url = url;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { StartServer } from "./StartServer";
|
|
2
2
|
export { createHandler } from "./handler";
|
|
3
3
|
export { getServerFunctionMeta } from "./serverFunction";
|
|
4
|
-
export
|
|
4
|
+
export type { DocumentComponentProps, Asset, HandlerOptions, ContextMatches, ResponseStub, FetchEvent, RequestEventLocals, PageEvent, APIEvent, APIHandler, ServerFunctionMeta } from "./types";
|
package/dist/server/index.jsx
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"homepage": "https://start.solidjs.com/",
|
|
8
|
+
"bugs": "https://github.com/solidjs/solid-start/issues",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/solidjs/solid-start.git",
|
|
12
|
+
"directory": "packages/start"
|
|
13
|
+
},
|
|
7
14
|
"publishConfig": {
|
|
8
15
|
"access": "public"
|
|
9
16
|
},
|
|
@@ -44,7 +51,7 @@
|
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
47
|
-
"solid-js": "^1.8.
|
|
54
|
+
"solid-js": "^1.8.16",
|
|
48
55
|
"vinxi": "^0.3.10",
|
|
49
56
|
"typescript": "^5.4.2"
|
|
50
57
|
},
|