@solidjs/start 2.0.0-beta.1 → 2.0.0-beta.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.
Files changed (231) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/client/StartClient.d.ts +7 -0
  3. package/{src/client/StartClient.tsx → dist/client/StartClient.jsx} +7 -15
  4. package/dist/client/index.jsx +2 -0
  5. package/dist/client/mount.d.ts +1 -0
  6. package/dist/client/mount.js +1 -0
  7. package/dist/client/spa/index.d.ts +4 -0
  8. package/dist/client/spa/index.jsx +5 -0
  9. package/dist/config/constants.d.ts +16 -0
  10. package/dist/config/constants.js +16 -0
  11. package/dist/config/dev-server.d.ts +2 -0
  12. package/dist/config/dev-server.js +128 -0
  13. package/dist/config/env.d.ts +19 -0
  14. package/dist/config/env.js +81 -0
  15. package/dist/config/fs-router.d.ts +37 -0
  16. package/dist/config/fs-router.js +141 -0
  17. package/dist/config/fs-routes/fs-watcher.d.ts +3 -0
  18. package/dist/config/fs-routes/fs-watcher.js +53 -0
  19. package/dist/config/fs-routes/index.d.ts +7 -0
  20. package/dist/config/fs-routes/index.js +107 -0
  21. package/dist/config/fs-routes/router.d.ts +42 -0
  22. package/dist/config/fs-routes/router.js +148 -0
  23. package/dist/config/fs-routes/tree-shake.d.ts +2 -0
  24. package/dist/config/fs-routes/tree-shake.js +305 -0
  25. package/dist/config/index.d.ts +25 -0
  26. package/dist/config/index.js +224 -0
  27. package/dist/config/lazy.d.ts +3 -0
  28. package/dist/config/lazy.js +114 -0
  29. package/dist/config/manifest.d.ts +3 -0
  30. package/dist/config/manifest.js +109 -0
  31. package/dist/config/utils.d.ts +4 -0
  32. package/dist/config/utils.js +6 -0
  33. package/dist/config/vite-utils.d.ts +21 -0
  34. package/dist/config/vite-utils.js +85 -0
  35. package/dist/directives/bubble-function-declaration.d.ts +3 -0
  36. package/dist/directives/bubble-function-declaration.js +23 -0
  37. package/dist/directives/compile.d.ts +9 -0
  38. package/dist/directives/compile.js +40 -0
  39. package/dist/directives/generate-unique-name.d.ts +3 -0
  40. package/dist/directives/generate-unique-name.js +16 -0
  41. package/dist/directives/get-descriptive-name.d.ts +2 -0
  42. package/dist/directives/get-descriptive-name.js +37 -0
  43. package/dist/directives/get-import-identifier.d.ts +4 -0
  44. package/dist/directives/get-import-identifier.js +19 -0
  45. package/dist/directives/get-root-statement-path.d.ts +2 -0
  46. package/dist/directives/get-root-statement-path.js +12 -0
  47. package/dist/directives/index.d.ts +14 -0
  48. package/dist/directives/index.js +170 -0
  49. package/dist/directives/is-statement-top-level.d.ts +3 -0
  50. package/dist/directives/is-statement-top-level.js +9 -0
  51. package/dist/directives/paths.d.ts +9 -0
  52. package/dist/directives/paths.js +36 -0
  53. package/dist/directives/plugin.d.ts +21 -0
  54. package/dist/directives/plugin.js +302 -0
  55. package/dist/directives/remove-unused-variables.d.ts +3 -0
  56. package/dist/directives/remove-unused-variables.js +66 -0
  57. package/{src/directives/types.ts → dist/directives/types.d.ts} +5 -7
  58. package/dist/directives/types.js +1 -0
  59. package/dist/directives/xxhash32.d.ts +6 -0
  60. package/dist/directives/xxhash32.js +193 -0
  61. package/dist/fns/client.d.ts +3 -0
  62. package/dist/fns/client.js +106 -0
  63. package/dist/fns/handler.d.ts +5 -0
  64. package/dist/fns/handler.js +269 -0
  65. package/dist/fns/registration.d.ts +2 -0
  66. package/dist/fns/registration.js +12 -0
  67. package/dist/fns/serialization.d.ts +6 -0
  68. package/dist/fns/serialization.js +208 -0
  69. package/dist/fns/server.d.ts +7 -0
  70. package/dist/fns/server.js +38 -0
  71. package/dist/fns/shared.d.ts +17 -0
  72. package/dist/fns/shared.js +105 -0
  73. package/dist/http/index.d.ts +81 -0
  74. package/dist/http/index.js +129 -0
  75. package/{src/index.tsx → dist/index.d.ts} +0 -2
  76. package/dist/index.jsx +6 -0
  77. package/dist/middleware/index.d.ts +38 -0
  78. package/dist/middleware/index.js +59 -0
  79. package/dist/router.d.ts +6 -0
  80. package/dist/router.jsx +29 -0
  81. package/dist/server/StartServer.d.ts +9 -0
  82. package/dist/server/StartServer.jsx +34 -0
  83. package/dist/server/assets/PatchVirtualDevStyles.d.ts +4 -0
  84. package/{src/server/assets/PatchVirtualDevStyles.tsx → dist/server/assets/PatchVirtualDevStyles.jsx} +7 -10
  85. package/dist/server/assets/index.d.ts +2 -0
  86. package/dist/server/assets/index.js +52 -0
  87. package/dist/server/assets/render.d.ts +19 -0
  88. package/dist/server/assets/render.jsx +14 -0
  89. package/dist/server/collect-styles.d.ts +3 -0
  90. package/dist/server/collect-styles.js +57 -0
  91. package/dist/server/fetchEvent.d.ts +7 -0
  92. package/dist/server/fetchEvent.js +26 -0
  93. package/dist/server/handler.d.ts +64 -0
  94. package/dist/server/handler.js +222 -0
  95. package/dist/server/index.d.ts +9 -0
  96. package/{src/server/index.tsx → dist/server/index.jsx} +4 -19
  97. package/dist/server/manifest/client-manifest.d.ts +9 -0
  98. package/dist/server/manifest/client-manifest.js +6 -0
  99. package/dist/server/manifest/dev-client-manifest.d.ts +4 -0
  100. package/dist/server/manifest/dev-client-manifest.js +24 -0
  101. package/dist/server/manifest/dev-ssr-manifest.d.ts +5 -0
  102. package/dist/server/manifest/dev-ssr-manifest.js +23 -0
  103. package/dist/server/manifest/prod-client-manifest.d.ts +5 -0
  104. package/dist/server/manifest/prod-client-manifest.js +26 -0
  105. package/dist/server/manifest/prod-ssr-manifest.d.ts +6 -0
  106. package/dist/server/manifest/prod-ssr-manifest.js +85 -0
  107. package/dist/server/manifest/ssr-manifest.d.ts +4 -0
  108. package/dist/server/manifest/ssr-manifest.js +6 -0
  109. package/dist/server/routes.d.ts +23 -0
  110. package/dist/server/routes.js +74 -0
  111. package/dist/server/spa/StartServer.d.ts +9 -0
  112. package/dist/server/spa/StartServer.jsx +25 -0
  113. package/dist/server/spa/handler.d.ts +36 -0
  114. package/dist/server/spa/handler.js +20 -0
  115. package/{src/server/spa/index.tsx → dist/server/spa/index.d.ts} +0 -1
  116. package/dist/server/spa/index.jsx +5 -0
  117. package/dist/server/types.d.ts +75 -0
  118. package/dist/server/types.js +1 -0
  119. package/dist/server/util.d.ts +2 -0
  120. package/dist/server/util.js +8 -0
  121. package/dist/shared/ErrorBoundary.d.ts +3 -0
  122. package/dist/shared/ErrorBoundary.jsx +36 -0
  123. package/dist/shared/GET.d.ts +5 -0
  124. package/dist/shared/GET.js +8 -0
  125. package/dist/shared/HttpHeader.d.ts +10 -0
  126. package/dist/shared/HttpHeader.jsx +38 -0
  127. package/dist/shared/HttpStatusCode.d.ts +9 -0
  128. package/dist/shared/HttpStatusCode.js +18 -0
  129. package/dist/shared/clientOnly.d.ts +12 -0
  130. package/dist/shared/clientOnly.js +27 -0
  131. package/dist/shared/dev-overlay/CodeView.d.ts +7 -0
  132. package/dist/shared/dev-overlay/CodeView.jsx +62 -0
  133. package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +9 -0
  134. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +226 -0
  135. package/dist/shared/dev-overlay/createStackFrame.d.ts +9 -0
  136. package/dist/shared/dev-overlay/createStackFrame.js +56 -0
  137. package/dist/shared/dev-overlay/download.d.ts +1 -0
  138. package/dist/shared/dev-overlay/download.js +6 -0
  139. package/dist/shared/dev-overlay/get-source-map.d.ts +2 -0
  140. package/dist/shared/dev-overlay/get-source-map.js +25 -0
  141. package/dist/shared/dev-overlay/icons.d.ts +28 -0
  142. package/dist/shared/dev-overlay/icons.jsx +150 -0
  143. package/dist/shared/dev-overlay/index.d.ts +5 -0
  144. package/dist/shared/dev-overlay/index.jsx +39 -0
  145. package/dist/shared/lazy.d.ts +3 -0
  146. package/dist/shared/lazy.js +42 -0
  147. package/dist/shared/serverFunction.d.ts +6 -0
  148. package/dist/shared/serverFunction.js +8 -0
  149. package/dist/utils/debounce.d.ts +4 -0
  150. package/dist/utils/debounce.js +10 -0
  151. package/package.json +7 -2
  152. package/scripts/build.js +0 -15
  153. package/scripts/validate-imports.js +0 -316
  154. package/src/client/mount.ts +0 -1
  155. package/src/client/spa/index.tsx +0 -9
  156. package/src/config/constants.ts +0 -19
  157. package/src/config/dev-server.ts +0 -161
  158. package/src/config/env.ts +0 -105
  159. package/src/config/fs-router.ts +0 -162
  160. package/src/config/fs-routes/fs-watcher.ts +0 -66
  161. package/src/config/fs-routes/index.ts +0 -136
  162. package/src/config/fs-routes/router.ts +0 -184
  163. package/src/config/fs-routes/tree-shake.ts +0 -324
  164. package/src/config/index.ts +0 -239
  165. package/src/config/lazy.ts +0 -132
  166. package/src/config/manifest.ts +0 -120
  167. package/src/config/utils.ts +0 -5
  168. package/src/config/vite-utils.ts +0 -113
  169. package/src/directives/bubble-function-declaration.ts +0 -33
  170. package/src/directives/compile.ts +0 -54
  171. package/src/directives/generate-unique-name.ts +0 -22
  172. package/src/directives/get-descriptive-name.ts +0 -39
  173. package/src/directives/get-import-identifier.ts +0 -34
  174. package/src/directives/get-root-statement-path.ts +0 -14
  175. package/src/directives/index.ts +0 -233
  176. package/src/directives/is-statement-top-level.ts +0 -13
  177. package/src/directives/paths.ts +0 -63
  178. package/src/directives/plugin.ts +0 -389
  179. package/src/directives/remove-unused-variables.ts +0 -70
  180. package/src/directives/xxhash32.ts +0 -214
  181. package/src/env.d.ts +0 -17
  182. package/src/fns/client.ts +0 -141
  183. package/src/fns/handler.spec.ts +0 -85
  184. package/src/fns/handler.ts +0 -287
  185. package/src/fns/registration.ts +0 -19
  186. package/src/fns/serialization.ts +0 -250
  187. package/src/fns/server.ts +0 -46
  188. package/src/fns/shared.ts +0 -116
  189. package/src/http/index.ts +0 -216
  190. package/src/internal.d.ts +0 -14
  191. package/src/middleware/index.ts +0 -92
  192. package/src/router.tsx +0 -37
  193. package/src/server/StartServer.tsx +0 -58
  194. package/src/server/assets/index.ts +0 -70
  195. package/src/server/assets/render.tsx +0 -46
  196. package/src/server/collect-styles.ts +0 -70
  197. package/src/server/fetchEvent.spec.ts +0 -85
  198. package/src/server/fetchEvent.ts +0 -36
  199. package/src/server/handler.ts +0 -261
  200. package/src/server/manifest/client-manifest.ts +0 -8
  201. package/src/server/manifest/dev-client-manifest.ts +0 -21
  202. package/src/server/manifest/dev-ssr-manifest.ts +0 -23
  203. package/src/server/manifest/prod-client-manifest.ts +0 -21
  204. package/src/server/manifest/prod-ssr-manifest.ts +0 -109
  205. package/src/server/manifest/ssr-manifest.ts +0 -10
  206. package/src/server/routes.ts +0 -126
  207. package/src/server/spa/StartServer.tsx +0 -42
  208. package/src/server/spa/handler.ts +0 -29
  209. package/src/server/types.ts +0 -82
  210. package/src/server/util.ts +0 -12
  211. package/src/shared/ErrorBoundary.tsx +0 -52
  212. package/src/shared/GET.ts +0 -8
  213. package/src/shared/HttpHeader.tsx +0 -42
  214. package/src/shared/HttpStatusCode.ts +0 -27
  215. package/src/shared/clientOnly.ts +0 -44
  216. package/src/shared/dev-overlay/CodeView.tsx +0 -90
  217. package/src/shared/dev-overlay/DevOverlayDialog.tsx +0 -316
  218. package/src/shared/dev-overlay/createStackFrame.ts +0 -74
  219. package/src/shared/dev-overlay/download.ts +0 -6
  220. package/src/shared/dev-overlay/env.d.ts +0 -4
  221. package/src/shared/dev-overlay/get-source-map.ts +0 -33
  222. package/src/shared/dev-overlay/icons.tsx +0 -456
  223. package/src/shared/dev-overlay/index.tsx +0 -63
  224. package/src/shared/lazy.ts +0 -52
  225. package/src/shared/serverFunction.ts +0 -10
  226. package/src/utils/debounce.ts +0 -10
  227. package/src/virtual.d.ts +0 -27
  228. package/tsconfig.json +0 -24
  229. package/vitest.config.ts +0 -9
  230. /package/{src/client/index.tsx → dist/client/index.d.ts} +0 -0
  231. /package/{src → dist}/shared/dev-overlay/styles.css +0 -0
@@ -0,0 +1,9 @@
1
+ export { default as lazy } from "../shared/lazy.ts";
2
+ export { getServerFunctionMeta } from "../shared/serverFunction.ts";
3
+ export { StartServer } from "./StartServer.tsx";
4
+ export { createHandler } from "./handler.ts";
5
+ export type { APIEvent, APIHandler, Asset, ContextMatches, DocumentComponentProps, FetchEvent, HandlerOptions, PageEvent, ResponseStub, ServerFunctionMeta, } from "./types.ts";
6
+ /**
7
+ * Checks if user has set a redirect status in the response.
8
+ * If not, falls back to the 302 (temporary redirect)
9
+ */
@@ -1,21 +1,7 @@
1
- export { default as lazy } from "../shared/lazy.ts";
2
- export { getServerFunctionMeta } from "../shared/serverFunction.ts";
3
- export { StartServer } from "./StartServer.tsx";
4
- export { createHandler } from "./handler.ts";
5
-
6
- export type {
7
- APIEvent,
8
- APIHandler,
9
- Asset,
10
- ContextMatches,
11
- DocumentComponentProps,
12
- FetchEvent,
13
- HandlerOptions,
14
- PageEvent,
15
- ResponseStub,
16
- ServerFunctionMeta,
17
- } from "./types.ts";
18
-
1
+ export { default as lazy } from "../shared/lazy.js";
2
+ export { getServerFunctionMeta } from "../shared/serverFunction.js";
3
+ export { StartServer } from "./StartServer.jsx";
4
+ export { createHandler } from "./handler.js";
19
5
  /**
20
6
  * Checks if user has set a redirect status in the response.
21
7
  * If not, falls back to the 302 (temporary redirect)
@@ -24,6 +10,5 @@ export type {
24
10
  // if (response.status && validRedirectStatuses.has(response.status)) {
25
11
  // return response.status;
26
12
  // }
27
-
28
13
  // return 302;
29
14
  // }
@@ -0,0 +1,9 @@
1
+ export declare function getClientManifest(): {
2
+ import(id: string): Promise<any>;
3
+ getAssets(id: string): Promise<any[]>;
4
+ } | {
5
+ import(id: string): Promise<any>;
6
+ getAssets(id: string): Promise<any>;
7
+ json(): Promise<any>;
8
+ };
9
+ export { getClientManifest as getManifest };
@@ -0,0 +1,6 @@
1
+ import { getClientDevManifest } from "./dev-client-manifest.js";
2
+ import { getClientProdManifest } from "./prod-client-manifest.js";
3
+ export function getClientManifest() {
4
+ return import.meta.env.DEV ? getClientDevManifest() : getClientProdManifest();
5
+ }
6
+ export { getClientManifest as getManifest };
@@ -0,0 +1,4 @@
1
+ export declare function getClientDevManifest(): {
2
+ import(id: string): Promise<any>;
3
+ getAssets(id: string): Promise<any[]>;
4
+ };
@@ -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,5 @@
1
+ export declare function getSsrDevManifest(environment: "client" | "ssr"): {
2
+ path: (id: string) => string;
3
+ getAssets(id: string): Promise<any[]>;
4
+ };
5
+ export { getSsrDevManifest as getSsrManifest };
@@ -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,5 @@
1
+ export declare function getClientProdManifest(): {
2
+ import(id: string): Promise<any>;
3
+ getAssets(id: string): Promise<any>;
4
+ json(): Promise<any>;
5
+ };
@@ -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,6 @@
1
+ import type { Asset } from "../assets/render.tsx";
2
+ export declare function getSsrProdManifest(): {
3
+ path(id: string): string;
4
+ getAssets(id: string): Promise<Asset[]>;
5
+ json(): Promise<Record<string, any>>;
6
+ };
@@ -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)}/>
22
+ </>}/>
23
+ </TopErrorBoundary>
24
+ </NoHydration>);
25
+ }
@@ -0,0 +1,36 @@
1
+ import type { JSX } from "solid-js";
2
+ import type { HandlerOptions, PageEvent } from "../types.ts";
3
+ /**
4
+ *
5
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/create-handler
6
+ */
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
+ };
@@ -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
+ }
@@ -1,4 +1,3 @@
1
- // @refresh skip
2
1
  export { default as lazy } from "../../shared/lazy.ts";
3
2
  export * from "../types.ts";
4
3
  export { StartServer } from "./StartServer.tsx";
@@ -0,0 +1,5 @@
1
+ // @refresh skip
2
+ export { default as lazy } from "../../shared/lazy.js";
3
+ export * from "../types.js";
4
+ export { StartServer } from "./StartServer.jsx";
5
+ export { createHandler } from "./handler.js";
@@ -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,2 @@
1
+ import type { ResponseStub } from "./types.ts";
2
+ export declare function getExpectedRedirectStatus(response: ResponseStub): number;
@@ -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,3 @@
1
+ import { type ParentProps } from "solid-js";
2
+ export declare const ErrorBoundary: (props: ParentProps) => import("solid-js").JSX.Element;
3
+ export declare const TopErrorBoundary: (props: ParentProps) => import("solid-js").JSX.Element;
@@ -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,5 @@
1
+ /**
2
+ *
3
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get
4
+ */
5
+ export declare function GET<T extends (...args: any[]) => any>(fn: T): (...args: Parameters<T>) => ReturnType<T>;
@@ -0,0 +1,8 @@
1
+ // @refresh skip
2
+ /**
3
+ *
4
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/get
5
+ */
6
+ export function GET(fn) {
7
+ return fn.GET;
8
+ }
@@ -0,0 +1,10 @@
1
+ export interface HttpHeaderProps {
2
+ name: string;
3
+ value: string;
4
+ append?: boolean;
5
+ }
6
+ /**
7
+ *
8
+ * Read more: https://docs.solidjs.com/solid-start/reference/server/http-header
9
+ */
10
+ export declare const HttpHeader: (props: HttpHeaderProps) => null;