@solidjs/start 2.0.0-beta.1 → 2.0.0-beta.10
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 +64 -0
- package/dist/client/StartClient.d.ts +7 -0
- package/{src/client/StartClient.tsx → dist/client/StartClient.jsx} +7 -15
- package/dist/client/index.jsx +2 -0
- package/dist/client/mount.d.ts +1 -0
- package/dist/client/mount.js +1 -0
- package/dist/client/spa/index.d.ts +4 -0
- package/dist/client/spa/index.jsx +5 -0
- package/dist/config/boundary-modules.d.ts +14 -0
- package/dist/config/boundary-modules.js +41 -0
- package/dist/config/constants.d.ts +16 -0
- package/dist/config/constants.js +16 -0
- package/dist/config/dev-server.d.ts +4 -0
- package/dist/config/dev-server.js +146 -0
- package/dist/config/env.d.ts +19 -0
- package/dist/config/env.js +85 -0
- package/dist/config/fs-router.d.ts +37 -0
- package/dist/config/fs-router.js +148 -0
- package/dist/config/fs-routes/fs-watcher.d.ts +3 -0
- package/dist/config/fs-routes/fs-watcher.js +53 -0
- package/dist/config/fs-routes/index.d.ts +7 -0
- package/dist/config/fs-routes/index.js +107 -0
- package/dist/config/fs-routes/router.d.ts +43 -0
- package/dist/config/fs-routes/router.js +146 -0
- package/dist/config/fs-routes/tree-shake.d.ts +2 -0
- package/dist/config/fs-routes/tree-shake.js +305 -0
- package/dist/config/index.d.ts +25 -0
- package/dist/config/index.js +252 -0
- package/dist/config/lazy.d.ts +3 -0
- package/dist/config/lazy.js +114 -0
- package/dist/config/manifest.d.ts +3 -0
- package/dist/config/manifest.js +109 -0
- package/dist/config/utils.d.ts +4 -0
- package/dist/config/utils.js +6 -0
- package/dist/config/vite-utils.d.ts +21 -0
- package/dist/config/vite-utils.js +85 -0
- 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 +202 -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 +66 -0
- package/{src/directives/types.ts → dist/directives/types.d.ts} +5 -7
- package/dist/directives/types.js +1 -0
- package/dist/directives/xxhash32.d.ts +6 -0
- package/dist/directives/xxhash32.js +193 -0
- package/dist/fns/client.d.ts +3 -0
- package/dist/fns/client.js +106 -0
- package/dist/fns/handler.d.ts +5 -0
- package/dist/fns/handler.js +305 -0
- package/dist/fns/registration.d.ts +3 -0
- package/dist/fns/registration.js +15 -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/fns/server.js +38 -0
- package/dist/fns/shared.d.ts +17 -0
- package/dist/fns/shared.js +105 -0
- package/dist/http/http.d.ts +81 -0
- package/dist/http/http.js +129 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +6 -0
- package/{src/index.tsx → dist/index.d.ts} +0 -2
- package/dist/index.jsx +6 -0
- package/dist/middleware/index.d.ts +39 -0
- package/dist/middleware/index.js +60 -0
- package/dist/router.d.ts +6 -0
- package/dist/router.jsx +29 -0
- package/dist/server/StartServer.d.ts +9 -0
- package/dist/server/StartServer.jsx +34 -0
- package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
- package/{src/server/assets/PatchVirtualDevStyles.tsx → dist/server/assets/PatchVirtualDevStyles.jsx} +7 -10
- package/dist/server/assets/index.d.ts +2 -0
- package/dist/server/assets/index.js +52 -0
- package/dist/server/assets/render.d.ts +19 -0
- package/dist/server/assets/render.jsx +14 -0
- package/dist/server/collect-styles.d.ts +3 -0
- package/dist/server/collect-styles.js +57 -0
- package/dist/server/fetchEvent.d.ts +7 -0
- package/dist/server/fetchEvent.js +26 -0
- package/dist/server/handler.d.ts +6 -0
- package/dist/server/handler.js +218 -0
- package/dist/server/index.d.ts +9 -0
- package/{src/server/index.tsx → dist/server/index.jsx} +4 -19
- package/dist/server/manifest/client-manifest.d.ts +9 -0
- package/dist/server/manifest/client-manifest.js +6 -0
- package/dist/server/manifest/dev-client-manifest.d.ts +4 -0
- package/dist/server/manifest/dev-client-manifest.js +24 -0
- package/dist/server/manifest/dev-ssr-manifest.d.ts +5 -0
- package/dist/server/manifest/dev-ssr-manifest.js +23 -0
- package/dist/server/manifest/prod-client-manifest.d.ts +5 -0
- package/dist/server/manifest/prod-client-manifest.js +26 -0
- package/dist/server/manifest/prod-ssr-manifest.d.ts +6 -0
- package/dist/server/manifest/prod-ssr-manifest.js +85 -0
- package/dist/server/manifest/ssr-manifest.d.ts +4 -0
- package/dist/server/manifest/ssr-manifest.js +6 -0
- package/dist/server/routes.d.ts +23 -0
- package/dist/server/routes.js +74 -0
- package/dist/server/spa/StartServer.d.ts +9 -0
- package/dist/server/spa/StartServer.jsx +25 -0
- package/dist/server/spa/handler.d.ts +8 -0
- package/dist/server/spa/handler.js +20 -0
- package/{src/server/spa/index.tsx → dist/server/spa/index.d.ts} +0 -1
- package/dist/server/spa/index.jsx +5 -0
- package/dist/server/types.d.ts +75 -0
- package/dist/server/types.js +1 -0
- package/dist/server/util.d.ts +2 -0
- package/dist/server/util.js +8 -0
- package/dist/server/web-stream.d.ts +9 -0
- package/dist/server/web-stream.js +26 -0
- package/dist/shared/ErrorBoundary.d.ts +3 -0
- package/dist/shared/ErrorBoundary.jsx +36 -0
- package/dist/shared/GET.d.ts +5 -0
- package/dist/shared/GET.js +8 -0
- package/dist/shared/HttpHeader.d.ts +10 -0
- package/dist/shared/HttpHeader.jsx +38 -0
- package/dist/shared/HttpStatusCode.d.ts +9 -0
- package/dist/shared/HttpStatusCode.js +18 -0
- package/dist/shared/clientOnly.d.ts +12 -0
- package/dist/shared/clientOnly.js +27 -0
- package/dist/shared/dev-overlay/CodeView.d.ts +7 -0
- package/dist/shared/dev-overlay/CodeView.jsx +62 -0
- package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +9 -0
- package/dist/shared/dev-overlay/DevOverlayDialog.jsx +226 -0
- package/dist/shared/dev-overlay/createStackFrame.d.ts +9 -0
- package/dist/shared/dev-overlay/createStackFrame.js +56 -0
- package/dist/shared/dev-overlay/download.d.ts +1 -0
- package/dist/shared/dev-overlay/download.js +6 -0
- package/dist/shared/dev-overlay/get-source-map.d.ts +2 -0
- package/dist/shared/dev-overlay/get-source-map.js +25 -0
- package/dist/shared/dev-overlay/icons.d.ts +28 -0
- package/dist/shared/dev-overlay/icons.jsx +150 -0
- package/dist/shared/dev-overlay/index.d.ts +5 -0
- package/dist/shared/dev-overlay/index.jsx +39 -0
- package/dist/shared/lazy.d.ts +3 -0
- package/dist/shared/lazy.js +42 -0
- package/dist/shared/serverFunction.d.ts +6 -0
- package/dist/shared/serverFunction.js +8 -0
- package/dist/utils/debounce.d.ts +4 -0
- package/dist/utils/debounce.js +10 -0
- package/env.d.ts +12 -0
- package/package.json +10 -5
- package/scripts/build.js +0 -15
- package/scripts/validate-imports.js +0 -316
- package/src/client/mount.ts +0 -1
- package/src/client/spa/index.tsx +0 -9
- package/src/config/constants.ts +0 -19
- package/src/config/dev-server.ts +0 -161
- package/src/config/env.ts +0 -105
- package/src/config/fs-router.ts +0 -162
- package/src/config/fs-routes/fs-watcher.ts +0 -66
- package/src/config/fs-routes/index.ts +0 -136
- package/src/config/fs-routes/router.ts +0 -184
- package/src/config/fs-routes/tree-shake.ts +0 -324
- package/src/config/index.ts +0 -239
- package/src/config/lazy.ts +0 -132
- package/src/config/manifest.ts +0 -120
- package/src/config/utils.ts +0 -5
- package/src/config/vite-utils.ts +0 -113
- package/src/directives/bubble-function-declaration.ts +0 -33
- package/src/directives/compile.ts +0 -54
- package/src/directives/generate-unique-name.ts +0 -22
- package/src/directives/get-descriptive-name.ts +0 -39
- package/src/directives/get-import-identifier.ts +0 -34
- package/src/directives/get-root-statement-path.ts +0 -14
- package/src/directives/index.ts +0 -233
- package/src/directives/is-statement-top-level.ts +0 -13
- package/src/directives/paths.ts +0 -63
- package/src/directives/plugin.ts +0 -389
- package/src/directives/remove-unused-variables.ts +0 -70
- package/src/directives/xxhash32.ts +0 -214
- package/src/env.d.ts +0 -17
- package/src/fns/client.ts +0 -141
- package/src/fns/handler.spec.ts +0 -85
- package/src/fns/handler.ts +0 -287
- package/src/fns/registration.ts +0 -19
- package/src/fns/serialization.ts +0 -250
- package/src/fns/server.ts +0 -46
- package/src/fns/shared.ts +0 -116
- package/src/http/index.ts +0 -216
- package/src/internal.d.ts +0 -14
- package/src/middleware/index.ts +0 -92
- package/src/router.tsx +0 -37
- package/src/server/StartServer.tsx +0 -58
- package/src/server/assets/index.ts +0 -70
- package/src/server/assets/render.tsx +0 -46
- package/src/server/collect-styles.ts +0 -70
- package/src/server/fetchEvent.spec.ts +0 -85
- package/src/server/fetchEvent.ts +0 -36
- package/src/server/handler.ts +0 -261
- package/src/server/manifest/client-manifest.ts +0 -8
- package/src/server/manifest/dev-client-manifest.ts +0 -21
- package/src/server/manifest/dev-ssr-manifest.ts +0 -23
- package/src/server/manifest/prod-client-manifest.ts +0 -21
- package/src/server/manifest/prod-ssr-manifest.ts +0 -109
- package/src/server/manifest/ssr-manifest.ts +0 -10
- package/src/server/routes.ts +0 -126
- package/src/server/spa/StartServer.tsx +0 -42
- package/src/server/spa/handler.ts +0 -29
- package/src/server/types.ts +0 -82
- package/src/server/util.ts +0 -12
- package/src/shared/ErrorBoundary.tsx +0 -52
- package/src/shared/GET.ts +0 -8
- package/src/shared/HttpHeader.tsx +0 -42
- package/src/shared/HttpStatusCode.ts +0 -27
- package/src/shared/clientOnly.ts +0 -44
- package/src/shared/dev-overlay/CodeView.tsx +0 -90
- package/src/shared/dev-overlay/DevOverlayDialog.tsx +0 -316
- package/src/shared/dev-overlay/createStackFrame.ts +0 -74
- package/src/shared/dev-overlay/download.ts +0 -6
- package/src/shared/dev-overlay/env.d.ts +0 -4
- package/src/shared/dev-overlay/get-source-map.ts +0 -33
- package/src/shared/dev-overlay/icons.tsx +0 -456
- package/src/shared/dev-overlay/index.tsx +0 -63
- package/src/shared/lazy.ts +0 -52
- package/src/shared/serverFunction.ts +0 -10
- package/src/utils/debounce.ts +0 -10
- package/src/virtual.d.ts +0 -27
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -9
- /package/{src/client/index.tsx → dist/client/index.d.ts} +0 -0
- /package/{src → dist}/shared/dev-overlay/styles.css +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { join } from "pathe";
|
|
10
|
+
export function getClientDevManifest() {
|
|
11
|
+
return {
|
|
12
|
+
import(id) {
|
|
13
|
+
return import(__rewriteRelativeImportExtension(/* @vite-ignore */ join("/", id), true));
|
|
14
|
+
},
|
|
15
|
+
async getAssets(id) {
|
|
16
|
+
const assetsPath = `/@manifest/client/${Date.now()}/assets?id=${id}`;
|
|
17
|
+
const assets = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ assetsPath, true))).default;
|
|
18
|
+
return await Promise.all(assets.map(async (v) => ({
|
|
19
|
+
...v,
|
|
20
|
+
children: await v.children(),
|
|
21
|
+
})));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { join, normalize } from "pathe";
|
|
10
|
+
export function getSsrDevManifest(environment) {
|
|
11
|
+
return {
|
|
12
|
+
path: (id) => normalize(join(import.meta.env.BASE_URL, id)),
|
|
13
|
+
async getAssets(id) {
|
|
14
|
+
const assetsPath = `/@manifest/${environment}/${Date.now()}/assets?id=${id}`;
|
|
15
|
+
const assets = (await import(__rewriteRelativeImportExtension(/* @vite-ignore */ assetsPath, true))).default;
|
|
16
|
+
return await Promise.all(assets.map(async (v) => ({
|
|
17
|
+
...v,
|
|
18
|
+
children: await v.children(),
|
|
19
|
+
})));
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { getSsrDevManifest as getSsrManifest };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
export function getClientProdManifest() {
|
|
10
|
+
return {
|
|
11
|
+
import(id) {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
return import(__rewriteRelativeImportExtension(/* @vite-ignore */ window.manifest[id].output, true));
|
|
14
|
+
},
|
|
15
|
+
async getAssets(id) {
|
|
16
|
+
if (id.startsWith("./"))
|
|
17
|
+
id = id.slice(2);
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
return window.manifest[id]?.assets ?? [];
|
|
20
|
+
},
|
|
21
|
+
async json() {
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
return window.manifest;
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { clientViteManifest } from "solid-start:client-vite-manifest";
|
|
2
|
+
import { join } from "pathe";
|
|
3
|
+
// Only reads from client manifest atm, might need server support for islands
|
|
4
|
+
export function getSsrProdManifest() {
|
|
5
|
+
const viteManifest = clientViteManifest;
|
|
6
|
+
return {
|
|
7
|
+
path(id) {
|
|
8
|
+
if (id.startsWith("./"))
|
|
9
|
+
id = id.slice(2);
|
|
10
|
+
const viteManifestEntry = clientViteManifest[id /*import.meta.env.START_CLIENT_ENTRY*/];
|
|
11
|
+
if (!viteManifestEntry)
|
|
12
|
+
throw new Error(`No entry found in vite manifest for '${id}'`);
|
|
13
|
+
return join("/", viteManifestEntry.file);
|
|
14
|
+
},
|
|
15
|
+
async getAssets(id) {
|
|
16
|
+
if (id.startsWith("./"))
|
|
17
|
+
id = id.slice(2);
|
|
18
|
+
return createHtmlTagsForAssets(findAssetsInViteManifest(clientViteManifest, id));
|
|
19
|
+
},
|
|
20
|
+
async json() {
|
|
21
|
+
const json = {};
|
|
22
|
+
const entryKeys = Object.keys(viteManifest)
|
|
23
|
+
.filter(id => viteManifest[id]?.isEntry || viteManifest[id]?.isDynamicEntry)
|
|
24
|
+
.map(id => id);
|
|
25
|
+
for (const entryKey of entryKeys) {
|
|
26
|
+
json[entryKey] = {
|
|
27
|
+
output: join("/", viteManifest[entryKey].file),
|
|
28
|
+
assets: await this.getAssets(entryKey),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return json;
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createHtmlTagsForAssets(assets) {
|
|
36
|
+
return assets
|
|
37
|
+
.filter(asset => asset.endsWith(".css") ||
|
|
38
|
+
asset.endsWith(".js") ||
|
|
39
|
+
asset.endsWith(".ts") ||
|
|
40
|
+
asset.endsWith(".mjs"))
|
|
41
|
+
.map(asset => ({
|
|
42
|
+
tag: "link",
|
|
43
|
+
attrs: {
|
|
44
|
+
href: "/" + asset,
|
|
45
|
+
key: asset,
|
|
46
|
+
...(asset.endsWith(".css") ? { rel: "stylesheet" } : { rel: "modulepreload" }),
|
|
47
|
+
},
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const entryId = import.meta.env.START_CLIENT_ENTRY.slice(2);
|
|
51
|
+
let entryImports = undefined;
|
|
52
|
+
function findAssetsInViteManifest(manifest, id, assetMap = new Map(), stack = []) {
|
|
53
|
+
if (stack.includes(id)) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
const cached = assetMap.get(id);
|
|
57
|
+
if (cached) {
|
|
58
|
+
return cached;
|
|
59
|
+
}
|
|
60
|
+
const chunk = manifest[id];
|
|
61
|
+
if (!chunk) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
if (!entryImports) {
|
|
65
|
+
entryImports = [entryId, ...(manifest[entryId]?.imports ?? [])];
|
|
66
|
+
}
|
|
67
|
+
// Only include entry imports, if we are specifically crawling the entry
|
|
68
|
+
// Chunks (e.g. routes) that import something from entry, should not render entry css redundantly
|
|
69
|
+
const excludeEntryImports = id !== entryId;
|
|
70
|
+
const assets = chunk.css?.filter(Boolean) || [];
|
|
71
|
+
if (chunk.imports) {
|
|
72
|
+
stack.push(id);
|
|
73
|
+
for (let i = 0, l = chunk.imports.length; i < l; i++) {
|
|
74
|
+
const importId = chunk.imports[i];
|
|
75
|
+
if (!importId || (excludeEntryImports && entryImports.includes(importId)))
|
|
76
|
+
continue;
|
|
77
|
+
assets.push(...findAssetsInViteManifest(manifest, importId, assetMap, stack));
|
|
78
|
+
}
|
|
79
|
+
stack.pop();
|
|
80
|
+
}
|
|
81
|
+
assets.push(chunk.file);
|
|
82
|
+
const all = Array.from(new Set(assets));
|
|
83
|
+
assetMap.set(id, all);
|
|
84
|
+
return all;
|
|
85
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { getSsrDevManifest } from "./dev-ssr-manifest.ts";
|
|
2
|
+
import { getSsrProdManifest } from "./prod-ssr-manifest.ts";
|
|
3
|
+
export declare function getSsrManifest(target: "client" | "ssr"): ReturnType<typeof getSsrDevManifest> | ReturnType<typeof getSsrProdManifest>;
|
|
4
|
+
export { getSsrManifest as getManifest };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { getSsrDevManifest } from "./dev-ssr-manifest.js";
|
|
2
|
+
import { getSsrProdManifest } from "./prod-ssr-manifest.js";
|
|
3
|
+
export function getSsrManifest(target) {
|
|
4
|
+
return import.meta.env.DEV ? getSsrDevManifest(target) : getSsrProdManifest();
|
|
5
|
+
}
|
|
6
|
+
export { getSsrManifest as getManifest };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FetchEvent } from "./types.ts";
|
|
2
|
+
interface Route {
|
|
3
|
+
path: string;
|
|
4
|
+
id: string;
|
|
5
|
+
children?: Route[];
|
|
6
|
+
page?: boolean;
|
|
7
|
+
$component?: any;
|
|
8
|
+
$HEAD?: any;
|
|
9
|
+
$GET?: any;
|
|
10
|
+
$POST?: any;
|
|
11
|
+
$PUT?: any;
|
|
12
|
+
$PATCH?: any;
|
|
13
|
+
$DELETE?: any;
|
|
14
|
+
}
|
|
15
|
+
export declare const pageRoutes: Route[];
|
|
16
|
+
export declare function matchAPIRoute(path: string, method: string): {
|
|
17
|
+
params?: Record<string, any>;
|
|
18
|
+
handler: {
|
|
19
|
+
import: () => Promise<Record<string, (e: FetchEvent) => Promise<any>>>;
|
|
20
|
+
};
|
|
21
|
+
isPage: boolean;
|
|
22
|
+
} | undefined;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @ts-expect-error
|
|
2
|
+
import fileRoutes from "solid-start:routes";
|
|
3
|
+
import { createRouter } from "radix3";
|
|
4
|
+
export const pageRoutes = defineRoutes(fileRoutes.filter(o => o.page));
|
|
5
|
+
function defineRoutes(fileRoutes) {
|
|
6
|
+
function processRoute(routes, route, id, full) {
|
|
7
|
+
const parentRoute = Object.values(routes).find(o => {
|
|
8
|
+
return id.startsWith(o.id + "/");
|
|
9
|
+
});
|
|
10
|
+
if (!parentRoute) {
|
|
11
|
+
routes.push({
|
|
12
|
+
...route,
|
|
13
|
+
id,
|
|
14
|
+
path: id.replace(/\([^)/]+\)/g, "").replace(/\/+/g, "/"),
|
|
15
|
+
});
|
|
16
|
+
return routes;
|
|
17
|
+
}
|
|
18
|
+
processRoute(parentRoute.children || (parentRoute.children = []), route, id.slice(parentRoute.id.length), full);
|
|
19
|
+
return routes;
|
|
20
|
+
}
|
|
21
|
+
return fileRoutes
|
|
22
|
+
.sort((a, b) => a.path.length - b.path.length)
|
|
23
|
+
.reduce((prevRoutes, route) => {
|
|
24
|
+
return processRoute(prevRoutes, route, route.path, route.path);
|
|
25
|
+
}, []);
|
|
26
|
+
}
|
|
27
|
+
const router = createRouter({
|
|
28
|
+
routes: fileRoutes.reduce((memo, route) => {
|
|
29
|
+
if (!containsHTTP(route))
|
|
30
|
+
return memo;
|
|
31
|
+
const path = route.path
|
|
32
|
+
.replace(/\([^)/]+\)/g, "")
|
|
33
|
+
.replace(/\/+/g, "/")
|
|
34
|
+
.replace(/\*([^/]*)/g, (_, m) => `**:${m}`)
|
|
35
|
+
.split("/")
|
|
36
|
+
.map(s => (s.startsWith(":") || s.startsWith("*") ? s : encodeURIComponent(s)))
|
|
37
|
+
.join("/");
|
|
38
|
+
if (/:[^/]*\?/g.test(path)) {
|
|
39
|
+
throw new Error(`Optional parameters are not supported in API routes: ${path}`);
|
|
40
|
+
}
|
|
41
|
+
if (memo[path]) {
|
|
42
|
+
throw new Error(`Duplicate API routes for "${path}" found at "${memo[path].route.path}" and "${route.path}"`);
|
|
43
|
+
}
|
|
44
|
+
memo[path] = { route };
|
|
45
|
+
return memo;
|
|
46
|
+
}, {}),
|
|
47
|
+
});
|
|
48
|
+
function containsHTTP(route) {
|
|
49
|
+
return (route["$HEAD"] ||
|
|
50
|
+
route["$GET"] ||
|
|
51
|
+
route["$POST"] ||
|
|
52
|
+
route["$PUT"] ||
|
|
53
|
+
route["$PATCH"] ||
|
|
54
|
+
route["$DELETE"]);
|
|
55
|
+
}
|
|
56
|
+
export function matchAPIRoute(path, method) {
|
|
57
|
+
const match = router.lookup(path);
|
|
58
|
+
if (match && match.route) {
|
|
59
|
+
const route = match.route;
|
|
60
|
+
// Find the appropriate handler for the HTTP method
|
|
61
|
+
const handler = method === "HEAD" ? route.$HEAD || route.$GET : route[`$${method}`];
|
|
62
|
+
if (handler === undefined)
|
|
63
|
+
return;
|
|
64
|
+
// Check if this is a page route
|
|
65
|
+
const isPage = route.page === true && route.$component !== undefined;
|
|
66
|
+
// Return comprehensive route information
|
|
67
|
+
return {
|
|
68
|
+
handler,
|
|
69
|
+
params: match.params,
|
|
70
|
+
isPage,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Component } from "solid-js";
|
|
2
|
+
import type { DocumentComponentProps } from "../types.ts";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
|
|
6
|
+
*/
|
|
7
|
+
export declare function StartServer(props: {
|
|
8
|
+
document: Component<DocumentComponentProps>;
|
|
9
|
+
}): import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { NoHydration, getRequestEvent, ssr } from "solid-js/web";
|
|
2
|
+
import { getSsrManifest } from "../manifest/ssr-manifest.js";
|
|
3
|
+
import { TopErrorBoundary } from "../../shared/ErrorBoundary.jsx";
|
|
4
|
+
import { useAssets } from "../assets/index.js";
|
|
5
|
+
import PatchVirtualDevStyles from "../assets/PatchVirtualDevStyles.jsx";
|
|
6
|
+
const docType = ssr("<!DOCTYPE html>");
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/start-server
|
|
10
|
+
*/
|
|
11
|
+
export function StartServer(props) {
|
|
12
|
+
const context = getRequestEvent();
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const nonce = context.nonce;
|
|
15
|
+
useAssets(context.assets, nonce);
|
|
16
|
+
return (<NoHydration>
|
|
17
|
+
{docType}
|
|
18
|
+
<TopErrorBoundary>
|
|
19
|
+
<props.document scripts={<>
|
|
20
|
+
<PatchVirtualDevStyles nonce={nonce}/>
|
|
21
|
+
<script type="module" src={getSsrManifest("client").path(import.meta.env.START_CLIENT_ENTRY_URL)}/>
|
|
22
|
+
</>}/>
|
|
23
|
+
</TopErrorBoundary>
|
|
24
|
+
</NoHydration>);
|
|
25
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { H3 } from "h3/generic";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { HandlerOptions, PageEvent } from "../types.ts";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
7
|
+
*/
|
|
8
|
+
export declare function createHandler(fn: (context: PageEvent) => JSX.Element, options?: HandlerOptions | ((context: PageEvent) => HandlerOptions)): H3;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createBaseHandler } from "../handler.js";
|
|
2
|
+
import { getSsrManifest } from "../manifest/ssr-manifest.js";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
|
|
6
|
+
*/
|
|
7
|
+
export function createHandler(fn, options) {
|
|
8
|
+
return createBaseHandler(createPageEvent, fn, options);
|
|
9
|
+
}
|
|
10
|
+
async function createPageEvent(ctx) {
|
|
11
|
+
const manifest = getSsrManifest("ssr");
|
|
12
|
+
const pageEvent = Object.assign(ctx, {
|
|
13
|
+
manifest: "json" in manifest ? await manifest.json() : {},
|
|
14
|
+
assets: await manifest.getAssets(import.meta.env.START_CLIENT_ENTRY),
|
|
15
|
+
routes: [],
|
|
16
|
+
complete: false,
|
|
17
|
+
$islands: new Set(),
|
|
18
|
+
});
|
|
19
|
+
return pageEvent;
|
|
20
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { H3Event } from "h3";
|
|
2
|
+
import type { JSX } from "solid-js";
|
|
3
|
+
import type { RequestEvent } from "solid-js/web";
|
|
4
|
+
export type DocumentComponentProps = {
|
|
5
|
+
assets?: JSX.Element;
|
|
6
|
+
scripts: JSX.Element;
|
|
7
|
+
children?: JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export type Asset = {
|
|
10
|
+
tag: "style";
|
|
11
|
+
attrs: JSX.StyleHTMLAttributes<HTMLStyleElement> & {
|
|
12
|
+
key?: string;
|
|
13
|
+
};
|
|
14
|
+
children?: JSX.Element;
|
|
15
|
+
} | {
|
|
16
|
+
tag: "script";
|
|
17
|
+
attrs: JSX.ScriptHTMLAttributes<HTMLScriptElement> & {
|
|
18
|
+
key?: string;
|
|
19
|
+
};
|
|
20
|
+
} | {
|
|
21
|
+
tag: "link";
|
|
22
|
+
attrs: JSX.LinkHTMLAttributes<HTMLLinkElement> & {
|
|
23
|
+
key?: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export type HandlerOptions = {
|
|
27
|
+
mode?: "sync" | "async" | "stream";
|
|
28
|
+
nonce?: string;
|
|
29
|
+
renderId?: string;
|
|
30
|
+
onCompleteAll?: (options: {
|
|
31
|
+
write: (v: any) => void;
|
|
32
|
+
}) => void;
|
|
33
|
+
onCompleteShell?: (options: {
|
|
34
|
+
write: (v: any) => void;
|
|
35
|
+
}) => void;
|
|
36
|
+
};
|
|
37
|
+
export type ContextMatches = {
|
|
38
|
+
originalPath: string;
|
|
39
|
+
pattern: string;
|
|
40
|
+
path: string;
|
|
41
|
+
params: unknown;
|
|
42
|
+
};
|
|
43
|
+
export interface ResponseStub {
|
|
44
|
+
status?: number;
|
|
45
|
+
statusText?: string;
|
|
46
|
+
headers: Headers;
|
|
47
|
+
}
|
|
48
|
+
export interface FetchEvent {
|
|
49
|
+
request: Request;
|
|
50
|
+
response: ResponseStub;
|
|
51
|
+
clientAddress?: string;
|
|
52
|
+
locals: App.RequestEventLocals;
|
|
53
|
+
nativeEvent: H3Event;
|
|
54
|
+
}
|
|
55
|
+
export interface PageEvent extends RequestEvent {
|
|
56
|
+
assets: any[];
|
|
57
|
+
routes: any[];
|
|
58
|
+
$islands: Set<string>;
|
|
59
|
+
complete: boolean;
|
|
60
|
+
nonce?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface APIEvent extends FetchEvent {
|
|
63
|
+
params: {
|
|
64
|
+
[key: string]: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export type APIHandler = (event: APIEvent) => any;
|
|
68
|
+
export interface ServerFunctionMeta {
|
|
69
|
+
id: string;
|
|
70
|
+
}
|
|
71
|
+
declare module "solid-js/web" {
|
|
72
|
+
interface RequestEvent extends FetchEvent {
|
|
73
|
+
serverOnly?: boolean;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#redirection_messages
|
|
2
|
+
const validRedirectStatuses = new Set([301, 302, 303, 307, 308]);
|
|
3
|
+
export function getExpectedRedirectStatus(response) {
|
|
4
|
+
if (response.status && validRedirectStatuses.has(response.status)) {
|
|
5
|
+
return response.status;
|
|
6
|
+
}
|
|
7
|
+
return 302;
|
|
8
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @refresh skip
|
|
2
|
+
import { ErrorBoundary as DefaultErrorBoundary, catchError } from "solid-js";
|
|
3
|
+
import { isServer } from "solid-js/web";
|
|
4
|
+
import { HttpStatusCode } from "./HttpStatusCode.js";
|
|
5
|
+
import { DevOverlay } from "./dev-overlay/index.jsx";
|
|
6
|
+
export const ErrorBoundary = import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY
|
|
7
|
+
? (props) => <DevOverlay>{props.children}</DevOverlay>
|
|
8
|
+
: (props) => {
|
|
9
|
+
const message = isServer
|
|
10
|
+
? "500 | Internal Server Error"
|
|
11
|
+
: "Error | Uncaught Client Exception";
|
|
12
|
+
return (<DefaultErrorBoundary fallback={error => {
|
|
13
|
+
console.error(error);
|
|
14
|
+
return (<>
|
|
15
|
+
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">
|
|
16
|
+
{message}
|
|
17
|
+
</span>
|
|
18
|
+
<HttpStatusCode code={500}/>
|
|
19
|
+
</>);
|
|
20
|
+
}}>
|
|
21
|
+
{props.children}
|
|
22
|
+
</DefaultErrorBoundary>);
|
|
23
|
+
};
|
|
24
|
+
export const TopErrorBoundary = (props) => {
|
|
25
|
+
let isError = false;
|
|
26
|
+
const res = catchError(() => props.children, err => {
|
|
27
|
+
console.error(err);
|
|
28
|
+
isError = !!err;
|
|
29
|
+
});
|
|
30
|
+
return isError ? (<>
|
|
31
|
+
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">
|
|
32
|
+
500 | Internal Server Error
|
|
33
|
+
</span>
|
|
34
|
+
<HttpStatusCode code={500}/>
|
|
35
|
+
</>) : (res);
|
|
36
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @refresh skip
|
|
2
|
+
import { onCleanup } from "solid-js";
|
|
3
|
+
import { getRequestEvent, isServer } from "solid-js/web";
|
|
4
|
+
import { appendHeader, setHeader } from "../http/http.js";
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/http-header
|
|
8
|
+
*/
|
|
9
|
+
export const HttpHeader = isServer
|
|
10
|
+
? (props) => {
|
|
11
|
+
const event = getRequestEvent();
|
|
12
|
+
if (props.append)
|
|
13
|
+
appendHeader(props.name, props.value);
|
|
14
|
+
else
|
|
15
|
+
setHeader(props.name, props.value);
|
|
16
|
+
onCleanup(() => {
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
if (event.nativeEvent.handled || event.complete)
|
|
19
|
+
return;
|
|
20
|
+
const value = event.response.headers.get(props.name);
|
|
21
|
+
if (!value)
|
|
22
|
+
return;
|
|
23
|
+
if (!value.includes(", ")) {
|
|
24
|
+
if (value === props.value)
|
|
25
|
+
event.response.headers.delete(props.name);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const values = value.split(", ");
|
|
29
|
+
const index = values.indexOf(props.value);
|
|
30
|
+
index !== -1 && values.splice(index, 1);
|
|
31
|
+
if (values.length)
|
|
32
|
+
event.response.headers.set(props.name, values.join(","));
|
|
33
|
+
else
|
|
34
|
+
event.response.headers.delete(props.name);
|
|
35
|
+
});
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
: (_props) => null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @refresh skip
|
|
2
|
+
import { onCleanup } from "solid-js";
|
|
3
|
+
import { getRequestEvent, isServer } from "solid-js/web";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/server/http-status-code
|
|
7
|
+
*/
|
|
8
|
+
export const HttpStatusCode = isServer
|
|
9
|
+
? (props) => {
|
|
10
|
+
const event = getRequestEvent();
|
|
11
|
+
event.response.status = props.code;
|
|
12
|
+
event.response.statusText = props.text;
|
|
13
|
+
onCleanup(() =>
|
|
14
|
+
// !event.nativeEvent.handled &&
|
|
15
|
+
!event.complete && (event.response.status = 200));
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
: (_props) => null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Component, ComponentProps, JSX } from "solid-js";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Read more: https://docs.solidjs.com/solid-start/reference/client/client-only
|
|
5
|
+
*/
|
|
6
|
+
export default function clientOnly<T extends Component<any>>(fn: () => Promise<{
|
|
7
|
+
default: T;
|
|
8
|
+
}>, options?: {
|
|
9
|
+
lazy?: boolean;
|
|
10
|
+
}): (props: ComponentProps<T> & {
|
|
11
|
+
fallback?: JSX.Element;
|
|
12
|
+
}) => any;
|