@solidjs/start 2.0.0-rc.1 → 2.0.0-rc.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/CHANGELOG.md +22 -0
- package/dist/config/fs-routes/tree-shake.js +5 -0
- package/dist/config/index.d.ts +78 -3
- package/dist/fns/client.js +13 -3
- package/dist/fns/handler.js +7 -5
- package/dist/fns/serialization.d.ts +15 -0
- package/dist/fns/serialization.js +1 -1
- package/dist/server/handler.d.ts +3 -4
- package/dist/server/handler.js +8 -46
- package/dist/server/index.d.ts +1 -1
- package/dist/server/spa/handler.d.ts +2 -3
- package/dist/server/spa/handler.js +2 -2
- package/dist/server/types.d.ts +12 -1
- package/dist/server/web-stream.d.ts +1 -1
- package/dist/server/web-stream.js +5 -2
- package/dist/shared/ErrorBoundary.jsx +3 -3
- package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/CodeView.jsx +3 -3
- package/dist/shared/{dev-overlay/DevOverlayDialog.d.ts → dev-toolbar/error-viewer/index.d.ts} +3 -2
- package/dist/shared/{dev-overlay/DevOverlayDialog.jsx → dev-toolbar/error-viewer/index.jsx} +66 -77
- package/dist/shared/dev-toolbar/error-viewer/styles.css +224 -0
- package/dist/shared/dev-toolbar/functions/BlobViewer.css +4 -0
- package/dist/shared/dev-toolbar/functions/BlobViewer.d.ts +6 -0
- package/dist/shared/dev-toolbar/functions/BlobViewer.jsx +41 -0
- package/dist/shared/dev-toolbar/functions/FormDataViewer.d.ts +5 -0
- package/dist/shared/dev-toolbar/functions/FormDataViewer.jsx +27 -0
- package/dist/shared/dev-toolbar/functions/HeadersViewer.css +8 -0
- package/dist/shared/dev-toolbar/functions/HeadersViewer.d.ts +6 -0
- package/dist/shared/dev-toolbar/functions/HeadersViewer.jsx +15 -0
- package/dist/shared/dev-toolbar/functions/HexViewer.css +34 -0
- package/dist/shared/dev-toolbar/functions/HexViewer.d.ts +11 -0
- package/dist/shared/dev-toolbar/functions/HexViewer.jsx +78 -0
- package/dist/shared/dev-toolbar/functions/SerovalValue.css +7 -0
- package/dist/shared/dev-toolbar/functions/SerovalValue.d.ts +7 -0
- package/dist/shared/dev-toolbar/functions/SerovalValue.jsx +10 -0
- package/dist/shared/dev-toolbar/functions/SerovalViewer.css +71 -0
- package/dist/shared/dev-toolbar/functions/SerovalViewer.d.ts +6 -0
- package/dist/shared/dev-toolbar/functions/SerovalViewer.jsx +796 -0
- package/dist/shared/dev-toolbar/functions/URLSearchParamsViewer.d.ts +5 -0
- package/dist/shared/dev-toolbar/functions/URLSearchParamsViewer.jsx +24 -0
- package/dist/shared/dev-toolbar/functions/index.d.ts +13 -0
- package/dist/shared/dev-toolbar/functions/index.jsx +216 -0
- package/dist/shared/dev-toolbar/functions/styles.css +110 -0
- package/dist/shared/dev-toolbar/functions/tracker.d.ts +19 -0
- package/dist/shared/dev-toolbar/functions/tracker.js +29 -0
- package/dist/shared/{dev-overlay → dev-toolbar}/icons.d.ts +9 -0
- package/dist/shared/{dev-overlay → dev-toolbar}/icons.jsx +19 -1
- package/dist/shared/dev-toolbar/index.css +88 -0
- package/dist/shared/dev-toolbar/index.d.ts +6 -0
- package/dist/shared/dev-toolbar/index.jsx +175 -0
- package/dist/shared/ui/Badge.css +34 -0
- package/dist/shared/ui/Badge.d.ts +7 -0
- package/dist/shared/ui/Badge.jsx +7 -0
- package/dist/shared/ui/Button.css +32 -0
- package/dist/shared/ui/Button.d.ts +4 -0
- package/dist/shared/ui/Button.jsx +4 -0
- package/dist/shared/ui/Cascade.css +29 -0
- package/dist/shared/ui/Cascade.d.ts +4 -0
- package/dist/shared/ui/Cascade.jsx +4 -0
- package/dist/shared/ui/Dialog.css +26 -0
- package/dist/shared/ui/Dialog.d.ts +5 -0
- package/dist/shared/ui/Dialog.jsx +5 -0
- package/dist/shared/ui/IconButton.css +39 -0
- package/dist/shared/ui/IconButton.d.ts +4 -0
- package/dist/shared/ui/IconButton.jsx +4 -0
- package/dist/shared/ui/Placeholder.css +12 -0
- package/dist/shared/ui/Placeholder.d.ts +6 -0
- package/dist/shared/ui/Placeholder.jsx +6 -0
- package/dist/shared/ui/Section.css +19 -0
- package/dist/shared/ui/Section.d.ts +9 -0
- package/dist/shared/ui/Section.jsx +12 -0
- package/dist/shared/ui/Select.css +37 -0
- package/dist/shared/ui/Select.d.ts +4 -0
- package/dist/shared/ui/Select.jsx +4 -0
- package/dist/shared/ui/Table.css +22 -0
- package/dist/shared/ui/Table.d.ts +11 -0
- package/dist/shared/ui/Table.jsx +13 -0
- package/dist/shared/ui/Tabs.css +51 -0
- package/dist/shared/ui/Tabs.d.ts +6 -0
- package/dist/shared/ui/Tabs.jsx +6 -0
- package/dist/shared/ui/Text.css +69 -0
- package/dist/shared/ui/Text.d.ts +12 -0
- package/dist/shared/ui/Text.jsx +17 -0
- package/package.json +4 -4
- package/dist/shared/dev-overlay/index.d.ts +0 -5
- package/dist/shared/dev-overlay/index.jsx +0 -39
- package/dist/shared/dev-overlay/styles.css +0 -292
- /package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/CodeView.d.ts +0 -0
- /package/dist/shared/{dev-overlay/createStackFrame.d.ts → dev-toolbar/error-viewer/create-stack-frame.d.ts} +0 -0
- /package/dist/shared/{dev-overlay/createStackFrame.js → dev-toolbar/error-viewer/create-stack-frame.js} +0 -0
- /package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/download.d.ts +0 -0
- /package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/download.js +0 -0
- /package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/get-source-map.d.ts +0 -0
- /package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/get-source-map.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @solidjs/start
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d9018d6: fix(types): add missing properties to `SolidStartOptions` and expose them via Vite plugin configuration
|
|
8
|
+
- e26cef0: Fix TS2883/TS2742 when emitting declarations for `entry-server.tsx`. `createHandler` now returns `StartHandler`, a type owned by `@solidjs/start`, instead of h3's `H3`, so the inferred type of `export default createHandler(...)` no longer has to be named through a nested `node_modules/@solidjs/start/node_modules/h3` path.
|
|
9
|
+
- 7c8dbe6: keep TypeScript namespace members in route files during production builds
|
|
10
|
+
- b3c7aaf: Update `h3` to `2.0.1-rc.26`.
|
|
11
|
+
- b3c7aaf: Fixed event response status and headers set during server-side rendering with deferred async resources, not being applied on the outgoing response.
|
|
12
|
+
|
|
13
|
+
## 2.0.0-rc.2
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- eeff49a: add new dev toolbar
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- bd8cb01: Update srvx to version 0.12.0.
|
|
22
|
+
- 4e98ac0: Restore the optional `routerLoad` third argument to `createHandler`, which primes custom routers (e.g. TanStack Router) on the server before SSR rendering. It was accidentally dropped in the v2 rewrite.
|
|
23
|
+
|
|
3
24
|
## 2.0.0-rc.1
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -144,6 +165,7 @@
|
|
|
144
165
|
- 8256190: Rework `@solidjs/start/env`
|
|
145
166
|
- 6cbba24: Fix multiple Set-Cookie headers being lost on redirect responses
|
|
146
167
|
- d4cc548: ## Bump Seroval
|
|
168
|
+
|
|
147
169
|
- version `1.4.1`
|
|
148
170
|
|
|
149
171
|
- dd40610: Handle base url in api routes
|
|
@@ -133,6 +133,11 @@ function treeShakeTransform({ types: t }) {
|
|
|
133
133
|
if (!state.opts.pick) {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
+
// Only module-level exports are route exports; `export` inside a
|
|
137
|
+
// TS namespace/module block is unrelated to the pick list.
|
|
138
|
+
if (!exportNamedPath.parentPath.isProgram()) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
136
141
|
const specifiers = exportNamedPath.get("specifiers");
|
|
137
142
|
if (specifiers.length) {
|
|
138
143
|
specifiers.forEach(s => {
|
package/dist/config/index.d.ts
CHANGED
|
@@ -2,24 +2,99 @@ import type { PluginOption } from "vite";
|
|
|
2
2
|
import { type Options as SolidOptions } from "vite-plugin-solid";
|
|
3
3
|
import { type ServerFunctionsOptions } from "../directives/index.ts";
|
|
4
4
|
import { type EnvPluginOptions } from "./env.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for SolidStart. (previously in `app.config.ts`)
|
|
7
|
+
*
|
|
8
|
+
* @see https://docs.solidjs.com/solid-start/v2/migrating-from-v1#move-framework-configuration-into-viteconfigts
|
|
9
|
+
*/
|
|
5
10
|
export interface SolidStartOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Path to the root of the application (where `app.tsx` / `app.jsx` lives).
|
|
13
|
+
*
|
|
14
|
+
* @default "./src"
|
|
15
|
+
*/
|
|
16
|
+
appRoot?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Options forwarded to `vite-plugin-solid`.
|
|
19
|
+
*
|
|
20
|
+
* @see https://github.com/solidjs/vite-plugin-solid#api
|
|
21
|
+
*/
|
|
6
22
|
solid?: Partial<SolidOptions>;
|
|
23
|
+
/**
|
|
24
|
+
* Enable or disable server-side rendering.
|
|
25
|
+
*
|
|
26
|
+
* - `true` — SSR (default)
|
|
27
|
+
* - `false` — client-side rendering only (SPA mode)
|
|
28
|
+
*
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
7
31
|
ssr?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Show the SolidStart development overlay (error overlay, etc.) in development.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
devOverlay?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Experimental features.
|
|
40
|
+
*/
|
|
41
|
+
experimental?: {
|
|
42
|
+
/**
|
|
43
|
+
* Enable islands architecture mode.
|
|
44
|
+
*
|
|
45
|
+
* Currently fixed to `false` (not yet fully supported).
|
|
46
|
+
*
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
islands?: false;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Directory containing file-system routes, relative to {@link appRoot}.
|
|
53
|
+
*
|
|
54
|
+
* @default "./routes"
|
|
55
|
+
*/
|
|
8
56
|
routeDir?: string;
|
|
57
|
+
/**
|
|
58
|
+
* File extensions that should be treated as routes.
|
|
59
|
+
*
|
|
60
|
+
* @default ["js", "jsx", "ts", "tsx"]
|
|
61
|
+
*/
|
|
9
62
|
extensions?: string[];
|
|
63
|
+
/**
|
|
64
|
+
* Path to an optional middleware module.
|
|
65
|
+
*
|
|
66
|
+
* The module should export a middleware created with `createMiddleware`
|
|
67
|
+
* from `@solidjs/start/middleware`.
|
|
68
|
+
*
|
|
69
|
+
* @example "src/middleware/index.ts"
|
|
70
|
+
*/
|
|
10
71
|
middleware?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Serialization settings for server-function / action payloads
|
|
74
|
+
* that cross the server-client boundary.
|
|
75
|
+
*/
|
|
11
76
|
serialization?: {
|
|
12
77
|
/**
|
|
13
78
|
* The serialization mode to use for server functions/actions.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
79
|
+
*
|
|
80
|
+
* - `"js"` — Uses a custom binary format (Seroval) that is more efficient
|
|
81
|
+
* than JSON, but requires a custom deserializer (with `eval()`) on the client.
|
|
82
|
+
* A strong CSP that blocks `eval()` will prevent this mode from working.
|
|
83
|
+
* - `"json"` — Uses JSON for serialization. Less efficient / larger payloads,
|
|
84
|
+
* but can be deserialized with `JSON.parse` on the client and is CSP-friendly.
|
|
17
85
|
*
|
|
18
86
|
* @default "json"
|
|
19
87
|
*/
|
|
20
88
|
mode?: "js" | "json";
|
|
21
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Configures plugin behavior per build environment
|
|
92
|
+
*/
|
|
22
93
|
env?: EnvPluginOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Options controlling which files are processed as server functions
|
|
96
|
+
* (inclusion / exclusion filters for the `"use server"` transform).
|
|
97
|
+
*/
|
|
23
98
|
serverFunctions?: Pick<ServerFunctionsOptions, "filter">;
|
|
24
99
|
}
|
|
25
100
|
export declare function solidStart(options?: SolidStartOptions): Array<PluginOption>;
|
package/dist/fns/client.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { pushRequest, pushResponse } from "../shared/dev-toolbar/functions/tracker.js";
|
|
1
2
|
import {
|
|
2
3
|
// serializeToJSONStream,
|
|
3
4
|
serializeToJSONString, } from "./serialization.js";
|
|
4
|
-
import { BODY_FORMAT_KEY, BodyFormat, extractBody, getHeadersAndBody
|
|
5
|
+
import { BODY_FORMAT_KEY, BodyFormat, extractBody, getHeadersAndBody } from "./shared.js";
|
|
5
6
|
let INSTANCE = 0;
|
|
6
|
-
function createRequest(base, id, instance, options) {
|
|
7
|
-
|
|
7
|
+
async function createRequest(base, id, instance, options) {
|
|
8
|
+
const request = new Request(base, {
|
|
8
9
|
method: "POST",
|
|
9
10
|
...options,
|
|
10
11
|
headers: {
|
|
@@ -13,6 +14,15 @@ function createRequest(base, id, instance, options) {
|
|
|
13
14
|
"X-Server-Instance": instance,
|
|
14
15
|
},
|
|
15
16
|
});
|
|
17
|
+
if (import.meta.env.DEV) {
|
|
18
|
+
console.log(pushRequest);
|
|
19
|
+
pushRequest(id, instance, request.clone());
|
|
20
|
+
}
|
|
21
|
+
const response = await fetch(request);
|
|
22
|
+
if (import.meta.env.DEV) {
|
|
23
|
+
pushResponse(id, instance, response.clone());
|
|
24
|
+
}
|
|
25
|
+
return response;
|
|
16
26
|
}
|
|
17
27
|
async function initializeResponse(base, id, instance, options, args) {
|
|
18
28
|
// No args, skip serialization
|
package/dist/fns/handler.js
CHANGED
|
@@ -121,7 +121,6 @@ export async function handleServerFunction(h3Event) {
|
|
|
121
121
|
h3Event.res.headers.set("content-type", "text/javascript");
|
|
122
122
|
return serializeToJSStream(instance, result);
|
|
123
123
|
}
|
|
124
|
-
h3Event.res.headers.set("content-type", "text/plain");
|
|
125
124
|
return serializeToJSONStream(result);
|
|
126
125
|
}
|
|
127
126
|
catch (x) {
|
|
@@ -133,7 +132,8 @@ export async function handleServerFunction(h3Event) {
|
|
|
133
132
|
if (x.headers)
|
|
134
133
|
mergeResponseHeaders(h3Event, x.headers);
|
|
135
134
|
// forward non-redirect statuses
|
|
136
|
-
if (x.status &&
|
|
135
|
+
if (x.status &&
|
|
136
|
+
(!instance || x.status < 300 || x.status >= 400))
|
|
137
137
|
h3Event.res.status = x.status;
|
|
138
138
|
if (x.customBody) {
|
|
139
139
|
x = await x.customBody();
|
|
@@ -166,7 +166,6 @@ export async function handleServerFunction(h3Event) {
|
|
|
166
166
|
h3Event.res.headers.set("content-type", "text/javascript");
|
|
167
167
|
return serializeToJSStream(instance, x);
|
|
168
168
|
}
|
|
169
|
-
h3Event.res.headers.set("content-type", "text/plain");
|
|
170
169
|
return serializeToJSONStream(x);
|
|
171
170
|
}
|
|
172
171
|
return x;
|
|
@@ -205,7 +204,10 @@ function handleNoJS(result, request, parsed, thrown) {
|
|
|
205
204
|
result: isError ? result.message : result,
|
|
206
205
|
thrown: thrown,
|
|
207
206
|
error: isError,
|
|
208
|
-
input: [
|
|
207
|
+
input: [
|
|
208
|
+
...parsed.slice(0, -1),
|
|
209
|
+
[...parsed[parsed.length - 1].entries()],
|
|
210
|
+
],
|
|
209
211
|
}))}; Secure; HttpOnly;`);
|
|
210
212
|
}
|
|
211
213
|
return new Response(null, {
|
|
@@ -227,7 +229,7 @@ export function createSingleFlightHeaders(sourceEvent) {
|
|
|
227
229
|
// useH3Internals = true;
|
|
228
230
|
// sourceEvent.nativeEvent.node.req.headers.cookie = "";
|
|
229
231
|
// }
|
|
230
|
-
SetCookies.forEach(cookie => {
|
|
232
|
+
SetCookies.forEach((cookie) => {
|
|
231
233
|
if (!cookie)
|
|
232
234
|
return;
|
|
233
235
|
const { maxAge, expires, name, value } = parseSetCookie(cookie);
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
export declare function serializeToJSStream(id: string, value: any): ReadableStream<any>;
|
|
2
2
|
export declare function serializeToJSONStream(value: any): ReadableStream<any>;
|
|
3
|
+
export declare class SerovalChunkReader {
|
|
4
|
+
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
5
|
+
buffer: Uint8Array;
|
|
6
|
+
done: boolean;
|
|
7
|
+
constructor(stream: ReadableStream<Uint8Array>);
|
|
8
|
+
readChunk(): Promise<void>;
|
|
9
|
+
next(): Promise<{
|
|
10
|
+
done: true;
|
|
11
|
+
value: undefined;
|
|
12
|
+
} | {
|
|
13
|
+
done: false;
|
|
14
|
+
value: string;
|
|
15
|
+
}>;
|
|
16
|
+
drain(interpret: (chunk: string) => void): Promise<void>;
|
|
17
|
+
}
|
|
3
18
|
export declare function serializeToJSONString(value: any): Promise<string>;
|
|
4
19
|
export declare function deserializeFromJSONString(json: string): Promise<unknown>;
|
|
5
20
|
export declare function deserializeJSONStream(response: Response | Request): Promise<unknown>;
|
package/dist/server/handler.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { H3 } from "h3/generic";
|
|
2
1
|
import type { JSX } from "solid-js";
|
|
3
|
-
import type { FetchEvent, HandlerOptions, PageEvent } from "./types.ts";
|
|
4
|
-
export declare function createBaseHandler(createPageEvent: (e: FetchEvent) => Promise<PageEvent>, fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)):
|
|
5
|
-
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)):
|
|
2
|
+
import type { FetchEvent, HandlerOptions, PageEvent, StartHandler } from "./types.ts";
|
|
3
|
+
export declare function createBaseHandler(createPageEvent: (e: FetchEvent) => Promise<PageEvent>, fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>), routerLoad?: (event: FetchEvent) => Promise<void>): StartHandler;
|
|
4
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>), routerLoad?: (event: FetchEvent) => Promise<void>): StartHandler;
|
|
6
5
|
export declare function createPageEvent(ctx: FetchEvent): Promise<PageEvent>;
|
package/dist/server/handler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import middleware from "solid-start:middleware";
|
|
2
|
-
import { defineHandler, getCookie, H3, redirect, setCookie } from "h3/generic";
|
|
2
|
+
import { defineHandler, getCookie, H3, iterable, redirect, setCookie, } from "h3/generic";
|
|
3
3
|
import { sharedConfig } from "solid-js";
|
|
4
4
|
import { getRequestEvent, renderToStream, renderToString } from "solid-js/web";
|
|
5
5
|
import { createRoutes } from "../router.jsx";
|
|
@@ -11,7 +11,7 @@ import { getExpectedRedirectStatus } from "./util.js";
|
|
|
11
11
|
import { toWebReadableStream } from "./web-stream.js";
|
|
12
12
|
import { stripPathBase } from "./strip-path-base.js";
|
|
13
13
|
const SERVER_FN_BASE = "/_server";
|
|
14
|
-
export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
14
|
+
export function createBaseHandler(createPageEvent, fn, options = {}, routerLoad) {
|
|
15
15
|
const handler = defineHandler({
|
|
16
16
|
middleware: middleware.length ? middleware.map(decorateMiddleware) : undefined,
|
|
17
17
|
handler: decorateHandler(async (e) => {
|
|
@@ -19,12 +19,7 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
19
19
|
const url = new URL(event.request.url);
|
|
20
20
|
const pathname = stripBaseUrl(url.pathname);
|
|
21
21
|
if (pathname.startsWith(SERVER_FN_BASE)) {
|
|
22
|
-
|
|
23
|
-
if (serverFnResponse instanceof Response)
|
|
24
|
-
return produceResponseWithEventHeaders(serverFnResponse);
|
|
25
|
-
return new Response(serverFnResponse, {
|
|
26
|
-
headers: e.res.headers,
|
|
27
|
-
});
|
|
22
|
+
return await handleServerFunction(e);
|
|
28
23
|
}
|
|
29
24
|
const match = matchAPIRoute(pathname, event.request.method);
|
|
30
25
|
if (match) {
|
|
@@ -36,8 +31,6 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
36
31
|
sharedConfig.context = { event };
|
|
37
32
|
const res = await fn(event);
|
|
38
33
|
if (res !== undefined) {
|
|
39
|
-
if (res instanceof Response)
|
|
40
|
-
return produceResponseWithEventHeaders(res);
|
|
41
34
|
return res;
|
|
42
35
|
}
|
|
43
36
|
if (event.request.method !== "GET") {
|
|
@@ -47,6 +40,8 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
47
40
|
return;
|
|
48
41
|
}
|
|
49
42
|
}
|
|
43
|
+
if (routerLoad)
|
|
44
|
+
await routerLoad(event);
|
|
50
45
|
const context = await createPageEvent(event);
|
|
51
46
|
const resolvedOptions = typeof options === "function" ? await options(context) : { ...options };
|
|
52
47
|
const mode = resolvedOptions.mode || "stream";
|
|
@@ -94,18 +89,17 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
94
89
|
}
|
|
95
90
|
if (mode === "async")
|
|
96
91
|
return await stream;
|
|
97
|
-
delete stream.then;
|
|
98
92
|
// h3 expects a standard web ReadableStream across runtimes. The adapter
|
|
99
93
|
// also tolerates cancellation while Solid finishes outstanding work.
|
|
100
|
-
return toWebReadableStream(stream);
|
|
94
|
+
return iterable(toWebReadableStream(stream));
|
|
101
95
|
}),
|
|
102
96
|
});
|
|
103
97
|
const app = new H3();
|
|
104
98
|
app.use(handler);
|
|
105
99
|
return app;
|
|
106
100
|
}
|
|
107
|
-
export function createHandler(fn, options = {}) {
|
|
108
|
-
return createBaseHandler(createPageEvent, fn, options);
|
|
101
|
+
export function createHandler(fn, options = {}, routerLoad) {
|
|
102
|
+
return createBaseHandler(createPageEvent, fn, options, routerLoad);
|
|
109
103
|
}
|
|
110
104
|
export async function createPageEvent(ctx) {
|
|
111
105
|
ctx.response.headers.set("Content-Type", "text/html");
|
|
@@ -180,38 +174,6 @@ function handleStreamCompleteRedirect(context) {
|
|
|
180
174
|
to && write(`<script>window.location=${JSON.stringify(to).replace(/</g, "\\u003c")}</script>`);
|
|
181
175
|
};
|
|
182
176
|
}
|
|
183
|
-
function produceResponseWithEventHeaders(res) {
|
|
184
|
-
const event = getRequestEvent();
|
|
185
|
-
let ret = res;
|
|
186
|
-
// Response.redirect returns an immutable value, so we clone on any redirect just in case
|
|
187
|
-
if (300 <= res.status && res.status < 400) {
|
|
188
|
-
const cookies = res.headers.getSetCookie?.() ?? [];
|
|
189
|
-
const headers = new Headers();
|
|
190
|
-
res.headers.forEach((value, key) => {
|
|
191
|
-
if (key.toLowerCase() !== "set-cookie") {
|
|
192
|
-
headers.set(key, value);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
for (const cookie of cookies) {
|
|
196
|
-
headers.append("Set-Cookie", cookie);
|
|
197
|
-
}
|
|
198
|
-
ret = new Response(res.body, {
|
|
199
|
-
status: res.status,
|
|
200
|
-
statusText: res.statusText,
|
|
201
|
-
headers,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
const eventCookies = event.response.headers.getSetCookie?.() ?? [];
|
|
205
|
-
for (const cookie of eventCookies) {
|
|
206
|
-
ret.headers.append("Set-Cookie", cookie);
|
|
207
|
-
}
|
|
208
|
-
for (const [name, value] of event.response.headers) {
|
|
209
|
-
if (name.toLowerCase() !== "set-cookie") {
|
|
210
|
-
ret.headers.set(name, value);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return ret;
|
|
214
|
-
}
|
|
215
177
|
function stripBaseUrl(path) {
|
|
216
178
|
const base = import.meta.env.SERVER_BASE_URL || import.meta.env.BASE_URL || "/";
|
|
217
179
|
return stripPathBase(path, base);
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { getServerFunctionMeta } from "../shared/serverFunction.ts";
|
|
|
3
3
|
export { StartServer } from "./StartServer.tsx";
|
|
4
4
|
export { decorateHandler, decorateMiddleware } from "./fetchEvent.ts";
|
|
5
5
|
export { createHandler } from "./handler.ts";
|
|
6
|
-
export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta, } from "./types.ts";
|
|
6
|
+
export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta, StartHandler, } from "./types.ts";
|
|
7
7
|
/**
|
|
8
8
|
* Checks if user has set a redirect status in the response.
|
|
9
9
|
* If not, falls back to the 302 (temporary redirect)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { H3 } from "h3/generic";
|
|
2
1
|
import type { JSX } from "solid-js";
|
|
3
|
-
import type { HandlerOptions, PageEvent } from "../types.ts";
|
|
2
|
+
import type { FetchEvent, HandlerOptions, PageEvent, StartHandler } from "../types.ts";
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
5
|
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
7
6
|
*/
|
|
8
|
-
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions)):
|
|
7
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions), routerLoad?: (event: FetchEvent) => Promise<void>): StartHandler;
|
|
@@ -4,8 +4,8 @@ import { getSsrManifest } from "../manifest/ssr-manifest.js";
|
|
|
4
4
|
*
|
|
5
5
|
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
6
6
|
*/
|
|
7
|
-
export function createHandler(fn, options) {
|
|
8
|
-
return createBaseHandler(createPageEvent, fn, options);
|
|
7
|
+
export function createHandler(fn, options, routerLoad) {
|
|
8
|
+
return createBaseHandler(createPageEvent, fn, options, routerLoad);
|
|
9
9
|
}
|
|
10
10
|
async function createPageEvent(ctx) {
|
|
11
11
|
const manifest = getSsrManifest("ssr");
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
import type { H3Event } from "h3";
|
|
1
|
+
import type { H3, H3Event } from "h3";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
3
|
import type { RequestEvent } from "solid-js/web";
|
|
4
|
+
/**
|
|
5
|
+
* The h3 app instance returned by `createHandler`.
|
|
6
|
+
*
|
|
7
|
+
* Structurally identical to h3's `H3`, but declared here so that `export default
|
|
8
|
+
* createHandler(...)` in `entry-server.tsx` can be named through `@solidjs/start`.
|
|
9
|
+
* Referring to `H3` directly makes TypeScript emit a reference to h3's internal
|
|
10
|
+
* `H3$1` class, which is not portable when h3 is nested inside
|
|
11
|
+
* `node_modules/@solidjs/start/node_modules` (TS2742 / TS2883).
|
|
12
|
+
*/
|
|
13
|
+
export interface StartHandler extends H3 {
|
|
14
|
+
}
|
|
4
15
|
export type DocumentComponentProps = {
|
|
5
16
|
assets?: JSX.Element;
|
|
6
17
|
scripts: JSX.Element;
|
|
@@ -5,5 +5,5 @@ type PipeableStream = {
|
|
|
5
5
|
}): void;
|
|
6
6
|
};
|
|
7
7
|
/** Convert Solid's streaming SSR result into a cancellation-safe web stream. */
|
|
8
|
-
export declare function toWebReadableStream(stream: PipeableStream): ReadableStream<Uint8Array
|
|
8
|
+
export declare function toWebReadableStream(stream: PipeableStream): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
9
9
|
export {};
|
|
@@ -6,8 +6,11 @@ export function toWebReadableStream(stream) {
|
|
|
6
6
|
start(controller) {
|
|
7
7
|
stream.pipe({
|
|
8
8
|
write(payload) {
|
|
9
|
-
if (active)
|
|
10
|
-
|
|
9
|
+
if (!active)
|
|
10
|
+
return;
|
|
11
|
+
// Encoding string to Uint8Array makes sure that
|
|
12
|
+
// the stream can be consumed as Response body
|
|
13
|
+
controller.enqueue(encoder.encode(payload));
|
|
11
14
|
},
|
|
12
15
|
end() {
|
|
13
16
|
if (!active)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @refresh skip
|
|
2
|
-
import { ErrorBoundary as DefaultErrorBoundary
|
|
2
|
+
import { catchError, ErrorBoundary as DefaultErrorBoundary } from "solid-js";
|
|
3
3
|
import { isServer } from "solid-js/web";
|
|
4
|
+
import { DevToolbar } from "./dev-toolbar/index.jsx";
|
|
4
5
|
import { HttpStatusCode } from "./HttpStatusCode.js";
|
|
5
|
-
import { DevOverlay } from "./dev-overlay/index.jsx";
|
|
6
6
|
export const ErrorBoundary = import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY
|
|
7
|
-
? (props) => <
|
|
7
|
+
? (props) => <DevToolbar>{props.children}</DevToolbar>
|
|
8
8
|
: (props) => {
|
|
9
9
|
const message = isServer
|
|
10
10
|
? "500 | Internal Server Error"
|
|
@@ -51,12 +51,12 @@ export function CodeView(props) {
|
|
|
51
51
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
52
52
|
const el = lines[i];
|
|
53
53
|
if (props.line - minLine() - 1 === i) {
|
|
54
|
-
el.dataset.
|
|
54
|
+
el.dataset.startErrorViewerErrorLine = '';
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
return (<div ref={ref} data-start-
|
|
60
|
-
"--
|
|
59
|
+
return (<div ref={ref} data-start-error-viewer-code-view style={{
|
|
60
|
+
"--error-viewer-code-view-start": minLine() + 1,
|
|
61
61
|
}}/>);
|
|
62
62
|
}
|
package/dist/shared/{dev-overlay/DevOverlayDialog.d.ts → dev-toolbar/error-viewer/index.d.ts}
RENAMED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { JSX } from "solid-js";
|
|
2
2
|
import "./styles.css";
|
|
3
3
|
export declare function classNames(...classes: (string | boolean | undefined)[]): string;
|
|
4
|
-
interface
|
|
4
|
+
interface ErrorViewerProps {
|
|
5
|
+
show?: boolean;
|
|
5
6
|
errors: any[];
|
|
6
7
|
resetError: () => void;
|
|
7
8
|
}
|
|
8
|
-
export default function
|
|
9
|
+
export default function ErrorViewer(props: ErrorViewerProps): JSX.Element;
|
|
9
10
|
export {};
|