@torpor/build 0.1.24 → 0.1.26
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/{Site-DgXPSQoO.d.ts → Site-4tGiw2-I.d.ts} +23 -2
- package/dist/{Site-BeCLcGj_.d.cts → Site-BXX-S541.d.cts} +23 -2
- package/dist/bin/index.cjs +1 -1
- package/dist/bin/index.cjs.map +1 -1
- package/dist/bin/index.js +3 -3
- package/dist/{chunk-WMHM5RGZ.js → chunk-565UOT3F.js} +5 -2
- package/dist/chunk-565UOT3F.js.map +1 -0
- package/dist/{chunk-D6LHMH2C.js → chunk-B2UNTYN5.js} +8 -8
- package/dist/chunk-B2UNTYN5.js.map +1 -0
- package/dist/{chunk-65K3R3CP.js → chunk-PTVHEJZ5.js} +4 -2
- package/dist/{chunk-65K3R3CP.js.map → chunk-PTVHEJZ5.js.map} +1 -1
- package/dist/{chunk-LHRCEWBG.js → chunk-UCA7KIGG.js} +2 -2
- package/dist/{chunk-2QQN3D3K.js → chunk-WVXAN4IV.js} +2 -2
- package/dist/{chunk-2QQN3D3K.js.map → chunk-WVXAN4IV.js.map} +1 -1
- package/dist/index.cjs +64 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -10
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/response.cjs +7 -7
- package/dist/response.cjs.map +1 -1
- package/dist/response.js +2 -2
- package/dist/run.cjs +1 -1
- package/dist/run.cjs.map +1 -1
- package/dist/run.d.cts +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.js +3 -3
- package/dist/state.cjs +4 -1
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.cts +4 -0
- package/dist/state.d.ts +4 -0
- package/dist/state.js +1 -1
- package/dist/test.cjs +5 -2
- package/dist/test.cjs.map +1 -1
- package/dist/test.d.cts +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +3 -3
- package/package.json +4 -4
- package/src/response/badRequest.ts +1 -1
- package/src/response/forbidden.ts +1 -1
- package/src/response/methodNotAllowed.ts +1 -1
- package/src/response/notFound.ts +1 -1
- package/src/response/serverError.ts +1 -1
- package/src/response/unauthorized.ts +1 -1
- package/src/response/unprocessable.ts +1 -1
- package/src/site/Site.ts +82 -20
- package/src/site/clientEntry.ts +11 -4
- package/src/site/serverEntry.ts +42 -5
- package/src/state/$page.ts +4 -5
- package/src/state/Page.ts +8 -0
- package/src/types/RouteType.ts +12 -0
- package/dist/chunk-D6LHMH2C.js.map +0 -1
- package/dist/chunk-WMHM5RGZ.js.map +0 -1
- /package/dist/{chunk-LHRCEWBG.js.map → chunk-UCA7KIGG.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -36,8 +36,8 @@ __export(index_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/site/pathToRegex.ts
|
|
39
|
-
function pathToRegex(
|
|
40
|
-
const pattern =
|
|
39
|
+
function pathToRegex(path) {
|
|
40
|
+
const pattern = path.split("/").map((p) => {
|
|
41
41
|
return p.replace(/\[([^\/]+?)\]/, "(?<$1>[^\\/]+?)");
|
|
42
42
|
}).join("\\/").replaceAll("*", ".*") + // Ignore trailing slashes -- `/path` should be treated the same as `/path/`
|
|
43
43
|
"/*";
|
|
@@ -67,10 +67,10 @@ var Router = class {
|
|
|
67
67
|
return this;
|
|
68
68
|
}
|
|
69
69
|
// TODO: Allow calling with the endpoint itself, so that you can setup an app with no scaffold
|
|
70
|
-
addPage(
|
|
70
|
+
addPage(path, type, endPoint) {
|
|
71
71
|
this.routes.push(
|
|
72
|
-
new Route(
|
|
73
|
-
path
|
|
72
|
+
new Route(path, {
|
|
73
|
+
path,
|
|
74
74
|
type,
|
|
75
75
|
endPoint
|
|
76
76
|
})
|
|
@@ -87,9 +87,9 @@ var Router = class {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
*/
|
|
90
|
-
match(
|
|
90
|
+
match(path, query) {
|
|
91
91
|
for (let route of this.routes) {
|
|
92
|
-
let match =
|
|
92
|
+
let match = path.match(route.regex);
|
|
93
93
|
if (match) {
|
|
94
94
|
if (!route.handler.loaded) {
|
|
95
95
|
this.#loadHandler(route.handler, route.path);
|
|
@@ -101,16 +101,16 @@ var Router = class {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
console.log(`not found: '${
|
|
104
|
+
console.log(`not found: '${path}'`);
|
|
105
105
|
}
|
|
106
|
-
#loadHandler(handler,
|
|
107
|
-
handler.layouts = this.#findLayouts(
|
|
108
|
-
handler.serverEndPoint = this.#findServer(
|
|
109
|
-
handler.serverHook = this.#findServerHook(
|
|
106
|
+
#loadHandler(handler, path) {
|
|
107
|
+
handler.layouts = this.#findLayouts(path);
|
|
108
|
+
handler.serverEndPoint = this.#findServer(path);
|
|
109
|
+
handler.serverHook = this.#findServerHook(path);
|
|
110
110
|
}
|
|
111
|
-
#findLayouts(
|
|
111
|
+
#findLayouts(path) {
|
|
112
112
|
let layouts = [];
|
|
113
|
-
let parts =
|
|
113
|
+
let parts = path.replace(/\/~server$/, "").split("/");
|
|
114
114
|
let basePath = "";
|
|
115
115
|
for (let i = 0; i < parts.length; i++) {
|
|
116
116
|
if (i > 0) {
|
|
@@ -128,14 +128,14 @@ var Router = class {
|
|
|
128
128
|
}
|
|
129
129
|
return layouts.length ? layouts : void 0;
|
|
130
130
|
}
|
|
131
|
-
#findServer(
|
|
132
|
-
const serverPath =
|
|
131
|
+
#findServer(path) {
|
|
132
|
+
const serverPath = path.replace(/\/$/, "") + "/~server";
|
|
133
133
|
const serverRoute = this.routes.find((r) => r.path === serverPath);
|
|
134
134
|
return serverRoute && serverRoute.handler.endPoint;
|
|
135
135
|
}
|
|
136
|
-
#findServerHook(
|
|
136
|
+
#findServerHook(path) {
|
|
137
137
|
let serverHookPath = "/_hook/~server";
|
|
138
|
-
if (
|
|
138
|
+
if (path.startsWith("/api/")) {
|
|
139
139
|
serverHookPath = "/api" + serverHookPath;
|
|
140
140
|
}
|
|
141
141
|
const serverHookRoute = this.routes.find((r) => r.path === serverHookPath);
|
|
@@ -163,9 +163,9 @@ var Route = class {
|
|
|
163
163
|
path;
|
|
164
164
|
regex;
|
|
165
165
|
handler;
|
|
166
|
-
constructor(
|
|
167
|
-
this.path =
|
|
168
|
-
this.regex = pathToRegex(
|
|
166
|
+
constructor(path, handler) {
|
|
167
|
+
this.path = path;
|
|
168
|
+
this.regex = pathToRegex(path);
|
|
169
169
|
this.handler = handler;
|
|
170
170
|
}
|
|
171
171
|
};
|
|
@@ -183,6 +183,7 @@ var LAYOUT_ROUTE = 4;
|
|
|
183
183
|
var LAYOUT_SERVER_ROUTE = 5;
|
|
184
184
|
var HOOK_ROUTE = 6;
|
|
185
185
|
var HOOK_SERVER_ROUTE = 7;
|
|
186
|
+
var ERROR_ROUTE = 8;
|
|
186
187
|
|
|
187
188
|
// src/site/defaultAdapter.ts
|
|
188
189
|
var defaultAdapter = {
|
|
@@ -219,13 +220,16 @@ var Site = class {
|
|
|
219
220
|
constructor() {
|
|
220
221
|
this.root = process.cwd();
|
|
221
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Adds a folder of routes, based on the names of the files in the folder
|
|
225
|
+
* @param folder The folder containing the routes
|
|
226
|
+
*/
|
|
222
227
|
async addRouteFolder(folder) {
|
|
223
228
|
const routeFolder = import_node_path.default.join(this.root, folder);
|
|
224
229
|
const routeFiles = await import_node_fs.promises.readdir(routeFolder, { recursive: true });
|
|
225
230
|
for (let file of routeFiles) {
|
|
226
231
|
if (/^(\+|_).+(\.js|\.ts)$/.test(import_node_path.default.basename(file))) {
|
|
227
|
-
let routePath = file
|
|
228
|
-
routePath = routePath.length > 0 ? `/${routePath}` : "/";
|
|
232
|
+
let routePath = this.#routePath(file);
|
|
229
233
|
let type = this.#routeType(file);
|
|
230
234
|
file = import_node_path.default.relative(this.root, import_node_path.default.resolve(routeFolder, file));
|
|
231
235
|
this.routes.push({ path: routePath, file, type });
|
|
@@ -233,11 +237,23 @@ var Site = class {
|
|
|
233
237
|
}
|
|
234
238
|
this.#sortRoutes();
|
|
235
239
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
240
|
+
/**
|
|
241
|
+
* Adds a file route, which can have a standard name (e.g. +page.ts) or any
|
|
242
|
+
* name if you pass the type
|
|
243
|
+
* @param path The route path
|
|
244
|
+
* @param file The file
|
|
245
|
+
* @param type The file type (if the file name is non-standard)
|
|
246
|
+
*/
|
|
247
|
+
addRouteFile(path, file, type) {
|
|
248
|
+
let routePath = this.#routePath(import_node_path.default.join(path, type ?? import_node_path.default.basename(file)));
|
|
249
|
+
let routeType = type ? this.#routeTypeFromString(type) : this.#routeType(file);
|
|
250
|
+
this.routes.push({ path: routePath, file, type: routeType });
|
|
239
251
|
this.#sortRoutes();
|
|
240
252
|
}
|
|
253
|
+
#routePath(file) {
|
|
254
|
+
let routePath = file.replace(/^\//, "").replace(/(\.ts|\.js)$/, "").replace(/_hook.server$/, "_hook/~server").replace(/_layout.server$/, "_layout/~server").replace(/\+page.server$/, "~server").replace(/\+server$/, "").replace(/\+page$/, "").replace(/\/$/, "");
|
|
255
|
+
return routePath.length > 0 ? `/${routePath}` : "/";
|
|
256
|
+
}
|
|
241
257
|
#routeType(file) {
|
|
242
258
|
let routePath = file.replace(/^\//, "").replace(/(\.ts|\.js)$/, "");
|
|
243
259
|
if (routePath.endsWith("+page")) {
|
|
@@ -254,9 +270,31 @@ var Site = class {
|
|
|
254
270
|
return HOOK_ROUTE;
|
|
255
271
|
} else if (routePath.endsWith("_hook.server")) {
|
|
256
272
|
return HOOK_SERVER_ROUTE;
|
|
273
|
+
} else if (routePath.endsWith("_error")) {
|
|
274
|
+
return ERROR_ROUTE;
|
|
257
275
|
}
|
|
258
276
|
return -1;
|
|
259
277
|
}
|
|
278
|
+
#routeTypeFromString(type) {
|
|
279
|
+
switch (type) {
|
|
280
|
+
case "+page":
|
|
281
|
+
return PAGE_ROUTE;
|
|
282
|
+
case "+page.server":
|
|
283
|
+
return PAGE_SERVER_ROUTE;
|
|
284
|
+
case "+server":
|
|
285
|
+
return SERVER_ROUTE;
|
|
286
|
+
case "_layout":
|
|
287
|
+
return LAYOUT_ROUTE;
|
|
288
|
+
case "_layout.server":
|
|
289
|
+
return LAYOUT_SERVER_ROUTE;
|
|
290
|
+
case "_hook":
|
|
291
|
+
return HOOK_ROUTE;
|
|
292
|
+
case "_hook.server":
|
|
293
|
+
return HOOK_SERVER_ROUTE;
|
|
294
|
+
case "_error":
|
|
295
|
+
return ERROR_ROUTE;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
260
298
|
// TODO: You could make your site in a single file, like e.g. Hono...
|
|
261
299
|
//addPage(path: string, endPoint: PageEndPoint, serverEndPoint?: PageServerEndPoint) {}
|
|
262
300
|
//addEndPoint(path: string, endPoint: ServerEndPoint) {}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/site/pathToRegex.ts","../src/site/Router.ts","../src/site/Site.ts","../src/types/RouteType.ts","../src/site/defaultAdapter.ts"],"sourcesContent":["import Router from \"./site/Router\";\nimport Site from \"./site/Site\";\nimport type Adapter from \"./types/Adapter\";\nimport type PageEndPoint from \"./types/PageEndPoint\";\nimport type PageLoadEvent from \"./types/PageLoadEvent\";\nimport type PageServerAction from \"./types/PageServerAction\";\nimport type PageServerEndPoint from \"./types/PageServerEndPoint\";\nimport type PageServerLoad from \"./types/PageServerLoad\";\nimport type ServerEndPoint from \"./types/ServerEndPoint\";\nimport type ServerHook from \"./types/ServerHook\";\nimport type ServerLoadEvent from \"./types/ServerLoadEvent\";\nimport type ServerRequest from \"./types/ServerRequest\";\n\nexport { Site, Router };\n\nexport type {\n\tAdapter,\n\tPageEndPoint,\n\tPageServerEndPoint,\n\tPageServerLoad,\n\tPageServerAction,\n\tServerEndPoint,\n\tServerRequest,\n\tServerHook,\n\tPageLoadEvent,\n\tServerLoadEvent,\n};\n","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","import type LayoutHandler from \"../types/LayoutHandler\";\nimport type ManifestRoute from \"../types/ManifestRoute\";\nimport type RouteHandler from \"../types/RouteHandler\";\nimport pathToRegex from \"./pathToRegex\";\n\n/**\n * A router that handles file routes with layouts, hooks, etc.\n */\nexport default class Router {\n\troutes: Route[] = [];\n\n\tconstructor() {}\n\n\t//add(path: string, file: string) {\n\t//\t// TODO: Call the specific addX method based on the file path\n\t//\tthis.addPage(route, file);\n\t//}\n\n\taddPages(routes: ManifestRoute[]): this {\n\t\tfor (let r of routes) {\n\t\t\tthis.routes.push(\n\t\t\t\tnew Route(r.path, {\n\t\t\t\t\tpath: r.path,\n\t\t\t\t\ttype: r.type,\n\t\t\t\t\tendPoint: r.endPoint,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tthis.#sortRoutes();\n\t\treturn this;\n\t}\n\n\t// TODO: Allow calling with the endpoint itself, so that you can setup an app with no scaffold\n\taddPage(path: string, type: number, endPoint: () => Promise<any>): this {\n\t\tthis.routes.push(\n\t\t\tnew Route(path, {\n\t\t\t\tpath,\n\t\t\t\ttype,\n\t\t\t\tendPoint,\n\t\t\t}),\n\t\t);\n\t\tthis.#sortRoutes();\n\t\treturn this;\n\t}\n\n\t/*\n\tloadPage(ev: ServerEvent, file: string): Response {\n\t\tlet page = this.pages.get(file);\n\t\tif (!page) {\n\t\t\tpage = {};\n\t\t\tthis.pages.set(file, page);\n\t\t}\n\t}\n\t*/\n\n\tmatch(path: string, query: URLSearchParams): Match | undefined {\n\t\tfor (let route of this.routes) {\n\t\t\tlet match = path.match(route.regex);\n\t\t\tif (match) {\n\t\t\t\t// Lazy load server endpoints and layouts\n\t\t\t\tif (!route.handler.loaded) {\n\t\t\t\t\tthis.#loadHandler(route.handler, route.path);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\thandler: route.handler,\n\t\t\t\t\tparams: match.groups,\n\t\t\t\t\tquery,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconsole.log(`not found: '${path}'`);\n\t}\n\n\t#loadHandler(handler: RouteHandler, path: string) {\n\t\thandler.layouts = this.#findLayouts(path);\n\t\thandler.serverEndPoint = this.#findServer(path);\n\t\thandler.serverHook = this.#findServerHook(path);\n\t}\n\n\t#findLayouts(path: string): LayoutHandler[] | undefined {\n\t\tlet layouts: LayoutHandler[] = [];\n\t\tlet parts = path\n\t\t\t// Strip the trailing`~/server` (so we don't look for `~/server/_layout`\n\t\t\t// which will never exist)\n\t\t\t.replace(/\\/~server$/, \"\")\n\t\t\t// The path will always start with / so splitting e.g. `/first/second`\n\t\t\t// will result in ['', 'first', 'second'] and checks for `/_layout`,\n\t\t\t// `/first/_layout` and `/second/_layout`\n\t\t\t.split(\"/\");\n\t\tlet basePath = \"\";\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tif (i > 0) {\n\t\t\t\tbasePath += \"/\" + parts[i];\n\t\t\t}\n\t\t\tconst layoutPath = basePath + \"/_layout\";\n\t\t\tconst layoutRoute = this.routes.find((r) => r.path === layoutPath);\n\t\t\tif (layoutRoute) {\n\t\t\t\tlayouts.push({\n\t\t\t\t\tpath: layoutPath,\n\t\t\t\t\tendPoint: layoutRoute.handler.endPoint,\n\t\t\t\t\tserverEndPoint: this.#findServer(layoutPath),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn layouts.length ? layouts : undefined;\n\t}\n\n\t#findServer(path: string): (() => Promise<any>) | undefined {\n\t\tconst serverPath = path.replace(/\\/$/, \"\") + \"/~server\";\n\t\tconst serverRoute = this.routes.find((r) => r.path === serverPath);\n\t\treturn serverRoute && serverRoute.handler.endPoint;\n\t}\n\n\t#findServerHook(path: string): (() => Promise<any>) | undefined {\n\t\t// TODO: Should this be a collection, like layouts?\n\t\tlet serverHookPath = \"/_hook/~server\";\n\t\t// HACK: Generalise this\n\t\tif (path.startsWith(\"/api/\")) {\n\t\t\tserverHookPath = \"/api\" + serverHookPath;\n\t\t}\n\t\tconst serverHookRoute = this.routes.find((r) => r.path === serverHookPath);\n\t\treturn serverHookRoute && serverHookRoute.handler.endPoint;\n\t}\n\n\t// HACK: We're doing this here as well as in Site, so that you can use the\n\t// Router externally without Site\n\t#sortRoutes() {\n\t\tthis.routes = this.routes.sort((a, b) => {\n\t\t\t// Sort [param]s after paths\n\t\t\t// There might be a quicker/easier way to do this\n\t\t\tfor (let i = 0; i < Math.min(a.path.length, b.path.length); i++) {\n\t\t\t\tif (a.path[i] === \"[\" && b.path[i] !== \"[\") {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (b.path[i] === \"[\" && a.path[i] !== \"[\") {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (a.path[i] === b.path[i]) {\n\t\t\t\t\t// Keep going...\n\t\t\t\t} else {\n\t\t\t\t\treturn a.path[i].localeCompare(b.path[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a.path.length - b.path.length;\n\t\t});\n\t}\n}\n\nclass Route {\n\tpath: string;\n\tregex: RegExp;\n\thandler: RouteHandler;\n\n\tconstructor(path: string, handler: RouteHandler) {\n\t\tthis.path = path;\n\t\tthis.regex = pathToRegex(path);\n\t\tthis.handler = handler;\n\t}\n}\n\ntype Match = {\n\thandler: RouteHandler;\n\tparams?: Record<string, string>;\n\tquery: URLSearchParams;\n};\n","import { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { type Plugin, type UserConfig } from \"vite\";\nimport tsconfigPaths from \"vite-tsconfig-paths\";\nimport type Adapter from \"../types/Adapter\";\nimport {\n\tHOOK_ROUTE,\n\tHOOK_SERVER_ROUTE,\n\tLAYOUT_ROUTE,\n\tLAYOUT_SERVER_ROUTE,\n\tPAGE_ROUTE,\n\tPAGE_SERVER_ROUTE,\n\tSERVER_ROUTE,\n} from \"../types/RouteType\";\nimport defaultAdapter from \"./defaultAdapter\";\n\n// 1. The user sets this up\n// 2. It is passed into serverEntry and clientEntry through a Vite plugin\n// (defined in manifest.ts)\n// 3. In those files, it is used to build a Router\n\n/**\n * The Site class contains the information necessary to setup a @torpor/build\n * site, including routes, plugins, and options.\n */\nexport default class Site {\n\troot: string;\n\troutes: { path: string; file: string; type: number }[] = [];\n\t// Is default plugins a bad idea?\n\t// HACK: Set loose because otherwise it uses a list of allowed extensions\n\t// TODO: Should probably just do this ourselves and let the user pass in\n\t// tsconfigPaths themselves if they want to do something funky\n\tplugins: Plugin[] = [tsconfigPaths({ loose: true })];\n\t// Is default adapter a bad idea?\n\tadapter: Adapter = defaultAdapter;\n\t/**\n\t * Extra inputs, as absolute file paths, that will be compiled with the\n\t * output. What you do with them after that is up to you. File paths ending\n\t * with server.ts/js will only be compiled with the server output\n\t */\n\tinputs: string[] = [];\n\t/**\n\t * Vite config options to merge with the standard Torpor build options.\n\t * `plugins` and `build.rollupOptions.input` will be overridden, so you\n\t * should set `Site.plugins` and `Site.inputs` instead. Other options may be\n\t * overridden or incompatible, so experimentation may be required\n\t */\n\tviteConfig?: UserConfig;\n\n\tconstructor() {\n\t\tthis.root = process.cwd();\n\t}\n\n\tasync addRouteFolder(folder: string): Promise<void> {\n\t\tconst routeFolder = path.join(this.root, folder);\n\t\tconst routeFiles = await fs.readdir(routeFolder, { recursive: true });\n\n\t\tfor (let file of routeFiles) {\n\t\t\t// The file must start with `+` or `_` and end with `.js` or `.ts`\n\t\t\tif (/^(\\+|_).+(\\.js|\\.ts)$/.test(path.basename(file))) {\n\t\t\t\tlet routePath = file\n\t\t\t\t\t.replace(/^\\//, \"\")\n\t\t\t\t\t.replace(/(\\.ts|\\.js)$/, \"\")\n\t\t\t\t\t.replace(/_hook.server$/, \"_hook/~server\")\n\t\t\t\t\t.replace(/_layout.server$/, \"_layout/~server\")\n\t\t\t\t\t.replace(/\\+page.server$/, \"~server\")\n\t\t\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t\t\t.replace(/\\+page$/, \"\")\n\t\t\t\t\t.replace(/\\/$/, \"\");\n\t\t\t\troutePath = routePath.length > 0 ? `/${routePath}` : \"/\";\n\t\t\t\tlet type = this.#routeType(file);\n\t\t\t\tfile = path.relative(this.root, path.resolve(routeFolder, file));\n\t\t\t\tthis.routes.push({ path: routePath, file, type });\n\t\t\t}\n\t\t}\n\t\tthis.#sortRoutes();\n\t}\n\n\taddRouteFile(path: string, file: string): void {\n\t\tlet type = this.#routeType(file);\n\t\tthis.routes.push({ path, file, type });\n\t\tthis.#sortRoutes();\n\t}\n\n\t#routeType(file: string): number {\n\t\tlet routePath = file.replace(/^\\//, \"\").replace(/(\\.ts|\\.js)$/, \"\");\n\t\tif (routePath.endsWith(\"+page\")) {\n\t\t\treturn PAGE_ROUTE;\n\t\t} else if (routePath.endsWith(\"+page.server\")) {\n\t\t\treturn PAGE_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"+server\")) {\n\t\t\treturn SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout\")) {\n\t\t\treturn LAYOUT_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout.server\")) {\n\t\t\treturn LAYOUT_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook\")) {\n\t\t\treturn HOOK_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook.server\")) {\n\t\t\treturn HOOK_SERVER_ROUTE;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t// TODO: You could make your site in a single file, like e.g. Hono...\n\t//addPage(path: string, endPoint: PageEndPoint, serverEndPoint?: PageServerEndPoint) {}\n\t//addEndPoint(path: string, endPoint: ServerEndPoint) {}\n\n\t#sortRoutes() {\n\t\tthis.routes = this.routes.sort((a, b) => {\n\t\t\t// Sort [param]s after paths\n\t\t\t// There might be a quicker/easier way to do this\n\t\t\tfor (let i = 0; i < Math.min(a.path.length, b.path.length); i++) {\n\t\t\t\tif (a.path[i] === \"[\" && b.path[i] !== \"[\") {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (b.path[i] === \"[\" && a.path[i] !== \"[\") {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (a.path[i] === b.path[i]) {\n\t\t\t\t\t// Keep going...\n\t\t\t\t} else {\n\t\t\t\t\treturn a.path[i].localeCompare(b.path[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a.path.length - b.path.length;\n\t\t});\n\t}\n}\n","export const PAGE_ROUTE = 0;\nexport const PAGE_SERVER_ROUTE = 1;\nexport const SERVER_ROUTE = 3;\nexport const LAYOUT_ROUTE = 4;\nexport const LAYOUT_SERVER_ROUTE = 5;\nexport const HOOK_ROUTE = 6;\nexport const HOOK_SERVER_ROUTE = 7;\n","import Adapter from \"../types/Adapter\";\n\n// TODO: This should be an adapter-auto package that conditionally loads other packages...\n\nconst defaultAdapter: Adapter = {\n\tserve: () => {\n\t\tconsole.log(\"An adapter needs to be set in site.config\");\n\t},\n};\n\nexport default defaultAdapter;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAe,SAAR,YAA6BA,OAAsB;AACzD,QAAM,UACLA,MACE,MAAM,GAAG,EAET,IAAI,CAAC,MAAM;AACX,WAAO,EAAE,QAAQ,iBAAiB,iBAAiB;AAAA,EACpD,CAAC,EACA,KAAK,KAAK,EAEV,WAAW,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,aAAO;AAAA,IACR,WAAW,UAAU,SAAS,OAAO,GAAG;AACvC,aAAO;AAAA,IACR,WAAW,UAAU,SAAS,cAAc,GAAG;AAC9C,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc;AACb,SAAK,SAAS,KAAK,OAAO,KAAK,CAAC,GAAG,MAAM;AAGxC,eAAS,IAAI,GAAG,IAAI,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK;AAChE,YAAI,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK;AAC3C,iBAAO;AAAA,QACR,WAAW,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK;AAClD,iBAAO;AAAA,QACR,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG;AAAA,QAEpC,OAAO;AACN,iBAAO,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAAA,QACzC;AAAA,MACD;AACA,aAAO,EAAE,KAAK,SAAS,EAAE,KAAK;AAAA,IAC/B,CAAC;AAAA,EACF;AACD;","names":["path","path","tsconfigPaths","path","fs"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/site/pathToRegex.ts","../src/site/Router.ts","../src/site/Site.ts","../src/types/RouteType.ts","../src/site/defaultAdapter.ts"],"sourcesContent":["import Router from \"./site/Router\";\nimport Site from \"./site/Site\";\nimport type Adapter from \"./types/Adapter\";\nimport type PageEndPoint from \"./types/PageEndPoint\";\nimport type PageLoadEvent from \"./types/PageLoadEvent\";\nimport type PageServerAction from \"./types/PageServerAction\";\nimport type PageServerEndPoint from \"./types/PageServerEndPoint\";\nimport type PageServerLoad from \"./types/PageServerLoad\";\nimport type ServerEndPoint from \"./types/ServerEndPoint\";\nimport type ServerHook from \"./types/ServerHook\";\nimport type ServerLoadEvent from \"./types/ServerLoadEvent\";\nimport type ServerRequest from \"./types/ServerRequest\";\n\nexport { Site, Router };\n\nexport type {\n\tAdapter,\n\tPageEndPoint,\n\tPageServerEndPoint,\n\tPageServerLoad,\n\tPageServerAction,\n\tServerEndPoint,\n\tServerRequest,\n\tServerHook,\n\tPageLoadEvent,\n\tServerLoadEvent,\n};\n","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","import type LayoutHandler from \"../types/LayoutHandler\";\nimport type ManifestRoute from \"../types/ManifestRoute\";\nimport type RouteHandler from \"../types/RouteHandler\";\nimport pathToRegex from \"./pathToRegex\";\n\n/**\n * A router that handles file routes with layouts, hooks, etc.\n */\nexport default class Router {\n\troutes: Route[] = [];\n\n\tconstructor() {}\n\n\t//add(path: string, file: string) {\n\t//\t// TODO: Call the specific addX method based on the file path\n\t//\tthis.addPage(route, file);\n\t//}\n\n\taddPages(routes: ManifestRoute[]): this {\n\t\tfor (let r of routes) {\n\t\t\tthis.routes.push(\n\t\t\t\tnew Route(r.path, {\n\t\t\t\t\tpath: r.path,\n\t\t\t\t\ttype: r.type,\n\t\t\t\t\tendPoint: r.endPoint,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t\tthis.#sortRoutes();\n\t\treturn this;\n\t}\n\n\t// TODO: Allow calling with the endpoint itself, so that you can setup an app with no scaffold\n\taddPage(path: string, type: number, endPoint: () => Promise<any>): this {\n\t\tthis.routes.push(\n\t\t\tnew Route(path, {\n\t\t\t\tpath,\n\t\t\t\ttype,\n\t\t\t\tendPoint,\n\t\t\t}),\n\t\t);\n\t\tthis.#sortRoutes();\n\t\treturn this;\n\t}\n\n\t/*\n\tloadPage(ev: ServerEvent, file: string): Response {\n\t\tlet page = this.pages.get(file);\n\t\tif (!page) {\n\t\t\tpage = {};\n\t\t\tthis.pages.set(file, page);\n\t\t}\n\t}\n\t*/\n\n\tmatch(path: string, query: URLSearchParams): Match | undefined {\n\t\tfor (let route of this.routes) {\n\t\t\tlet match = path.match(route.regex);\n\t\t\tif (match) {\n\t\t\t\t// Lazy load server endpoints and layouts\n\t\t\t\tif (!route.handler.loaded) {\n\t\t\t\t\tthis.#loadHandler(route.handler, route.path);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\thandler: route.handler,\n\t\t\t\t\tparams: match.groups,\n\t\t\t\t\tquery,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconsole.log(`not found: '${path}'`);\n\t}\n\n\t#loadHandler(handler: RouteHandler, path: string) {\n\t\thandler.layouts = this.#findLayouts(path);\n\t\thandler.serverEndPoint = this.#findServer(path);\n\t\thandler.serverHook = this.#findServerHook(path);\n\t}\n\n\t#findLayouts(path: string): LayoutHandler[] | undefined {\n\t\tlet layouts: LayoutHandler[] = [];\n\t\tlet parts = path\n\t\t\t// Strip the trailing`~/server` (so we don't look for `~/server/_layout`\n\t\t\t// which will never exist)\n\t\t\t.replace(/\\/~server$/, \"\")\n\t\t\t// The path will always start with / so splitting e.g. `/first/second`\n\t\t\t// will result in ['', 'first', 'second'] and checks for `/_layout`,\n\t\t\t// `/first/_layout` and `/second/_layout`\n\t\t\t.split(\"/\");\n\t\tlet basePath = \"\";\n\t\tfor (let i = 0; i < parts.length; i++) {\n\t\t\tif (i > 0) {\n\t\t\t\tbasePath += \"/\" + parts[i];\n\t\t\t}\n\t\t\tconst layoutPath = basePath + \"/_layout\";\n\t\t\tconst layoutRoute = this.routes.find((r) => r.path === layoutPath);\n\t\t\tif (layoutRoute) {\n\t\t\t\tlayouts.push({\n\t\t\t\t\tpath: layoutPath,\n\t\t\t\t\tendPoint: layoutRoute.handler.endPoint,\n\t\t\t\t\tserverEndPoint: this.#findServer(layoutPath),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn layouts.length ? layouts : undefined;\n\t}\n\n\t#findServer(path: string): (() => Promise<any>) | undefined {\n\t\tconst serverPath = path.replace(/\\/$/, \"\") + \"/~server\";\n\t\tconst serverRoute = this.routes.find((r) => r.path === serverPath);\n\t\treturn serverRoute && serverRoute.handler.endPoint;\n\t}\n\n\t#findServerHook(path: string): (() => Promise<any>) | undefined {\n\t\t// TODO: Should this be a collection, like layouts?\n\t\tlet serverHookPath = \"/_hook/~server\";\n\t\t// HACK: Generalise this\n\t\tif (path.startsWith(\"/api/\")) {\n\t\t\tserverHookPath = \"/api\" + serverHookPath;\n\t\t}\n\t\tconst serverHookRoute = this.routes.find((r) => r.path === serverHookPath);\n\t\treturn serverHookRoute && serverHookRoute.handler.endPoint;\n\t}\n\n\t// HACK: We're doing this here as well as in Site, so that you can use the\n\t// Router externally without Site\n\t#sortRoutes() {\n\t\tthis.routes = this.routes.sort((a, b) => {\n\t\t\t// Sort [param]s after paths\n\t\t\t// There might be a quicker/easier way to do this\n\t\t\tfor (let i = 0; i < Math.min(a.path.length, b.path.length); i++) {\n\t\t\t\tif (a.path[i] === \"[\" && b.path[i] !== \"[\") {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (b.path[i] === \"[\" && a.path[i] !== \"[\") {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (a.path[i] === b.path[i]) {\n\t\t\t\t\t// Keep going...\n\t\t\t\t} else {\n\t\t\t\t\treturn a.path[i].localeCompare(b.path[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a.path.length - b.path.length;\n\t\t});\n\t}\n}\n\nclass Route {\n\tpath: string;\n\tregex: RegExp;\n\thandler: RouteHandler;\n\n\tconstructor(path: string, handler: RouteHandler) {\n\t\tthis.path = path;\n\t\tthis.regex = pathToRegex(path);\n\t\tthis.handler = handler;\n\t}\n}\n\ntype Match = {\n\thandler: RouteHandler;\n\tparams?: Record<string, string>;\n\tquery: URLSearchParams;\n};\n","import { promises as fs } from \"node:fs\";\nimport fpath from \"node:path\";\nimport { type Plugin, type UserConfig } from \"vite\";\nimport tsconfigPaths from \"vite-tsconfig-paths\";\nimport type Adapter from \"../types/Adapter\";\nimport {\n\tERROR_ROUTE,\n\tHOOK_ROUTE,\n\tHOOK_SERVER_ROUTE,\n\tLAYOUT_ROUTE,\n\tLAYOUT_SERVER_ROUTE,\n\tPAGE_ROUTE,\n\tPAGE_SERVER_ROUTE,\n\tRouteType,\n\tSERVER_ROUTE,\n} from \"../types/RouteType\";\nimport defaultAdapter from \"./defaultAdapter\";\n\n// 1. The user sets this up\n// 2. It is passed into serverEntry and clientEntry through a Vite plugin\n// (defined in manifest.ts)\n// 3. In those files, it is used to build a Router\n\n/**\n * The Site class contains the information necessary to setup a @torpor/build\n * site, including routes, plugins, and options.\n */\nexport default class Site {\n\troot: string;\n\troutes: { path: string; file: string; type: RouteType }[] = [];\n\t// Is default plugins a bad idea?\n\t// HACK: Set loose because otherwise it uses a list of allowed extensions\n\t// TODO: Should probably just do this ourselves and let the user pass in\n\t// tsconfigPaths themselves if they want to do something funky\n\tplugins: Plugin[] = [tsconfigPaths({ loose: true })];\n\t// Is default adapter a bad idea?\n\tadapter: Adapter = defaultAdapter;\n\t/**\n\t * Extra inputs, as absolute file paths, that will be compiled with the\n\t * output. What you do with them after that is up to you. File paths ending\n\t * with server.ts/js will only be compiled with the server output\n\t */\n\tinputs: string[] = [];\n\t/**\n\t * Vite config options to merge with the standard Torpor build options.\n\t * `plugins` and `build.rollupOptions.input` will be overridden, so you\n\t * should set `Site.plugins` and `Site.inputs` instead. Other options may be\n\t * overridden or incompatible, so experimentation may be required\n\t */\n\tviteConfig?: UserConfig;\n\n\tconstructor() {\n\t\tthis.root = process.cwd();\n\t}\n\n\t/**\n\t * Adds a folder of routes, based on the names of the files in the folder\n\t * @param folder The folder containing the routes\n\t */\n\tasync addRouteFolder(folder: string): Promise<void> {\n\t\tconst routeFolder = fpath.join(this.root, folder);\n\t\tconst routeFiles = await fs.readdir(routeFolder, { recursive: true });\n\t\tfor (let file of routeFiles) {\n\t\t\t// The file must start with `+` or `_` and end with `.js` or `.ts`\n\t\t\tif (/^(\\+|_).+(\\.js|\\.ts)$/.test(fpath.basename(file))) {\n\t\t\t\tlet routePath = this.#routePath(file);\n\t\t\t\tlet type = this.#routeType(file);\n\t\t\t\tfile = fpath.relative(this.root, fpath.resolve(routeFolder, file));\n\t\t\t\tthis.routes.push({ path: routePath, file, type });\n\t\t\t}\n\t\t}\n\t\tthis.#sortRoutes();\n\t}\n\n\t/**\n\t * Adds a file route, which can have a standard name (e.g. +page.ts) or any\n\t * name if you pass the type\n\t * @param path The route path\n\t * @param file The file\n\t * @param type The file type (if the file name is non-standard)\n\t */\n\taddRouteFile(\n\t\tpath: string,\n\t\tfile: string,\n\t\ttype?:\n\t\t\t| \"+page\"\n\t\t\t| \"+page.server\"\n\t\t\t| \"+server\"\n\t\t\t| \"_layout\"\n\t\t\t| \"_layout.server\"\n\t\t\t| \"_hook\"\n\t\t\t| \"_hook.server\"\n\t\t\t| \"_error\",\n\t): void {\n\t\tlet routePath = this.#routePath(fpath.join(path, type ?? fpath.basename(file)));\n\t\tlet routeType = type ? this.#routeTypeFromString(type) : this.#routeType(file);\n\t\tthis.routes.push({ path: routePath, file, type: routeType });\n\t\tthis.#sortRoutes();\n\t}\n\n\t#routePath(file: string): string {\n\t\tlet routePath = file\n\t\t\t.replace(/^\\//, \"\")\n\t\t\t.replace(/(\\.ts|\\.js)$/, \"\")\n\t\t\t.replace(/_hook.server$/, \"_hook/~server\")\n\t\t\t.replace(/_layout.server$/, \"_layout/~server\")\n\t\t\t.replace(/\\+page.server$/, \"~server\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\+page$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\t#routeType(file: string): RouteType {\n\t\tlet routePath = file.replace(/^\\//, \"\").replace(/(\\.ts|\\.js)$/, \"\");\n\t\tif (routePath.endsWith(\"+page\")) {\n\t\t\treturn PAGE_ROUTE;\n\t\t} else if (routePath.endsWith(\"+page.server\")) {\n\t\t\treturn PAGE_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"+server\")) {\n\t\t\treturn SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout\")) {\n\t\t\treturn LAYOUT_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout.server\")) {\n\t\t\treturn LAYOUT_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook\")) {\n\t\t\treturn HOOK_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook.server\")) {\n\t\t\treturn HOOK_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_error\")) {\n\t\t\treturn ERROR_ROUTE;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t#routeTypeFromString(\n\t\ttype:\n\t\t\t| \"+page\"\n\t\t\t| \"+page.server\"\n\t\t\t| \"+server\"\n\t\t\t| \"_layout\"\n\t\t\t| \"_layout.server\"\n\t\t\t| \"_hook\"\n\t\t\t| \"_hook.server\"\n\t\t\t| \"_error\",\n\t) {\n\t\tswitch (type) {\n\t\t\tcase \"+page\":\n\t\t\t\treturn PAGE_ROUTE;\n\t\t\tcase \"+page.server\":\n\t\t\t\treturn PAGE_SERVER_ROUTE;\n\t\t\tcase \"+server\":\n\t\t\t\treturn SERVER_ROUTE;\n\t\t\tcase \"_layout\":\n\t\t\t\treturn LAYOUT_ROUTE;\n\t\t\tcase \"_layout.server\":\n\t\t\t\treturn LAYOUT_SERVER_ROUTE;\n\t\t\tcase \"_hook\":\n\t\t\t\treturn HOOK_ROUTE;\n\t\t\tcase \"_hook.server\":\n\t\t\t\treturn HOOK_SERVER_ROUTE;\n\t\t\tcase \"_error\":\n\t\t\t\treturn ERROR_ROUTE;\n\t\t}\n\t}\n\n\t// TODO: You could make your site in a single file, like e.g. Hono...\n\t//addPage(path: string, endPoint: PageEndPoint, serverEndPoint?: PageServerEndPoint) {}\n\t//addEndPoint(path: string, endPoint: ServerEndPoint) {}\n\n\t#sortRoutes() {\n\t\tthis.routes = this.routes.sort((a, b) => {\n\t\t\t// Sort [param]s after paths\n\t\t\t// There might be a quicker/easier way to do this\n\t\t\tfor (let i = 0; i < Math.min(a.path.length, b.path.length); i++) {\n\t\t\t\tif (a.path[i] === \"[\" && b.path[i] !== \"[\") {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (b.path[i] === \"[\" && a.path[i] !== \"[\") {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (a.path[i] === b.path[i]) {\n\t\t\t\t\t// Keep going...\n\t\t\t\t} else {\n\t\t\t\t\treturn a.path[i].localeCompare(b.path[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a.path.length - b.path.length;\n\t\t});\n\t}\n}\n","export const PAGE_ROUTE = 0;\nexport const PAGE_SERVER_ROUTE = 1;\nexport const SERVER_ROUTE = 3;\nexport const LAYOUT_ROUTE = 4;\nexport const LAYOUT_SERVER_ROUTE = 5;\nexport const HOOK_ROUTE = 6;\nexport const HOOK_SERVER_ROUTE = 7;\nexport const ERROR_ROUTE = 8;\n\nexport type RouteType =\n\t| typeof PAGE_ROUTE\n\t| typeof PAGE_SERVER_ROUTE\n\t| typeof SERVER_ROUTE\n\t| typeof LAYOUT_ROUTE\n\t| typeof LAYOUT_SERVER_ROUTE\n\t| typeof HOOK_ROUTE\n\t| typeof HOOK_SERVER_ROUTE\n\t| typeof ERROR_ROUTE\n\t| -1;\n","import Adapter from \"../types/Adapter\";\n\n// TODO: This should be an adapter-auto package that conditionally loads other packages...\n\nconst defaultAdapter: Adapter = {\n\tserve: () => {\n\t\tconsole.log(\"An ad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AAG,KAAK;AAChE,YAAI,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK;AAC3C,iBAAO;AAAA,QACR,WAAW,EAAE,KAAK,CAAC,MAAM,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK;AAClD,iBAAO;AAAA,QACR,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG;AAAA,QAEpC,OAAO;AACN,iBAAO,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAAA,QACzC;AAAA,MACD;AACA,aAAO,EAAE,KAAK,SAAS,EAAE,KAAK;AAAA,IAC/B,CAAC;AAAA,EACF;AACD;","names":["tsconfigPaths","fpath","fs"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ERROR_ROUTE,
|
|
2
3
|
HOOK_ROUTE,
|
|
3
4
|
HOOK_SERVER_ROUTE,
|
|
4
5
|
LAYOUT_ROUTE,
|
|
@@ -7,12 +8,12 @@ import {
|
|
|
7
8
|
PAGE_SERVER_ROUTE,
|
|
8
9
|
Router,
|
|
9
10
|
SERVER_ROUTE
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PTVHEJZ5.js";
|
|
11
12
|
import "./chunk-SJVHHGVW.js";
|
|
12
13
|
|
|
13
14
|
// src/site/Site.ts
|
|
14
15
|
import { promises as fs } from "fs";
|
|
15
|
-
import
|
|
16
|
+
import fpath from "path";
|
|
16
17
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
17
18
|
|
|
18
19
|
// src/site/defaultAdapter.ts
|
|
@@ -50,25 +51,40 @@ var Site = class {
|
|
|
50
51
|
constructor() {
|
|
51
52
|
this.root = process.cwd();
|
|
52
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Adds a folder of routes, based on the names of the files in the folder
|
|
56
|
+
* @param folder The folder containing the routes
|
|
57
|
+
*/
|
|
53
58
|
async addRouteFolder(folder) {
|
|
54
|
-
const routeFolder =
|
|
59
|
+
const routeFolder = fpath.join(this.root, folder);
|
|
55
60
|
const routeFiles = await fs.readdir(routeFolder, { recursive: true });
|
|
56
61
|
for (let file of routeFiles) {
|
|
57
|
-
if (/^(\+|_).+(\.js|\.ts)$/.test(
|
|
58
|
-
let routePath = file
|
|
59
|
-
routePath = routePath.length > 0 ? `/${routePath}` : "/";
|
|
62
|
+
if (/^(\+|_).+(\.js|\.ts)$/.test(fpath.basename(file))) {
|
|
63
|
+
let routePath = this.#routePath(file);
|
|
60
64
|
let type = this.#routeType(file);
|
|
61
|
-
file =
|
|
65
|
+
file = fpath.relative(this.root, fpath.resolve(routeFolder, file));
|
|
62
66
|
this.routes.push({ path: routePath, file, type });
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
this.#sortRoutes();
|
|
66
70
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Adds a file route, which can have a standard name (e.g. +page.ts) or any
|
|
73
|
+
* name if you pass the type
|
|
74
|
+
* @param path The route path
|
|
75
|
+
* @param file The file
|
|
76
|
+
* @param type The file type (if the file name is non-standard)
|
|
77
|
+
*/
|
|
78
|
+
addRouteFile(path, file, type) {
|
|
79
|
+
let routePath = this.#routePath(fpath.join(path, type ?? fpath.basename(file)));
|
|
80
|
+
let routeType = type ? this.#routeTypeFromString(type) : this.#routeType(file);
|
|
81
|
+
this.routes.push({ path: routePath, file, type: routeType });
|
|
70
82
|
this.#sortRoutes();
|
|
71
83
|
}
|
|
84
|
+
#routePath(file) {
|
|
85
|
+
let routePath = file.replace(/^\//, "").replace(/(\.ts|\.js)$/, "").replace(/_hook.server$/, "_hook/~server").replace(/_layout.server$/, "_layout/~server").replace(/\+page.server$/, "~server").replace(/\+server$/, "").replace(/\+page$/, "").replace(/\/$/, "");
|
|
86
|
+
return routePath.length > 0 ? `/${routePath}` : "/";
|
|
87
|
+
}
|
|
72
88
|
#routeType(file) {
|
|
73
89
|
let routePath = file.replace(/^\//, "").replace(/(\.ts|\.js)$/, "");
|
|
74
90
|
if (routePath.endsWith("+page")) {
|
|
@@ -85,9 +101,31 @@ var Site = class {
|
|
|
85
101
|
return HOOK_ROUTE;
|
|
86
102
|
} else if (routePath.endsWith("_hook.server")) {
|
|
87
103
|
return HOOK_SERVER_ROUTE;
|
|
104
|
+
} else if (routePath.endsWith("_error")) {
|
|
105
|
+
return ERROR_ROUTE;
|
|
88
106
|
}
|
|
89
107
|
return -1;
|
|
90
108
|
}
|
|
109
|
+
#routeTypeFromString(type) {
|
|
110
|
+
switch (type) {
|
|
111
|
+
case "+page":
|
|
112
|
+
return PAGE_ROUTE;
|
|
113
|
+
case "+page.server":
|
|
114
|
+
return PAGE_SERVER_ROUTE;
|
|
115
|
+
case "+server":
|
|
116
|
+
return SERVER_ROUTE;
|
|
117
|
+
case "_layout":
|
|
118
|
+
return LAYOUT_ROUTE;
|
|
119
|
+
case "_layout.server":
|
|
120
|
+
return LAYOUT_SERVER_ROUTE;
|
|
121
|
+
case "_hook":
|
|
122
|
+
return HOOK_ROUTE;
|
|
123
|
+
case "_hook.server":
|
|
124
|
+
return HOOK_SERVER_ROUTE;
|
|
125
|
+
case "_error":
|
|
126
|
+
return ERROR_ROUTE;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
91
129
|
// TODO: You could make your site in a single file, like e.g. Hono...
|
|
92
130
|
//addPage(path: string, endPoint: PageEndPoint, serverEndPoint?: PageServerEndPoint) {}
|
|
93
131
|
//addEndPoint(path: string, endPoint: ServerEndPoint) {}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/site/Site.ts","../src/site/defaultAdapter.ts"],"sourcesContent":["import { promises as fs } from \"node:fs\";\nimport
|
|
1
|
+
{"version":3,"sources":["../src/site/Site.ts","../src/site/defaultAdapter.ts"],"sourcesContent":["import { promises as fs } from \"node:fs\";\nimport fpath from \"node:path\";\nimport { type Plugin, type UserConfig } from \"vite\";\nimport tsconfigPaths from \"vite-tsconfig-paths\";\nimport type Adapter from \"../types/Adapter\";\nimport {\n\tERROR_ROUTE,\n\tHOOK_ROUTE,\n\tHOOK_SERVER_ROUTE,\n\tLAYOUT_ROUTE,\n\tLAYOUT_SERVER_ROUTE,\n\tPAGE_ROUTE,\n\tPAGE_SERVER_ROUTE,\n\tRouteType,\n\tSERVER_ROUTE,\n} from \"../types/RouteType\";\nimport defaultAdapter from \"./defaultAdapter\";\n\n// 1. The user sets this up\n// 2. It is passed into serverEntry and clientEntry through a Vite plugin\n// (defined in manifest.ts)\n// 3. In those files, it is used to build a Router\n\n/**\n * The Site class contains the information necessary to setup a @torpor/build\n * site, including routes, plugins, and options.\n */\nexport default class Site {\n\troot: string;\n\troutes: { path: string; file: string; type: RouteType }[] = [];\n\t// Is default plugins a bad idea?\n\t// HACK: Set loose because otherwise it uses a list of allowed extensions\n\t// TODO: Should probably just do this ourselves and let the user pass in\n\t// tsconfigPaths themselves if they want to do something funky\n\tplugins: Plugin[] = [tsconfigPaths({ loose: true })];\n\t// Is default adapter a bad idea?\n\tadapter: Adapter = defaultAdapter;\n\t/**\n\t * Extra inputs, as absolute file paths, that will be compiled with the\n\t * output. What you do with them after that is up to you. File paths ending\n\t * with server.ts/js will only be compiled with the server output\n\t */\n\tinputs: string[] = [];\n\t/**\n\t * Vite config options to merge with the standard Torpor build options.\n\t * `plugins` and `build.rollupOptions.input` will be overridden, so you\n\t * should set `Site.plugins` and `Site.inputs` instead. Other options may be\n\t * overridden or incompatible, so experimentation may be required\n\t */\n\tviteConfig?: UserConfig;\n\n\tconstructor() {\n\t\tthis.root = process.cwd();\n\t}\n\n\t/**\n\t * Adds a folder of routes, based on the names of the files in the folder\n\t * @param folder The folder containing the routes\n\t */\n\tasync addRouteFolder(folder: string): Promise<void> {\n\t\tconst routeFolder = fpath.join(this.root, folder);\n\t\tconst routeFiles = await fs.readdir(routeFolder, { recursive: true });\n\t\tfor (let file of routeFiles) {\n\t\t\t// The file must start with `+` or `_` and end with `.js` or `.ts`\n\t\t\tif (/^(\\+|_).+(\\.js|\\.ts)$/.test(fpath.basename(file))) {\n\t\t\t\tlet routePath = this.#routePath(file);\n\t\t\t\tlet type = this.#routeType(file);\n\t\t\t\tfile = fpath.relative(this.root, fpath.resolve(routeFolder, file));\n\t\t\t\tthis.routes.push({ path: routePath, file, type });\n\t\t\t}\n\t\t}\n\t\tthis.#sortRoutes();\n\t}\n\n\t/**\n\t * Adds a file route, which can have a standard name (e.g. +page.ts) or any\n\t * name if you pass the type\n\t * @param path The route path\n\t * @param file The file\n\t * @param type The file type (if the file name is non-standard)\n\t */\n\taddRouteFile(\n\t\tpath: string,\n\t\tfile: string,\n\t\ttype?:\n\t\t\t| \"+page\"\n\t\t\t| \"+page.server\"\n\t\t\t| \"+server\"\n\t\t\t| \"_layout\"\n\t\t\t| \"_layout.server\"\n\t\t\t| \"_hook\"\n\t\t\t| \"_hook.server\"\n\t\t\t| \"_error\",\n\t): void {\n\t\tlet routePath = this.#routePath(fpath.join(path, type ?? fpath.basename(file)));\n\t\tlet routeType = type ? this.#routeTypeFromString(type) : this.#routeType(file);\n\t\tthis.routes.push({ path: routePath, file, type: routeType });\n\t\tthis.#sortRoutes();\n\t}\n\n\t#routePath(file: string): string {\n\t\tlet routePath = file\n\t\t\t.replace(/^\\//, \"\")\n\t\t\t.replace(/(\\.ts|\\.js)$/, \"\")\n\t\t\t.replace(/_hook.server$/, \"_hook/~server\")\n\t\t\t.replace(/_layout.server$/, \"_layout/~server\")\n\t\t\t.replace(/\\+page.server$/, \"~server\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\+page$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\t#routeType(file: string): RouteType {\n\t\tlet routePath = file.replace(/^\\//, \"\").replace(/(\\.ts|\\.js)$/, \"\");\n\t\tif (routePath.endsWith(\"+page\")) {\n\t\t\treturn PAGE_ROUTE;\n\t\t} else if (routePath.endsWith(\"+page.server\")) {\n\t\t\treturn PAGE_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"+server\")) {\n\t\t\treturn SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout\")) {\n\t\t\treturn LAYOUT_ROUTE;\n\t\t} else if (routePath.endsWith(\"_layout.server\")) {\n\t\t\treturn LAYOUT_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook\")) {\n\t\t\treturn HOOK_ROUTE;\n\t\t} else if (routePath.endsWith(\"_hook.server\")) {\n\t\t\treturn HOOK_SERVER_ROUTE;\n\t\t} else if (routePath.endsWith(\"_error\")) {\n\t\t\treturn ERROR_ROUTE;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t#routeTypeFromString(\n\t\ttype:\n\t\t\t| \"+page\"\n\t\t\t| \"+page.server\"\n\t\t\t| \"+server\"\n\t\t\t| \"_layout\"\n\t\t\t| \"_layout.server\"\n\t\t\t| \"_hook\"\n\t\t\t| \"_hook.server\"\n\t\t\t| \"_error\",\n\t) {\n\t\tswitch (type) {\n\t\t\tcase \"+page\":\n\t\t\t\treturn PAGE_ROUTE;\n\t\t\tcase \"+page.server\":\n\t\t\t\treturn PAGE_SERVER_ROUTE;\n\t\t\tcase \"+server\":\n\t\t\t\treturn SERVER_ROUTE;\n\t\t\tcase \"_layout\":\n\t\t\t\treturn LAYOUT_ROUTE;\n\t\t\tcase \"_layout.server\":\n\t\t\t\treturn LAYOUT_SERVER_ROUTE;\n\t\t\tcase \"_hook\":\n\t\t\t\treturn HOOK_ROUTE;\n\t\t\tcase \"_hook.server\":\n\t\t\t\treturn HOOK_SERVER_ROUTE;\n\t\t\tcase \"_error\":\n\t\t\t\treturn ERROR_ROUTE;\n\t\t}\n\t}\n\n\t// TODO: You could make your site in a single file, like e.g. Hono...\n\t//addPage(path: string, endPoint: PageEndPoint, serverEndPoint?: PageServerEndPoint) {}\n\t//addEndPoint(path: string, endPoint: ServerEndPoint) {}\n\n\t#sortRoutes() {\n\t\tthis.routes = this.routes.sort((a, b) => {\n\t\t\t// Sort [param]s after paths\n\t\t\t// There might be a quicker/easier way to do this\n\t\t\tfor (let i = 0; i < Math.min(a.path.length, b.path.length); i++) {\n\t\t\t\tif (a.path[i] === \"[\" && b.path[i] !== \"[\") {\n\t\t\t\t\treturn 1;\n\t\t\t\t} else if (b.path[i] === \"[\" && a.path[i] !== \"[\") {\n\t\t\t\t\treturn -1;\n\t\t\t\t} else if (a.path[i] === b.path[i]) {\n\t\t\t\t\t// Keep going...\n\t\t\t\t} else {\n\t\t\t\t\treturn a.path[i].localeCompare(b.path[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn a.path.length - b.path.length;\n\t\t});\n\t}\n}\n","import Adapter from \"../types/Adapter\";\n\n// TODO: This should be an adapter-auto package that conditionally loads other packages...\n\nconst defaultAdapter: Adapter = {\n\tserve: () => {\n\t\tconsole.log(\"An adapter needs to be set in site.config\");\n\t},\n};\n\nexport default defaultAdapter;\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,YAAY,UAAU;AAC/B,OAAO,WAAW;AAElB,OAAO,mBAAmB;;;ACC1B,IAAM,iBAA0B;AAAA,EAC/B,OAAO,MAAM;AACZ,YAAQ,IAAI,2CAA2C;AAAA,EACxD;AACD;AAEA,IAAO,yBAAQ;;;ADiBf,IAAqB,OAArB,MAA0B;AAAA,EACzB;AAAA,EACA,SAA4D,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7D,UAAoB,CAAC,cAAc,EAAE,OAAO,KAAK,CAAC,CAAC;AAAA;AAAA,EAEnD,UAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnB,SAAmB,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOpB;AAAA,EAEA,cAAc;AACb,SAAK,O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OAAO;AACN,iBAAO,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;AAAA,QACzC;AAAA,MACD;AACA,aAAO,EAAE,KAAK,SAAS,EAAE,KAAK;AAAA,IAC/B,CAAC;AAAA,EACF;AACD;","names":[]}
|
package/dist/metafile-cjs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/site/pathToRegex.ts":{"bytes":459,"imports":[],"format":"esm"},"src/site/Router.ts":{"bytes":4384,"imports":[{"path":"src/site/pathToRegex.ts","kind":"import-statement","original":"./pathToRegex"}],"format":"esm"},"src/types/RouteType.ts":{"bytes":230,"imports":[],"format":"esm"},"src/site/defaultAdapter.ts":{"bytes":282,"imports":[{"path":"../types/Adapter","kind":"import-statement","external":true}],"format":"esm"},"src/site/Site.ts":{"bytes":4321,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"vite-tsconfig-paths","kind":"import-statement","external":true},{"path":"src/types/RouteType.ts","kind":"import-statement","original":"../types/RouteType"},{"path":"src/site/defaultAdapter.ts","kind":"import-statement","original":"./defaultAdapter"}],"format":"esm"},"src/index.ts":{"bytes":838,"imports":[{"path":"src/site/Router.ts","kind":"import-statement","original":"./site/Router"},{"path":"src/site/Site.ts","kind":"import-statement","original":"./site/Site"}],"format":"esm"},"src/response/response.ts":{"bytes":691,"imports":[],"format":"esm"},"src/response/badRequest.ts":{"bytes":451,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/created.ts":{"bytes":384,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/forbidden.ts":{"bytes":458,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/methodNotAllowed.ts":{"bytes":419,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/transfer.ts":{"bytes":264,"imports":[],"format":"esm"},"src/response/moved.ts":{"bytes":613,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/notFound.ts":{"bytes":671,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/notModified.ts":{"bytes":419,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/ok.ts":{"bytes":684,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/redirect.ts":{"bytes":640,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/seeOther.ts":{"bytes":355,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/serverError.ts":{"bytes":315,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/unauthorized.ts":{"bytes":432,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/unprocessable.ts":{"bytes":337,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response.ts":{"bytes":886,"imports":[{"path":"src/response/badRequest.ts","kind":"import-statement","original":"./response/badRequest"},{"path":"src/response/created.ts","kind":"import-statement","original":"./response/created"},{"path":"src/response/forbidden.ts","kind":"import-statement","original":"./response/forbidden"},{"path":"src/response/methodNotAllowed.ts","kind":"import-statement","original":"./response/methodNotAllowed"},{"path":"src/response/moved.ts","kind":"import-statement","original":"./response/moved"},{"path":"src/response/notFound.ts","kind":"import-statement","original":"./response/notFound"},{"path":"src/response/notModified.ts","kind":"import-statement","original":"./response/notModified"},{"path":"src/response/ok.ts","kind":"import-statement","original":"./response/ok"},{"path":"src/response/redirect.ts","kind":"import-statement","original":"./response/redirect"},{"path":"src/response/response.ts","kind":"import-statement","original":"./response/response"},{"path":"src/response/seeOther.ts","kind":"import-statement","original":"./response/seeOther"},{"path":"src/response/serverError.ts","kind":"import-statement","original":"./response/serverError"},{"path":"src/response/transfer.ts","kind":"import-statement","original":"./response/transfer"},{"path":"src/response/unauthorized.ts","kind":"import-statement","original":"./response/unauthorized"},{"path":"src/response/unprocessable.ts","kind":"import-statement","original":"./response/unprocessable"}],"format":"esm"},"src/site/manifest.ts":{"bytes":1553,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site","kind":"import-statement","external":true}],"format":"esm"},"src/site/runBuild.ts":{"bytes":2902,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site.ts","kind":"import-statement","external":true},{"path":"src/site/manifest.ts","kind":"import-statement","original":"./manifest.ts"}],"format":"esm"},"src/server/CookieHelper.ts":{"bytes":1078,"imports":[{"path":"cookie","kind":"import-statement","external":true}],"format":"esm"},"src/server/HeaderHelper.ts":{"bytes":571,"imports":[],"format":"esm"},"src/server/ServerEvent.ts":{"bytes":956,"imports":[{"path":"src/server/CookieHelper.ts","kind":"import-statement","original":"./CookieHelper"},{"path":"src/server/HeaderHelper.ts","kind":"import-statement","original":"./HeaderHelper"}],"format":"esm"},"src/server/Server.ts":{"bytes":3639,"imports":[{"path":"src/site/pathToRegex.ts","kind":"import-statement","original":"../site/pathToRegex"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"./ServerEvent"}],"format":"esm"},"src/server/connect/flattenHeaders.ts":{"bytes":1017,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"node:http2","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytes":2363,"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/readableToBuffer.ts":{"bytes":388,"imports":[{"path":"node:stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/requestToNodeMessage.ts":{"bytes":1109,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/connectMiddleware.ts":{"bytes":2655,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"src/server/connect/flattenHeaders.ts","kind":"import-statement","original":"./flattenHeaders"},{"path":"src/server/connect/nodeMessageToNodeResponse.ts","kind":"import-statement","original":"./nodeMessageToNodeResponse"},{"path":"src/server/connect/readableToBuffer.ts","kind":"import-statement","original":"./readableToBuffer"},{"path":"src/server/connect/requestToNodeMessage.ts","kind":"import-statement","original":"./requestToNodeMessage"}],"format":"esm"},"src/site/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/site/runDev.ts":{"bytes":3047,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"dotenv","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/response.ts","kind":"import-statement","original":"../response.ts"},{"path":"src/server/Server.ts","kind":"import-statement","original":"../server/Server.ts"},{"path":"src/server/connect/connectMiddleware.ts","kind":"import-statement","original":"../server/connect/connectMiddleware.ts"},{"path":"./Site.ts","kind":"import-statement","external":true},{"path":"src/site/manifest.ts","kind":"import-statement","original":"./manifest.ts"},{"path":"src/site/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate.ts"}],"format":"esm"},"src/server/contentType.ts":{"bytes":2679,"imports":[],"format":"esm"},"src/site/runPreview.ts":{"bytes":2543,"imports":[{"path":"dotenv","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/response.ts","kind":"import-statement","original":"../response.ts"},{"path":"src/server/Server.ts","kind":"import-statement","original":"../server/Server.ts"},{"path":"src/server/contentType.ts","kind":"import-statement","original":"../server/contentType.ts"},{"path":"./Site","kind":"import-statement","external":true},{"path":"src/site/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate.ts"},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./runBuild"}],"format":"esm"},"src/site/run.ts":{"bytes":1695,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site","kind":"import-statement","external":true},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./runBuild"},{"path":"src/site/runDev.ts","kind":"import-statement","original":"./runDev"},{"path":"src/site/runPreview.ts","kind":"import-statement","original":"./runPreview"}],"format":"esm"},"src/run.ts":{"bytes":197,"imports":[{"path":"src/site/run.ts","kind":"import-statement","original":"./site/run"},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./site/runBuild"},{"path":"src/site/runDev.ts","kind":"import-statement","original":"./site/runDev"},{"path":"src/site/runPreview.ts","kind":"import-statement","original":"./site/runPreview"}],"format":"esm"},"src/server.ts":{"bytes":334,"imports":[{"path":"src/server/CookieHelper.ts","kind":"import-statement","original":"./server/CookieHelper"},{"path":"src/server/HeaderHelper.ts","kind":"import-statement","original":"./server/HeaderHelper"},{"path":"src/server/Server.ts","kind":"import-statement","original":"./server/Server"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"./server/ServerEvent"},{"path":"src/server/connect/connectMiddleware.ts","kind":"import-statement","original":"./server/connect/connectMiddleware"}],"format":"esm"},"src/state/$page.ts":{"bytes":218,"imports":[{"path":"@torpor/view","kind":"import-statement","external":true}],"format":"esm"},"src/state.ts":{"bytes":54,"imports":[{"path":"src/state/$page.ts","kind":"import-statement","original":"./state/$page"}],"format":"esm"},"src/test/runTest.ts":{"bytes":9832,"imports":[{"path":"@torpor/view","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/response/notFound.ts","kind":"import-statement","original":"../response/notFound.ts"},{"path":"src/response/ok.ts","kind":"import-statement","original":"../response/ok.ts"},{"path":"src/response/seeOther.ts","kind":"import-statement","original":"../response/seeOther.ts"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"../server/ServerEvent.ts"},{"path":"src/site/Router.ts","kind":"import-statement","original":"../site/Router.ts"},{"path":"../site/Site","kind":"import-statement","external":true},{"path":"src/state/$page.ts","kind":"import-statement","original":"../state/$page.ts"},{"path":"../types/RouteHandler.ts","kind":"import-statement","external":true},{"path":"src/types/RouteType.ts","kind":"import-statement","original":"../types/RouteType"}],"format":"esm"},"src/test.ts":{"bytes":59,"imports":[{"path":"src/test/runTest.ts","kind":"import-statement","original":"./test/runTest"}],"format":"esm"},"src/bin/index.ts":{"bytes":351,"imports":[{"path":"src/site/run.ts","kind":"import-statement","original":"../site/run"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":16981},"dist/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite-tsconfig-paths","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":143},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/site/Router.ts":{"bytesInOutput":3423},"src/site/Site.ts":{"bytesInOutput":3655},"src/types/RouteType.ts":{"bytesInOutput":167},"src/site/defaultAdapter.ts":{"bytesInOutput":154}},"bytes":9517},"dist/response.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10313},"dist/response.cjs":{"imports":[],"exports":[],"entryPoint":"src/response.ts","inputs":{"src/response.ts":{"bytesInOutput":560},"src/response/response.ts":{"bytesInOutput":334},"src/response/badRequest.ts":{"bytesInOutput":60},"src/response/created.ts":{"bytesInOutput":57},"src/response/forbidden.ts":{"bytesInOutput":59},"src/response/methodNotAllowed.ts":{"bytesInOutput":66},"src/response/transfer.ts":{"bytesInOutput":124},"src/response/moved.ts":{"bytesInOutput":63},"src/response/notFound.ts":{"bytesInOutput":58},"src/response/notModified.ts":{"bytesInOutput":69},"src/response/ok.ts":{"bytesInOutput":52},"src/response/redirect.ts":{"bytesInOutput":66},"src/response/seeOther.ts":{"bytesInOutput":66},"src/response/serverError.ts":{"bytesInOutput":61},"src/response/unauthorized.ts":{"bytesInOutput":62},"src/response/unprocessable.ts":{"bytesInOutput":63}},"bytes":3376},"dist/run.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":49613},"dist/run.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/run.ts","inputs":{"src/run.ts":{"bytesInOutput":195},"src/site/run.ts":{"bytesInOutput":1556},"src/site/runBuild.ts":{"bytesInOutput":2616},"src/site/manifest.ts":{"bytesInOutput":1256},"src/site/runDev.ts":{"bytesInOutput":1514},"src/response/response.ts":{"bytesInOutput":334},"src/response/serverError.ts":{"bytesInOutput":61},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2764},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381},"src/site/prepareTemplate.ts":{"bytesInOutput":698},"src/site/runPreview.ts":{"bytesInOutput":1939},"src/server/contentType.ts":{"bytesInOutput":2608}},"bytes":24126},"dist/server.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23404},"dist/server.cjs":{"imports":[{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/server.ts","inputs":{"src/server.ts":{"bytesInOutput":278},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/site/pathToRegex.ts":{"bytesInOutput":301},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2756},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381}},"bytes":10720},"dist/state.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":637},"dist/state.cjs":{"imports":[{"path":"@torpor/view","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/state.ts","inputs":{"src/state.ts":{"bytesInOutput":128},"src/state/$page.ts":{"bytesInOutput":192}},"bytes":1258},"dist/test.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":32812},"dist/test.cjs":{"imports":[{"path":"path","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"@torpor/view","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/test.ts","inputs":{"src/test.ts":{"bytesInOutput":122},"src/test/runTest.ts":{"bytesInOutput":6540},"src/response/response.ts":{"bytesInOutput":334},"src/response/notFound.ts":{"bytesInOutput":58},"src/response/ok.ts":{"bytesInOutput":52},"src/response/transfer.ts":{"bytesInOutput":124},"src/response/seeOther.ts":{"bytesInOutput":66},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/site/Router.ts":{"bytesInOutput":3423},"src/state/$page.ts":{"bytesInOutput":192},"src/types/RouteType.ts":{"bytesInOutput":167}},"bytes":15186},"dist/bin/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":50067},"dist/bin/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/bin/index.ts","inputs":{"src/site/run.ts":{"bytesInOutput":1556},"src/site/runBuild.ts":{"bytesInOutput":2616},"src/site/manifest.ts":{"bytesInOutput":1256},"src/site/runDev.ts":{"bytesInOutput":1514},"src/response/response.ts":{"bytesInOutput":334},"src/response/serverError.ts":{"bytesInOutput":61},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2764},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381},"src/site/prepareTemplate.ts":{"bytesInOutput":698},"src/site/runPreview.ts":{"bytesInOutput":1939},"src/server/contentType.ts":{"bytesInOutput":2608},"src/bin/index.ts":{"bytesInOutput":309}},"bytes":23914}}}
|
|
1
|
+
{"inputs":{"src/site/pathToRegex.ts":{"bytes":459,"imports":[],"format":"esm"},"src/site/Router.ts":{"bytes":4384,"imports":[{"path":"src/site/pathToRegex.ts","kind":"import-statement","original":"./pathToRegex"}],"format":"esm"},"src/types/RouteType.ts":{"bytes":488,"imports":[],"format":"esm"},"src/site/defaultAdapter.ts":{"bytes":282,"imports":[{"path":"../types/Adapter","kind":"import-statement","external":true}],"format":"esm"},"src/site/Site.ts":{"bytes":5729,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"vite-tsconfig-paths","kind":"import-statement","external":true},{"path":"src/types/RouteType.ts","kind":"import-statement","original":"../types/RouteType"},{"path":"src/site/defaultAdapter.ts","kind":"import-statement","original":"./defaultAdapter"}],"format":"esm"},"src/index.ts":{"bytes":838,"imports":[{"path":"src/site/Router.ts","kind":"import-statement","original":"./site/Router"},{"path":"src/site/Site.ts","kind":"import-statement","original":"./site/Site"}],"format":"esm"},"src/response/response.ts":{"bytes":691,"imports":[],"format":"esm"},"src/response/badRequest.ts":{"bytes":468,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/created.ts":{"bytes":384,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/forbidden.ts":{"bytes":473,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/methodNotAllowed.ts":{"bytes":443,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/transfer.ts":{"bytes":264,"imports":[],"format":"esm"},"src/response/moved.ts":{"bytes":613,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/notFound.ts":{"bytes":686,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/notModified.ts":{"bytes":419,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/ok.ts":{"bytes":684,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/redirect.ts":{"bytes":640,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/seeOther.ts":{"bytes":355,"imports":[{"path":"src/response/transfer.ts","kind":"import-statement","original":"./transfer"}],"format":"esm"},"src/response/serverError.ts":{"bytes":333,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/unauthorized.ts":{"bytes":450,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response/unprocessable.ts":{"bytes":356,"imports":[{"path":"src/response/response.ts","kind":"import-statement","original":"./response"}],"format":"esm"},"src/response.ts":{"bytes":886,"imports":[{"path":"src/response/badRequest.ts","kind":"import-statement","original":"./response/badRequest"},{"path":"src/response/created.ts","kind":"import-statement","original":"./response/created"},{"path":"src/response/forbidden.ts","kind":"import-statement","original":"./response/forbidden"},{"path":"src/response/methodNotAllowed.ts","kind":"import-statement","original":"./response/methodNotAllowed"},{"path":"src/response/moved.ts","kind":"import-statement","original":"./response/moved"},{"path":"src/response/notFound.ts","kind":"import-statement","original":"./response/notFound"},{"path":"src/response/notModified.ts","kind":"import-statement","original":"./response/notModified"},{"path":"src/response/ok.ts","kind":"import-statement","original":"./response/ok"},{"path":"src/response/redirect.ts","kind":"import-statement","original":"./response/redirect"},{"path":"src/response/response.ts","kind":"import-statement","original":"./response/response"},{"path":"src/response/seeOther.ts","kind":"import-statement","original":"./response/seeOther"},{"path":"src/response/serverError.ts","kind":"import-statement","original":"./response/serverError"},{"path":"src/response/transfer.ts","kind":"import-statement","original":"./response/transfer"},{"path":"src/response/unauthorized.ts","kind":"import-statement","original":"./response/unauthorized"},{"path":"src/response/unprocessable.ts","kind":"import-statement","original":"./response/unprocessable"}],"format":"esm"},"src/site/manifest.ts":{"bytes":1553,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site","kind":"import-statement","external":true}],"format":"esm"},"src/site/runBuild.ts":{"bytes":2902,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site.ts","kind":"import-statement","external":true},{"path":"src/site/manifest.ts","kind":"import-statement","original":"./manifest.ts"}],"format":"esm"},"src/server/CookieHelper.ts":{"bytes":1078,"imports":[{"path":"cookie","kind":"import-statement","external":true}],"format":"esm"},"src/server/HeaderHelper.ts":{"bytes":571,"imports":[],"format":"esm"},"src/server/ServerEvent.ts":{"bytes":956,"imports":[{"path":"src/server/CookieHelper.ts","kind":"import-statement","original":"./CookieHelper"},{"path":"src/server/HeaderHelper.ts","kind":"import-statement","original":"./HeaderHelper"}],"format":"esm"},"src/server/Server.ts":{"bytes":3639,"imports":[{"path":"src/site/pathToRegex.ts","kind":"import-statement","original":"../site/pathToRegex"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"./ServerEvent"}],"format":"esm"},"src/server/connect/flattenHeaders.ts":{"bytes":1017,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"node:http2","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytes":2363,"imports":[{"path":"http","kind":"import-statement","external":true},{"path":"stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/readableToBuffer.ts":{"bytes":388,"imports":[{"path":"node:stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/requestToNodeMessage.ts":{"bytes":1109,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"stream","kind":"import-statement","external":true}],"format":"esm"},"src/server/connect/connectMiddleware.ts":{"bytes":2655,"imports":[{"path":"node:http","kind":"import-statement","external":true},{"path":"src/server/connect/flattenHeaders.ts","kind":"import-statement","original":"./flattenHeaders"},{"path":"src/server/connect/nodeMessageToNodeResponse.ts","kind":"import-statement","original":"./nodeMessageToNodeResponse"},{"path":"src/server/connect/readableToBuffer.ts","kind":"import-statement","original":"./readableToBuffer"},{"path":"src/server/connect/requestToNodeMessage.ts","kind":"import-statement","original":"./requestToNodeMessage"}],"format":"esm"},"src/site/prepareTemplate.ts":{"bytes":809,"imports":[],"format":"esm"},"src/site/runDev.ts":{"bytes":3047,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"dotenv","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"src/response.ts","kind":"import-statement","original":"../response.ts"},{"path":"src/server/Server.ts","kind":"import-statement","original":"../server/Server.ts"},{"path":"src/server/connect/connectMiddleware.ts","kind":"import-statement","original":"../server/connect/connectMiddleware.ts"},{"path":"./Site.ts","kind":"import-statement","external":true},{"path":"src/site/manifest.ts","kind":"import-statement","original":"./manifest.ts"},{"path":"src/site/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate.ts"}],"format":"esm"},"src/server/contentType.ts":{"bytes":2679,"imports":[],"format":"esm"},"src/site/runPreview.ts":{"bytes":2543,"imports":[{"path":"dotenv","kind":"import-statement","external":true},{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/response.ts","kind":"import-statement","original":"../response.ts"},{"path":"src/server/Server.ts","kind":"import-statement","original":"../server/Server.ts"},{"path":"src/server/contentType.ts","kind":"import-statement","original":"../server/contentType.ts"},{"path":"./Site","kind":"import-statement","external":true},{"path":"src/site/prepareTemplate.ts","kind":"import-statement","original":"./prepareTemplate.ts"},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./runBuild"}],"format":"esm"},"src/site/run.ts":{"bytes":1695,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vite","kind":"import-statement","external":true},{"path":"./Site","kind":"import-statement","external":true},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./runBuild"},{"path":"src/site/runDev.ts","kind":"import-statement","original":"./runDev"},{"path":"src/site/runPreview.ts","kind":"import-statement","original":"./runPreview"}],"format":"esm"},"src/run.ts":{"bytes":197,"imports":[{"path":"src/site/run.ts","kind":"import-statement","original":"./site/run"},{"path":"src/site/runBuild.ts","kind":"import-statement","original":"./site/runBuild"},{"path":"src/site/runDev.ts","kind":"import-statement","original":"./site/runDev"},{"path":"src/site/runPreview.ts","kind":"import-statement","original":"./site/runPreview"}],"format":"esm"},"src/server.ts":{"bytes":334,"imports":[{"path":"src/server/CookieHelper.ts","kind":"import-statement","original":"./server/CookieHelper"},{"path":"src/server/HeaderHelper.ts","kind":"import-statement","original":"./server/HeaderHelper"},{"path":"src/server/Server.ts","kind":"import-statement","original":"./server/Server"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"./server/ServerEvent"},{"path":"src/server/connect/connectMiddleware.ts","kind":"import-statement","original":"./server/connect/connectMiddleware"}],"format":"esm"},"src/state/$page.ts":{"bytes":231,"imports":[{"path":"@torpor/view","kind":"import-statement","external":true},{"path":"./Page","kind":"import-statement","external":true}],"format":"esm"},"src/state.ts":{"bytes":54,"imports":[{"path":"src/state/$page.ts","kind":"import-statement","original":"./state/$page"}],"format":"esm"},"src/test/runTest.ts":{"bytes":9832,"imports":[{"path":"@torpor/view","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/response/notFound.ts","kind":"import-statement","original":"../response/notFound.ts"},{"path":"src/response/ok.ts","kind":"import-statement","original":"../response/ok.ts"},{"path":"src/response/seeOther.ts","kind":"import-statement","original":"../response/seeOther.ts"},{"path":"src/server/ServerEvent.ts","kind":"import-statement","original":"../server/ServerEvent.ts"},{"path":"src/site/Router.ts","kind":"import-statement","original":"../site/Router.ts"},{"path":"../site/Site","kind":"import-statement","external":true},{"path":"src/state/$page.ts","kind":"import-statement","original":"../state/$page.ts"},{"path":"../types/RouteHandler.ts","kind":"import-statement","external":true},{"path":"src/types/RouteType.ts","kind":"import-statement","original":"../types/RouteType"}],"format":"esm"},"src/test.ts":{"bytes":59,"imports":[{"path":"src/test/runTest.ts","kind":"import-statement","original":"./test/runTest"}],"format":"esm"},"src/bin/index.ts":{"bytes":351,"imports":[{"path":"src/site/run.ts","kind":"import-statement","original":"../site/run"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":19419},"dist/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite-tsconfig-paths","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":143},"src/site/pathToRegex.ts":{"bytesInOutput":301},"src/site/Router.ts":{"bytesInOutput":3398},"src/site/Site.ts":{"bytesInOutput":4854},"src/types/RouteType.ts":{"bytesInOutput":188},"src/site/defaultAdapter.ts":{"bytesInOutput":154}},"bytes":10710},"dist/response.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10490},"dist/response.cjs":{"imports":[],"exports":[],"entryPoint":"src/response.ts","inputs":{"src/response.ts":{"bytesInOutput":560},"src/response/response.ts":{"bytesInOutput":334},"src/response/badRequest.ts":{"bytesInOutput":77},"src/response/created.ts":{"bytesInOutput":57},"src/response/forbidden.ts":{"bytesInOutput":74},"src/response/methodNotAllowed.ts":{"bytesInOutput":90},"src/response/transfer.ts":{"bytesInOutput":124},"src/response/moved.ts":{"bytesInOutput":63},"src/response/notFound.ts":{"bytesInOutput":73},"src/response/notModified.ts":{"bytesInOutput":69},"src/response/ok.ts":{"bytesInOutput":52},"src/response/redirect.ts":{"bytesInOutput":66},"src/response/seeOther.ts":{"bytesInOutput":66},"src/response/serverError.ts":{"bytesInOutput":79},"src/response/unauthorized.ts":{"bytesInOutput":80},"src/response/unprocessable.ts":{"bytesInOutput":82}},"bytes":3502},"dist/run.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":49638},"dist/run.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/run.ts","inputs":{"src/run.ts":{"bytesInOutput":195},"src/site/run.ts":{"bytesInOutput":1556},"src/site/runBuild.ts":{"bytesInOutput":2616},"src/site/manifest.ts":{"bytesInOutput":1256},"src/site/runDev.ts":{"bytesInOutput":1514},"src/response/response.ts":{"bytesInOutput":334},"src/response/serverError.ts":{"bytesInOutput":79},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2764},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381},"src/site/prepareTemplate.ts":{"bytesInOutput":698},"src/site/runPreview.ts":{"bytesInOutput":1939},"src/server/contentType.ts":{"bytesInOutput":2608}},"bytes":24144},"dist/server.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":23404},"dist/server.cjs":{"imports":[{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/server.ts","inputs":{"src/server.ts":{"bytesInOutput":278},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/site/pathToRegex.ts":{"bytesInOutput":301},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2756},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381}},"bytes":10720},"dist/state.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":698},"dist/state.cjs":{"imports":[{"path":"@torpor/view","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/state.ts","inputs":{"src/state.ts":{"bytesInOutput":128},"src/state/$page.ts":{"bytesInOutput":230}},"bytes":1296},"dist/test.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":33174},"dist/test.cjs":{"imports":[{"path":"path","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"@torpor/view","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/test.ts","inputs":{"src/test.ts":{"bytesInOutput":122},"src/test/runTest.ts":{"bytesInOutput":6540},"src/response/response.ts":{"bytesInOutput":334},"src/response/notFound.ts":{"bytesInOutput":73},"src/response/ok.ts":{"bytesInOutput":52},"src/response/transfer.ts":{"bytesInOutput":124},"src/response/seeOther.ts":{"bytesInOutput":66},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/site/Router.ts":{"bytesInOutput":3423},"src/state/$page.ts":{"bytesInOutput":230},"src/types/RouteType.ts":{"bytesInOutput":167}},"bytes":15239},"dist/bin/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":50092},"dist/bin/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vite","kind":"require-call","external":true},{"path":"cookie","kind":"require-call","external":true},{"path":"http","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"stream","kind":"require-call","external":true},{"path":"dotenv","kind":"require-call","external":true},{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/bin/index.ts","inputs":{"src/site/run.ts":{"bytesInOutput":1556},"src/site/runBuild.ts":{"bytesInOutput":2616},"src/site/manifest.ts":{"bytesInOutput":1256},"src/site/runDev.ts":{"bytesInOutput":1514},"src/response/response.ts":{"bytesInOutput":334},"src/response/serverError.ts":{"bytesInOutput":79},"src/site/pathToRegex.ts":{"bytesInOutput":303},"src/server/CookieHelper.ts":{"bytesInOutput":819},"src/server/HeaderHelper.ts":{"bytesInOutput":397},"src/server/ServerEvent.ts":{"bytesInOutput":696},"src/server/Server.ts":{"bytesInOutput":2764},"src/server/connect/flattenHeaders.ts":{"bytesInOutput":472},"src/server/connect/nodeMessageToNodeResponse.ts":{"bytesInOutput":1430},"src/server/connect/readableToBuffer.ts":{"bytesInOutput":304},"src/server/connect/requestToNodeMessage.ts":{"bytesInOutput":529},"src/server/connect/connectMiddleware.ts":{"bytesInOutput":1381},"src/site/prepareTemplate.ts":{"bytesInOutput":698},"src/site/runPreview.ts":{"bytesInOutput":1939},"src/server/contentType.ts":{"bytesInOutput":2608},"src/bin/index.ts":{"bytesInOutput":309}},"bytes":23932}}}
|