@solidjs/start 1.2.1 → 2.0.0-alpha.1

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 (191) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -2
  3. package/dist/client/StartClient.d.ts +0 -1
  4. package/dist/client/StartClient.jsx +2 -4
  5. package/dist/client/index.d.ts +2 -3
  6. package/dist/client/index.jsx +2 -4
  7. package/dist/client/mount.d.ts +1 -7
  8. package/dist/client/mount.js +1 -91
  9. package/dist/client/spa/index.d.ts +1 -2
  10. package/dist/client/spa/index.jsx +1 -2
  11. package/dist/config/constants.d.ts +16 -0
  12. package/dist/config/constants.js +16 -0
  13. package/dist/config/dev-server.d.ts +2 -0
  14. package/dist/config/dev-server.js +108 -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 +49 -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 +37 -0
  22. package/dist/config/fs-routes/router.js +136 -0
  23. package/dist/config/fs-routes/tree-shake.d.ts +2 -0
  24. package/dist/config/fs-routes/tree-shake.js +348 -0
  25. package/dist/config/index.d.ts +10 -0
  26. package/dist/config/index.js +214 -0
  27. package/dist/config/lazy.d.ts +3 -0
  28. package/dist/config/lazy.js +82 -0
  29. package/dist/config/manifest.d.ts +3 -0
  30. package/dist/config/manifest.js +74 -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 +16 -0
  34. package/dist/config/vite-utils.js +81 -0
  35. package/dist/http/index.d.ts +81 -0
  36. package/dist/http/index.js +129 -0
  37. package/dist/index.d.ts +5 -5
  38. package/dist/index.jsx +5 -5
  39. package/dist/middleware/index.d.ts +6 -6
  40. package/dist/middleware/index.js +39 -0
  41. package/dist/{router/FileRoutes.js → router.jsx} +7 -8
  42. package/dist/server/StartServer.d.ts +3 -3
  43. package/dist/server/StartServer.jsx +9 -63
  44. package/dist/server/assets/index.d.ts +2 -0
  45. package/dist/server/assets/index.js +52 -0
  46. package/dist/server/assets/render.d.ts +19 -0
  47. package/dist/server/{renderAsset.jsx → assets/render.jsx} +1 -1
  48. package/dist/server/collect-styles.d.ts +3 -0
  49. package/dist/server/collect-styles.js +69 -0
  50. package/dist/server/fetchEvent.d.ts +4 -3
  51. package/dist/server/fetchEvent.js +12 -74
  52. package/dist/server/fetchEvent.spec.js +18 -197
  53. package/dist/server/handler.d.ts +6 -12
  54. package/dist/server/handler.js +193 -96
  55. package/dist/server/index.d.ts +9 -6
  56. package/dist/server/index.jsx +14 -6
  57. package/dist/server/manifest/client-manifest.d.ts +9 -0
  58. package/dist/server/manifest/client-manifest.js +6 -0
  59. package/dist/server/manifest/dev-client-manifest.d.ts +4 -0
  60. package/dist/server/manifest/dev-client-manifest.js +24 -0
  61. package/dist/server/manifest/dev-ssr-manifest.d.ts +5 -0
  62. package/dist/server/manifest/dev-ssr-manifest.js +23 -0
  63. package/dist/server/manifest/prod-client-manifest.d.ts +5 -0
  64. package/dist/server/manifest/prod-client-manifest.js +26 -0
  65. package/dist/server/manifest/prod-ssr-manifest.d.ts +6 -0
  66. package/dist/server/manifest/prod-ssr-manifest.js +85 -0
  67. package/dist/server/manifest/ssr-manifest.d.ts +4 -0
  68. package/dist/server/manifest/ssr-manifest.js +6 -0
  69. package/dist/{router → server}/routes.d.ts +5 -10
  70. package/dist/{router → server}/routes.js +32 -33
  71. package/dist/{runtime → server}/server-fns-runtime.d.ts +1 -1
  72. package/dist/{runtime → server}/server-fns-runtime.js +8 -7
  73. package/dist/server/server-functions-handler.d.ts +2 -0
  74. package/dist/{runtime/server-handler.js → server/server-functions-handler.js} +57 -97
  75. package/dist/server/server-runtime.d.ts +3 -0
  76. package/dist/{runtime → server}/server-runtime.js +17 -24
  77. package/dist/server/spa/StartServer.d.ts +1 -1
  78. package/dist/server/spa/StartServer.jsx +7 -9
  79. package/dist/server/spa/handler.d.ts +3 -3
  80. package/dist/server/spa/handler.js +9 -11
  81. package/dist/server/spa/index.d.ts +4 -3
  82. package/dist/server/spa/index.jsx +4 -3
  83. package/dist/server/types.d.ts +7 -9
  84. package/dist/server/util.d.ts +2 -0
  85. package/dist/server/util.js +8 -0
  86. package/dist/shared/ErrorBoundary.jsx +2 -2
  87. package/dist/shared/HttpHeader.jsx +4 -2
  88. package/dist/shared/{HttpStatusCode.jsx → HttpStatusCode.js} +3 -1
  89. package/dist/shared/dev-overlay/CodeView.d.ts +1 -1
  90. package/dist/shared/dev-overlay/CodeView.jsx +23 -34
  91. package/dist/shared/dev-overlay/DevOverlayDialog.d.ts +2 -2
  92. package/dist/shared/dev-overlay/DevOverlayDialog.jsx +73 -64
  93. package/dist/shared/dev-overlay/createStackFrame.js +3 -3
  94. package/dist/shared/dev-overlay/get-source-map.d.ts +1 -1
  95. package/dist/shared/dev-overlay/get-source-map.js +5 -5
  96. package/dist/shared/dev-overlay/icons.d.ts +10 -10
  97. package/dist/shared/dev-overlay/icons.jsx +91 -91
  98. package/dist/shared/dev-overlay/index.jsx +6 -9
  99. package/dist/shared/lazy.d.ts +3 -0
  100. package/dist/shared/lazy.js +42 -0
  101. package/dist/shared/serverFunction.d.ts +1 -1
  102. package/env.d.ts +2 -19
  103. package/package.json +44 -65
  104. package/scripts/build.js +15 -0
  105. package/scripts/validate-imports.js +316 -0
  106. package/src/client/StartClient.tsx +34 -0
  107. package/src/client/index.tsx +2 -0
  108. package/src/client/mount.ts +1 -0
  109. package/src/client/spa/index.tsx +9 -0
  110. package/src/config/constants.ts +19 -0
  111. package/src/config/dev-server.ts +145 -0
  112. package/{config/fs-router.js → src/config/fs-router.ts} +49 -29
  113. package/src/config/fs-routes/fs-watcher.ts +77 -0
  114. package/src/config/fs-routes/index.ts +136 -0
  115. package/src/config/fs-routes/router.ts +169 -0
  116. package/src/config/fs-routes/tree-shake.ts +371 -0
  117. package/src/config/index.ts +233 -0
  118. package/src/config/lazy.ts +100 -0
  119. package/src/config/manifest.ts +84 -0
  120. package/src/config/utils.ts +5 -0
  121. package/src/config/vite-utils.ts +109 -0
  122. package/src/env.d.ts +17 -0
  123. package/src/http/index.ts +216 -0
  124. package/src/index.tsx +7 -0
  125. package/src/internal.d.ts +14 -0
  126. package/src/middleware/index.ts +72 -0
  127. package/src/router.tsx +37 -0
  128. package/src/server/StartServer.tsx +56 -0
  129. package/src/server/assets/index.ts +70 -0
  130. package/src/server/assets/render.tsx +46 -0
  131. package/src/server/collect-styles.ts +87 -0
  132. package/src/server/fetchEvent.spec.ts +85 -0
  133. package/src/server/fetchEvent.ts +36 -0
  134. package/src/server/handler.ts +257 -0
  135. package/src/server/index.tsx +29 -0
  136. package/src/server/manifest/client-manifest.ts +8 -0
  137. package/src/server/manifest/dev-client-manifest.ts +21 -0
  138. package/src/server/manifest/dev-ssr-manifest.ts +23 -0
  139. package/src/server/manifest/prod-client-manifest.ts +21 -0
  140. package/src/server/manifest/prod-ssr-manifest.ts +109 -0
  141. package/src/server/manifest/ssr-manifest.ts +10 -0
  142. package/src/server/routes.ts +126 -0
  143. package/src/server/server-fns-runtime.ts +31 -0
  144. package/src/server/server-functions-handler.ts +339 -0
  145. package/src/server/server-runtime.ts +240 -0
  146. package/src/server/spa/StartServer.tsx +40 -0
  147. package/src/server/spa/handler.ts +29 -0
  148. package/src/server/spa/index.tsx +5 -0
  149. package/src/server/types.ts +82 -0
  150. package/src/server/util.ts +12 -0
  151. package/src/shared/ErrorBoundary.tsx +52 -0
  152. package/src/shared/GET.ts +8 -0
  153. package/src/shared/HttpHeader.tsx +42 -0
  154. package/src/shared/HttpStatusCode.ts +27 -0
  155. package/src/shared/clientOnly.ts +44 -0
  156. package/src/shared/dev-overlay/CodeView.tsx +92 -0
  157. package/src/shared/dev-overlay/DevOverlayDialog.tsx +316 -0
  158. package/src/shared/dev-overlay/createStackFrame.ts +74 -0
  159. package/src/shared/dev-overlay/download.ts +6 -0
  160. package/src/shared/dev-overlay/env.d.ts +4 -0
  161. package/src/shared/dev-overlay/get-source-map.ts +33 -0
  162. package/src/shared/dev-overlay/icons.tsx +456 -0
  163. package/src/shared/dev-overlay/index.tsx +63 -0
  164. package/src/shared/dev-overlay/styles.css +292 -0
  165. package/src/shared/lazy.ts +52 -0
  166. package/src/shared/serverFunction.ts +10 -0
  167. package/src/virtual.d.ts +27 -0
  168. package/tsconfig.json +23 -0
  169. package/vitest.config.ts +9 -0
  170. package/config/index.d.ts +0 -40
  171. package/config/index.js +0 -304
  172. package/config/server-components.js +0 -106
  173. package/dist/client/islands.d.ts +0 -7
  174. package/dist/client/islands.jsx +0 -10
  175. package/dist/middleware/index.jsx +0 -35
  176. package/dist/router/index.d.ts +0 -1
  177. package/dist/router/index.jsx +0 -2
  178. package/dist/router/lazyRoute.d.ts +0 -6
  179. package/dist/router/lazyRoute.js +0 -53
  180. package/dist/runtime/server-handler.d.ts +0 -2
  181. package/dist/runtime/server-runtime.d.ts +0 -3
  182. package/dist/server/islands/index.d.ts +0 -19
  183. package/dist/server/islands/index.jsx +0 -62
  184. package/dist/server/islands/utils.d.ts +0 -1
  185. package/dist/server/islands/utils.jsx +0 -85
  186. package/dist/server/pageEvent.d.ts +0 -2
  187. package/dist/server/pageEvent.js +0 -56
  188. package/dist/server/renderAsset.d.ts +0 -2
  189. /package/dist/{router/FileRoutes.d.ts → router.d.ts} +0 -0
  190. /package/dist/shared/{clientOnly.jsx → clientOnly.js} +0 -0
  191. /package/dist/shared/{serverFunction.jsx → serverFunction.js} +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,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 };
@@ -1,3 +1,4 @@
1
+ import type { FetchEvent } from "./types.ts";
1
2
  interface Route {
2
3
  path: string;
3
4
  id: string;
@@ -11,18 +12,12 @@ interface Route {
11
12
  $PATCH?: any;
12
13
  $DELETE?: any;
13
14
  }
14
- declare module "vinxi/routes" {
15
- interface Register {
16
- route: {
17
- path: string;
18
- children?: Route[];
19
- };
20
- }
21
- }
22
15
  export declare const pageRoutes: Route[];
23
16
  export declare function matchAPIRoute(path: string, method: string): {
24
- handler: any;
25
- params: Record<string, any> | undefined;
17
+ params?: Record<string, any>;
18
+ handler: {
19
+ import: () => Promise<Record<string, (e: FetchEvent) => Promise<any>>>;
20
+ };
26
21
  isPage: boolean;
27
22
  } | undefined;
28
23
  export {};
@@ -1,5 +1,6 @@
1
+ // @ts-expect-error
2
+ import fileRoutes from "solid-start:routes";
1
3
  import { createRouter } from "radix3";
2
- import fileRoutes from "vinxi/routes";
3
4
  export const pageRoutes = defineRoutes(fileRoutes.filter(o => o.page));
4
5
  function defineRoutes(fileRoutes) {
5
6
  function processRoute(routes, route, id, full) {
@@ -10,7 +11,7 @@ function defineRoutes(fileRoutes) {
10
11
  routes.push({
11
12
  ...route,
12
13
  id,
13
- path: id.replace(/\([^)/]+\)/g, "").replace(/\/+/g, "/")
14
+ path: id.replace(/\([^)/]+\)/g, "").replace(/\/+/g, "/"),
14
15
  });
15
16
  return routes;
16
17
  }
@@ -23,40 +24,11 @@ function defineRoutes(fileRoutes) {
23
24
  return processRoute(prevRoutes, route, route.path, route.path);
24
25
  }, []);
25
26
  }
26
- export function matchAPIRoute(path, method) {
27
- const match = router.lookup(path);
28
- if (match && match.route) {
29
- const route = match.route;
30
- // Find the appropriate handler for the HTTP method
31
- const handler = method === "HEAD"
32
- ? route.$HEAD || route.$GET
33
- : route[`$${method}`];
34
- if (handler === undefined)
35
- return;
36
- // Check if this is a page route
37
- const isPage = route.page === true && route.$component !== undefined;
38
- // Return comprehensive route information
39
- return {
40
- handler,
41
- params: match.params,
42
- isPage
43
- };
44
- }
45
- return undefined;
46
- }
47
- function containsHTTP(route) {
48
- return (route["$HEAD"] ||
49
- route["$GET"] ||
50
- route["$POST"] ||
51
- route["$PUT"] ||
52
- route["$PATCH"] ||
53
- route["$DELETE"]);
54
- }
55
27
  const router = createRouter({
56
28
  routes: fileRoutes.reduce((memo, route) => {
57
29
  if (!containsHTTP(route))
58
30
  return memo;
59
- let path = route.path
31
+ const path = route.path
60
32
  .replace(/\([^)/]+\)/g, "")
61
33
  .replace(/\/+/g, "/")
62
34
  .replace(/\*([^/]*)/g, (_, m) => `**:${m}`)
@@ -71,5 +43,32 @@ const router = createRouter({
71
43
  }
72
44
  memo[path] = { route };
73
45
  return memo;
74
- }, {})
46
+ }, {}),
75
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
+ }
@@ -1 +1 @@
1
- export declare function createServerReference(fn: Function, id: string, name: string): Function;
1
+ export declare function createServerReference(fn: Function, id: string): Function;
@@ -1,14 +1,15 @@
1
1
  import { getRequestEvent } from "solid-js/web";
2
2
  import { provideRequestEvent } from "solid-js/web/storage";
3
- import { cloneEvent } from "../server/fetchEvent";
4
- export function createServerReference(fn, id, name) {
3
+ export function createServerReference(fn, id) {
5
4
  if (typeof fn !== "function")
6
5
  throw new Error("Export from a 'use server' module must be a function");
7
- const baseURL = import.meta.env.SERVER_BASE_URL;
6
+ let baseURL = import.meta.env.BASE_URL ?? "/";
7
+ if (!baseURL.endsWith("/"))
8
+ baseURL += "/";
8
9
  return new Proxy(fn, {
9
10
  get(target, prop, receiver) {
10
11
  if (prop === "url") {
11
- return `${baseURL}/_server?id=${encodeURIComponent(id)}&name=${encodeURIComponent(name)}`;
12
+ return `${baseURL}_server?id=${encodeURIComponent(id)}`;
12
13
  }
13
14
  if (prop === "GET")
14
15
  return receiver;
@@ -18,14 +19,14 @@ export function createServerReference(fn, id, name) {
18
19
  const ogEvt = getRequestEvent();
19
20
  if (!ogEvt)
20
21
  throw new Error("Cannot call server function outside of a request");
21
- const evt = cloneEvent(ogEvt);
22
+ const evt = { ...ogEvt };
22
23
  evt.locals.serverFunctionMeta = {
23
- id: id + "#" + name,
24
+ id,
24
25
  };
25
26
  evt.serverOnly = true;
26
27
  return provideRequestEvent(evt, () => {
27
28
  return fn.apply(thisArg, args);
28
29
  });
29
- }
30
+ },
30
31
  });
31
32
  }
@@ -0,0 +1,2 @@
1
+ import { type H3Event } from "h3";
2
+ export declare function handleServerFunction(h3Event: H3Event): Promise<unknown>;