@torpor/build 0.1.34 → 0.3.0

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 (164) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/RouteType-g8Ce5gOd.js +107 -0
  3. package/dist/RouteType-g8Ce5gOd.js.map +1 -0
  4. package/dist/Server-CSpY_-Ba.d.ts +78 -0
  5. package/dist/Server-CSpY_-Ba.d.ts.map +1 -0
  6. package/dist/ServerEvent-2-CnAy1W.js +74 -0
  7. package/dist/ServerEvent-2-CnAy1W.js.map +1 -0
  8. package/dist/Site-D4x1l0p5.d.ts +67 -0
  9. package/dist/Site-D4x1l0p5.d.ts.map +1 -0
  10. package/dist/_page-CsdPubw4.js +33 -0
  11. package/dist/_page-CsdPubw4.js.map +1 -0
  12. package/dist/bin/index.d.ts +1 -1
  13. package/dist/bin/index.js +14 -19
  14. package/dist/bin/index.js.map +1 -1
  15. package/dist/connectMiddleware-DbLj0St1.js +252 -0
  16. package/dist/connectMiddleware-DbLj0St1.js.map +1 -0
  17. package/dist/index.d.ts +191 -182
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +109 -145
  20. package/dist/index.js.map +1 -1
  21. package/dist/nav.d.ts +14 -0
  22. package/dist/nav.d.ts.map +1 -0
  23. package/dist/nav.js +184 -0
  24. package/dist/nav.js.map +1 -0
  25. package/dist/pathToRegex-CTgx7hQP.js +11 -0
  26. package/dist/pathToRegex-CTgx7hQP.js.map +1 -0
  27. package/dist/response-D-XpIuMH.js +307 -0
  28. package/dist/response-D-XpIuMH.js.map +1 -0
  29. package/dist/response.d.ts +336 -151
  30. package/dist/response.d.ts.map +1 -0
  31. package/dist/response.js +4 -37
  32. package/dist/run-CNdaKSPR.js +331 -0
  33. package/dist/run-CNdaKSPR.js.map +1 -0
  34. package/dist/run.d.ts +11 -8
  35. package/dist/run.d.ts.map +1 -0
  36. package/dist/run.js +8 -18
  37. package/dist/seeOther-BmehiI4C.js +110 -0
  38. package/dist/seeOther-BmehiI4C.js.map +1 -0
  39. package/dist/server.d.ts +12 -11
  40. package/dist/server.d.ts.map +1 -0
  41. package/dist/server.js +5 -18
  42. package/dist/state.d.ts +14 -10
  43. package/dist/state.d.ts.map +1 -0
  44. package/dist/state.js +3 -7
  45. package/dist/test.d.ts +12 -11
  46. package/dist/test.d.ts.map +1 -0
  47. package/dist/test.js +152 -225
  48. package/dist/test.js.map +1 -1
  49. package/package.json +25 -29
  50. package/src/bin/index.ts +9 -11
  51. package/src/index.ts +3 -0
  52. package/src/nav/load.ts +9 -0
  53. package/src/nav/loadData.ts +121 -0
  54. package/src/nav/navigate.ts +154 -0
  55. package/src/nav/reload.ts +9 -0
  56. package/src/nav.ts +4 -0
  57. package/src/response/badRequest.ts +9 -4
  58. package/src/response/created.ts +10 -3
  59. package/src/response/forbidden.ts +11 -4
  60. package/src/response/found.ts +30 -0
  61. package/src/response/methodNotAllowed.ts +8 -4
  62. package/src/response/movedPermanently.ts +25 -0
  63. package/src/response/notFound.ts +14 -7
  64. package/src/response/notModified.ts +24 -4
  65. package/src/response/ok.ts +19 -10
  66. package/src/response/permanentRedirect.ts +30 -0
  67. package/src/response/seeOther.ts +9 -3
  68. package/src/response/serverError.ts +14 -2
  69. package/src/response/temporaryRedirect.ts +31 -0
  70. package/src/response/unauthorized.ts +11 -4
  71. package/src/response/unprocessable.ts +8 -2
  72. package/src/response.ts +8 -4
  73. package/src/run/prepareTemplate.ts +32 -0
  74. package/src/{site → run}/run.ts +1 -1
  75. package/src/{site → run}/runBuild.ts +2 -2
  76. package/src/{site → run}/runDev.ts +2 -2
  77. package/src/{site → run}/runPreview.ts +12 -2
  78. package/src/run.ts +4 -4
  79. package/src/server/Routerx.ts +3 -3
  80. package/src/server/Server.ts +3 -3
  81. package/src/server/ServerEvent.ts +1 -1
  82. package/src/server/connect/bufferToArrayBuffer.ts +8 -0
  83. package/src/server/connect/connectMiddleware.ts +4 -2
  84. package/src/server/connect/nodeMessageToNodeResponse.ts +2 -2
  85. package/src/server/types/ServerFunction.ts +3 -1
  86. package/src/site/Router.ts +3 -3
  87. package/src/site/clientEntry.ts +40 -273
  88. package/src/site/defaultAdapter.ts +1 -1
  89. package/src/site/serverEntry.ts +86 -50
  90. package/src/state/$page.ts +3 -12
  91. package/src/state/client.ts +6 -0
  92. package/src/state/internal.ts +45 -0
  93. package/src/test/runTest.ts +4 -4
  94. package/src/types/Adapter.ts +2 -4
  95. package/src/types/ClientState.ts +8 -0
  96. package/src/types/InternalState.ts +7 -0
  97. package/src/types/LayoutHandler.ts +2 -4
  98. package/src/types/LayoutPath.ts +10 -0
  99. package/src/types/ManifestRoute.ts +2 -4
  100. package/src/types/PageEndPoint.ts +5 -5
  101. package/src/types/PageLoadEvent.ts +2 -4
  102. package/src/types/PageServerAction.ts +1 -1
  103. package/src/types/PageServerEndPoint.ts +2 -4
  104. package/src/types/PageServerLoad.ts +1 -1
  105. package/src/types/PageState.ts +8 -0
  106. package/src/types/RouteHandler.ts +2 -4
  107. package/src/types/RouteLayoutHandler.ts +2 -4
  108. package/src/types/RouteMatchResult.ts +2 -4
  109. package/src/types/ServerHook.ts +3 -7
  110. package/src/types/ServerLoadEvent.ts +2 -4
  111. package/src/types/ServerRequest.ts +1 -1
  112. package/src/{site → utils}/pathToRegex.ts +1 -1
  113. package/{tsup.config.ts → tsdown.config.ts} +3 -4
  114. package/dist/Server-BC_dixZQ.d.cts +0 -71
  115. package/dist/Server-BC_dixZQ.d.ts +0 -71
  116. package/dist/Site-4tGiw2-I.d.ts +0 -63
  117. package/dist/Site-BXX-S541.d.cts +0 -63
  118. package/dist/bin/index.cjs +0 -755
  119. package/dist/bin/index.cjs.map +0 -1
  120. package/dist/bin/index.d.cts +0 -1
  121. package/dist/chunk-565UOT3F.js +0 -18
  122. package/dist/chunk-565UOT3F.js.map +0 -1
  123. package/dist/chunk-B2UNTYN5.js +0 -68
  124. package/dist/chunk-B2UNTYN5.js.map +0 -1
  125. package/dist/chunk-KKFND4HK.js +0 -85
  126. package/dist/chunk-KKFND4HK.js.map +0 -1
  127. package/dist/chunk-LO7P2LJE.js +0 -278
  128. package/dist/chunk-LO7P2LJE.js.map +0 -1
  129. package/dist/chunk-PTVHEJZ5.js +0 -152
  130. package/dist/chunk-PTVHEJZ5.js.map +0 -1
  131. package/dist/chunk-RHDSM5GS.js +0 -357
  132. package/dist/chunk-RHDSM5GS.js.map +0 -1
  133. package/dist/chunk-SJVHHGVW.js +0 -13
  134. package/dist/chunk-SJVHHGVW.js.map +0 -1
  135. package/dist/chunk-WVXAN4IV.js +0 -50
  136. package/dist/chunk-WVXAN4IV.js.map +0 -1
  137. package/dist/index.cjs +0 -322
  138. package/dist/index.cjs.map +0 -1
  139. package/dist/index.d.cts +0 -199
  140. package/dist/metafile-cjs.json +0 -1
  141. package/dist/metafile-esm.json +0 -1
  142. package/dist/response.cjs +0 -150
  143. package/dist/response.cjs.map +0 -1
  144. package/dist/response.d.cts +0 -166
  145. package/dist/response.js.map +0 -1
  146. package/dist/run.cjs +0 -764
  147. package/dist/run.cjs.map +0 -1
  148. package/dist/run.d.cts +0 -14
  149. package/dist/run.js.map +0 -1
  150. package/dist/server.cjs +0 -390
  151. package/dist/server.cjs.map +0 -1
  152. package/dist/server.d.cts +0 -17
  153. package/dist/server.js.map +0 -1
  154. package/dist/state.cjs +0 -44
  155. package/dist/state.cjs.map +0 -1
  156. package/dist/state.d.cts +0 -11
  157. package/dist/state.js.map +0 -1
  158. package/dist/test.cjs +0 -538
  159. package/dist/test.cjs.map +0 -1
  160. package/dist/test.d.cts +0 -15
  161. package/src/response/moved.ts +0 -16
  162. package/src/response/redirect.ts +0 -17
  163. package/src/site/prepareTemplate.ts +0 -20
  164. package/src/state/Page.ts +0 -8
@@ -3,9 +3,21 @@ import response from "./response";
3
3
  /**
4
4
  * 500 Server Error
5
5
  *
6
- * The server has encountered a situation it does not know how to handle.
6
+ * The HTTP 500 Internal Server Error server error response status code
7
+ * indicates that the server encountered an unexpected condition that prevented
8
+ * it from fulfilling the request. This error is a generic "catch-all" response
9
+ * to server issues, indicating that the server cannot find a more appropriate
10
+ * 5XX error to respond with.
7
11
  *
8
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500
12
+ * If you're a visitor seeing 500 errors on a web page, these issues require
13
+ * investigation by server owners or administrators. There are many possible
14
+ * causes of 500 errors, including: improper server configuration, out-of-memory
15
+ * (OOM) issues, unhandled exceptions, improper file permissions, or other
16
+ * complex factors. Server administrators may proactively log occurrences of
17
+ * server error responses, like the 500 status code, with details about the
18
+ * initiating requests to improve the stability of a service in the future.
19
+ *
20
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500
9
21
  */
10
22
  export default function serverError(body?: object | string): Response {
11
23
  return response(500, body ?? "Server error");
@@ -0,0 +1,31 @@
1
+ import transfer from "./transfer";
2
+
3
+ /**
4
+ * 307 Temporary Redirect
5
+ *
6
+ * The HTTP 307 Temporary Redirect redirection response status code indicates
7
+ * that the resource requested has been temporarily moved to the URL in the
8
+ * Location header.
9
+ *
10
+ * A browser receiving this status will automatically request the resource at
11
+ * the URL in the Location header, redirecting the user to the new page. Search
12
+ * engines receiving this response will not attribute links to the original URL
13
+ * to the new resource, meaning no SEO value is transferred to the new URL.
14
+ *
15
+ * The method and the body of the original request are reused to perform the
16
+ * redirected request. In the cases where you want the request method to be
17
+ * changed to GET, use 303 See Other instead. This is useful when you want to
18
+ * give an answer to a successful PUT request that is not the uploaded resource,
19
+ * but a status monitor or confirmation message like "You have successfully
20
+ * uploaded XYZ".
21
+ *
22
+ * The difference between 307 and 302 is that 307 guarantees that the client
23
+ * will not change the request method and body when the redirected request is
24
+ * made. With 302, older clients incorrectly changed the method to GET. 307 and
25
+ * 302 responses are identical when the request method is GET.
26
+ *
27
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307
28
+ */
29
+ export default function temporaryRedirect(location: string): Response {
30
+ return transfer(307, location);
31
+ }
@@ -3,11 +3,18 @@ import response from "./response";
3
3
  /**
4
4
  * 401 Unauthorized
5
5
  *
6
- * Although the HTTP standard specifies "unauthorized", semantically this
7
- * response means "unauthenticated". That is, the client must authenticate
8
- * itself to get the requested response.
6
+ * The HTTP 401 Unauthorized client error response status code indicates that a
7
+ * request was not successful because it lacks valid authentication credentials
8
+ * for the requested resource. This status code is sent with an HTTP
9
+ * WWW-Authenticate response header that contains information on the
10
+ * authentication scheme the server expects the client to include to make the
11
+ * request successfully.
9
12
  *
10
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
13
+ * A 401 Unauthorized is similar to the 403 Forbidden response, except that a
14
+ * 403 is returned when a request contains valid credentials, but the client
15
+ * does not have permissions to perform a certain action.
16
+ *
17
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
11
18
  */
12
19
  export default function unauthorized(body?: object | string): Response {
13
20
  return response(401, body ?? "Unauthorized");
@@ -3,9 +3,15 @@ import response from "./response";
3
3
  /**
4
4
  * 422 Unprocessable Content
5
5
  *
6
- * The request was well-formed but was unable to be followed due to semantic errors.
6
+ * The HTTP 422 Unprocessable Content client error response status code
7
+ * indicates that the server understood the content type of the request content,
8
+ * and the syntax of the request content was correct, but it was unable to
9
+ * process the contained instructions.
7
10
  *
8
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
11
+ * Clients that receive a 422 response should expect that repeating the request
12
+ * without modification will fail with the same error.
13
+ *
14
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422
9
15
  */
10
16
  export default function unprocessable(body?: object | string): Response {
11
17
  return response(422, body ?? "Unprocessable");
package/src/response.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import badRequest from "./response/badRequest";
2
2
  import created from "./response/created";
3
3
  import forbidden from "./response/forbidden";
4
+ import found from "./response/found";
4
5
  import methodNotAllowed from "./response/methodNotAllowed";
5
- import moved from "./response/moved";
6
+ import movedPermanently from "./response/movedPermanently";
6
7
  import notFound from "./response/notFound";
7
8
  import notModified from "./response/notModified";
8
9
  import ok from "./response/ok";
9
- import redirect from "./response/redirect";
10
+ import permanentRedirect from "./response/permanentRedirect";
10
11
  import response from "./response/response";
11
12
  import seeOther from "./response/seeOther";
12
13
  import serverError from "./response/serverError";
14
+ import temporaryRedirect from "./response/temporaryRedirect";
13
15
  import transfer from "./response/transfer";
14
16
  import unauthorized from "./response/unauthorized";
15
17
  import unprocessable from "./response/unprocessable";
@@ -19,10 +21,12 @@ export {
19
21
  ok,
20
22
  created,
21
23
  transfer,
24
+ movedPermanently,
25
+ found,
22
26
  seeOther,
23
27
  notModified,
24
- redirect,
25
- moved,
28
+ temporaryRedirect,
29
+ permanentRedirect,
26
30
  badRequest,
27
31
  unauthorized,
28
32
  forbidden,
@@ -0,0 +1,32 @@
1
+ export default function prepareTemplate(template: string, clientScript: string): string {
2
+ let result = template;
3
+
4
+ // Put %COMPONENT_HEAD% before </head>
5
+ // This is where styles will go
6
+ let headStart = result.indexOf("</head>");
7
+ if (headStart === -1) {
8
+ throw new Error(`Couldn't find <head> end tag`);
9
+ }
10
+ result = result.substring(0, headStart) + "%COMPONENT_HEAD%" + result.substring(headStart);
11
+
12
+ // Put %COMPONENT_BODY% inside <div id="app"></div>
13
+ // This is where the component's HTML will go
14
+ let bodyStart = regexIndexOf(result, /<div\s+id=("app"|'app'|app)\s+/);
15
+ bodyStart = result.indexOf(">", bodyStart) + 1;
16
+ let bodyEnd = result.indexOf("</div>", bodyStart);
17
+ if (bodyStart === -1 || bodyEnd === -1) {
18
+ throw new Error(`Couldn't find <div id="app"></div>`);
19
+ }
20
+ result = result.substring(0, bodyStart) + "%COMPONENT_BODY%" + result.substring(bodyEnd);
21
+
22
+ // Add the clientEntry script at the very end, for hydrating and navigating
23
+ result += `<script type="module" src="${clientScript}"></script>`;
24
+
25
+ return result;
26
+ }
27
+
28
+ // From https://stackoverflow.com/a/274094
29
+ function regexIndexOf(string: string, regex: RegExp, position?: number) {
30
+ var indexOf = string.substring(position || 0).search(regex);
31
+ return indexOf >= 0 ? indexOf + (position || 0) : indexOf;
32
+ }
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { transformWithEsbuild } from "vite";
4
- import Site from "./Site";
4
+ import Site from "../site/Site";
5
5
  import runBuild from "./runBuild";
6
6
  import runDev from "./runDev";
7
7
  import runPreview from "./runPreview";
@@ -2,8 +2,8 @@ import torpor from "@torpor/unplugin/vite";
2
2
  import { existsSync, promises as fs } from "node:fs";
3
3
  import path from "node:path";
4
4
  import { build, defineConfig } from "vite";
5
- import Site from "./Site.ts";
6
- import manifest from "./manifest.ts";
5
+ import Site from "../site/Site";
6
+ import manifest from "../site/manifest.ts";
7
7
 
8
8
  // TODO: Don't cache index.html in dev?
9
9
  // TODO: Multiple hook.server locations
@@ -7,8 +7,8 @@ import { createServer as createViteServer } from "vite";
7
7
  import { serverError } from "../response.ts";
8
8
  import Server from "../server/Server.ts";
9
9
  import connectMiddleware from "../server/connect/connectMiddleware.ts";
10
- import Site from "./Site.ts";
11
- import manifest from "./manifest.ts";
10
+ import Site from "../site/Site.ts";
11
+ import manifest from "../site/manifest.ts";
12
12
  import prepareTemplate from "./prepareTemplate.ts";
13
13
 
14
14
  export default async function runDev(site: Site): Promise<void> {
@@ -4,7 +4,7 @@ import path from "node:path";
4
4
  import { serverError } from "../response.ts";
5
5
  import Server from "../server/Server.ts";
6
6
  import contentType from "../server/contentType.ts";
7
- import Site from "./Site";
7
+ import Site from "../site/Site";
8
8
  import prepareTemplate from "./prepareTemplate.ts";
9
9
  import runBuild from "./runBuild";
10
10
 
@@ -44,7 +44,8 @@ export default async function runPreview(site: Site): Promise<void> {
44
44
  const file = path.join(site.root, "dist", "client", url.pathname);
45
45
  if (existsSync(file)) {
46
46
  // TODO: Stream the data?
47
- return new Response(await fs.readFile(file), {
47
+ const body = bufferToArrayBuffer(await fs.readFile(file));
48
+ return new Response(body, {
48
49
  status: 200,
49
50
  headers: {
50
51
  "Content-Type": contentType(path.extname(file)),
@@ -81,3 +82,12 @@ export default async function runPreview(site: Site): Promise<void> {
81
82
  // Serve the site
82
83
  site.adapter.serve(server, site);
83
84
  }
85
+
86
+ // From https://stackoverflow.com/a/79345620
87
+ // No idea why it is needed
88
+ function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {
89
+ return buffer.buffer.slice(
90
+ buffer.byteOffset,
91
+ buffer.byteOffset + buffer.byteLength,
92
+ ) as ArrayBuffer;
93
+ }
package/src/run.ts CHANGED
@@ -1,6 +1,6 @@
1
- import run from "./site/run";
2
- import runBuild from "./site/runBuild";
3
- import runDev from "./site/runDev";
4
- import runPreview from "./site/runPreview";
1
+ import run from "./run/run";
2
+ import runBuild from "./run/runBuild";
3
+ import runDev from "./run/runDev";
4
+ import runPreview from "./run/runPreview";
5
5
 
6
6
  export { run, runDev, runBuild, runPreview };
@@ -1,4 +1,4 @@
1
- import pathToRegex from "../site/pathToRegex";
1
+ import pathToRegex from "../utils/pathToRegex";
2
2
  import type HttpMethod from "./types/HttpMethod";
3
3
  import type MiddlewareFunction from "./types/MiddlewareFunction";
4
4
  import type ServerFunction from "./types/ServerFunction";
@@ -66,7 +66,7 @@ class MiddlewareHandler {
66
66
  }
67
67
  }
68
68
 
69
- type Match = {
69
+ interface Match {
70
70
  fn: ServerFunction;
71
71
  params?: Record<string, string>;
72
- };
72
+ }
@@ -1,4 +1,4 @@
1
- import pathToRegex from "../site/pathToRegex";
1
+ import pathToRegex from "../utils/pathToRegex";
2
2
  import ServerEvent from "./ServerEvent";
3
3
  import type MiddlewareFunction from "./types/MiddlewareFunction";
4
4
  import type ServerFunction from "./types/ServerFunction";
@@ -138,7 +138,7 @@ class RouteHandler {
138
138
  // }
139
139
  //}
140
140
 
141
- type Match = {
141
+ interface Match {
142
142
  fn: ServerFunction;
143
143
  params?: Record<string, string>;
144
- };
144
+ }
@@ -3,7 +3,7 @@ import HeaderHelper from "./HeaderHelper";
3
3
 
4
4
  export default class ServerEvent {
5
5
  request: Request;
6
- response?: Response;
6
+ response: Response | undefined | void;
7
7
  // TODO: Should we cast types??
8
8
  params?: Record<string, string>;
9
9
 
@@ -0,0 +1,8 @@
1
+ // From https://stackoverflow.com/a/79345620
2
+ // No idea why it is needed
3
+ export default function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {
4
+ return buffer.buffer.slice(
5
+ buffer.byteOffset,
6
+ buffer.byteOffset + buffer.byteLength,
7
+ ) as ArrayBuffer;
8
+ }
@@ -1,5 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type MiddlewareFunction from "../types/MiddlewareFunction";
3
+ import bufferToArrayBuffer from "./bufferToArrayBuffer";
3
4
  import flattenHeaders from "./flattenHeaders";
4
5
  import nodeMessageToNodeResponse from "./nodeMessageToNodeResponse";
5
6
  import readableToBuffer from "./readableToBuffer";
@@ -27,7 +28,7 @@ export default function connectMiddleware(
27
28
  : //(Readable.toWeb(readable) as ReadableStream);
28
29
  // HACK: Chunked bodies are not being
29
30
  // read correctly somewhere...
30
- await readableToBuffer(readable);
31
+ bufferToArrayBuffer(await readableToBuffer(readable));
31
32
  ev.response = new Response(responseBody, {
32
33
  status,
33
34
  headers: flattenHeaders(headers),
@@ -37,6 +38,7 @@ export default function connectMiddleware(
37
38
 
38
39
  const cnext = async (error?: unknown) => {
39
40
  if (error) {
41
+ // eslint-disable-next-line no-base-to-string
40
42
  reject(error instanceof Error ? error : new Error(String(error)));
41
43
  } else {
42
44
  // TODO: Can we nest the next functions less? This is a bit weird
@@ -52,7 +54,7 @@ export default function connectMiddleware(
52
54
  resolve();
53
55
  }
54
56
  } catch (e) {
55
- cnext(e);
57
+ await cnext(e);
56
58
  }
57
59
  });
58
60
  };
@@ -81,9 +81,9 @@ export default function nodeMessageToNodeResponse(
81
81
  };
82
82
  }
83
83
 
84
- type ServerResponseResponse = {
84
+ interface ServerResponseResponse {
85
85
  res: ServerResponse;
86
86
  onReadable: (
87
87
  cb: (result: { readable: Readable; headers: OutgoingHttpHeaders; status: number }) => void,
88
88
  ) => void;
89
- };
89
+ }
@@ -1,5 +1,7 @@
1
1
  import ServerEvent from "../ServerEvent";
2
2
 
3
- type ServerFunction = (e: ServerEvent) => Response | Promise<Response | undefined> | undefined;
3
+ type ServerFunction = (
4
+ e: ServerEvent,
5
+ ) => Response | undefined | void | Promise<Response | undefined | void>;
4
6
 
5
7
  export default ServerFunction;
@@ -1,7 +1,7 @@
1
1
  import type LayoutHandler from "../types/LayoutHandler";
2
2
  import type ManifestRoute from "../types/ManifestRoute";
3
3
  import type RouteHandler from "../types/RouteHandler";
4
- import pathToRegex from "./pathToRegex";
4
+ import pathToRegex from "../utils/pathToRegex";
5
5
 
6
6
  /**
7
7
  * A router that handles file routes with layouts, hooks, etc.
@@ -158,8 +158,8 @@ class Route {
158
158
  }
159
159
  }
160
160
 
161
- type Match = {
161
+ interface Match {
162
162
  handler: RouteHandler;
163
163
  params?: Record<string, string>;
164
164
  query: URLSearchParams;
165
- };
165
+ }