@torpor/build 0.3.1 → 0.4.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.
- package/CHANGELOG.md +22 -0
- package/dist/{RouteType-g8Ce5gOd.js → RouteType-VOBjKJ8I.js} +3 -3
- package/dist/{RouteType-g8Ce5gOd.js.map → RouteType-VOBjKJ8I.js.map} +1 -1
- package/dist/{Server-CSpY_-Ba.d.ts → Server-DL9neaq0.d.ts} +2 -2
- package/dist/Server-DL9neaq0.d.ts.map +1 -0
- package/dist/{ServerEvent-2-CnAy1W.js → ServerEvent-Dnk2FIKQ.js} +3 -4
- package/dist/{ServerEvent-2-CnAy1W.js.map → ServerEvent-Dnk2FIKQ.js.map} +1 -1
- package/dist/{Site-D4x1l0p5.d.ts → Site-B8TxSzPk.d.ts} +3 -3
- package/dist/Site-B8TxSzPk.d.ts.map +1 -0
- package/dist/{_page-Cv6YWocY.js → _page-B8QZDML_.js} +2 -2
- package/dist/_page-B8QZDML_.js.map +1 -0
- package/dist/bin/index.js +6 -6
- package/dist/{connectMiddleware-DbLj0St1.js → connectMiddleware-PBcWWRr-.js} +4 -4
- package/dist/{connectMiddleware-DbLj0St1.js.map → connectMiddleware-PBcWWRr-.js.map} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/nav.js +10 -13
- package/dist/nav.js.map +1 -1
- package/dist/{pathToRegex-CTgx7hQP.js → pathToRegex-BTPkBIYJ.js} +2 -2
- package/dist/{pathToRegex-CTgx7hQP.js.map → pathToRegex-BTPkBIYJ.js.map} +1 -1
- package/dist/{response-D-XpIuMH.js → response-KnPcsvtU.js} +3 -3
- package/dist/{response-D-XpIuMH.js.map → response-KnPcsvtU.js.map} +1 -1
- package/dist/response.js +2 -2
- package/dist/{run-CVKpO0HO.js → run-CaFHeN6K.js} +40 -39
- package/dist/run-CaFHeN6K.js.map +1 -0
- package/dist/run.d.ts +2 -2
- package/dist/run.js +6 -6
- package/dist/{seeOther-BmehiI4C.js → seeOther-C-36lhS5.js} +2 -2
- package/dist/{seeOther-BmehiI4C.js.map → seeOther-C-36lhS5.js.map} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +3 -3
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +1 -1
- package/dist/test.d.ts +2 -2
- package/dist/test.js +12 -19
- package/dist/test.js.map +1 -1
- package/package.json +8 -8
- package/src/nav/loadData.ts +1 -1
- package/src/nav/navigate.ts +5 -5
- package/src/run/prepareTemplate.ts +8 -1
- package/src/run/runBuild.ts +0 -1
- package/src/run/runDev.ts +3 -3
- package/src/site/clientEntryDev.ts +3 -0
- package/src/site/serverEntry.ts +1 -1
- package/src/state/internal.ts +3 -2
- package/src/test/runTest.ts +1 -1
- package/src/types/LayoutPath.ts +1 -1
- package/dist/Server-CSpY_-Ba.d.ts.map +0 -1
- package/dist/Site-D4x1l0p5.d.ts.map +0 -1
- package/dist/_page-Cv6YWocY.js.map +0 -1
- package/dist/run-CVKpO0HO.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathToRegex-
|
|
1
|
+
{"version":3,"file":"pathToRegex-BTPkBIYJ.js","names":[],"sources":["../src/utils/pathToRegex.ts"],"sourcesContent":["export default function pathToRegex(path: string): RegExp {\n\tconst pattern =\n\t\tpath\n\t\t\t.split(\"/\")\n\t\t\t// Replace `[slug]` with a grouped match so we can pull out params\n\t\t\t.map((p) => {\n\t\t\t\treturn p.replace(/\\[([^/]+?)\\]/, \"(?<$1>[^\\\\/]+?)\");\n\t\t\t})\n\t\t\t.join(\"\\\\/\")\n\t\t\t// Replace globs with regex syntax\n\t\t\t.replaceAll(\"*\", \".*\") +\n\t\t// Ignore trailing slashes -- `/path` should be treated the same as `/path/`\n\t\t\"/*\";\n\treturn new RegExp(`^${pattern}/*$`);\n}\n"],"mappings":";AAAA,SAAwB,YAAY,MAAsB;CACzD,MAAM,UACL,KACE,MAAM,IAAI,CAEV,KAAK,MAAM;AACX,SAAO,EAAE,QAAQ,gBAAgB,kBAAkB;GAClD,CACD,KAAK,MAAM,CAEX,WAAW,KAAK,KAAK,GAEvB;AACD,wBAAO,IAAI,OAAO,IAAI,QAAQ,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { response, transfer } from "./seeOther-
|
|
1
|
+
import { a as response, i as transfer } from "./seeOther-C-36lhS5.js";
|
|
2
2
|
|
|
3
3
|
//#region src/response/badRequest.ts
|
|
4
4
|
/**
|
|
@@ -303,5 +303,5 @@ function unprocessable(body) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
//#endregion
|
|
306
|
-
export {
|
|
307
|
-
//# sourceMappingURL=response-
|
|
306
|
+
export { permanentRedirect as a, methodNotAllowed as c, created as d, badRequest as f, serverError as i, permRedirect as l, unauthorized as n, notModified as o, temporaryRedirect as r, permRedirect$1 as s, unprocessable as t, forbidden as u };
|
|
307
|
+
//# sourceMappingURL=response-KnPcsvtU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-D-XpIuMH.js","names":["permRedirect"],"sources":["../src/response/badRequest.ts","../src/response/created.ts","../src/response/forbidden.ts","../src/response/found.ts","../src/response/methodNotAllowed.ts","../src/response/movedPermanently.ts","../src/response/notModified.ts","../src/response/permanentRedirect.ts","../src/response/serverError.ts","../src/response/temporaryRedirect.ts","../src/response/unauthorized.ts","../src/response/unprocessable.ts"],"sourcesContent":["import response from \"./response\";\n\n/**\n * 400 Bad Request\n *\n * The HTTP 400 Bad Request client error response status code indicates that the\n * server would not process the request due to something the server considered\n * to be a client error. The reason for a 400 response is typically due to\n * malformed request syntax, invalid request message framing, or deceptive\n * request routing.\n *\n * Clients that receive a 400 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400\n */\nexport default function badRequest(body?: object | string): Response {\n\treturn response(400, body ?? \"Bad request\");\n}\n","import response from \"./response\";\n\n/**\n * 201 Created\n *\n * The HTTP 201 Created successful response status code indicates that the HTTP\n * request has led to the creation of a resource. This status code is commonly\n * sent as the result of a POST request.\n *\n * The new resource, or a description and link to the new resource, is created\n * before the response is returned. The newly-created items can be returned in\n * the body of the response message, but must be locatable by the URL of the\n * initiating request or by the URL in the value of the Location header provided\n * with the response.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201\n */\nexport default function created(body?: object | string): Response {\n\treturn response(201, body);\n}\n","import response from \"./response\";\n\n/**\n * 403 Forbidden\n *\n * The HTTP 403 Forbidden client error response status code indicates that the\n * server understood the request but refused to process it. This status is\n * similar to 401, except that for 403 Forbidden responses, authenticating or\n * re-authenticating makes no difference. The request failure is tied to\n * application logic, such as insufficient permissions to a resource or action.\n *\n * Clients that receive a 403 response should expect that repeating the request\n * without modification will fail with the same error. Server owners may decide\n * to send a 404 response instead of a 403 if acknowledging the existence of a\n * resource to clients with insufficient privileges is not desired.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403\n */\nexport default function forbidden(body?: object | string): Response {\n\treturn response(403, body ?? \"Forbidden\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 302 Found\n *\n * The HTTP 302 Found redirection response status code indicates that the\n * requested resource has been temporarily moved to the URL in the Location\n * header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 302 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 307 Temporary Redirect instead, as altering the\n * > method after a 307 response is prohibited.\n *\n * > In cases where you want any request method to be changed to GET, use 303\n * > See Other. This is useful when you want to give a response to a PUT method\n * > that is not the uploaded resource but a confirmation message such as: \"you\n * > successfully uploaded XYZ\".\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 405 Method Not Allowed\n *\n * The HTTP 405 Method Not Allowed client error response status code indicates\n * that the server knows the request method, but the target resource doesn't\n * support this method. The server must generate an Allow header in a 405\n * response with a list of methods that the target resource currently supports.\n *\n * Improper server-side permissions set on files or directories may cause a 405\n * response when the request would otherwise be expected to succeed.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405\n */\nexport default function methodNotAllowed(body?: object | string): Response {\n\treturn response(405, body ?? \"Method not allowed\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 301 Moved Permanently\n *\n * The HTTP 301 Moved Permanently redirection response status code indicates\n * that the requested resource has been permanently moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 301 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 308 Permanent Redirect instead, as altering the\n * > method after a 308 response is prohibited.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 304 Not Modified\n *\n * The HTTP 304 Not Modified redirection response status code indicates that\n * there is no need to retransmit the requested resources.\n *\n * This response code is sent when the request is a conditional GET or HEAD\n * request with an If-None-Match or an If-Modified-Since header and the\n * condition evaluates to 'false'. It confirms that the resource cached by the\n * client is still valid and that the server would have sent a 200 OK response\n * with the resource if the condition evaluated to 'true'. See HTTP caching for\n * more information.\n *\n * The response must not contain a body and must include the headers that would\n * have been sent in an equivalent 200 response, such as:\n *\n * - Cache-Control\n * - Content-Location\n * - Date\n * - ETag\n * - Expires\n * - Vary\n *\n * > Note: Many developer tools' network panels of browsers create extraneous\n * > requests leading to 304 responses, so that access to the local cache is\n * > visible to developers.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304\n */\nexport default function notModified(location: string): Response {\n\treturn transfer(304, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 308 Permanent Redirect\n *\n * The HTTP 308 Permanent Redirect redirection response status code indicates\n * that the requested resource has been permanently moved to the URL given by\n * the Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * The request method and the body will not be modified by the client in the\n * redirected request. A 301 Moved Permanently requires the request method and\n * the body to remain unchanged when redirection is performed, but this is\n * incorrectly handled by older clients to use the GET method instead.\n *\n * > Note: Some Web applications may use the 308 Permanent Redirect in a\n * > non-standard way and for different purposes. For example, Google Drive uses\n * > a 308 Resume Incomplete response to indicate to the client when an\n * > unfinished upload has stalled. See Perform a resumable download on the\n * > Google Drive documentation for more information.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308\n */\nexport default function permanentRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 500 Server Error\n *\n * The HTTP 500 Internal Server Error server error response status code\n * indicates that the server encountered an unexpected condition that prevented\n * it from fulfilling the request. This error is a generic \"catch-all\" response\n * to server issues, indicating that the server cannot find a more appropriate\n * 5XX error to respond with.\n *\n * If you're a visitor seeing 500 errors on a web page, these issues require\n * investigation by server owners or administrators. There are many possible\n * causes of 500 errors, including: improper server configuration, out-of-memory\n * (OOM) issues, unhandled exceptions, improper file permissions, or other\n * complex factors. Server administrators may proactively log occurrences of\n * server error responses, like the 500 status code, with details about the\n * initiating requests to improve the stability of a service in the future.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500\n */\nexport default function serverError(body?: object | string): Response {\n\treturn response(500, body ?? \"Server error\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 307 Temporary Redirect\n *\n * The HTTP 307 Temporary Redirect redirection response status code indicates\n * that the resource requested has been temporarily moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * The method and the body of the original request are reused to perform the\n * redirected request. In the cases where you want the request method to be\n * changed to GET, use 303 See Other instead. This is useful when you want to\n * give an answer to a successful PUT request that is not the uploaded resource,\n * but a status monitor or confirmation message like \"You have successfully\n * uploaded XYZ\".\n *\n * The difference between 307 and 302 is that 307 guarantees that the client\n * will not change the request method and body when the redirected request is\n * made. With 302, older clients incorrectly changed the method to GET. 307 and\n * 302 responses are identical when the request method is GET.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307\n */\nexport default function temporaryRedirect(location: string): Response {\n\treturn transfer(307, location);\n}\n","import response from \"./response\";\n\n/**\n * 401 Unauthorized\n *\n * The HTTP 401 Unauthorized client error response status code indicates that a\n * request was not successful because it lacks valid authentication credentials\n * for the requested resource. This status code is sent with an HTTP\n * WWW-Authenticate response header that contains information on the\n * authentication scheme the server expects the client to include to make the\n * request successfully.\n *\n * A 401 Unauthorized is similar to the 403 Forbidden response, except that a\n * 403 is returned when a request contains valid credentials, but the client\n * does not have permissions to perform a certain action.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401\n */\nexport default function unauthorized(body?: object | string): Response {\n\treturn response(401, body ?? \"Unauthorized\");\n}\n","import response from \"./response\";\n\n/**\n * 422 Unprocessable Content\n *\n * The HTTP 422 Unprocessable Content client error response status code\n * indicates that the server understood the content type of the request content,\n * and the syntax of the request content was correct, but it was unable to\n * process the contained instructions.\n *\n * Clients that receive a 422 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422\n */\nexport default function unprocessable(body?: object | string): Response {\n\treturn response(422, body ?? \"Unprocessable\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAwB,WAAW,MAAkC;AACpE,QAAO,SAAS,KAAK,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;ACA5C,SAAwB,QAAQ,MAAkC;AACjE,QAAO,SAAS,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;ACA3B,SAAwB,UAAU,MAAkC;AACnE,QAAO,SAAS,KAAK,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ1C,SAAwB,aAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;ACb/B,SAAwB,iBAAiB,MAAkC;AAC1E,QAAO,SAAS,KAAK,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;ACMnD,SAAwBA,eAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ/B,SAAwB,YAAY,UAA4B;AAC/D,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL/B,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;ACP/B,SAAwB,YAAY,MAAkC;AACrE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACM7C,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;ACX/B,SAAwB,aAAa,MAAkC;AACtE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;ACJ7C,SAAwB,cAAc,MAAkC;AACvE,QAAO,SAAS,KAAK,QAAQ,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"response-KnPcsvtU.js","names":["permRedirect"],"sources":["../src/response/badRequest.ts","../src/response/created.ts","../src/response/forbidden.ts","../src/response/found.ts","../src/response/methodNotAllowed.ts","../src/response/movedPermanently.ts","../src/response/notModified.ts","../src/response/permanentRedirect.ts","../src/response/serverError.ts","../src/response/temporaryRedirect.ts","../src/response/unauthorized.ts","../src/response/unprocessable.ts"],"sourcesContent":["import response from \"./response\";\n\n/**\n * 400 Bad Request\n *\n * The HTTP 400 Bad Request client error response status code indicates that the\n * server would not process the request due to something the server considered\n * to be a client error. The reason for a 400 response is typically due to\n * malformed request syntax, invalid request message framing, or deceptive\n * request routing.\n *\n * Clients that receive a 400 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400\n */\nexport default function badRequest(body?: object | string): Response {\n\treturn response(400, body ?? \"Bad request\");\n}\n","import response from \"./response\";\n\n/**\n * 201 Created\n *\n * The HTTP 201 Created successful response status code indicates that the HTTP\n * request has led to the creation of a resource. This status code is commonly\n * sent as the result of a POST request.\n *\n * The new resource, or a description and link to the new resource, is created\n * before the response is returned. The newly-created items can be returned in\n * the body of the response message, but must be locatable by the URL of the\n * initiating request or by the URL in the value of the Location header provided\n * with the response.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201\n */\nexport default function created(body?: object | string): Response {\n\treturn response(201, body);\n}\n","import response from \"./response\";\n\n/**\n * 403 Forbidden\n *\n * The HTTP 403 Forbidden client error response status code indicates that the\n * server understood the request but refused to process it. This status is\n * similar to 401, except that for 403 Forbidden responses, authenticating or\n * re-authenticating makes no difference. The request failure is tied to\n * application logic, such as insufficient permissions to a resource or action.\n *\n * Clients that receive a 403 response should expect that repeating the request\n * without modification will fail with the same error. Server owners may decide\n * to send a 404 response instead of a 403 if acknowledging the existence of a\n * resource to clients with insufficient privileges is not desired.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403\n */\nexport default function forbidden(body?: object | string): Response {\n\treturn response(403, body ?? \"Forbidden\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 302 Found\n *\n * The HTTP 302 Found redirection response status code indicates that the\n * requested resource has been temporarily moved to the URL in the Location\n * header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 302 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 307 Temporary Redirect instead, as altering the\n * > method after a 307 response is prohibited.\n *\n * > In cases where you want any request method to be changed to GET, use 303\n * > See Other. This is useful when you want to give a response to a PUT method\n * > that is not the uploaded resource but a confirmation message such as: \"you\n * > successfully uploaded XYZ\".\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 405 Method Not Allowed\n *\n * The HTTP 405 Method Not Allowed client error response status code indicates\n * that the server knows the request method, but the target resource doesn't\n * support this method. The server must generate an Allow header in a 405\n * response with a list of methods that the target resource currently supports.\n *\n * Improper server-side permissions set on files or directories may cause a 405\n * response when the request would otherwise be expected to succeed.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405\n */\nexport default function methodNotAllowed(body?: object | string): Response {\n\treturn response(405, body ?? \"Method not allowed\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 301 Moved Permanently\n *\n * The HTTP 301 Moved Permanently redirection response status code indicates\n * that the requested resource has been permanently moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * > Note: In the Fetch Standard, when a user agent receives a 301 in response\n * > to a POST request, it uses the GET method in the subsequent redirection\n * > request, as permitted by the HTTP specification. To avoid user agents\n * > modifying the request, use 308 Permanent Redirect instead, as altering the\n * > method after a 308 response is prohibited.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301\n */\nexport default function permRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 304 Not Modified\n *\n * The HTTP 304 Not Modified redirection response status code indicates that\n * there is no need to retransmit the requested resources.\n *\n * This response code is sent when the request is a conditional GET or HEAD\n * request with an If-None-Match or an If-Modified-Since header and the\n * condition evaluates to 'false'. It confirms that the resource cached by the\n * client is still valid and that the server would have sent a 200 OK response\n * with the resource if the condition evaluated to 'true'. See HTTP caching for\n * more information.\n *\n * The response must not contain a body and must include the headers that would\n * have been sent in an equivalent 200 response, such as:\n *\n * - Cache-Control\n * - Content-Location\n * - Date\n * - ETag\n * - Expires\n * - Vary\n *\n * > Note: Many developer tools' network panels of browsers create extraneous\n * > requests leading to 304 responses, so that access to the local cache is\n * > visible to developers.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304\n */\nexport default function notModified(location: string): Response {\n\treturn transfer(304, location);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 308 Permanent Redirect\n *\n * The HTTP 308 Permanent Redirect redirection response status code indicates\n * that the requested resource has been permanently moved to the URL given by\n * the Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will attribute links to the original URL to\n * the redirected resource, passing the SEO ranking to the new URL.\n *\n * The request method and the body will not be modified by the client in the\n * redirected request. A 301 Moved Permanently requires the request method and\n * the body to remain unchanged when redirection is performed, but this is\n * incorrectly handled by older clients to use the GET method instead.\n *\n * > Note: Some Web applications may use the 308 Permanent Redirect in a\n * > non-standard way and for different purposes. For example, Google Drive uses\n * > a 308 Resume Incomplete response to indicate to the client when an\n * > unfinished upload has stalled. See Perform a resumable download on the\n * > Google Drive documentation for more information.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308\n */\nexport default function permanentRedirect(location: string): Response {\n\treturn transfer(308, location);\n}\n","import response from \"./response\";\n\n/**\n * 500 Server Error\n *\n * The HTTP 500 Internal Server Error server error response status code\n * indicates that the server encountered an unexpected condition that prevented\n * it from fulfilling the request. This error is a generic \"catch-all\" response\n * to server issues, indicating that the server cannot find a more appropriate\n * 5XX error to respond with.\n *\n * If you're a visitor seeing 500 errors on a web page, these issues require\n * investigation by server owners or administrators. There are many possible\n * causes of 500 errors, including: improper server configuration, out-of-memory\n * (OOM) issues, unhandled exceptions, improper file permissions, or other\n * complex factors. Server administrators may proactively log occurrences of\n * server error responses, like the 500 status code, with details about the\n * initiating requests to improve the stability of a service in the future.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500\n */\nexport default function serverError(body?: object | string): Response {\n\treturn response(500, body ?? \"Server error\");\n}\n","import transfer from \"./transfer\";\n\n/**\n * 307 Temporary Redirect\n *\n * The HTTP 307 Temporary Redirect redirection response status code indicates\n * that the resource requested has been temporarily moved to the URL in the\n * Location header.\n *\n * A browser receiving this status will automatically request the resource at\n * the URL in the Location header, redirecting the user to the new page. Search\n * engines receiving this response will not attribute links to the original URL\n * to the new resource, meaning no SEO value is transferred to the new URL.\n *\n * The method and the body of the original request are reused to perform the\n * redirected request. In the cases where you want the request method to be\n * changed to GET, use 303 See Other instead. This is useful when you want to\n * give an answer to a successful PUT request that is not the uploaded resource,\n * but a status monitor or confirmation message like \"You have successfully\n * uploaded XYZ\".\n *\n * The difference between 307 and 302 is that 307 guarantees that the client\n * will not change the request method and body when the redirected request is\n * made. With 302, older clients incorrectly changed the method to GET. 307 and\n * 302 responses are identical when the request method is GET.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307\n */\nexport default function temporaryRedirect(location: string): Response {\n\treturn transfer(307, location);\n}\n","import response from \"./response\";\n\n/**\n * 401 Unauthorized\n *\n * The HTTP 401 Unauthorized client error response status code indicates that a\n * request was not successful because it lacks valid authentication credentials\n * for the requested resource. This status code is sent with an HTTP\n * WWW-Authenticate response header that contains information on the\n * authentication scheme the server expects the client to include to make the\n * request successfully.\n *\n * A 401 Unauthorized is similar to the 403 Forbidden response, except that a\n * 403 is returned when a request contains valid credentials, but the client\n * does not have permissions to perform a certain action.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401\n */\nexport default function unauthorized(body?: object | string): Response {\n\treturn response(401, body ?? \"Unauthorized\");\n}\n","import response from \"./response\";\n\n/**\n * 422 Unprocessable Content\n *\n * The HTTP 422 Unprocessable Content client error response status code\n * indicates that the server understood the content type of the request content,\n * and the syntax of the request content was correct, but it was unable to\n * process the contained instructions.\n *\n * Clients that receive a 422 response should expect that repeating the request\n * without modification will fail with the same error.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422\n */\nexport default function unprocessable(body?: object | string): Response {\n\treturn response(422, body ?? \"Unprocessable\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,SAAwB,WAAW,MAAkC;AACpE,QAAO,SAAS,KAAK,QAAQ,cAAc;;;;;;;;;;;;;;;;;;;;ACA5C,SAAwB,QAAQ,MAAkC;AACjE,QAAO,SAAS,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;ACA3B,SAAwB,UAAU,MAAkC;AACnE,QAAO,SAAS,KAAK,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ1C,SAAwB,aAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;ACb/B,SAAwB,iBAAiB,MAAkC;AAC1E,QAAO,SAAS,KAAK,QAAQ,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;ACMnD,SAAwBA,eAAa,UAA4B;AAChE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACQ/B,SAAwB,YAAY,UAA4B;AAC/D,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACL/B,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;;;;ACP/B,SAAwB,YAAY,MAAkC;AACrE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACM7C,SAAwB,kBAAkB,UAA4B;AACrE,QAAO,SAAS,KAAK,SAAS;;;;;;;;;;;;;;;;;;;;;ACX/B,SAAwB,aAAa,MAAkC;AACtE,QAAO,SAAS,KAAK,QAAQ,eAAe;;;;;;;;;;;;;;;;;;ACJ7C,SAAwB,cAAc,MAAkC;AACvE,QAAO,SAAS,KAAK,QAAQ,gBAAgB"}
|
package/dist/response.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as response, i as transfer, n as ok, r as notFound, t as seeOther } from "./seeOther-C-36lhS5.js";
|
|
2
|
+
import { a as permanentRedirect, c as methodNotAllowed, d as created, f as badRequest, i as serverError, l as permRedirect, n as unauthorized, o as notModified, r as temporaryRedirect, s as permRedirect$1, t as unprocessable, u as forbidden } from "./response-KnPcsvtU.js";
|
|
3
3
|
|
|
4
4
|
export { badRequest, created, forbidden, permRedirect as found, methodNotAllowed, permRedirect$1 as movedPermanently, notFound, notModified, ok, permanentRedirect, response, seeOther, serverError, temporaryRedirect, transfer, unauthorized, unprocessable };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { serverError } from "./response-
|
|
2
|
-
import { Server, connectMiddleware } from "./connectMiddleware-
|
|
1
|
+
import { i as serverError } from "./response-KnPcsvtU.js";
|
|
2
|
+
import { n as Server, t as connectMiddleware } from "./connectMiddleware-PBcWWRr-.js";
|
|
3
3
|
import fs, { existsSync, promises, readFileSync } from "node:fs";
|
|
4
|
-
import
|
|
4
|
+
import fpath from "node:path";
|
|
5
5
|
import { build, createServer, defineConfig, transformWithEsbuild } from "vite";
|
|
6
6
|
import torpor from "@torpor/unplugin/vite";
|
|
7
7
|
import estorpor from "@torpor/unplugin/esbuild";
|
|
@@ -30,9 +30,9 @@ ${!serverRequest ? "const load = { default: { load: true } };" : ""}
|
|
|
30
30
|
export default {
|
|
31
31
|
routes: [
|
|
32
32
|
${site.routes.map((r) => {
|
|
33
|
-
if (serverRequest || !/server\.(ts|js)$/.test(r.file)) return `{ path: "${r.path}", type: ${r.type}, endPoint: ${serverRequest || !/server\.(ts|js)$/.test(r.file) ? `() => import(/* @vite-ignore */ "${
|
|
33
|
+
if (serverRequest || !/server\.(ts|js)$/.test(r.file)) return `{ path: "${r.path}", type: ${r.type}, endPoint: ${serverRequest || !/server\.(ts|js)$/.test(r.file) ? `() => import(/* @vite-ignore */ "${fpath.join(site.root, r.file)}")` : "undefined"} }`;
|
|
34
34
|
else {
|
|
35
|
-
const haveLoad = readFileSync(
|
|
35
|
+
const haveLoad = readFileSync(fpath.join(site.root, r.file)).includes("load:");
|
|
36
36
|
return `{ path: "${r.path}", type: ${r.type}, endPoint: ${haveLoad ? "() => load" : "undefined"} }`;
|
|
37
37
|
}
|
|
38
38
|
}).join(",\n ")}
|
|
@@ -47,15 +47,15 @@ export default {
|
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region src/run/runBuild.ts
|
|
49
49
|
async function runBuild(site) {
|
|
50
|
-
const distFolder =
|
|
50
|
+
const distFolder = fpath.resolve(site.root, "dist");
|
|
51
51
|
if (existsSync(distFolder)) await promises.rm(distFolder, { recursive: true });
|
|
52
|
-
const clientFolder =
|
|
53
|
-
const serverFolder =
|
|
52
|
+
const clientFolder = fpath.join(distFolder, "client");
|
|
53
|
+
const serverFolder = fpath.join(distFolder, "server");
|
|
54
54
|
if (site.adapter.prebuild) await site.adapter.prebuild(site);
|
|
55
|
-
let siteHtml =
|
|
56
|
-
const siteFolder =
|
|
57
|
-
let clientScript =
|
|
58
|
-
let serverScript =
|
|
55
|
+
let siteHtml = fpath.resolve(site.root, "src/site.html");
|
|
56
|
+
const siteFolder = fpath.resolve(site.root, "./node_modules/@torpor/build/src/site/");
|
|
57
|
+
let clientScript = fpath.join(siteFolder, "clientEntry.ts");
|
|
58
|
+
let serverScript = fpath.join(siteFolder, "serverEntry.ts");
|
|
59
59
|
const clientConfig = structuredClone(site.viteConfig ?? {});
|
|
60
60
|
clientConfig.plugins = [
|
|
61
61
|
manifest(site),
|
|
@@ -68,7 +68,7 @@ async function runBuild(site) {
|
|
|
68
68
|
clientConfig.build.rollupOptions.input = [
|
|
69
69
|
siteHtml,
|
|
70
70
|
clientScript,
|
|
71
|
-
...site.routes.filter((r) => !/server\.(ts|js)$/.test(r.file)).map((r) =>
|
|
71
|
+
...site.routes.filter((r) => !/server\.(ts|js)$/.test(r.file)).map((r) => fpath.resolve(site.root, r.file)),
|
|
72
72
|
...site.inputs.filter((f) => !/server\.(ts|js)$/.test(f))
|
|
73
73
|
];
|
|
74
74
|
clientConfig.build.ssrManifest = true;
|
|
@@ -84,20 +84,20 @@ async function runBuild(site) {
|
|
|
84
84
|
serverConfig.build.rollupOptions ??= {};
|
|
85
85
|
serverConfig.build.rollupOptions.input = [
|
|
86
86
|
serverScript,
|
|
87
|
-
...site.routes.map((r) =>
|
|
87
|
+
...site.routes.map((r) => fpath.resolve(site.root, r.file)),
|
|
88
88
|
...site.inputs
|
|
89
89
|
];
|
|
90
90
|
serverConfig.build.ssr = serverScript;
|
|
91
91
|
await build(defineConfig(serverConfig));
|
|
92
|
-
siteHtml =
|
|
93
|
-
await promises.rename(
|
|
94
|
-
await promises.rm(
|
|
92
|
+
siteHtml = fpath.join(clientFolder, "site.html");
|
|
93
|
+
await promises.rename(fpath.join(clientFolder, "src", "site.html"), siteHtml);
|
|
94
|
+
await promises.rm(fpath.join(clientFolder, "src"), { recursive: true });
|
|
95
95
|
if (site.adapter.postbuild) await site.adapter.postbuild(site);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region src/run/prepareTemplate.ts
|
|
100
|
-
function prepareTemplate(template, clientScript) {
|
|
100
|
+
function prepareTemplate(template, clientScript, clientDevScript) {
|
|
101
101
|
let result = template;
|
|
102
102
|
let headStart = result.indexOf("</head>");
|
|
103
103
|
if (headStart === -1) throw new Error(`Couldn't find <head> end tag`);
|
|
@@ -107,6 +107,7 @@ function prepareTemplate(template, clientScript) {
|
|
|
107
107
|
let bodyEnd = result.indexOf("</div>", bodyStart);
|
|
108
108
|
if (bodyStart === -1 || bodyEnd === -1) throw new Error(`Couldn't find <div id="app"></div>`);
|
|
109
109
|
result = result.substring(0, bodyStart) + "%COMPONENT_BODY%" + result.substring(bodyEnd);
|
|
110
|
+
if (clientDevScript) result += `<script type="module" src="${clientDevScript}"><\/script>`;
|
|
110
111
|
result += `<script type="module" src="${clientScript}"><\/script>`;
|
|
111
112
|
return result;
|
|
112
113
|
}
|
|
@@ -124,7 +125,7 @@ async function runDev(site) {
|
|
|
124
125
|
config.appType = "custom";
|
|
125
126
|
config.plugins = [
|
|
126
127
|
manifest(site, true),
|
|
127
|
-
torpor(),
|
|
128
|
+
torpor({ dev: true }),
|
|
128
129
|
...site.plugins
|
|
129
130
|
];
|
|
130
131
|
config.optimizeDeps ??= {};
|
|
@@ -134,13 +135,14 @@ async function runDev(site) {
|
|
|
134
135
|
config.optimizeDeps.esbuildOptions.plugins ??= [];
|
|
135
136
|
config.optimizeDeps.esbuildOptions.plugins.push(estorpor());
|
|
136
137
|
const vite = await createServer(config);
|
|
137
|
-
const templateFile =
|
|
138
|
+
const templateFile = fpath.resolve(site.root, "src/site.html");
|
|
138
139
|
let template = await promises.readFile(templateFile, "utf-8");
|
|
139
140
|
template = await vite.transformIndexHtml("", template);
|
|
140
|
-
const siteFolder =
|
|
141
|
-
let clientScript =
|
|
142
|
-
let
|
|
143
|
-
|
|
141
|
+
const siteFolder = fpath.resolve(site.root, "./node_modules/@torpor/build/src/site/");
|
|
142
|
+
let clientScript = fpath.join(siteFolder, "clientEntry.ts");
|
|
143
|
+
let clientDevScript = fpath.join(siteFolder, "clientEntryDev.ts");
|
|
144
|
+
let serverScript = fpath.join(siteFolder, "serverEntry.ts");
|
|
145
|
+
template = prepareTemplate(template, clientScript, clientDevScript);
|
|
144
146
|
server.use(connectMiddleware(vite.middlewares));
|
|
145
147
|
server.add("*", async (ev) => {
|
|
146
148
|
try {
|
|
@@ -247,32 +249,32 @@ const types = {
|
|
|
247
249
|
//#region src/run/runPreview.ts
|
|
248
250
|
async function runPreview(site) {
|
|
249
251
|
await runBuild(site);
|
|
250
|
-
const distFolder =
|
|
251
|
-
const clientFolder =
|
|
252
|
-
const serverFolder =
|
|
253
|
-
let clientScript = (await promises.readdir(
|
|
252
|
+
const distFolder = fpath.resolve(site.root, "dist");
|
|
253
|
+
const clientFolder = fpath.join(distFolder, "client");
|
|
254
|
+
const serverFolder = fpath.join(distFolder, "server");
|
|
255
|
+
let clientScript = (await promises.readdir(fpath.join(clientFolder, "assets"))).find((f) => f.startsWith("clientEntry-"));
|
|
254
256
|
if (!clientScript) throw new Error("clientEntry.js not found");
|
|
255
257
|
clientScript = `/assets/${clientScript}`;
|
|
256
|
-
let siteHtml =
|
|
258
|
+
let siteHtml = fpath.join(clientFolder, "site.html");
|
|
257
259
|
let template = await promises.readFile(siteHtml, "utf-8");
|
|
258
260
|
template = prepareTemplate(template, clientScript);
|
|
259
261
|
const server = new Server();
|
|
260
262
|
server.add("/assets/*", async (ev) => {
|
|
261
263
|
try {
|
|
262
264
|
const url = new URL(ev.request.url);
|
|
263
|
-
const file =
|
|
265
|
+
const file = fpath.join(site.root, "dist", "client", url.pathname);
|
|
264
266
|
if (existsSync(file)) {
|
|
265
267
|
const body = bufferToArrayBuffer(await promises.readFile(file));
|
|
266
268
|
return new Response(body, {
|
|
267
269
|
status: 200,
|
|
268
|
-
headers: { "Content-Type": contentType(
|
|
270
|
+
headers: { "Content-Type": contentType(fpath.extname(file)) }
|
|
269
271
|
});
|
|
270
272
|
}
|
|
271
273
|
} catch (e) {
|
|
272
274
|
return serverError(e);
|
|
273
275
|
}
|
|
274
276
|
});
|
|
275
|
-
const serverScript =
|
|
277
|
+
const serverScript = fpath.resolve(serverFolder, "serverEntry.js");
|
|
276
278
|
server.add("*", async (ev) => {
|
|
277
279
|
try {
|
|
278
280
|
const { load } = await import(serverScript);
|
|
@@ -296,13 +298,12 @@ function bufferToArrayBuffer(buffer) {
|
|
|
296
298
|
async function run(folder, mode) {
|
|
297
299
|
let configFile = "";
|
|
298
300
|
let deleteConfigFile = false;
|
|
299
|
-
const jsConfigFile =
|
|
300
|
-
const tsConfigFile =
|
|
301
|
+
const jsConfigFile = fpath.join(folder, "site.config.js");
|
|
302
|
+
const tsConfigFile = fpath.join(folder, "site.config.ts");
|
|
301
303
|
if (fs.existsSync(jsConfigFile)) configFile = jsConfigFile;
|
|
302
304
|
else if (fs.existsSync(tsConfigFile)) {
|
|
303
|
-
configFile =
|
|
304
|
-
let
|
|
305
|
-
let transformed = await transformWithEsbuild(source, tsConfigFile, { loader: "ts" });
|
|
305
|
+
configFile = fpath.join(folder, "site.config.temp.js");
|
|
306
|
+
let transformed = await transformWithEsbuild(fs.readFileSync(tsConfigFile, "utf-8"), tsConfigFile, { loader: "ts" });
|
|
306
307
|
fs.writeFileSync(configFile, transformed.code);
|
|
307
308
|
deleteConfigFile = true;
|
|
308
309
|
} else throw new Error("site.config file not found");
|
|
@@ -327,5 +328,5 @@ async function run(folder, mode) {
|
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
//#endregion
|
|
330
|
-
export {
|
|
331
|
-
//# sourceMappingURL=run-
|
|
331
|
+
export { runBuild as i, runPreview as n, runDev as r, run as t };
|
|
332
|
+
//# sourceMappingURL=run-CaFHeN6K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-CaFHeN6K.js","names":["path","path","fs","createViteServer","path","fs","e: any","types: Record<string, string>","path","fs","e: any","path"],"sources":["../src/site/manifest.ts","../src/run/runBuild.ts","../src/run/prepareTemplate.ts","../src/run/runDev.ts","../src/server/contentType.ts","../src/run/runPreview.ts","../src/run/run.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { Plugin } from \"vite\";\nimport Site from \"./Site\";\n\nconst moduleId = \"@torpor/build/manifest\";\n\n/**\n * A Vite plugin that provides information about the app to both clientEntry and\n * serverEntry.\n */\nexport default function manifest(site: Site, server = false): Plugin {\n\treturn {\n\t\tname: \"torpor-manifest\",\n\t\tresolveId: {\n\t\t\torder: \"pre\",\n\t\t\thandler(id) {\n\t\t\t\tif (id === moduleId) {\n\t\t\t\t\treturn id;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\t// @ts-ignore\n\t\tload(id, viteOptions) {\n\t\t\tif (id === moduleId) {\n\t\t\t\tlet serverRequest = server && !!viteOptions?.ssr;\n\t\t\t\treturn `\n${!serverRequest ? \"const load = { default: { load: true } };\" : \"\"}\nexport default {\n routes: [\n ${site.routes\n\t\t\t.map((r) => {\n\t\t\t\tif (serverRequest || !/server\\.(ts|js)$/.test(r.file)) {\n\t\t\t\t\treturn `{ path: \"${r.path}\", type: ${r.type}, endPoint: ${serverRequest || !/server\\.(ts|js)$/.test(r.file) ? `() => import(/* @vite-ignore */ \"${path.join(site.root, r.file)}\")` : \"undefined\"} }`;\n\t\t\t\t} else {\n\t\t\t\t\t// On the client, for a server route, we need to check\n\t\t\t\t\t// whether there's a load function and set a dummy endPoint\n\t\t\t\t\t// if so. The correct endpoint will be hit in clientEntry\n\t\t\t\t\t// HACK: Should do this better than checking for `load:` in source...\n\t\t\t\t\tconst haveLoad = readFileSync(path.join(site.root, r.file)).includes(\"load:\");\n\t\t\t\t\treturn `{ path: \"${r.path}\", type: ${r.type}, endPoint: ${haveLoad ? \"() => load\" : \"undefined\"} }`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.join(\",\\n \")}\n ],\n};\n`;\n\t\t\t}\n\t\t},\n\t};\n}\n","import torpor from \"@torpor/unplugin/vite\";\nimport { existsSync, promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { build, defineConfig } from \"vite\";\nimport Site from \"../site/Site\";\nimport manifest from \"../site/manifest.ts\";\n\n// TODO: Don't cache index.html in dev?\n// TODO: Multiple hook.server locations\n// TODO: Don't reload layouts during client routing\n// TODO: Call the correct +page and +server routes when in the same folder\n\nexport default async function runBuild(site: Site): Promise<void> {\n\t// Delete the dist folder if it exists\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tif (existsSync(distFolder)) {\n\t\tawait fs.rm(distFolder, { recursive: true });\n\t}\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\n\t// HOOK: Prebuild\n\tif (site.adapter.prebuild) {\n\t\tawait site.adapter.prebuild(site);\n\t}\n\n\t// TODO: From a setting\n\tlet siteHtml = path.resolve(site.root, \"src/site.html\");\n\n\tconst siteFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/site/\");\n\tlet clientScript = path.join(siteFolder, \"clientEntry.ts\");\n\tlet serverScript = path.join(siteFolder, \"serverEntry.ts\");\n\n\t// Build the client assets, including site.html and the route files\n\t// EXCLUDING anything with `server.js` in the name\n\tconst clientConfig = structuredClone(site.viteConfig ?? {});\n\tclientConfig.plugins = [manifest(site), torpor(), ...site.plugins];\n\tclientConfig.build ??= {};\n\tclientConfig.build.outDir = clientFolder;\n\tclientConfig.build.rollupOptions ??= {};\n\tclientConfig.build.rollupOptions.input = [\n\t\tsiteHtml,\n\t\tclientScript,\n\t\t...site.routes\n\t\t\t.filter((r) => !/server\\.(ts|js)$/.test(r.file))\n\t\t\t.map((r) => path.resolve(site.root, r.file)),\n\t\t...site.inputs.filter((f) => !/server\\.(ts|js)$/.test(f)),\n\t];\n\tclientConfig.build.ssrManifest = true;\n\tawait build(defineConfig(clientConfig));\n\n\t// Build the server assets, including the server entry script and the route\n\t// files\n\tconst serverConfig = structuredClone(site.viteConfig ?? {});\n\tserverConfig.plugins = [manifest(site, true), torpor(), ...site.plugins];\n\tserverConfig.build ??= {};\n\tserverConfig.build.outDir = serverFolder;\n\tserverConfig.build.rollupOptions ??= {};\n\tserverConfig.build.rollupOptions.input = [\n\t\tserverScript,\n\t\t...site.routes.map((r) => path.resolve(site.root, r.file)),\n\t\t...site.inputs,\n\t];\n\tserverConfig.build.ssr = serverScript;\n\tawait build(defineConfig(serverConfig));\n\n\t// Move the site.html file into /client\n\t// HACK: Should do this in Rollup if possible?\n\tsiteHtml = path.join(clientFolder, \"site.html\");\n\tawait fs.rename(path.join(clientFolder, \"src\", \"site.html\"), siteHtml);\n\tawait fs.rm(path.join(clientFolder, \"src\"), { recursive: true });\n\n\t// HOOK: Postbuild\n\tif (site.adapter.postbuild) {\n\t\tawait site.adapter.postbuild(site);\n\t}\n}\n","export default function prepareTemplate(\n\ttemplate: string,\n\tclientScript: string,\n\tclientDevScript?: string,\n): string {\n\tlet result = template;\n\n\t// Put %COMPONENT_HEAD% before </head>\n\t// This is where styles will go\n\tlet headStart = result.indexOf(\"</head>\");\n\tif (headStart === -1) {\n\t\tthrow new Error(`Couldn't find <head> end tag`);\n\t}\n\tresult = result.substring(0, headStart) + \"%COMPONENT_HEAD%\" + result.substring(headStart);\n\n\t// Put %COMPONENT_BODY% inside <div id=\"app\"></div>\n\t// This is where the component's HTML will go\n\tlet bodyStart = regexIndexOf(result, /<div\\s+id=(\"app\"|'app'|app)\\s+/);\n\tbodyStart = result.indexOf(\">\", bodyStart) + 1;\n\tlet bodyEnd = result.indexOf(\"</div>\", bodyStart);\n\tif (bodyStart === -1 || bodyEnd === -1) {\n\t\tthrow new Error(`Couldn't find <div id=\"app\"></div>`);\n\t}\n\tresult = result.substring(0, bodyStart) + \"%COMPONENT_BODY%\" + result.substring(bodyEnd);\n\n\t// Add the clientEntry script at the very end, for hydrating and navigating\n\tif (clientDevScript) {\n\t\tresult += `<script type=\"module\" src=\"${clientDevScript}\"></script>`;\n\t}\n\tresult += `<script type=\"module\" src=\"${clientScript}\"></script>`;\n\n\treturn result;\n}\n\n// From https://stackoverflow.com/a/274094\nfunction regexIndexOf(string: string, regex: RegExp, position?: number) {\n\tvar indexOf = string.substring(position || 0).search(regex);\n\treturn indexOf >= 0 ? indexOf + (position || 0) : indexOf;\n}\n","import estorpor from \"@torpor/unplugin/esbuild\";\nimport torpor from \"@torpor/unplugin/vite\";\nimport { configDotenv } from \"dotenv\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { createServer as createViteServer } from \"vite\";\nimport { serverError } from \"../response.ts\";\nimport Server from \"../server/Server.ts\";\nimport connectMiddleware from \"../server/connect/connectMiddleware.ts\";\nimport Site from \"../site/Site.ts\";\nimport manifest from \"../site/manifest.ts\";\nimport prepareTemplate from \"./prepareTemplate.ts\";\n\nexport default async function runDev(site: Site): Promise<void> {\n\tconst server = new Server();\n\n\t// Create the Vite server in middleware mode and configure the app type as\n\t// \"custom\", disabling Vite's own HTML serving logic so the parent server\n\t// can take control\n\tconst config = structuredClone(site.viteConfig ?? {});\n\tconfig.server = { middlewareMode: true };\n\tconfig.appType = \"custom\";\n\tconfig.plugins = [manifest(site, true), torpor({ dev: true }), ...site.plugins];\n\n\t// HACK: To be able to import `.torp` files from barrel files in\n\t// node_modules, we need to add their libraries to `ssr.noExternal` in\n\t// site.config.ts, and let esbuild know how to compile them here\n\tconfig.optimizeDeps ??= {};\n\tconfig.optimizeDeps.extensions ??= [];\n\tconfig.optimizeDeps.extensions.push(\".torp\");\n\tconfig.optimizeDeps.esbuildOptions ??= {};\n\tconfig.optimizeDeps.esbuildOptions.plugins ??= [];\n\tconfig.optimizeDeps.esbuildOptions.plugins.push(estorpor());\n\n\tconst vite = await createViteServer(config);\n\n\t// Read site.html\n\t// It's called site.html because @torpor/build builds the site (html, routes\n\t// etc) while the user builds the app (components etc)\n\tconst templateFile = path.resolve(site.root, \"src/site.html\");\n\tlet template = await fs.readFile(templateFile, \"utf-8\");\n\n\t// Apply Vite HTML transforms. This injects the Vite HMR client, and also\n\t// applies HTML transforms from Vite plugins. Note that we only support a\n\t// universal transform, not individual transforms for each route\n\ttemplate = await vite.transformIndexHtml(\"\", template);\n\n\tconst siteFolder = path.resolve(site.root, \"./node_modules/@torpor/build/src/site/\");\n\tlet clientScript = path.join(siteFolder, \"clientEntry.ts\");\n\tlet clientDevScript = path.join(siteFolder, \"clientEntryDev.ts\");\n\tlet serverScript = path.join(siteFolder, \"serverEntry.ts\");\n\n\t// Prepare site.html so that we can just splice components into it\n\ttemplate = prepareTemplate(template, clientScript, clientDevScript);\n\n\t// Use Vite's Connect instance as middleware. We need to wrap it with\n\t// createMiddlewareHandler that converts Connect middleware to\n\t// Request/Response web handlers\n\tserver.use(connectMiddleware(vite.middlewares));\n\n\t// Every request (GET, POST, etc) goes through loadEndPoint\n\tserver.add(\"*\", async (ev) => {\n\t\ttry {\n\t\t\t// Load the server entry. ssrLoadModule automatically transforms ESM\n\t\t\t// source code to be usable in Node.js. No bundling is required, and\n\t\t\t// it provides efficient invalidation similar to HMR\n\t\t\tconst { load } = await vite.ssrLoadModule(serverScript);\n\n\t\t\t// Render the app HTML (or fetch server data etc) via serverEntry's\n\t\t\t// exported `load` function\n\t\t\treturn await load(ev, template);\n\t\t} catch (e: any) {\n\t\t\t// If an error is caught, let Vite fix the stack trace so it maps\n\t\t\t// back to your actual source code\n\t\t\tvite.ssrFixStacktrace(e);\n\t\t\treturn serverError(e);\n\t\t}\n\t});\n\n\t// Load environment variables from a `.env` file, with defaults if not set\n\tconfigDotenv();\n\n\tprocess.env.PROTOCOL ??= \"http:\";\n\tprocess.env.HOST ??= \"localhost\";\n\tprocess.env.PORT ??= \"7059\";\n\n\t// Serve the site\n\tsite.adapter.serve(server, site);\n}\n","// From https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types\n\nexport default function contentType(extension: string): string {\n\treturn types[extension] || \"application/octet-stream\";\n}\n\nconst types: Record<string, string> = {\n\t\".aac\": \"audio/aac\",\n\t\".abw\": \"application/x-abiword\",\n\t\".apng\": \"image/apng\",\n\t\".arc\": \"application/x-freearc\",\n\t\".avif\": \"image/avif\",\n\t\".avi\": \"video/x-msvideo\",\n\t\".azw\": \"application/vnd.amazon.ebook\",\n\t\".bin\": \"application/octet-stream\",\n\t\".bmp\": \"image/bmp\",\n\t\".bz\": \"application/x-bzip\",\n\t\".bz2\": \"application/x-bzip2\",\n\t\".cda\": \"application/x-cdf\",\n\t\".csh\": \"application/x-csh\",\n\t\".css\": \"text/css\",\n\t\".csv\": \"text/csv\",\n\t\".doc\": \"application/msword\",\n\t\".docx\": \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n\t\".eot\": \"application/vnd.ms-fontobject\",\n\t\".epub\": \"application/epub+zip\",\n\t\".gz\": \"application/gzip\",\n\t\".gif\": \"image/gif\",\n\t\".htm\": \"text/html\",\n\t\".html\": \"text/html\",\n\t\".ico\": \"image/vnd.microsoft.icon\",\n\t\".ics\": \"text/calendar\",\n\t\".jar\": \"application/java-archive\",\n\t\".jpeg\": \"image/jpeg\",\n\t\".jpg\": \"image/jpeg\",\n\t\".js\": \"text/javascript\",\n\t\".json\": \"application/json\",\n\t\".jsonld\": \"application/ld+json\",\n\t\".mid\": \"audio/midi\",\n\t\".midi\": \"audio/midi\",\n\t\".mjs\": \"text/javascript\",\n\t\".mp3\": \"audio/mpeg\",\n\t\".mp4\": \"video/mp4\",\n\t\".mpeg\": \"video/mpeg\",\n\t\".mpkg\": \"application/vnd.apple.installer+xml\",\n\t\".odp\": \"application/vnd.oasis.opendocument.presentation\",\n\t\".ods\": \"application/vnd.oasis.opendocument.spreadsheet\",\n\t\".odt\": \"application/vnd.oasis.opendocument.text\",\n\t\".oga\": \"audio/ogg\",\n\t\".ogv\": \"video/ogg\",\n\t\".ogx\": \"application/ogg\",\n\t\".opus\": \"audio/ogg\",\n\t\".otf\": \"font/otf\",\n\t\".png\": \"image/png\",\n\t\".pdf\": \"application/pdf\",\n\t\".php\": \"application/x-httpd-php\",\n\t\".ppt\": \"application/vnd.ms-powerpoint\",\n\t\".pptx\": \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n\t\".rar\": \"application/vnd.rar\",\n\t\".rtf\": \"application/rtf\",\n\t\".sh\": \"application/x-sh\",\n\t\".svg\": \"image/svg+xml\",\n\t\".tar\": \"application/x-tar\",\n\t\".tif\": \"image/tiff\",\n\t\".tiff\": \"image/tiff\",\n\t\".ts\": \"video/mp2t\",\n\t\".ttf\": \"font/ttf\",\n\t\".txt\": \"text/plain\",\n\t\".vsd\": \"application/vnd.visio\",\n\t\".wav\": \"audio/wav\",\n\t\".weba\": \"audio/webm\",\n\t\".webm\": \"video/webm\",\n\t\".webp\": \"image/webp\",\n\t\".woff\": \"font/woff\",\n\t\".woff2\": \"font/woff2\",\n\t\".xhtml\": \"application/xhtml+xml\",\n\t\".xls\": \"application/vnd.ms-excel\",\n\t\".xlsx\": \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n\t\".xml\": \"application/xml\",\n\t\".xul\": \"application/vnd.mozilla.xul+xml\",\n\t\".zip\": \"application/zip\",\n\t\".3gp\": \"video/3gpp\",\n\t\".3g2\": \"video/3gpp2\",\n\t\".7z\": \"application/x-7z-compressed\",\n};\n","import { configDotenv } from \"dotenv\";\nimport { existsSync, promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { serverError } from \"../response.ts\";\nimport Server from \"../server/Server.ts\";\nimport contentType from \"../server/contentType.ts\";\nimport Site from \"../site/Site\";\nimport prepareTemplate from \"./prepareTemplate.ts\";\nimport runBuild from \"./runBuild\";\n\nexport default async function runPreview(site: Site): Promise<void> {\n\t// Build the site\n\tawait runBuild(site);\n\n\tconst distFolder = path.resolve(site.root, \"dist\");\n\tconst clientFolder = path.join(distFolder, \"client\");\n\tconst serverFolder = path.join(distFolder, \"server\");\n\n\t// Find the client script file in /assets\n\tlet clientScript = (await fs.readdir(path.join(clientFolder, \"assets\"))).find((f) =>\n\t\tf.startsWith(\"clientEntry-\"),\n\t);\n\tif (!clientScript) {\n\t\tthrow new Error(\"clientEntry.js not found\");\n\t}\n\tclientScript = `/assets/${clientScript}`;\n\n\t// Read site.html\n\t// It's called site.html because @torpor/build builds the site (html, routes\n\t// etc) while the user builds the app (components etc)\n\tlet siteHtml = path.join(clientFolder, \"site.html\");\n\tlet template = await fs.readFile(siteHtml, \"utf-8\");\n\n\t// Prepare site.html so that we can just splice components into it\n\ttemplate = prepareTemplate(template, clientScript);\n\n\t// Configure the server\n\tconst server = new Server();\n\n\t// Serve dist/client/assets statically\n\tserver.add(\"/assets/*\", async (ev) => {\n\t\ttry {\n\t\t\tconst url = new URL(ev.request.url);\n\t\t\tconst file = path.join(site.root, \"dist\", \"client\", url.pathname);\n\t\t\tif (existsSync(file)) {\n\t\t\t\t// TODO: Stream the data?\n\t\t\t\tconst body = bufferToArrayBuffer(await fs.readFile(file));\n\t\t\t\treturn new Response(body, {\n\t\t\t\t\tstatus: 200,\n\t\t\t\t\theaders: {\n\t\t\t\t\t\t\"Content-Type\": contentType(path.extname(file)),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (e: any) {\n\t\t\treturn serverError(e);\n\t\t}\n\t});\n\n\t// Every request (GET, POST, etc) goes through loadEndPoint\n\tconst serverScript = path.resolve(serverFolder, \"serverEntry.js\");\n\tserver.add(\"*\", async (ev) => {\n\t\ttry {\n\t\t\t// Load the server entry\n\t\t\tconst { load } = await import(serverScript);\n\n\t\t\t// Render the app HTML (or fetch server data etc) via serverEntry's\n\t\t\t// exported `load` function\n\t\t\treturn await load(ev, template);\n\t\t} catch (e: any) {\n\t\t\treturn serverError(e);\n\t\t}\n\t});\n\n\t// Load environment variables from a `.env` file, with defaults if not set\n\tconfigDotenv();\n\n\tprocess.env.PROTOCOL ??= \"http:\";\n\tprocess.env.HOST ??= \"localhost\";\n\tprocess.env.PORT ??= \"7059\";\n\n\t// Serve the site\n\tsite.adapter.serve(server, site);\n}\n\n// From https://stackoverflow.com/a/79345620\n// No idea why it is needed\nfunction bufferToArrayBuffer(buffer: Buffer): ArrayBuffer {\n\treturn buffer.buffer.slice(\n\t\tbuffer.byteOffset,\n\t\tbuffer.byteOffset + buffer.byteLength,\n\t) as ArrayBuffer;\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { transformWithEsbuild } from \"vite\";\nimport Site from \"../site/Site\";\nimport runBuild from \"./runBuild\";\nimport runDev from \"./runDev\";\nimport runPreview from \"./runPreview\";\n\nexport default async function run(\n\tfolder: string,\n\tmode: \"dev\" | \"build\" | \"preview\",\n): Promise<void> {\n\t// Look for and load a site.config.js/ts file in the working directory\n\tlet configFile = \"\";\n\tlet deleteConfigFile = false;\n\tconst jsConfigFile = path.join(folder, \"site.config.js\");\n\tconst tsConfigFile = path.join(folder, \"site.config.ts\");\n\tif (fs.existsSync(jsConfigFile)) {\n\t\t// If it's JS, we can just import it straight up\n\t\tconfigFile = jsConfigFile;\n\t} else if (fs.existsSync(tsConfigFile)) {\n\t\t// If it's TS, we need to convert it to JS\n\t\t// TODO: Put the generated file somewhere better (dist?)\n\t\tconfigFile = path.join(folder, \"site.config.temp.js\");\n\t\tlet source = fs.readFileSync(tsConfigFile, \"utf-8\");\n\t\tlet transformed = await transformWithEsbuild(source, tsConfigFile, {\n\t\t\tloader: \"ts\",\n\t\t});\n\t\tfs.writeFileSync(configFile, transformed.code);\n\t\tdeleteConfigFile = true;\n\t} else {\n\t\tthrow new Error(\"site.config file not found\");\n\t}\n\n\tconst site = (await import(configFile)).default as Site;\n\tif (!site || !site.root || !site.routes) {\n\t\tthrow new Error(\"Invalid site in config file\");\n\t}\n\tif (deleteConfigFile) {\n\t\tfs.rmSync(configFile);\n\t}\n\n\tswitch (mode) {\n\t\tcase \"dev\": {\n\t\t\tawait runDev(site);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"build\": {\n\t\t\tawait runBuild(site);\n\t\t\tbreak;\n\t\t}\n\t\tcase \"preview\": {\n\t\t\tawait runPreview(site);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tconsole.log(\"No mode passed, running in dev\");\n\t\t\tawait runDev(site);\n\t\t\tbreak;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;AAKA,MAAM,WAAW;;;;;AAMjB,SAAwB,SAAS,MAAY,SAAS,OAAe;AACpE,QAAO;EACN,MAAM;EACN,WAAW;GACV,OAAO;GACP,QAAQ,IAAI;AACX,QAAI,OAAO,SACV,QAAO;;GAGT;EAED,KAAK,IAAI,aAAa;AACrB,OAAI,OAAO,UAAU;IACpB,IAAI,gBAAgB,UAAU,CAAC,CAAC,aAAa;AAC7C,WAAO;EACT,CAAC,gBAAgB,8CAA8C,GAAG;;;MAG9D,KAAK,OACP,KAAK,MAAM;AACX,SAAI,iBAAiB,CAAC,mBAAmB,KAAK,EAAE,KAAK,CACpD,QAAO,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,iBAAiB,CAAC,mBAAmB,KAAK,EAAE,KAAK,GAAG,oCAAoCA,MAAK,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,MAAM,YAAY;UAC3L;MAKN,MAAM,WAAW,aAAaA,MAAK,KAAK,KAAK,MAAM,EAAE,KAAK,CAAC,CAAC,SAAS,QAAQ;AAC7E,aAAO,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,WAAW,eAAe,YAAY;;MAEhG,CACD,KAAK,UAAU,CAAC;;;;;;EAMlB;;;;;ACrCF,eAA8B,SAAS,MAA2B;CAEjE,MAAM,aAAaC,MAAK,QAAQ,KAAK,MAAM,OAAO;AAClD,KAAI,WAAW,WAAW,CACzB,OAAMC,SAAG,GAAG,YAAY,EAAE,WAAW,MAAM,CAAC;CAE7C,MAAM,eAAeD,MAAK,KAAK,YAAY,SAAS;CACpD,MAAM,eAAeA,MAAK,KAAK,YA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MAAM,qBADX,GAAG,aAAa,cAAc,QAAQ,EACE,cAAc,EAClE,QAAQ,MACR,CAAC;AACF,KAAG,cAAc,YAAY,YAAY,KAAK;AAC9C,qBAAmB;OAEnB,OAAM,IAAI,MAAM,6BAA6B;CAG9C,MAAM,QAAQ,MAAM,OAAO,aAAa;AACxC,KAAI,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,KAAK,OAChC,OAAM,IAAI,MAAM,8BAA8B;AAE/C,KAAI,iBACH,IAAG,OAAO,WAAW;AAGtB,SAAQ,MAAR;EACC,KAAK;AACJ,SAAM,OAAO,KAAK;AAClB;EAED,KAAK;AACJ,SAAM,SAAS,KAAK;AACpB;EAED,KAAK;AACJ,SAAM,WAAW,KAAK;AACtB;EAED;AACC,WAAQ,IAAI,iCAAiC;AAC7C,SAAM,OAAO,KAAK;AAClB"}
|
package/dist/run.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./Server-
|
|
2
|
-
import { Site } from "./Site-
|
|
1
|
+
import "./Server-DL9neaq0.js";
|
|
2
|
+
import { t as Site } from "./Site-B8TxSzPk.js";
|
|
3
3
|
|
|
4
4
|
//#region src/run/run.d.ts
|
|
5
5
|
declare function run(folder: string, mode: "dev" | "build" | "preview"): Promise<void>;
|
package/dist/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./pathToRegex-
|
|
2
|
-
import "./seeOther-
|
|
3
|
-
import "./response-
|
|
4
|
-
import {
|
|
5
|
-
import "./ServerEvent-
|
|
6
|
-
import "./connectMiddleware-
|
|
1
|
+
import "./pathToRegex-BTPkBIYJ.js";
|
|
2
|
+
import "./seeOther-C-36lhS5.js";
|
|
3
|
+
import "./response-KnPcsvtU.js";
|
|
4
|
+
import { i as runBuild, n as runPreview, r as runDev, t as run } from "./run-CaFHeN6K.js";
|
|
5
|
+
import "./ServerEvent-Dnk2FIKQ.js";
|
|
6
|
+
import "./connectMiddleware-PBcWWRr-.js";
|
|
7
7
|
|
|
8
8
|
export { run, runBuild, runDev, runPreview };
|
|
@@ -106,5 +106,5 @@ function seeOther(location) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
//#endregion
|
|
109
|
-
export {
|
|
110
|
-
//# sourceMappingURL=seeOther-
|
|
109
|
+
export { response as a, transfer as i, ok as n, notFound as r, seeOther as t };
|
|
110
|
+
//# sourceMappingURL=seeOther-C-36lhS5.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seeOther-
|
|
1
|
+
{"version":3,"file":"seeOther-C-36lhS5.js","names":["headers: Record<string, string> | undefined"],"sources":["../src/response/response.ts","../src/response/transfer.ts","../src/response/notFound.ts","../src/response/ok.ts","../src/response/seeOther.ts"],"sourcesContent":["/**\n * Creates a response with the supplied status code and optional body.\n *\n * If the body is an object, it will be converted to JSON and the content-type\n * header set to \"application/json\". Otherwise, if the body is a string, the\n * content-type header will be set to \"text/plain\".\n */\nexport default function response(status: number, body?: object | string): Response {\n\tlet headers: Record<string, string> | undefined = undefined;\n\tif (body) {\n\t\tif (typeof body === \"object\") {\n\t\t\theaders = { \"content-type\": \"application/json\" };\n\t\t\tbody = JSON.stringify(body);\n\t\t} else {\n\t\t\theaders = { \"content-type\": \"text/plain\" };\n\t\t}\n\t}\n\treturn new Response(body, {\n\t\tstatus,\n\t\theaders,\n\t});\n}\n","/**\n * Creates a redirect response with the supplied status code.\n */\nexport default function transfer(\n\tstatus: 300 | 301 | 302 | 303 | 304 | 307 | 308,\n\tlocation: string,\n): Response {\n\treturn new Response(null, {\n\t\tstatus,\n\t\theaders: {\n\t\t\tlocation,\n\t\t},\n\t});\n}\n","import response from \"./response\";\n\n/**\n * 404 Not Found\n *\n * The HTTP 404 Not Found client error response status code indicates that the\n * server cannot find the requested resource. Links that lead to a 404 page are\n * often called broken or dead links and can be subject to link rot.\n *\n * A 404 status code only indicates that the resource is missing without\n * indicating if this is temporary or permanent. If a resource is permanently\n * removed, servers should send the 410 Gone status instead.\n *\n * 404 errors on a website can lead to a poor user experience for your visitors,\n * so the number of broken links (internal and external) should be minimized to\n * prevent frustration for readers. Common causes of 404 responses are mistyped\n * URLs or pages that are moved or deleted without redirection. For more\n * information, see the Redirections in HTTP guide.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404\n */\nexport default function notFound(body?: object | string): Response {\n\treturn response(404, body ?? \"Not found\");\n}\n","import response from \"./response\";\n\n/**\n * 200 OK\n *\n * The HTTP 200 OK successful response status code indicates that a request has\n * succeeded. A 200 OK response is cacheable by default.\n *\n * A 200 OK response has a different meaning and format depending on the HTTP\n * request method. Here's how they vary for different methods:\n *\n * - GET: A resource was retrieved by the server and included in the response\n * body.\n * - POST: An action succeeded; the response has a message body describing the\n * result.\n * - HEAD: Identical to GET, except there is no message body.\n * - TRACE: The response has a message body containing the request as received\n * by the server.\n *\n * Although possible, successful PUT or DELETE requests often do not result in a\n * 200 OK response. It is more common to see 201 Created if the resource is\n * uploaded or created for the first time, or 204 No Content upon successful\n * deletion of a resource.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200\n */\nexport default function ok(body?: object | string): Response {\n\treturn response(200, body);\n}\n","import transfer from \"./transfer\";\n\n/**\n * 303 See Other\n *\n * The HTTP 303 See Other redirection response status code indicates that the\n * browser should redirect to the URL in the Location header instead of\n * rendering the requested resource.\n *\n * This response code is often sent back as a result of PUT or POST methods so\n * the client may retrieve a confirmation, or view a representation of a\n * real-world object (see HTTP range-14). The method to retrieve the redirected\n * resource is always GET.\n *\n * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/303\n */\nexport default function seeOther(location: string): Response {\n\treturn transfer(303, location);\n}\n"],"mappings":";;;;;;;;AAOA,SAAwB,SAAS,QAAgB,MAAkC;CAClF,IAAIA,UAA8C;AAClD,KAAI,KACH,KAAI,OAAO,SAAS,UAAU;AAC7B,YAAU,EAAE,gBAAgB,oBAAoB;AAChD,SAAO,KAAK,UAAU,KAAK;OAE3B,WAAU,EAAE,gBAAgB,cAAc;AAG5C,QAAO,IAAI,SAAS,MAAM;EACzB;EACA;EACA,CAAC;;;;;;;;ACjBH,SAAwB,SACvB,QACA,UACW;AACX,QAAO,IAAI,SAAS,MAAM;EACzB;EACA,SAAS,EACR,UACA;EACD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;ACSH,SAAwB,SAAS,MAAkC;AAClE,QAAO,SAAS,KAAK,QAAQ,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACI1C,SAAwB,GAAG,MAAkC;AAC5D,QAAO,SAAS,KAAK,KAAK;;;;;;;;;;;;;;;;;;;ACX3B,SAAwB,SAAS,UAA4B;AAC5D,QAAO,SAAS,KAAK,SAAS"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CookieHelper, HeaderHelper, MiddlewareFunction,
|
|
1
|
+
import { a as CookieHelper, i as HeaderHelper, n as MiddlewareFunction, r as ServerEvent, t as Server } from "./Server-DL9neaq0.js";
|
|
2
2
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
3
|
|
|
4
4
|
//#region src/server/connect/connectMiddleware.d.ts
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server/connect/connectMiddleware.ts"],"sourcesContent":[],"mappings":";;;;;;;AACoC;;;;AAiBjC,iBAFqB,iBAAA,CAErB,OAAA,EADO,iBACP,GAD2B,wBAC3B,CAAA,EAAA,kBAAA;KAsDE,YAAA,
|
|
1
|
+
{"version":3,"file":"server.d.ts","names":[],"sources":["../src/server/connect/connectMiddleware.ts"],"sourcesContent":[],"mappings":";;;;;;;AACoC;;;;AAiBjC,iBAFqB,iBAAA,CAErB,OAAA,EADO,iBACP,GAD2B,wBAC3B,CAAA,EAAA,kBAAA;AAAA,KAsDE,YAAA,GAAA,CAAA,GAAA,CAAA,EAAA,OAAA,EAAA,GAAA,IAAA;AAAA,KACA,iBAAA,CACoB,wBAAA,eAAA,GAAkB,eAAlB,EAAkB,yBACjB,cADiB,GACA,cADA,CACjB,GAAA,CAAA,GAAA,EAChB,eADgB,EAAA,GAAA,EACM,gBADN,EAAA,IAAA,EAC8B,YAD9B,EAAA,GAAA,IAAA,GACsD,OADtD,CAAA,IAAA,CAAA;KAErB,wBAFsC,CACjC,wBAEe,eAFf,GAEiC,eAFjC,EAAsB,yBAGN,cAHM,GAGW,cAHX,CAAwB,GAAA,CAAA,GAAA,EAI9C,eAJ8C,EAAA,GAAA,EAIxB,gBAJwB,EAAA,IAAA,EAIA,YAJA,EAAA,GAAA,OAAA,GAI2B,OAJ3B,CAAA,OAAA,CAAA"}
|
package/dist/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./pathToRegex-
|
|
2
|
-
import {
|
|
3
|
-
import { Server, connectMiddleware } from "./connectMiddleware-
|
|
1
|
+
import "./pathToRegex-BTPkBIYJ.js";
|
|
2
|
+
import { n as HeaderHelper, r as CookieHelper, t as ServerEvent } from "./ServerEvent-Dnk2FIKQ.js";
|
|
3
|
+
import { n as Server, t as connectMiddleware } from "./connectMiddleware-PBcWWRr-.js";
|
|
4
4
|
|
|
5
5
|
export { CookieHelper, HeaderHelper, Server, ServerEvent, connectMiddleware };
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","names":["$page: PageState"],"sources":["../src/types/PageState.ts","../src/state/$page.ts"],"sourcesContent":[],"mappings":";UAAyB,SAAA;QAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"state.d.ts","names":["$page: PageState"],"sources":["../src/types/PageState.ts","../src/state/$page.ts"],"sourcesContent":[],"mappings":";UAAyB,SAAA;QAAA,EAAA,MAAA;OAEnB;SACE;;ICHmB,OAGrBA,EAAAA,MAAO;;;;;cAAPA,KDHmB,ECGZ,SDDP"}
|
package/dist/state.js
CHANGED
package/dist/test.d.ts
CHANGED
package/dist/test.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "./pathToRegex-
|
|
2
|
-
import {
|
|
3
|
-
import { $page_default } from "./_page-
|
|
4
|
-
import {
|
|
5
|
-
import { ServerEvent } from "./ServerEvent-
|
|
6
|
-
import
|
|
1
|
+
import "./pathToRegex-BTPkBIYJ.js";
|
|
2
|
+
import { a as LAYOUT_SERVER_ROUTE, c as SERVER_ROUTE, i as LAYOUT_ROUTE, l as Router, n as HOOK_ROUTE, o as PAGE_ROUTE, r as HOOK_SERVER_ROUTE, s as PAGE_SERVER_ROUTE } from "./RouteType-VOBjKJ8I.js";
|
|
3
|
+
import { t as $page_default } from "./_page-B8QZDML_.js";
|
|
4
|
+
import { n as ok, r as notFound, t as seeOther } from "./seeOther-C-36lhS5.js";
|
|
5
|
+
import { t as ServerEvent } from "./ServerEvent-Dnk2FIKQ.js";
|
|
6
|
+
import fpath from "node:path";
|
|
7
7
|
|
|
8
8
|
//#region src/test/runTest.ts
|
|
9
9
|
/**
|
|
@@ -15,26 +15,23 @@ import path from "node:path";
|
|
|
15
15
|
*/
|
|
16
16
|
async function runTest(site, route, ev) {
|
|
17
17
|
if (!route.startsWith("/")) route += "/";
|
|
18
|
-
if (!ev) {
|
|
19
|
-
const req = new Request(`http://localhost${route}`);
|
|
20
|
-
ev = new ServerEvent(req);
|
|
21
|
-
}
|
|
18
|
+
if (!ev) ev = new ServerEvent(new Request(`http://localhost${route}`));
|
|
22
19
|
const router = new Router();
|
|
23
20
|
router.addPages(site.routes.map((r) => ({
|
|
24
21
|
path: r.path,
|
|
25
22
|
type: r.type,
|
|
26
23
|
endPoint: () => import(
|
|
27
24
|
/* @vite-ignore */
|
|
28
|
-
|
|
25
|
+
fpath.join(site.root, r.file)
|
|
29
26
|
)
|
|
30
27
|
})));
|
|
31
28
|
return await load(router, ev, "%COMPONENT_BODY%");
|
|
32
29
|
}
|
|
33
30
|
async function load(router, ev, template) {
|
|
34
31
|
const url = new URL(ev.request.url);
|
|
35
|
-
const path
|
|
32
|
+
const path = url.pathname;
|
|
36
33
|
const query = url.searchParams;
|
|
37
|
-
const route = router.match(path
|
|
34
|
+
const route = router.match(path, query);
|
|
38
35
|
if (!route) return notFound();
|
|
39
36
|
$page_default.url = url;
|
|
40
37
|
const handler = route.handler;
|
|
@@ -49,10 +46,7 @@ async function load(router, ev, template) {
|
|
|
49
46
|
case LAYOUT_SERVER_ROUTE:
|
|
50
47
|
if (ev.request.method === "GET") return await loadData(ev, url, handler, "load", params);
|
|
51
48
|
break;
|
|
52
|
-
case SERVER_ROUTE:
|
|
53
|
-
const functionName = ev.request.method.toLowerCase().replace("delete", "del");
|
|
54
|
-
return await loadData(ev, url, handler, functionName, params);
|
|
55
|
-
}
|
|
49
|
+
case SERVER_ROUTE: return await loadData(ev, url, handler, ev.request.method.toLowerCase().replace("delete", "del"), params);
|
|
56
50
|
case HOOK_ROUTE:
|
|
57
51
|
case HOOK_SERVER_ROUTE: break;
|
|
58
52
|
}
|
|
@@ -82,8 +76,7 @@ async function loadView(ev, url, handler, params, template) {
|
|
|
82
76
|
let data = {};
|
|
83
77
|
if (handler.layouts) for (let layout of handler.layouts) {
|
|
84
78
|
const layoutEndPoint = (await layout.endPoint())?.default;
|
|
85
|
-
const
|
|
86
|
-
const layoutResponse = await loadClientAndServerData(url, params, serverParams, data, layoutEndPoint, layoutServerEndPoint);
|
|
79
|
+
const layoutResponse = await loadClientAndServerData(url, params, serverParams, data, layoutEndPoint, layout.serverEndPoint && (await layout.serverEndPoint())?.default);
|
|
87
80
|
if (layoutResponse?.ok === false) return layoutResponse;
|
|
88
81
|
}
|
|
89
82
|
let endPointResponse = await loadClientAndServerData(url, params, serverParams, data, clientEndPoint, serverEndPoint);
|