@solidjs/start 2.0.0-alpha.1 → 2.0.0-alpha.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 +33 -0
- package/dist/config/constants.d.ts +1 -1
- package/dist/config/constants.js +1 -1
- package/dist/config/dev-server.js +18 -0
- package/dist/config/env.d.ts +19 -0
- package/dist/config/env.js +81 -0
- package/dist/config/fs-routes/fs-watcher.js +14 -20
- package/dist/config/fs-routes/index.js +2 -2
- package/dist/config/fs-routes/router.js +7 -8
- package/dist/config/index.d.ts +16 -1
- package/dist/config/index.js +30 -29
- package/dist/config/lazy.js +35 -5
- package/dist/config/manifest.js +40 -6
- package/dist/config/vite-utils.d.ts +6 -1
- package/dist/config/vite-utils.js +7 -3
- package/dist/directives/bubble-function-declaration.d.ts +3 -0
- package/dist/directives/bubble-function-declaration.js +23 -0
- package/dist/directives/compile.d.ts +9 -0
- package/dist/directives/compile.js +40 -0
- package/dist/directives/generate-unique-name.d.ts +3 -0
- package/dist/directives/generate-unique-name.js +16 -0
- package/dist/directives/get-descriptive-name.d.ts +2 -0
- package/dist/directives/get-descriptive-name.js +37 -0
- package/dist/directives/get-import-identifier.d.ts +4 -0
- package/dist/directives/get-import-identifier.js +19 -0
- package/dist/directives/get-root-statement-path.d.ts +2 -0
- package/dist/directives/get-root-statement-path.js +12 -0
- package/dist/directives/index.d.ts +14 -0
- package/dist/directives/index.js +169 -0
- package/dist/directives/is-statement-top-level.d.ts +3 -0
- package/dist/directives/is-statement-top-level.js +9 -0
- package/dist/directives/paths.d.ts +9 -0
- package/dist/directives/paths.js +36 -0
- package/dist/directives/plugin.d.ts +21 -0
- package/dist/directives/plugin.js +302 -0
- package/dist/directives/remove-unused-variables.d.ts +3 -0
- package/dist/directives/remove-unused-variables.js +53 -0
- package/dist/directives/types.d.ts +10 -0
- package/dist/directives/xxhash32.d.ts +6 -0
- package/dist/directives/xxhash32.js +193 -0
- package/dist/{server/server-runtime.d.ts → fns/client.d.ts} +1 -1
- package/dist/fns/client.js +106 -0
- package/dist/fns/handler.d.ts +5 -0
- package/dist/{server/server-functions-handler.js → fns/handler.js} +55 -96
- package/dist/fns/registration.d.ts +2 -0
- package/dist/fns/registration.js +12 -0
- package/dist/fns/serialization.d.ts +6 -0
- package/dist/fns/serialization.js +208 -0
- package/dist/fns/server.d.ts +7 -0
- package/dist/{server/server-fns-runtime.js → fns/server.js} +7 -1
- package/dist/fns/shared.d.ts +17 -0
- package/dist/fns/shared.js +105 -0
- package/dist/http/index.d.ts +1 -1
- package/dist/middleware/index.d.ts +20 -0
- package/dist/middleware/index.js +21 -1
- package/dist/server/StartServer.jsx +2 -0
- package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
- package/dist/server/assets/PatchVirtualDevStyles.jsx +28 -0
- package/dist/server/collect-styles.js +9 -21
- package/dist/server/handler.d.ts +61 -3
- package/dist/server/handler.js +18 -15
- package/dist/server/spa/StartServer.jsx +2 -0
- package/dist/server/spa/handler.d.ts +30 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/shared/dev-overlay/CodeView.jsx +4 -4
- package/dist/shared/dev-overlay/DevOverlayDialog.jsx +34 -34
- package/dist/shared/dev-overlay/index.jsx +2 -2
- package/dist/shared/dev-overlay/styles.css +40 -40
- package/package.json +27 -20
- package/src/config/constants.ts +1 -1
- package/src/config/dev-server.ts +12 -0
- package/src/config/env.ts +105 -0
- package/src/config/fs-routes/fs-watcher.ts +17 -24
- package/src/config/fs-routes/index.ts +2 -2
- package/src/config/fs-routes/router.ts +7 -8
- package/src/config/index.ts +44 -40
- package/src/config/lazy.ts +36 -5
- package/src/config/manifest.ts +40 -9
- package/src/config/vite-utils.ts +8 -4
- package/src/directives/bubble-function-declaration.ts +33 -0
- package/src/directives/compile.ts +54 -0
- package/src/directives/generate-unique-name.ts +22 -0
- package/src/directives/get-descriptive-name.ts +39 -0
- package/src/directives/get-import-identifier.ts +34 -0
- package/src/directives/get-root-statement-path.ts +14 -0
- package/src/directives/index.ts +232 -0
- package/src/directives/is-statement-top-level.ts +13 -0
- package/src/directives/paths.ts +63 -0
- package/src/directives/plugin.ts +389 -0
- package/src/directives/remove-unused-variables.ts +55 -0
- package/src/directives/types.ts +12 -0
- package/src/directives/xxhash32.ts +214 -0
- package/src/env.d.ts +1 -1
- package/src/fns/client.ts +141 -0
- package/src/fns/handler.spec.ts +85 -0
- package/src/{server/server-functions-handler.ts → fns/handler.ts} +65 -117
- package/src/fns/registration.ts +19 -0
- package/src/fns/serialization.ts +250 -0
- package/src/{server/server-fns-runtime.ts → fns/server.ts} +17 -2
- package/src/fns/shared.ts +116 -0
- package/src/middleware/index.ts +21 -1
- package/src/server/StartServer.tsx +2 -0
- package/src/server/assets/PatchVirtualDevStyles.tsx +31 -0
- package/src/server/collect-styles.ts +9 -26
- package/src/server/handler.ts +20 -16
- package/src/server/spa/StartServer.tsx +2 -0
- package/src/server/types.ts +1 -1
- package/src/shared/dev-overlay/CodeView.tsx +5 -7
- package/src/shared/dev-overlay/DevOverlayDialog.tsx +34 -34
- package/src/shared/dev-overlay/get-source-map.ts +1 -1
- package/src/shared/dev-overlay/index.tsx +4 -4
- package/src/shared/dev-overlay/styles.css +40 -40
- package/tsconfig.json +1 -0
- package/dist/server/fetchEvent.spec.js +0 -65
- package/dist/server/server-fns-runtime.d.ts +0 -1
- package/dist/server/server-functions-handler.d.ts +0 -2
- package/dist/server/server-runtime.js +0 -194
- package/src/server/server-runtime.ts +0 -240
- /package/dist/{server/fetchEvent.spec.d.ts → directives/types.js} +0 -0
|
@@ -2,6 +2,7 @@ import { Hydration, HydrationScript, NoHydration, getRequestEvent, ssr } from "s
|
|
|
2
2
|
import App from "solid-start:app";
|
|
3
3
|
import { ErrorBoundary, TopErrorBoundary } from "../shared/ErrorBoundary.jsx";
|
|
4
4
|
import { useAssets } from "./assets/index.js";
|
|
5
|
+
import PatchVirtualDevStyles from "./assets/PatchVirtualDevStyles.jsx";
|
|
5
6
|
import { getSsrManifest } from "./manifest/ssr-manifest.js";
|
|
6
7
|
const docType = ssr("<!DOCTYPE html>");
|
|
7
8
|
/**
|
|
@@ -17,6 +18,7 @@ export function StartServer(props) {
|
|
|
17
18
|
{docType}
|
|
18
19
|
<TopErrorBoundary>
|
|
19
20
|
<props.document assets={<HydrationScript />} scripts={<>
|
|
21
|
+
<PatchVirtualDevStyles nonce={nonce}/>
|
|
20
22
|
<script type="module" nonce={nonce} async src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY)}/>
|
|
21
23
|
</>}>
|
|
22
24
|
{!import.meta.env.START_ISLANDS ? (<Hydration>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patches the data-vite-dev-id attribute for style tags of virtual modules
|
|
3
|
+
*
|
|
4
|
+
* Per Vite's convention, virtual module ids are prefixed with \0 (null byte):
|
|
5
|
+
* https://vite.dev/guide/api-plugin#virtual-modules-convention
|
|
6
|
+
*
|
|
7
|
+
* However this null byte cannot be server rendered properly.
|
|
8
|
+
* Vite client runtime then fails to find style's with wrong null bytes,
|
|
9
|
+
* and instead inserts duplicate style's.
|
|
10
|
+
*
|
|
11
|
+
* This patch replaces the serializable /@id/__x00__ with the proper null byte,
|
|
12
|
+
* and has to run before Vite's client runtime:
|
|
13
|
+
* https://github.com/vitejs/vite/blob/130e7181a55c524383c63bbfb1749d0ff7185cad/packages/vite/src/client/client.ts#L529
|
|
14
|
+
*
|
|
15
|
+
* TODO: This should be solved in Vite directly!
|
|
16
|
+
*/
|
|
17
|
+
const patch = function () {
|
|
18
|
+
document.querySelectorAll("style[data-vite-dev-id]").forEach(function (el) {
|
|
19
|
+
el.setAttribute("data-vite-dev-id", el.dataset.viteDevId.replace("/@id/__x00__", "\0"));
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const serializedPatch = `(${patch.toString()})();`;
|
|
23
|
+
const PatchVirtualDevStyles = (props) => {
|
|
24
|
+
if (!import.meta.env.PROD) {
|
|
25
|
+
return <script nonce={props.nonce} innerHTML={serializedPatch}/>;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export default PatchVirtualDevStyles;
|
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!node) {
|
|
7
|
-
const resolvedId = await vite.pluginContainer.resolveId(file, undefined);
|
|
8
|
-
if (!resolvedId)
|
|
2
|
+
async function getViteModuleNode(vite, file, importer) {
|
|
3
|
+
try {
|
|
4
|
+
const res = await vite.fetchModule(file, importer);
|
|
5
|
+
if (!("id" in res))
|
|
9
6
|
return;
|
|
10
|
-
|
|
11
|
-
node = vite.moduleGraph.getModuleById(file);
|
|
12
|
-
}
|
|
13
|
-
if (!node) {
|
|
14
|
-
nodePath = resolve(nodePath);
|
|
15
|
-
node = await vite.moduleGraph.getModuleByUrl(file);
|
|
16
|
-
}
|
|
17
|
-
if (!node) {
|
|
18
|
-
await vite.moduleGraph.ensureEntryFromUrl(nodePath, false);
|
|
19
|
-
node = vite.moduleGraph.getModuleById(nodePath);
|
|
7
|
+
return vite.moduleGraph.getModuleById(res.id);
|
|
20
8
|
}
|
|
21
|
-
|
|
9
|
+
catch (err) { }
|
|
22
10
|
}
|
|
23
|
-
async function findModuleDependencies(vite, file, deps, crawledFiles = new Set()) {
|
|
11
|
+
async function findModuleDependencies(vite, file, deps, crawledFiles = new Set(), importer) {
|
|
24
12
|
crawledFiles.add(file);
|
|
25
|
-
const module = await getViteModuleNode(vite, file);
|
|
13
|
+
const module = await getViteModuleNode(vite, file, importer);
|
|
26
14
|
if (!module?.id || deps.has(module))
|
|
27
15
|
return;
|
|
28
16
|
deps.add(module);
|
|
@@ -40,7 +28,7 @@ async function findModuleDependencies(vite, file, deps, crawledFiles = new Set()
|
|
|
40
28
|
if (crawledFiles.has(dep)) {
|
|
41
29
|
continue;
|
|
42
30
|
}
|
|
43
|
-
await findModuleDependencies(vite, dep, deps, crawledFiles);
|
|
31
|
+
await findModuleDependencies(vite, dep, deps, crawledFiles, module.id);
|
|
44
32
|
}
|
|
45
33
|
}
|
|
46
34
|
// Vite doesn't expose these so we just copy the list for now
|
package/dist/server/handler.d.ts
CHANGED
|
@@ -1,6 +1,64 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type H3Event } from "h3";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
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
|
-
|
|
4
|
+
export declare function createBaseHandler(createPageEvent: (e: FetchEvent) => Promise<PageEvent>, fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): {
|
|
5
|
+
"~rou3": import("h3").RouterContext;
|
|
6
|
+
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
7
|
+
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
8
|
+
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
9
|
+
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
10
|
+
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
11
|
+
mount(base: string, input: import("srvx").FetchHandler | {
|
|
12
|
+
fetch: import("srvx").FetchHandler;
|
|
13
|
+
} | /*elided*/ any): /*elided*/ any;
|
|
14
|
+
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
15
|
+
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
16
|
+
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
17
|
+
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
18
|
+
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
19
|
+
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
20
|
+
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
21
|
+
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
22
|
+
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
23
|
+
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
24
|
+
readonly config: import("h3").H3Config;
|
|
25
|
+
"~middleware": import("h3").Middleware[];
|
|
26
|
+
"~routes": import("h3").H3Route[];
|
|
27
|
+
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
28
|
+
handler(event: H3Event): unknown | Promise<unknown>;
|
|
29
|
+
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
30
|
+
"~findRoute"(_event: H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
31
|
+
"~getMiddleware"(event: H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
32
|
+
"~addRoute"(_route: import("h3").H3Route): void;
|
|
33
|
+
};
|
|
34
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): {
|
|
35
|
+
"~rou3": import("h3").RouterContext;
|
|
36
|
+
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
37
|
+
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
38
|
+
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
39
|
+
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
40
|
+
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
41
|
+
mount(base: string, input: import("srvx").FetchHandler | {
|
|
42
|
+
fetch: import("srvx").FetchHandler;
|
|
43
|
+
} | /*elided*/ any): /*elided*/ any;
|
|
44
|
+
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
45
|
+
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
46
|
+
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
47
|
+
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
48
|
+
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
49
|
+
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
50
|
+
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
51
|
+
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
52
|
+
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
53
|
+
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
54
|
+
readonly config: import("h3").H3Config;
|
|
55
|
+
"~middleware": import("h3").Middleware[];
|
|
56
|
+
"~routes": import("h3").H3Route[];
|
|
57
|
+
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
58
|
+
handler(event: H3Event): unknown | Promise<unknown>;
|
|
59
|
+
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
60
|
+
"~findRoute"(_event: H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
61
|
+
"~getMiddleware"(event: H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
62
|
+
"~addRoute"(_route: import("h3").H3Route): void;
|
|
63
|
+
};
|
|
6
64
|
export declare function createPageEvent(ctx: FetchEvent): Promise<PageEvent>;
|
package/dist/server/handler.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createRoutes } from "../router.jsx";
|
|
|
6
6
|
import { decorateHandler, decorateMiddleware } from "./fetchEvent.js";
|
|
7
7
|
import { getSsrManifest } from "./manifest/ssr-manifest.js";
|
|
8
8
|
import { matchAPIRoute } from "./routes.js";
|
|
9
|
-
import { handleServerFunction } from "
|
|
9
|
+
import { handleServerFunction } from "../fns/handler.js";
|
|
10
10
|
import { getExpectedRedirectStatus } from "./util.js";
|
|
11
11
|
const SERVER_FN_BASE = "/_server";
|
|
12
12
|
export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
@@ -28,20 +28,22 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
28
28
|
if (match) {
|
|
29
29
|
const mod = await match.handler.import();
|
|
30
30
|
const fn = event.request.method === "HEAD" ? mod["HEAD"] || mod["GET"] : mod[event.request.method];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (res
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
if (typeof fn === "function") {
|
|
32
|
+
event.params = match.params || {};
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
sharedConfig.context = { event };
|
|
35
|
+
const res = await fn(event);
|
|
36
|
+
if (res !== undefined) {
|
|
37
|
+
if (res instanceof Response)
|
|
38
|
+
return produceResponseWithEventHeaders(res);
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
if (event.request.method !== "GET") {
|
|
42
|
+
throw new Error(`API handler for ${event.request.method} "${event.request.url}" did not return a response.`);
|
|
43
|
+
}
|
|
44
|
+
if (!match.isPage)
|
|
45
|
+
return;
|
|
39
46
|
}
|
|
40
|
-
if (event.request.method !== "GET") {
|
|
41
|
-
throw new Error(`API handler for ${event.request.method} "${event.request.url}" did not return a response.`);
|
|
42
|
-
}
|
|
43
|
-
if (!match.isPage)
|
|
44
|
-
return;
|
|
45
47
|
}
|
|
46
48
|
const context = await createPageEvent(event);
|
|
47
49
|
const resolvedOptions = typeof options === "function" ? await options(context) : { ...options };
|
|
@@ -58,6 +60,7 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
58
60
|
const status = getExpectedRedirectStatus(context.response);
|
|
59
61
|
return redirect(context.response.headers.get("Location"), status);
|
|
60
62
|
}
|
|
63
|
+
event.response.headers.set("content-type", "text/html");
|
|
61
64
|
return html;
|
|
62
65
|
}
|
|
63
66
|
if (resolvedOptions.onCompleteAll) {
|
|
@@ -177,7 +180,7 @@ function handleStreamCompleteRedirect(context) {
|
|
|
177
180
|
return ({ write }) => {
|
|
178
181
|
context.complete = true;
|
|
179
182
|
const to = context.response && context.response.headers.get("Location");
|
|
180
|
-
to && write(`<script>window.location
|
|
183
|
+
to && write(`<script>window.location=${JSON.stringify(to).replace(/</g, "\\u003c")}</script>`);
|
|
181
184
|
};
|
|
182
185
|
}
|
|
183
186
|
function produceResponseWithEventHeaders(res) {
|
|
@@ -2,6 +2,7 @@ import { NoHydration, getRequestEvent, ssr } from "solid-js/web";
|
|
|
2
2
|
import { getSsrManifest } from "../manifest/ssr-manifest.js";
|
|
3
3
|
import { TopErrorBoundary } from "../../shared/ErrorBoundary.jsx";
|
|
4
4
|
import { useAssets } from "../assets/index.js";
|
|
5
|
+
import PatchVirtualDevStyles from "../assets/PatchVirtualDevStyles.jsx";
|
|
5
6
|
const docType = ssr("<!DOCTYPE html>");
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -16,6 +17,7 @@ export function StartServer(props) {
|
|
|
16
17
|
{docType}
|
|
17
18
|
<TopErrorBoundary>
|
|
18
19
|
<props.document scripts={<>
|
|
20
|
+
<PatchVirtualDevStyles nonce={nonce}/>
|
|
19
21
|
<script type="module" src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY)}/>
|
|
20
22
|
</>}/>
|
|
21
23
|
</TopErrorBoundary>
|
|
@@ -4,4 +4,33 @@ import type { HandlerOptions, PageEvent } from "../types.ts";
|
|
|
4
4
|
*
|
|
5
5
|
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
6
6
|
*/
|
|
7
|
-
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)): {
|
|
8
|
+
"~rou3": import("h3").RouterContext;
|
|
9
|
+
request(request: import("srvx").ServerRequest | URL | string, options?: RequestInit, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
10
|
+
use(route: string, handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
11
|
+
use(handler: import("h3").Middleware, opts?: import("h3").MiddlewareOptions): /*elided*/ any;
|
|
12
|
+
on(method: import("h3").HTTPMethod | Lowercase<import("h3").HTTPMethod> | "", route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
13
|
+
register(plugin: import("h3").H3Plugin): /*elided*/ any;
|
|
14
|
+
mount(base: string, input: import("srvx").FetchHandler | {
|
|
15
|
+
fetch: import("srvx").FetchHandler;
|
|
16
|
+
} | /*elided*/ any): /*elided*/ any;
|
|
17
|
+
all(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
18
|
+
get(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
19
|
+
post(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
20
|
+
put(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
21
|
+
delete(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
22
|
+
patch(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
23
|
+
head(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
24
|
+
options(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
25
|
+
connect(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
26
|
+
trace(route: string, handler: import("h3").HTTPHandler, opts?: import("h3").RouteOptions): /*elided*/ any;
|
|
27
|
+
readonly config: import("h3").H3Config;
|
|
28
|
+
"~middleware": import("h3").Middleware[];
|
|
29
|
+
"~routes": import("h3").H3Route[];
|
|
30
|
+
fetch(_request: import("srvx").ServerRequest): Response | Promise<Response>;
|
|
31
|
+
handler(event: import("h3").H3Event): unknown | Promise<unknown>;
|
|
32
|
+
"~request"(request: import("srvx").ServerRequest, context?: import("h3").H3EventContext): Response | Promise<Response>;
|
|
33
|
+
"~findRoute"(_event: import("h3").H3Event): import("h3").MatchedRoute<import("h3").H3Route> | void;
|
|
34
|
+
"~getMiddleware"(event: import("h3").H3Event, route: import("h3").MatchedRoute<import("h3").H3Route> | undefined): import("h3").Middleware[];
|
|
35
|
+
"~addRoute"(_route: import("h3").H3Route): void;
|
|
36
|
+
};
|
package/dist/server/types.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface APIEvent extends FetchEvent {
|
|
|
64
64
|
[key: string]: string;
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
export type APIHandler = (event: APIEvent) =>
|
|
67
|
+
export type APIHandler = (event: APIEvent) => any;
|
|
68
68
|
export interface ServerFunctionMeta {
|
|
69
69
|
id: string;
|
|
70
70
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @refresh skip
|
|
2
2
|
import { getSingletonHighlighter } from "shiki";
|
|
3
3
|
import { loadWasm } from "shiki/engine/oniguruma";
|
|
4
|
-
import { createEffect, createResource } from "solid-js";
|
|
5
|
-
import url from "shiki/onig.wasm?url";
|
|
6
4
|
import langJS from "shiki/langs/javascript.mjs";
|
|
7
5
|
import langJSX from "shiki/langs/jsx.mjs";
|
|
8
6
|
import langTSX from "shiki/langs/tsx.mjs";
|
|
9
7
|
import langTS from "shiki/langs/typescript.mjs";
|
|
8
|
+
import url from "shiki/onig.wasm?url";
|
|
10
9
|
import darkPlus from "shiki/themes/dark-plus.mjs";
|
|
10
|
+
import { createEffect, createResource } from "solid-js";
|
|
11
11
|
let HIGHLIGHTER;
|
|
12
12
|
async function loadHighlighter() {
|
|
13
13
|
if (!HIGHLIGHTER) {
|
|
@@ -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.
|
|
54
|
+
el.dataset.startDevOverlayErrorLine = '';
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
return (<div ref={ref}
|
|
59
|
+
return (<div ref={ref} data-start-dev-overlay-code-view style={{
|
|
60
60
|
"--dev-overlay-code-view-start": minLine() + 1,
|
|
61
61
|
}}/>);
|
|
62
62
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @refresh skip
|
|
2
2
|
import ErrorStackParser from "error-stack-parser";
|
|
3
3
|
import * as htmlToImage from "html-to-image";
|
|
4
|
-
import { ErrorBoundary, For, Show, Suspense
|
|
4
|
+
import { createMemo, createSignal, ErrorBoundary, For, Show, Suspense } from "solid-js";
|
|
5
5
|
import { Portal } from "solid-js/web";
|
|
6
6
|
// @ts-ignore - terracotta module resolution issue with NodeNext
|
|
7
7
|
import { Dialog, DialogOverlay, DialogPanel, Select, SelectOption } from "terracotta";
|
|
@@ -25,9 +25,9 @@ function ErrorInfo(props) {
|
|
|
25
25
|
}
|
|
26
26
|
return { message: e.toString() };
|
|
27
27
|
});
|
|
28
|
-
return (<span
|
|
29
|
-
<span
|
|
30
|
-
<span
|
|
28
|
+
return (<span data-start-dev-overlay-error-info>
|
|
29
|
+
<span data-start-dev-overlay-error-info-name>{error().name}</span>
|
|
30
|
+
<span data-start-dev-overlay-error-info-message>{error().message}</span>
|
|
31
31
|
</span>);
|
|
32
32
|
}
|
|
33
33
|
function getFileName(source) {
|
|
@@ -46,23 +46,23 @@ function getFilePath(source) {
|
|
|
46
46
|
return `${getFileName(source.source)}${line}${column}`;
|
|
47
47
|
}
|
|
48
48
|
function CodeFallback() {
|
|
49
|
-
return (<div
|
|
49
|
+
return (<div data-start-dev-overlay-stack-frames-code-fallback>
|
|
50
50
|
<span>Source not available.</span>
|
|
51
51
|
</div>);
|
|
52
52
|
}
|
|
53
53
|
function StackFramesContent(props) {
|
|
54
54
|
const stackframes = ErrorStackParser.parse(props.error);
|
|
55
55
|
const [selectedFrame, setSelectedFrame] = createSignal(stackframes[0]);
|
|
56
|
-
return (<div
|
|
57
|
-
<div
|
|
56
|
+
return (<div data-start-dev-overlay-stack-frames-content>
|
|
57
|
+
<div data-start-dev-overlay-stack-frames-code>
|
|
58
58
|
<ErrorBoundary fallback={null}>
|
|
59
59
|
{(() => {
|
|
60
60
|
const data = createStackFrame(selectedFrame(), () => props.isCompiled);
|
|
61
61
|
return (<Suspense fallback={<CodeFallback />}>
|
|
62
62
|
<Show when={data()} keyed fallback={<CodeFallback />}>
|
|
63
63
|
{source => (<>
|
|
64
|
-
<span
|
|
65
|
-
<div
|
|
64
|
+
<span data-start-dev-overlay-stack-frames-code-source>{source.source}</span>
|
|
65
|
+
<div data-start-dev-overlay-stack-frames-code-container>
|
|
66
66
|
<CodeView fileName={source.source} line={source.line} content={source.content}/>
|
|
67
67
|
</div>
|
|
68
68
|
</>)}
|
|
@@ -71,13 +71,13 @@ function StackFramesContent(props) {
|
|
|
71
71
|
})()}
|
|
72
72
|
</ErrorBoundary>
|
|
73
73
|
</div>
|
|
74
|
-
<Select
|
|
74
|
+
<Select data-start-dev-overlay-stack-frames value={selectedFrame()} onChange={setSelectedFrame}>
|
|
75
75
|
<For each={stackframes}>
|
|
76
|
-
{current => (<ErrorBoundary fallback={<div
|
|
77
|
-
<span
|
|
76
|
+
{current => (<ErrorBoundary fallback={<div data-start-dev-overlay-stack-frame>
|
|
77
|
+
<span data-start-dev-overlay-stack-frame-function>
|
|
78
78
|
{current.functionName ?? "<anonymous>"}
|
|
79
79
|
</span>
|
|
80
|
-
<span
|
|
80
|
+
<span data-start-dev-overlay-stack-frame-file>
|
|
81
81
|
{getFilePath({
|
|
82
82
|
source: current.getFileName(),
|
|
83
83
|
content: "",
|
|
@@ -91,11 +91,11 @@ function StackFramesContent(props) {
|
|
|
91
91
|
const data = createStackFrame(current, () => props.isCompiled);
|
|
92
92
|
return (<Suspense>
|
|
93
93
|
<Show when={data()} keyed>
|
|
94
|
-
{source => (<SelectOption
|
|
95
|
-
<span
|
|
94
|
+
{source => (<SelectOption data-start-dev-overlay-stack-frame value={current}>
|
|
95
|
+
<span data-start-dev-overlay-stack-frame-function>
|
|
96
96
|
{source.name ?? "<anonymous>"}
|
|
97
97
|
</span>
|
|
98
|
-
<span
|
|
98
|
+
<span data-start-dev-overlay-stack-frame-file>{getFilePath(source)}</span>
|
|
99
99
|
</SelectOption>)}
|
|
100
100
|
</Show>
|
|
101
101
|
</Suspense>);
|
|
@@ -165,55 +165,55 @@ export default function DevOverlayDialog(props) {
|
|
|
165
165
|
window.open(DISCORD_INVITE, "_blank").focus();
|
|
166
166
|
}
|
|
167
167
|
return (<Portal>
|
|
168
|
-
<Dialog
|
|
168
|
+
<Dialog data-start-dev-overlay isOpen>
|
|
169
169
|
<div>
|
|
170
|
-
<DialogOverlay
|
|
171
|
-
<DialogPanel ref={setPanel}
|
|
172
|
-
<div
|
|
173
|
-
<div
|
|
174
|
-
<div
|
|
175
|
-
<div
|
|
170
|
+
<DialogOverlay data-start-dev-overlay-background/>
|
|
171
|
+
<DialogPanel ref={setPanel} data-start-dev-overlay-panel-container>
|
|
172
|
+
<div data-start-dev-overlay-panel>
|
|
173
|
+
<div data-start-dev-overlay-navbar>
|
|
174
|
+
<div data-start-dev-overlay-navbar-left>
|
|
175
|
+
<div data-start-dev-overlay-version>
|
|
176
176
|
<div>
|
|
177
177
|
<SolidStartIcon title="Solid Start Version"/>
|
|
178
178
|
</div>
|
|
179
179
|
<span>{info.version}</span>
|
|
180
180
|
</div>
|
|
181
181
|
<Show when={props.errors.length > 1}>
|
|
182
|
-
<div
|
|
183
|
-
<button
|
|
182
|
+
<div data-start-dev-overlay-pagination>
|
|
183
|
+
<button data-start-dev-overlay-button onClick={goPrev} type="button">
|
|
184
184
|
<ArrowLeftIcon title="Go Previous"/>
|
|
185
185
|
</button>
|
|
186
|
-
<div
|
|
186
|
+
<div data-start-dev-overlay-page-counter>
|
|
187
187
|
{`${truncated()} of ${props.errors.length}`}
|
|
188
188
|
</div>
|
|
189
|
-
<button
|
|
189
|
+
<button data-start-dev-overlay-button onClick={goNext} type="button">
|
|
190
190
|
<ArrowRightIcon title="Go Next"/>
|
|
191
191
|
</button>
|
|
192
192
|
</div>
|
|
193
193
|
</Show>
|
|
194
194
|
</div>
|
|
195
|
-
<div
|
|
196
|
-
<button
|
|
195
|
+
<div data-start-dev-overlay-controls>
|
|
196
|
+
<button data-start-dev-overlay-button onClick={redirectToGithub} type="button">
|
|
197
197
|
<GithubIcon title="Create an issue thread on Github"/>
|
|
198
198
|
</button>
|
|
199
|
-
<button
|
|
199
|
+
<button data-start-dev-overlay-button onClick={redirectToDiscord} type="button">
|
|
200
200
|
<DiscordIcon title="Join our Discord Channel"/>
|
|
201
201
|
</button>
|
|
202
|
-
<button
|
|
202
|
+
<button data-start-dev-overlay-button onClick={downloadScreenshot} type="button">
|
|
203
203
|
<CameraIcon title="Capture Error Overlay"/>
|
|
204
204
|
</button>
|
|
205
|
-
<button
|
|
205
|
+
<button data-start-dev-overlay-button onClick={toggleIsCompiled} type="button">
|
|
206
206
|
<Show when={isCompiled()} fallback={<ViewOriginalIcon title="View Original Source"/>}>
|
|
207
207
|
<ViewCompiledIcon title="View Compiled Source"/>
|
|
208
208
|
</Show>
|
|
209
209
|
</button>
|
|
210
|
-
<button
|
|
210
|
+
<button data-start-dev-overlay-button onClick={props.resetError} type="button">
|
|
211
211
|
<RefreshIcon title="Reset Error"/>
|
|
212
212
|
</button>
|
|
213
213
|
</div>
|
|
214
214
|
</div>
|
|
215
215
|
<Show when={props.errors[truncated() - 1]} keyed>
|
|
216
|
-
{current => (<div
|
|
216
|
+
{current => (<div data-start-dev-overlay-content>
|
|
217
217
|
<ErrorInfo error={current}/>
|
|
218
218
|
<StackFrames error={current} isCompiled={isCompiled()}/>
|
|
219
219
|
</div>)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @refresh skip
|
|
2
|
-
import {
|
|
3
|
-
import { HttpStatusCode } from "../HttpStatusCode.js";
|
|
2
|
+
import { createEffect, createSignal, ErrorBoundary, onCleanup, resetErrorBoundaries, Show, } from "solid-js";
|
|
4
3
|
import clientOnly from "../clientOnly.js";
|
|
4
|
+
import { HttpStatusCode } from "../HttpStatusCode.js";
|
|
5
5
|
const DevOverlayDialog = import.meta.env.PROD
|
|
6
6
|
? () => <></>
|
|
7
7
|
: clientOnly(() => import("./DevOverlayDialog"), { lazy: true });
|