@solidjs/start 2.0.0-beta.9 → 2.0.0-rc.2
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 +37 -0
- package/dist/config/env.js +11 -8
- package/dist/config/fs-routes/tree-shake.js +175 -32
- package/dist/config/index.js +7 -2
- package/dist/fns/client.js +13 -3
- package/dist/fns/handler.js +20 -7
- package/dist/fns/serialization.d.ts +15 -0
- package/dist/fns/serialization.js +1 -1
- package/dist/middleware/index.js +4 -1
- package/dist/server/StartServer.jsx +1 -1
- package/dist/server/fetchEvent.d.ts +10 -0
- package/dist/server/fetchEvent.js +10 -0
- package/dist/server/handler.d.ts +2 -2
- package/dist/server/handler.js +12 -14
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.jsx +1 -0
- package/dist/server/spa/StartServer.jsx +1 -1
- package/dist/server/spa/handler.d.ts +2 -2
- package/dist/server/spa/handler.js +2 -2
- package/dist/server/strip-path-base.d.ts +1 -0
- package/dist/server/strip-path-base.js +10 -0
- package/dist/server/web-stream.d.ts +9 -0
- package/dist/server/web-stream.js +26 -0
- package/dist/shared/ErrorBoundary.jsx +3 -3
- package/dist/shared/{dev-overlay → dev-toolbar/error-viewer}/CodeView.jsx +3 -3
- package/dist/shared/dev-toolbar/error-viewer/create-stack-frame.js +90 -0
- 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 +3 -3
- package/dist/shared/dev-overlay/createStackFrame.js +0 -56
- 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 → 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
|
@@ -22,5 +22,15 @@ export function mergeResponseHeaders(h3Event, headers) {
|
|
|
22
22
|
h3Event.res.headers.append(key, value);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Wrap an h3 event handler so Solid's request context is available while it runs.
|
|
27
|
+
*
|
|
28
|
+
* @experimental
|
|
29
|
+
*/
|
|
25
30
|
export const decorateHandler = (fn) => (event => provideRequestEvent(getFetchEvent(event), () => fn(event)));
|
|
31
|
+
/**
|
|
32
|
+
* Wrap h3 middleware so Solid's request context is available while it runs.
|
|
33
|
+
*
|
|
34
|
+
* @experimental
|
|
35
|
+
*/
|
|
26
36
|
export const decorateMiddleware = (fn) => ((event, next) => provideRequestEvent(getFetchEvent(event), () => fn(event, next)));
|
package/dist/server/handler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { H3 } from "h3/generic";
|
|
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>)): H3;
|
|
5
|
-
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>)): H3;
|
|
4
|
+
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>): H3;
|
|
5
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions | Promise<HandlerOptions>), routerLoad?: (event: FetchEvent) => Promise<void>): H3;
|
|
6
6
|
export declare function createPageEvent(ctx: FetchEvent): Promise<PageEvent>;
|
package/dist/server/handler.js
CHANGED
|
@@ -8,8 +8,10 @@ import { getSsrManifest } from "./manifest/ssr-manifest.js";
|
|
|
8
8
|
import { matchAPIRoute } from "./routes.js";
|
|
9
9
|
import { handleServerFunction } from "../fns/handler.js";
|
|
10
10
|
import { getExpectedRedirectStatus } from "./util.js";
|
|
11
|
+
import { toWebReadableStream } from "./web-stream.js";
|
|
12
|
+
import { stripPathBase } from "./strip-path-base.js";
|
|
11
13
|
const SERVER_FN_BASE = "/_server";
|
|
12
|
-
export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
14
|
+
export function createBaseHandler(createPageEvent, fn, options = {}, routerLoad) {
|
|
13
15
|
const handler = defineHandler({
|
|
14
16
|
middleware: middleware.length ? middleware.map(decorateMiddleware) : undefined,
|
|
15
17
|
handler: decorateHandler(async (e) => {
|
|
@@ -45,6 +47,8 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
45
47
|
return;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
50
|
+
if (routerLoad)
|
|
51
|
+
await routerLoad(event);
|
|
48
52
|
const context = await createPageEvent(event);
|
|
49
53
|
const resolvedOptions = typeof options === "function" ? await options(context) : { ...options };
|
|
50
54
|
const mode = resolvedOptions.mode || "stream";
|
|
@@ -93,22 +97,17 @@ export function createBaseHandler(createPageEvent, fn, options = {}) {
|
|
|
93
97
|
if (mode === "async")
|
|
94
98
|
return await stream;
|
|
95
99
|
delete stream.then;
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
return stream;
|
|
100
|
-
// returning stream directly breaks cloudflare workers
|
|
101
|
-
const { writable, readable } = new TransformStream();
|
|
102
|
-
stream.pipeTo(writable);
|
|
103
|
-
return readable;
|
|
100
|
+
// h3 expects a standard web ReadableStream across runtimes. The adapter
|
|
101
|
+
// also tolerates cancellation while Solid finishes outstanding work.
|
|
102
|
+
return toWebReadableStream(stream);
|
|
104
103
|
}),
|
|
105
104
|
});
|
|
106
105
|
const app = new H3();
|
|
107
106
|
app.use(handler);
|
|
108
107
|
return app;
|
|
109
108
|
}
|
|
110
|
-
export function createHandler(fn, options = {}) {
|
|
111
|
-
return createBaseHandler(createPageEvent, fn, options);
|
|
109
|
+
export function createHandler(fn, options = {}, routerLoad) {
|
|
110
|
+
return createBaseHandler(createPageEvent, fn, options, routerLoad);
|
|
112
111
|
}
|
|
113
112
|
export async function createPageEvent(ctx) {
|
|
114
113
|
ctx.response.headers.set("Content-Type", "text/html");
|
|
@@ -216,7 +215,6 @@ function produceResponseWithEventHeaders(res) {
|
|
|
216
215
|
return ret;
|
|
217
216
|
}
|
|
218
217
|
function stripBaseUrl(path) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return path.slice(import.meta.env.BASE_URL.length);
|
|
218
|
+
const base = import.meta.env.SERVER_BASE_URL || import.meta.env.BASE_URL || "/";
|
|
219
|
+
return stripPathBase(path, base);
|
|
222
220
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as lazy } from "../shared/lazy.ts";
|
|
2
2
|
export { getServerFunctionMeta } from "../shared/serverFunction.ts";
|
|
3
3
|
export { StartServer } from "./StartServer.tsx";
|
|
4
|
+
export { decorateHandler, decorateMiddleware } from "./fetchEvent.ts";
|
|
4
5
|
export { createHandler } from "./handler.ts";
|
|
5
6
|
export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta, } from "./types.ts";
|
|
6
7
|
/**
|
package/dist/server/index.jsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as lazy } from "../shared/lazy.js";
|
|
2
2
|
export { getServerFunctionMeta } from "../shared/serverFunction.js";
|
|
3
3
|
export { StartServer } from "./StartServer.jsx";
|
|
4
|
+
export { decorateHandler, decorateMiddleware } from "./fetchEvent.js";
|
|
4
5
|
export { createHandler } from "./handler.js";
|
|
5
6
|
/**
|
|
6
7
|
* Checks if user has set a redirect status in the response.
|
|
@@ -18,7 +18,7 @@ export function StartServer(props) {
|
|
|
18
18
|
<TopErrorBoundary>
|
|
19
19
|
<props.document scripts={<>
|
|
20
20
|
<PatchVirtualDevStyles nonce={nonce}/>
|
|
21
|
-
<script type="module" src={getSsrManifest("client").path(import.meta.env.
|
|
21
|
+
<script type="module" src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY_URL)}/>
|
|
22
22
|
</>}/>
|
|
23
23
|
</TopErrorBoundary>
|
|
24
24
|
</NoHydration>);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { H3 } from "h3/generic";
|
|
2
2
|
import type { JSX } from "solid-js";
|
|
3
|
-
import type { HandlerOptions, PageEvent } from "../types.ts";
|
|
3
|
+
import type { FetchEvent, HandlerOptions, PageEvent } from "../types.ts";
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
7
7
|
*/
|
|
8
|
-
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions)): H3;
|
|
8
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions), routerLoad?: (event: FetchEvent) => Promise<void>): H3;
|
|
@@ -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");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stripPathBase(path: string, base: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function stripPathBase(path, base) {
|
|
2
|
+
if (!base || base === "/")
|
|
3
|
+
return path;
|
|
4
|
+
const normalizedBase = base.endsWith("/") ? base.slice(0, -1) : base;
|
|
5
|
+
if (path === normalizedBase)
|
|
6
|
+
return "/";
|
|
7
|
+
if (path.startsWith(`${normalizedBase}/`))
|
|
8
|
+
return path.slice(normalizedBase.length);
|
|
9
|
+
return path;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type PipeableStream = {
|
|
2
|
+
pipe(writable: {
|
|
3
|
+
write(payload: string): void;
|
|
4
|
+
end(): void;
|
|
5
|
+
}): void;
|
|
6
|
+
};
|
|
7
|
+
/** Convert Solid's streaming SSR result into a cancellation-safe web stream. */
|
|
8
|
+
export declare function toWebReadableStream(stream: PipeableStream): ReadableStream<Uint8Array>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Convert Solid's streaming SSR result into a cancellation-safe web stream. */
|
|
2
|
+
export function toWebReadableStream(stream) {
|
|
3
|
+
const encoder = new TextEncoder();
|
|
4
|
+
let active = true;
|
|
5
|
+
return new ReadableStream({
|
|
6
|
+
start(controller) {
|
|
7
|
+
stream.pipe({
|
|
8
|
+
write(payload) {
|
|
9
|
+
if (active)
|
|
10
|
+
controller.enqueue(encoder.encode(payload));
|
|
11
|
+
},
|
|
12
|
+
end() {
|
|
13
|
+
if (!active)
|
|
14
|
+
return;
|
|
15
|
+
active = false;
|
|
16
|
+
controller.close();
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
cancel() {
|
|
21
|
+
// Solid may still resolve Suspense resources after the response is
|
|
22
|
+
// cancelled. Ignore those writes and let Solid finish its cleanup.
|
|
23
|
+
active = false;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createMemo, createResource } from "solid-js";
|
|
2
|
+
import getSourceMap from "./get-source-map.js";
|
|
3
|
+
const HTTP_URL_REGEX = /^https?:\/\//;
|
|
4
|
+
const LEADING_SLASH_REGEX = /^\/+/;
|
|
5
|
+
// Frames from an SSR error carry filesystem paths (or file:// URLs) rather
|
|
6
|
+
// than the http URL the module is served from. Their positions are already
|
|
7
|
+
// mapped back to the original source by the Vite module runner, unlike
|
|
8
|
+
// client frames whose positions refer to the compiled module.
|
|
9
|
+
function isServerSource(path) {
|
|
10
|
+
return !HTTP_URL_REGEX.test(path);
|
|
11
|
+
}
|
|
12
|
+
function getActualFileSource(path) {
|
|
13
|
+
if (path.startsWith("file://")) {
|
|
14
|
+
return "/@fs/" + path.substring("file://".length).replace(LEADING_SLASH_REGEX, "");
|
|
15
|
+
}
|
|
16
|
+
if (isServerSource(path)) {
|
|
17
|
+
return "/@fs/" + path.replace(LEADING_SLASH_REGEX, "");
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
export function createStackFrame(stackframe, isCompiled) {
|
|
22
|
+
const [data] = createResource(() => ({
|
|
23
|
+
fileName: stackframe.fileName,
|
|
24
|
+
line: stackframe.lineNumber,
|
|
25
|
+
column: stackframe.columnNumber,
|
|
26
|
+
functionName: stackframe.functionName,
|
|
27
|
+
}), async (source) => {
|
|
28
|
+
if (!source.fileName) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const url = getActualFileSource(source.fileName);
|
|
32
|
+
const response = await fetch(url);
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const content = await response.text();
|
|
37
|
+
const sourceMap = await getSourceMap(url, content);
|
|
38
|
+
return {
|
|
39
|
+
source,
|
|
40
|
+
content,
|
|
41
|
+
sourceMap,
|
|
42
|
+
isServer: isServerSource(source.fileName),
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
const info = createMemo(() => {
|
|
46
|
+
const current = data();
|
|
47
|
+
if (!current) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const { source, content, sourceMap, isServer } = current;
|
|
51
|
+
if (!isCompiled() && source.line && source.column && sourceMap) {
|
|
52
|
+
if (isServer) {
|
|
53
|
+
// The position is already original; only the original content needs
|
|
54
|
+
// to be pulled out of the source map.
|
|
55
|
+
const originalContent = sourceMap.sources.length
|
|
56
|
+
? sourceMap.sourceContentFor(sourceMap.sources[0], true)
|
|
57
|
+
: null;
|
|
58
|
+
if (originalContent) {
|
|
59
|
+
return {
|
|
60
|
+
source: source.fileName,
|
|
61
|
+
line: source.line,
|
|
62
|
+
column: source.column,
|
|
63
|
+
name: source.functionName,
|
|
64
|
+
content: originalContent,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const result = sourceMap.originalPositionFor({
|
|
70
|
+
line: source.line,
|
|
71
|
+
column: source.column,
|
|
72
|
+
});
|
|
73
|
+
if (result.source) {
|
|
74
|
+
return {
|
|
75
|
+
...result,
|
|
76
|
+
content: sourceMap.sourceContentFor(result.source, true),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
source: source.fileName,
|
|
83
|
+
line: source.line,
|
|
84
|
+
column: source.column,
|
|
85
|
+
name: source.functionName,
|
|
86
|
+
content,
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
return info;
|
|
90
|
+
}
|
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 {};
|
|
@@ -2,14 +2,12 @@
|
|
|
2
2
|
import ErrorStackParser from "error-stack-parser";
|
|
3
3
|
import * as htmlToImage from "html-to-image";
|
|
4
4
|
import { createMemo, createSignal, ErrorBoundary, For, Show, Suspense } from "solid-js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import info from "../../../package.json" with { type: "json" };
|
|
5
|
+
import IconButton from "../../ui/IconButton.jsx";
|
|
6
|
+
import { Select, SelectOption } from "../../ui/Select.jsx";
|
|
7
|
+
import { ArrowLeftIcon, ArrowRightIcon, CameraIcon, DiscordIcon, GithubIcon, RefreshIcon, ViewCompiledIcon, ViewOriginalIcon, } from "../icons.jsx";
|
|
9
8
|
import { CodeView } from "./CodeView.jsx";
|
|
10
|
-
import { createStackFrame } from "./
|
|
9
|
+
import { createStackFrame } from "./create-stack-frame.js";
|
|
11
10
|
import download from "./download.js";
|
|
12
|
-
import { ArrowLeftIcon, ArrowRightIcon, CameraIcon, DiscordIcon, GithubIcon, RefreshIcon, SolidStartIcon, ViewCompiledIcon, ViewOriginalIcon, } from "./icons.jsx";
|
|
13
11
|
import "./styles.css";
|
|
14
12
|
export function classNames(...classes) {
|
|
15
13
|
return classes.filter(Boolean).join(" ");
|
|
@@ -25,9 +23,9 @@ function ErrorInfo(props) {
|
|
|
25
23
|
}
|
|
26
24
|
return { message: e.toString() };
|
|
27
25
|
});
|
|
28
|
-
return (<span data-start-
|
|
29
|
-
<span data-start-
|
|
30
|
-
<span data-start-
|
|
26
|
+
return (<span data-start-error-viewer-error-info>
|
|
27
|
+
<span data-start-error-viewer-error-info-name>{error().name}</span>
|
|
28
|
+
<span data-start-error-viewer-error-info-message>{error().message}</span>
|
|
31
29
|
</span>);
|
|
32
30
|
}
|
|
33
31
|
function getFileName(source) {
|
|
@@ -46,23 +44,23 @@ function getFilePath(source) {
|
|
|
46
44
|
return `${getFileName(source.source)}${line}${column}`;
|
|
47
45
|
}
|
|
48
46
|
function CodeFallback() {
|
|
49
|
-
return (<div data-start-
|
|
47
|
+
return (<div data-start-error-viewer-stack-frames-code-fallback>
|
|
50
48
|
<span>Source not available.</span>
|
|
51
49
|
</div>);
|
|
52
50
|
}
|
|
53
51
|
function StackFramesContent(props) {
|
|
54
52
|
const stackframes = ErrorStackParser.parse(props.error);
|
|
55
53
|
const [selectedFrame, setSelectedFrame] = createSignal(stackframes[0]);
|
|
56
|
-
return (<div data-start-
|
|
57
|
-
<div data-start-
|
|
54
|
+
return (<div data-start-error-viewer-stack-frames-content>
|
|
55
|
+
<div data-start-error-viewer-stack-frames-code>
|
|
58
56
|
<ErrorBoundary fallback={null}>
|
|
59
57
|
{(() => {
|
|
60
58
|
const data = createStackFrame(selectedFrame(), () => props.isCompiled);
|
|
61
59
|
return (<Suspense fallback={<CodeFallback />}>
|
|
62
60
|
<Show when={data()} keyed fallback={<CodeFallback />}>
|
|
63
61
|
{source => (<>
|
|
64
|
-
<span data-start-
|
|
65
|
-
<div data-start-
|
|
62
|
+
<span data-start-error-viewer-stack-frames-code-source>{source.source}</span>
|
|
63
|
+
<div data-start-error-viewer-stack-frames-code-container>
|
|
66
64
|
<CodeView fileName={source.source} line={source.line} content={source.content}/>
|
|
67
65
|
</div>
|
|
68
66
|
</>)}
|
|
@@ -71,13 +69,13 @@ function StackFramesContent(props) {
|
|
|
71
69
|
})()}
|
|
72
70
|
</ErrorBoundary>
|
|
73
71
|
</div>
|
|
74
|
-
<Select data-start-
|
|
72
|
+
<Select data-start-error-viewer-stack-frames value={selectedFrame()} onChange={setSelectedFrame}>
|
|
75
73
|
<For each={stackframes}>
|
|
76
|
-
{current => (<ErrorBoundary fallback={<
|
|
77
|
-
<span data-start-
|
|
74
|
+
{current => (<ErrorBoundary fallback={<SelectOption value={current} disabled data-start-error-viewer-stack-frame>
|
|
75
|
+
<span data-start-error-viewer-stack-frame-function>
|
|
78
76
|
{current.functionName ?? "<anonymous>"}
|
|
79
77
|
</span>
|
|
80
|
-
<span data-start-
|
|
78
|
+
<span data-start-error-viewer-stack-frame-file>
|
|
81
79
|
{getFilePath({
|
|
82
80
|
source: current.getFileName(),
|
|
83
81
|
content: "",
|
|
@@ -86,16 +84,18 @@ function StackFramesContent(props) {
|
|
|
86
84
|
name: current.getFunctionName(),
|
|
87
85
|
})}
|
|
88
86
|
</span>
|
|
89
|
-
</
|
|
87
|
+
</SelectOption>}>
|
|
90
88
|
{(() => {
|
|
91
89
|
const data = createStackFrame(current, () => props.isCompiled);
|
|
92
90
|
return (<Suspense>
|
|
93
91
|
<Show when={data()} keyed>
|
|
94
|
-
{source => (<SelectOption data-start-
|
|
95
|
-
<span data-start-
|
|
92
|
+
{source => (<SelectOption data-start-error-viewer-stack-frame value={current}>
|
|
93
|
+
<span data-start-error-viewer-stack-frame-function>
|
|
96
94
|
{source.name ?? "<anonymous>"}
|
|
97
95
|
</span>
|
|
98
|
-
<span data-start-
|
|
96
|
+
<span data-start-error-viewer-stack-frame-file>
|
|
97
|
+
{getFilePath(source)}
|
|
98
|
+
</span>
|
|
99
99
|
</SelectOption>)}
|
|
100
100
|
</Show>
|
|
101
101
|
</Suspense>);
|
|
@@ -112,7 +112,7 @@ function StackFrames(props) {
|
|
|
112
112
|
}
|
|
113
113
|
const ISSUE_THREAD = "https://github.com/solidjs/solid-start/issues/new";
|
|
114
114
|
const DISCORD_INVITE = "https://discord.com/invite/solidjs";
|
|
115
|
-
export default function
|
|
115
|
+
export default function ErrorViewer(props) {
|
|
116
116
|
const [currentPage, setCurrentPage] = createSignal(1);
|
|
117
117
|
const [isCompiled, setIsCompiled] = createSignal(false);
|
|
118
118
|
const length = createMemo(() => props.errors.length);
|
|
@@ -164,63 +164,52 @@ export default function DevOverlayDialog(props) {
|
|
|
164
164
|
function redirectToDiscord() {
|
|
165
165
|
window.open(DISCORD_INVITE, "_blank").focus();
|
|
166
166
|
}
|
|
167
|
-
return (<
|
|
168
|
-
<
|
|
169
|
-
<div>
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
<span>{info.version}</span>
|
|
167
|
+
return (<Show when={props.show}>
|
|
168
|
+
<div data-start-dev-toolbar-panel>
|
|
169
|
+
<div ref={setPanel} data-start-error-viewer>
|
|
170
|
+
<div data-start-error-viewer-navbar>
|
|
171
|
+
<div data-start-error-viewer-navbar-left>
|
|
172
|
+
<Show when={props.errors.length > 1}>
|
|
173
|
+
<div data-start-error-viewer-pagination>
|
|
174
|
+
<IconButton data-start-error-viewer-button onClick={goPrev} type="button">
|
|
175
|
+
<ArrowLeftIcon title="Go Previous"/>
|
|
176
|
+
</IconButton>
|
|
177
|
+
<div data-start-error-viewer-page-counter>
|
|
178
|
+
{`${truncated()} of ${props.errors.length}`}
|
|
180
179
|
</div>
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
<ArrowLeftIcon title="Go Previous"/>
|
|
185
|
-
</button>
|
|
186
|
-
<div data-start-dev-overlay-page-counter>
|
|
187
|
-
{`${truncated()} of ${props.errors.length}`}
|
|
188
|
-
</div>
|
|
189
|
-
<button data-start-dev-overlay-button onClick={goNext} type="button">
|
|
190
|
-
<ArrowRightIcon title="Go Next"/>
|
|
191
|
-
</button>
|
|
192
|
-
</div>
|
|
193
|
-
</Show>
|
|
194
|
-
</div>
|
|
195
|
-
<div data-start-dev-overlay-controls>
|
|
196
|
-
<button data-start-dev-overlay-button onClick={redirectToGithub} type="button">
|
|
197
|
-
<GithubIcon title="Create an issue thread on Github"/>
|
|
198
|
-
</button>
|
|
199
|
-
<button data-start-dev-overlay-button onClick={redirectToDiscord} type="button">
|
|
200
|
-
<DiscordIcon title="Join our Discord Channel"/>
|
|
201
|
-
</button>
|
|
202
|
-
<button data-start-dev-overlay-button onClick={downloadScreenshot} type="button">
|
|
203
|
-
<CameraIcon title="Capture Error Overlay"/>
|
|
204
|
-
</button>
|
|
205
|
-
<button data-start-dev-overlay-button onClick={toggleIsCompiled} type="button">
|
|
206
|
-
<Show when={isCompiled()} fallback={<ViewOriginalIcon title="View Original Source"/>}>
|
|
207
|
-
<ViewCompiledIcon title="View Compiled Source"/>
|
|
208
|
-
</Show>
|
|
209
|
-
</button>
|
|
210
|
-
<button data-start-dev-overlay-button onClick={props.resetError} type="button">
|
|
211
|
-
<RefreshIcon title="Reset Error"/>
|
|
212
|
-
</button>
|
|
180
|
+
<IconButton data-start-error-viewer-button onClick={goNext} type="button">
|
|
181
|
+
<ArrowRightIcon title="Go Next"/>
|
|
182
|
+
</IconButton>
|
|
213
183
|
</div>
|
|
214
|
-
</div>
|
|
215
|
-
<Show when={props.errors[truncated() - 1]} keyed>
|
|
216
|
-
{current => (<div data-start-dev-overlay-content>
|
|
217
|
-
<ErrorInfo error={current}/>
|
|
218
|
-
<StackFrames error={current} isCompiled={isCompiled()}/>
|
|
219
|
-
</div>)}
|
|
220
184
|
</Show>
|
|
221
185
|
</div>
|
|
222
|
-
|
|
186
|
+
<div data-start-error-viewer-controls>
|
|
187
|
+
<IconButton data-start-error-viewer-button onClick={redirectToGithub} type="button">
|
|
188
|
+
<GithubIcon title="Create an issue thread on Github"/>
|
|
189
|
+
</IconButton>
|
|
190
|
+
<IconButton data-start-error-viewer-button onClick={redirectToDiscord} type="button">
|
|
191
|
+
<DiscordIcon title="Join our Discord Channel"/>
|
|
192
|
+
</IconButton>
|
|
193
|
+
<IconButton data-start-error-viewer-button onClick={downloadScreenshot} type="button">
|
|
194
|
+
<CameraIcon title="Capture Error Overlay"/>
|
|
195
|
+
</IconButton>
|
|
196
|
+
<IconButton data-start-error-viewer-button onClick={toggleIsCompiled} type="button">
|
|
197
|
+
<Show when={isCompiled()} fallback={<ViewOriginalIcon title="View Original Source"/>}>
|
|
198
|
+
<ViewCompiledIcon title="View Compiled Source"/>
|
|
199
|
+
</Show>
|
|
200
|
+
</IconButton>
|
|
201
|
+
<IconButton data-start-error-viewer-button onClick={props.resetError} type="button">
|
|
202
|
+
<RefreshIcon title="Reset Error"/>
|
|
203
|
+
</IconButton>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
<Show when={props.errors[truncated() - 1]} keyed>
|
|
207
|
+
{current => (<div data-start-error-viewer-content>
|
|
208
|
+
<ErrorInfo error={current}/>
|
|
209
|
+
<StackFrames error={current} isCompiled={isCompiled()}/>
|
|
210
|
+
</div>)}
|
|
211
|
+
</Show>
|
|
223
212
|
</div>
|
|
224
|
-
</
|
|
225
|
-
</
|
|
213
|
+
</div>
|
|
214
|
+
</Show>);
|
|
226
215
|
}
|