@solidjs/start 0.4.3 → 0.4.4
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
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,
|
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
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
|
}
|