@solidjs/start 0.4.0 → 0.4.1
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/fs-router.js +15 -17
- package/config/index.d.ts +3 -2
- package/config/server-handler.js +38 -1
- package/config/server-runtime.jsx +27 -2
- package/package.json +3 -2
package/config/fs-router.js
CHANGED
|
@@ -57,6 +57,19 @@ export class SolidStartClientFileRouter extends BaseFileSystemRouter {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
const HTTP_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
61
|
+
function createHTTPHandlers(src, exports) {
|
|
62
|
+
const handlers = {};
|
|
63
|
+
for (const exp of exports) {
|
|
64
|
+
if (HTTP_METHODS.includes(exp.n)) {
|
|
65
|
+
handlers[`$${exp.n}`] = {
|
|
66
|
+
src: src,
|
|
67
|
+
pick: [exp.n]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return handlers;
|
|
72
|
+
}
|
|
60
73
|
export class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
61
74
|
toPath(src) {
|
|
62
75
|
const routePath = cleanPath(src, this.config)
|
|
@@ -110,25 +123,10 @@ export class SolidStartServerFileRouter extends BaseFileSystemRouter {
|
|
|
110
123
|
path,
|
|
111
124
|
filePath: src
|
|
112
125
|
};
|
|
113
|
-
} else if (
|
|
114
|
-
exports.find(
|
|
115
|
-
exp => exp.n === "GET" || exp.n === "POST" || exp.n === "PUT" || exp.n === "DELETE"
|
|
116
|
-
)
|
|
117
|
-
) {
|
|
126
|
+
} else if (exports.find(exp => HTTP_METHODS.includes(exp.n))) {
|
|
118
127
|
return {
|
|
119
128
|
type: "api",
|
|
120
|
-
|
|
121
|
-
? {
|
|
122
|
-
src: src,
|
|
123
|
-
pick: ["GET"]
|
|
124
|
-
}
|
|
125
|
-
: undefined,
|
|
126
|
-
$POST: exports.find(exp => exp.n === "POST")
|
|
127
|
-
? {
|
|
128
|
-
src: src,
|
|
129
|
-
pick: ["POST"]
|
|
130
|
-
}
|
|
131
|
-
: undefined,
|
|
129
|
+
...createHTTPHandlers(src, exports),
|
|
132
130
|
path,
|
|
133
131
|
filePath: src
|
|
134
132
|
};
|
package/config/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { AppOptions } from "vinxi";
|
|
1
2
|
import { InlineConfig } from "vite";
|
|
2
3
|
|
|
3
4
|
type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
|
|
4
5
|
start?: {
|
|
5
6
|
ssr?: boolean | "async",
|
|
6
7
|
extensions?: string[],
|
|
7
|
-
server?:
|
|
8
|
+
server?: AppOptions['server'],
|
|
8
9
|
appRoot?: string,
|
|
9
10
|
middleware?: string,
|
|
10
11
|
//islands?: boolean TODO: Get PROD bugs working probably missing release
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export declare function defineConfig(baseConfig
|
|
15
|
+
export declare function defineConfig(baseConfig?: SolidStartInlineConfig)
|
package/config/server-handler.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
/// <reference types="vinxi/types/server" />
|
|
2
2
|
import { crossSerializeStream, fromJSON } from "seroval";
|
|
3
|
+
import {
|
|
4
|
+
CustomEventPlugin,
|
|
5
|
+
DOMExceptionPlugin,
|
|
6
|
+
EventPlugin,
|
|
7
|
+
FormDataPlugin,
|
|
8
|
+
HeadersPlugin,
|
|
9
|
+
ReadableStreamPlugin,
|
|
10
|
+
RequestPlugin,
|
|
11
|
+
ResponsePlugin,
|
|
12
|
+
URLPlugin,
|
|
13
|
+
URLSearchParamsPlugin,
|
|
14
|
+
} from 'seroval-plugins/web';
|
|
3
15
|
import { provideRequestEvent } from "solid-js/web/storage";
|
|
4
16
|
import invariant from "vinxi/lib/invariant";
|
|
5
17
|
import {
|
|
@@ -17,6 +29,18 @@ function serializeToStream(id, value) {
|
|
|
17
29
|
start(controller) {
|
|
18
30
|
crossSerializeStream(value, {
|
|
19
31
|
scopeId: id,
|
|
32
|
+
plugins: [
|
|
33
|
+
CustomEventPlugin,
|
|
34
|
+
DOMExceptionPlugin,
|
|
35
|
+
EventPlugin,
|
|
36
|
+
FormDataPlugin,
|
|
37
|
+
HeadersPlugin,
|
|
38
|
+
ReadableStreamPlugin,
|
|
39
|
+
RequestPlugin,
|
|
40
|
+
ResponsePlugin,
|
|
41
|
+
URLSearchParamsPlugin,
|
|
42
|
+
URLPlugin,
|
|
43
|
+
],
|
|
20
44
|
onSerialize(data, initial) {
|
|
21
45
|
const result = initial ? `($R["${id}"]=[],${data})` : data;
|
|
22
46
|
controller.enqueue(new TextEncoder().encode(`${result};\n`));
|
|
@@ -67,7 +91,20 @@ async function handleServerFunction(event) {
|
|
|
67
91
|
) {
|
|
68
92
|
parsed.push(await readFormData(event));
|
|
69
93
|
} else {
|
|
70
|
-
parsed = fromJSON(await readBody(event)
|
|
94
|
+
parsed = fromJSON(await readBody(event), {
|
|
95
|
+
plugins: [
|
|
96
|
+
CustomEventPlugin,
|
|
97
|
+
DOMExceptionPlugin,
|
|
98
|
+
EventPlugin,
|
|
99
|
+
FormDataPlugin,
|
|
100
|
+
HeadersPlugin,
|
|
101
|
+
ReadableStreamPlugin,
|
|
102
|
+
RequestPlugin,
|
|
103
|
+
ResponsePlugin,
|
|
104
|
+
URLSearchParamsPlugin,
|
|
105
|
+
URLPlugin,
|
|
106
|
+
],
|
|
107
|
+
});
|
|
71
108
|
}
|
|
72
109
|
try {
|
|
73
110
|
const result = await provideRequestEvent(getFetchEvent(event), () => action(...parsed));
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { deserialize, toJSONAsync } from "seroval";
|
|
2
|
+
import {
|
|
3
|
+
CustomEventPlugin,
|
|
4
|
+
DOMExceptionPlugin,
|
|
5
|
+
EventPlugin,
|
|
6
|
+
FormDataPlugin,
|
|
7
|
+
HeadersPlugin,
|
|
8
|
+
ReadableStreamPlugin,
|
|
9
|
+
RequestPlugin,
|
|
10
|
+
ResponsePlugin,
|
|
11
|
+
URLPlugin,
|
|
12
|
+
URLSearchParamsPlugin,
|
|
13
|
+
} from 'seroval-plugins/web';
|
|
2
14
|
import { createIslandReference } from "../server/islands";
|
|
3
15
|
|
|
4
16
|
async function deserializeStream(id, response) {
|
|
@@ -41,7 +53,7 @@ async function deserializeStream(id, response) {
|
|
|
41
53
|
|
|
42
54
|
pop().then(
|
|
43
55
|
() => {
|
|
44
|
-
delete
|
|
56
|
+
delete $R[id];
|
|
45
57
|
},
|
|
46
58
|
() => {
|
|
47
59
|
// no-op
|
|
@@ -69,7 +81,20 @@ async function fetchServerFunction(base, id, args) {
|
|
|
69
81
|
const instance = `server-fn:${INSTANCE++}`;
|
|
70
82
|
const response = await (args.length === 1 && args[0] instanceof FormData
|
|
71
83
|
? createRequest(base, id, instance, args[0])
|
|
72
|
-
: createRequest(base, id, instance, JSON.stringify(await Promise.resolve(toJSONAsync(args
|
|
84
|
+
: createRequest(base, id, instance, JSON.stringify(await Promise.resolve(toJSONAsync(args, {
|
|
85
|
+
plugins: [
|
|
86
|
+
CustomEventPlugin,
|
|
87
|
+
DOMExceptionPlugin,
|
|
88
|
+
EventPlugin,
|
|
89
|
+
FormDataPlugin,
|
|
90
|
+
HeadersPlugin,
|
|
91
|
+
ReadableStreamPlugin,
|
|
92
|
+
RequestPlugin,
|
|
93
|
+
ResponsePlugin,
|
|
94
|
+
URLSearchParamsPlugin,
|
|
95
|
+
URLPlugin,
|
|
96
|
+
],
|
|
97
|
+
}))), "application/json"));
|
|
73
98
|
|
|
74
99
|
if (response.headers.get("Location")) throw response;
|
|
75
100
|
if (response.headers.get("X-Revalidate")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"publishConfig": {
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
"@vinxi/server-components": "0.0.44",
|
|
47
47
|
"@vinxi/server-functions": "0.0.45",
|
|
48
48
|
"defu": "^6.1.2",
|
|
49
|
-
"seroval": "^0.
|
|
49
|
+
"seroval": "^1.0.0",
|
|
50
|
+
"seroval-plugins": "^1.0.1",
|
|
50
51
|
"vite-plugin-inspect": "^0.7.33",
|
|
51
52
|
"vite-plugin-solid": "^2.8.0"
|
|
52
53
|
},
|