@solidjs/start 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/index.d.ts +4 -1
- package/config/index.js +33 -3
- package/config/server-handler.js +13 -24
- package/package.json +2 -2
- package/server/middleware.ts +7 -1
- package/server/types.ts +2 -2
- package/shared/FileRoutes.tsx +5 -2
- package/shared/dev-overlay/CodeView.tsx +22 -7
- package/shared/dev-overlay/createStackFrame.ts +34 -20
- package/shared/dev-overlay/styles.css +2 -5
package/config/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AppOptions } from "vinxi";
|
|
2
2
|
import { InlineConfig } from "vite";
|
|
3
|
+
import type { Options } from "vite-plugin-solid";
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
|
|
5
7
|
start?: {
|
|
@@ -9,6 +11,7 @@ type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
|
|
|
9
11
|
* async: ssr is in async mode
|
|
10
12
|
*/
|
|
11
13
|
ssr?: boolean | "async",
|
|
14
|
+
solid?: Options,
|
|
12
15
|
extensions?: string[],
|
|
13
16
|
server?: AppOptions['server'],
|
|
14
17
|
appRoot?: string,
|
|
@@ -17,4 +20,4 @@ type SolidStartInlineConfig = Omit<InlineConfig, "router"> & {
|
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
|
-
export declare function defineConfig(baseConfig?: SolidStartInlineConfig)
|
|
23
|
+
export declare function defineConfig(baseConfig?: SolidStartInlineConfig)
|
package/config/index.js
CHANGED
|
@@ -79,7 +79,17 @@ export function defineConfig(baseConfig = {}) {
|
|
|
79
79
|
extensions,
|
|
80
80
|
target: "server",
|
|
81
81
|
plugins: async () => [
|
|
82
|
-
config("user",
|
|
82
|
+
config("user", {
|
|
83
|
+
...userConfig,
|
|
84
|
+
optimizeDeps: {
|
|
85
|
+
...(userConfig.optimizeDeps || {}),
|
|
86
|
+
include: [
|
|
87
|
+
...(userConfig.optimizeDeps?.include || []),
|
|
88
|
+
'@solidjs/start > source-map-js',
|
|
89
|
+
'@solidjs/start > error-stack-parser',
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
}),
|
|
83
93
|
...(typeof plugins === "function" ? [...(await plugins())] : plugins),
|
|
84
94
|
|
|
85
95
|
serverTransform({
|
|
@@ -121,7 +131,17 @@ export function defineConfig(baseConfig = {}) {
|
|
|
121
131
|
extensions,
|
|
122
132
|
target: "browser",
|
|
123
133
|
plugins: async () => [
|
|
124
|
-
config("user",
|
|
134
|
+
config("user", {
|
|
135
|
+
...userConfig,
|
|
136
|
+
optimizeDeps: {
|
|
137
|
+
...(userConfig.optimizeDeps || {}),
|
|
138
|
+
include: [
|
|
139
|
+
...(userConfig.optimizeDeps?.include || []),
|
|
140
|
+
'@solidjs/start > source-map-js',
|
|
141
|
+
'@solidjs/start > error-stack-parser',
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
125
145
|
...(typeof plugins === "function" ? [...(await plugins())] : plugins),
|
|
126
146
|
serverFunctions.client({
|
|
127
147
|
runtime: normalize(fileURLToPath(new URL("./server-runtime.jsx", import.meta.url)))
|
|
@@ -161,7 +181,17 @@ export function defineConfig(baseConfig = {}) {
|
|
|
161
181
|
runtime: normalize(fileURLToPath(new URL("./server-fns-runtime.jsx", import.meta.url))),
|
|
162
182
|
// routes: solidStartServerFsRouter({ dir: `${start.appRoot}/routes`, extensions }),
|
|
163
183
|
plugins: async () => [
|
|
164
|
-
config("user",
|
|
184
|
+
config("user", {
|
|
185
|
+
...userConfig,
|
|
186
|
+
optimizeDeps: {
|
|
187
|
+
...(userConfig.optimizeDeps || {}),
|
|
188
|
+
include: [
|
|
189
|
+
...(userConfig.optimizeDeps?.include || []),
|
|
190
|
+
'@solidjs/start > source-map-js',
|
|
191
|
+
'@solidjs/start > error-stack-parser',
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
165
195
|
...(typeof plugins === "function" ? [...(await plugins())] : plugins),
|
|
166
196
|
|
|
167
197
|
solid({ ...start.solid, ssr: true, extensions: extensions.map(ext => `.${ext}`) }),
|
package/config/server-handler.js
CHANGED
|
@@ -18,10 +18,6 @@ import { provideRequestEvent } from "solid-js/web/storage";
|
|
|
18
18
|
import invariant from "vinxi/lib/invariant";
|
|
19
19
|
import {
|
|
20
20
|
eventHandler,
|
|
21
|
-
getHeader,
|
|
22
|
-
getRequestURL,
|
|
23
|
-
readBody,
|
|
24
|
-
readRawBody,
|
|
25
21
|
setHeader
|
|
26
22
|
} from "vinxi/server";
|
|
27
23
|
import { getFetchEvent } from "../server/middleware";
|
|
@@ -60,12 +56,14 @@ function serializeToStream(id, value) {
|
|
|
60
56
|
});
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
async function handleServerFunction(
|
|
64
|
-
invariant(
|
|
59
|
+
async function handleServerFunction(h3Event) {
|
|
60
|
+
invariant(h3Event.method === "POST", `Invalid method ${h3Event.method}. Expected POST.`);
|
|
61
|
+
const event = getFetchEvent(h3Event);
|
|
62
|
+
const request = event.request;
|
|
65
63
|
|
|
66
|
-
const serverReference =
|
|
67
|
-
const instance =
|
|
68
|
-
const url =
|
|
64
|
+
const serverReference = request.headers.get("x-server-id");
|
|
65
|
+
const instance = request.headers.get("x-server-instance");
|
|
66
|
+
const url = new URL(request.url);
|
|
69
67
|
let filepath, name;
|
|
70
68
|
if (serverReference) {
|
|
71
69
|
invariant(typeof serverReference === "string", "Invalid server function");
|
|
@@ -86,22 +84,14 @@ async function handleServerFunction(event) {
|
|
|
86
84
|
const args = url.searchParams.get("args");
|
|
87
85
|
if (args) JSON.parse(args).forEach(arg => parsed.push(arg));
|
|
88
86
|
}
|
|
89
|
-
const contentType =
|
|
87
|
+
const contentType = request.headers.get("content-type");
|
|
90
88
|
if (
|
|
91
89
|
contentType.startsWith("multipart/form-data") ||
|
|
92
90
|
contentType.startsWith("application/x-www-form-urlencoded")
|
|
93
91
|
) {
|
|
94
|
-
// Temporary workaround until https://github.com/unjs/nitro/issues/1721 is resolved
|
|
95
|
-
// parsed.push(await readFormData(event));
|
|
96
|
-
|
|
97
|
-
const request = new Request(getRequestURL(event), {
|
|
98
|
-
method: event.method,
|
|
99
|
-
headers: event.headers,
|
|
100
|
-
body: await readRawBody(event)
|
|
101
|
-
});
|
|
102
92
|
parsed.push(await request.formData());
|
|
103
93
|
} else {
|
|
104
|
-
parsed = fromJSON(await
|
|
94
|
+
parsed = fromJSON(await request.json(), {
|
|
105
95
|
plugins: [
|
|
106
96
|
CustomEventPlugin,
|
|
107
97
|
DOMExceptionPlugin,
|
|
@@ -117,17 +107,16 @@ async function handleServerFunction(event) {
|
|
|
117
107
|
});
|
|
118
108
|
}
|
|
119
109
|
try {
|
|
120
|
-
const
|
|
121
|
-
const result = await provideRequestEvent(evt, () => {
|
|
110
|
+
const result = await provideRequestEvent(event, () => {
|
|
122
111
|
/* @ts-ignore */
|
|
123
|
-
sharedConfig.context = { event
|
|
112
|
+
sharedConfig.context = { event };
|
|
124
113
|
return action(...parsed);
|
|
125
114
|
});
|
|
126
115
|
|
|
127
116
|
// handle no JS success case
|
|
128
117
|
if (!instance) {
|
|
129
118
|
const isError = result instanceof Error;
|
|
130
|
-
const refererUrl = new URL(
|
|
119
|
+
const refererUrl = new URL(request.headers.get("referer"));
|
|
131
120
|
return new Response(null, {
|
|
132
121
|
status: 302,
|
|
133
122
|
headers: {
|
|
@@ -146,7 +135,7 @@ async function handleServerFunction(event) {
|
|
|
146
135
|
});
|
|
147
136
|
}
|
|
148
137
|
if (typeof result === "string") return new Response(result);
|
|
149
|
-
setHeader(
|
|
138
|
+
setHeader(h3Event, "content-type", "text/javascript");
|
|
150
139
|
return serializeToStream(instance, result);
|
|
151
140
|
} catch (x) {
|
|
152
141
|
if (x instanceof Response && x.status === 302) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/start",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"publishConfig": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"solid-js": "^1.8.
|
|
41
|
+
"solid-js": "^1.8.9",
|
|
42
42
|
"vinxi": "0.1.1"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
package/server/middleware.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
defineMiddleware,
|
|
3
3
|
EventHandlerRequest,
|
|
4
4
|
getRequestIP,
|
|
5
|
+
getRequestURL,
|
|
5
6
|
H3Event,
|
|
6
7
|
sendWebResponse,
|
|
7
8
|
toWebRequest
|
|
@@ -18,9 +19,14 @@ const eventTraps = {
|
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export function createFetchEvent(event: H3Event<EventHandlerRequest>): FetchEvent {
|
|
22
|
+
event.web ||
|
|
23
|
+
(event.web = {
|
|
24
|
+
url: getRequestURL(event),
|
|
25
|
+
request: toWebRequest(event)
|
|
26
|
+
});
|
|
21
27
|
return new Proxy(
|
|
22
28
|
{
|
|
23
|
-
request:
|
|
29
|
+
request: event.web.request,
|
|
24
30
|
clientAddress: getRequestIP(event),
|
|
25
31
|
locals: {},
|
|
26
32
|
// @ts-ignore
|
package/server/types.ts
CHANGED
package/shared/FileRoutes.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getRequestEvent, isServer } from "solid-js/web";
|
|
3
3
|
import lazyRoute from "./lazyRoute";
|
|
4
4
|
|
|
5
|
-
import { PageEvent } from "../server";
|
|
5
|
+
import type { PageEvent } from "../server/types";
|
|
6
6
|
import { pageRoutes as routeConfigs } from "./routes";
|
|
7
7
|
|
|
8
8
|
export function createRoutes() {
|
|
@@ -10,7 +10,10 @@ export function createRoutes() {
|
|
|
10
10
|
return {
|
|
11
11
|
...route,
|
|
12
12
|
...(route.$$route ? route.$$route.require().route : undefined),
|
|
13
|
-
metadata: {
|
|
13
|
+
metadata: {
|
|
14
|
+
...(route.$$route ? route.$$route.require().route.metadata : {}),
|
|
15
|
+
filesystem: true
|
|
16
|
+
},
|
|
14
17
|
component: lazyRoute(
|
|
15
18
|
route.$component,
|
|
16
19
|
import.meta.env.START_ISLANDS
|
|
@@ -1,13 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BuiltinLanguage, Highlighter } from 'shikiji';
|
|
2
|
+
import { getHighlighterCore } from 'shikiji/core';
|
|
3
|
+
import { getWasmInlined } from 'shikiji/wasm';
|
|
2
4
|
import { createEffect, createResource, type JSX } from 'solid-js';
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
import langJS from 'shikiji/langs/javascript.mjs';
|
|
7
|
+
import langJSX from 'shikiji/langs/jsx.mjs';
|
|
8
|
+
import langTSX from 'shikiji/langs/tsx.mjs';
|
|
9
|
+
import langTS from 'shikiji/langs/typescript.mjs';
|
|
10
|
+
import darkPlus from 'shikiji/themes/dark-plus.mjs';
|
|
11
|
+
|
|
12
|
+
let HIGHLIGHTER: Highlighter;
|
|
5
13
|
|
|
6
14
|
async function loadHighlighter() {
|
|
7
15
|
if (!HIGHLIGHTER) {
|
|
8
|
-
HIGHLIGHTER = await
|
|
9
|
-
themes: [
|
|
10
|
-
|
|
16
|
+
HIGHLIGHTER = await getHighlighterCore({
|
|
17
|
+
themes: [
|
|
18
|
+
darkPlus,
|
|
19
|
+
],
|
|
20
|
+
langs: [
|
|
21
|
+
langJS,
|
|
22
|
+
langJSX,
|
|
23
|
+
langTS,
|
|
24
|
+
langTSX,
|
|
25
|
+
],
|
|
26
|
+
loadWasm: getWasmInlined,
|
|
11
27
|
});
|
|
12
28
|
}
|
|
13
29
|
return HIGHLIGHTER;
|
|
@@ -44,8 +60,7 @@ export function CodeView(props: CodeViewProps): JSX.Element | null {
|
|
|
44
60
|
.split(/[#?]/)[0]
|
|
45
61
|
.split('.')
|
|
46
62
|
.pop()
|
|
47
|
-
?.trim() as
|
|
48
|
-
await highlighter.loadLanguage(lang);
|
|
63
|
+
?.trim() as BuiltinLanguage;
|
|
49
64
|
return highlighter.codeToHtml(value, {
|
|
50
65
|
theme: 'dark-plus',
|
|
51
66
|
lang,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Accessor, createMemo, createResource } from "solid-js";
|
|
2
2
|
import getSourceMap from "./get-source-map";
|
|
3
3
|
|
|
4
4
|
export interface StackFrameSource {
|
|
@@ -12,10 +12,9 @@ export interface StackFrameSource {
|
|
|
12
12
|
export function createStackFrame(
|
|
13
13
|
stackframe: StackFrame,
|
|
14
14
|
isCompiled: () => boolean,
|
|
15
|
-
):
|
|
15
|
+
): Accessor<StackFrameSource> {
|
|
16
16
|
const [data] = createResource(
|
|
17
17
|
() => ({
|
|
18
|
-
isCompiled: isCompiled(),
|
|
19
18
|
fileName: stackframe.fileName,
|
|
20
19
|
line: stackframe.lineNumber,
|
|
21
20
|
column: stackframe.columnNumber,
|
|
@@ -31,27 +30,42 @@ export function createStackFrame(
|
|
|
31
30
|
}
|
|
32
31
|
const content = await response.text();
|
|
33
32
|
const sourceMap = await getSourceMap(source.fileName, content);
|
|
34
|
-
if (!source.isCompiled && sourceMap && source.line && source.column) {
|
|
35
|
-
const result = sourceMap.originalPositionFor({
|
|
36
|
-
line: source.line,
|
|
37
|
-
column: source.column,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
...result,
|
|
42
|
-
content: sourceMap.sourceContentFor(result.source),
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
33
|
return {
|
|
47
|
-
source
|
|
48
|
-
line: source.line,
|
|
49
|
-
column: source.column,
|
|
50
|
-
name: source.functionName,
|
|
34
|
+
source,
|
|
51
35
|
content,
|
|
36
|
+
sourceMap,
|
|
52
37
|
};
|
|
53
38
|
},
|
|
54
39
|
);
|
|
55
40
|
|
|
56
|
-
|
|
41
|
+
const info = createMemo<StackFrameSource>(() => {
|
|
42
|
+
const current = data();
|
|
43
|
+
if (!current) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const { source, content, sourceMap } = current;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if (!isCompiled() && source.line && source.column) {
|
|
50
|
+
const result = sourceMap.originalPositionFor({
|
|
51
|
+
line: source.line,
|
|
52
|
+
column: source.column,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
...result,
|
|
57
|
+
content: sourceMap.sourceContentFor(result.source),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
source: source.fileName,
|
|
63
|
+
line: source.line,
|
|
64
|
+
column: source.column,
|
|
65
|
+
name: source.functionName,
|
|
66
|
+
content,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return info;
|
|
57
71
|
}
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
margin-bottom: 2rem;
|
|
28
28
|
z-index: 10;
|
|
29
29
|
gap: 0.5rem;
|
|
30
|
+
color: rgb(17 24 39);
|
|
31
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
.dev-overlay-navbar {
|
|
@@ -87,7 +89,6 @@
|
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
.dev-overlay-page-counter {
|
|
90
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
91
92
|
font-size: 0.875rem;
|
|
92
93
|
line-height: 1.25rem;
|
|
93
94
|
font-weight: 600;
|
|
@@ -120,7 +121,6 @@
|
|
|
120
121
|
border-radius: 9999px;
|
|
121
122
|
background-color: rgb(249 250 251);
|
|
122
123
|
padding: 0.25rem 0.5rem;
|
|
123
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
124
124
|
font-size: 0.875rem;
|
|
125
125
|
line-height: 1.25rem;
|
|
126
126
|
font-weight: 600;
|
|
@@ -146,7 +146,6 @@
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
.dev-overlay-error-info {
|
|
149
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
150
149
|
display: flex;
|
|
151
150
|
flex-direction: column;
|
|
152
151
|
gap: 0.25rem;
|
|
@@ -208,7 +207,6 @@
|
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
.dev-overlay-stack-frame-function {
|
|
211
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
212
210
|
font-weight: 700;
|
|
213
211
|
}
|
|
214
212
|
|
|
@@ -245,7 +243,6 @@
|
|
|
245
243
|
.dev-overlay-stack-frames-code-source {
|
|
246
244
|
font-size: 0.875rem;
|
|
247
245
|
line-height: 1.25rem;
|
|
248
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
|
249
246
|
color: rgb(249 250 251);
|
|
250
247
|
}
|
|
251
248
|
|