@torpor/build 0.0.5 → 0.0.6
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 +8 -0
- package/dist/bin/index.cjs.map +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/{chunk-L7GOYKUG.js → chunk-IE5EKBNX.js} +1 -1
- package/dist/chunk-IE5EKBNX.js.map +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -19
- package/dist/index.d.ts +24 -19
- package/dist/index.js +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +3 -3
- package/dist/chunk-L7GOYKUG.js.map +0 -1
package/CHANGELOG.md
CHANGED
package/dist/bin/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/index.ts","../../src/site/defineConfig.ts","../../src/site/FileSystemRouter.ts"],"sourcesContent":["#! /usr/bin/env node\n//import { existsSync, promises as fs } from \"node:fs\";\nimport fs from \"node:fs\";\nimport path from \"path\";\nimport defineConfig from \"../site/defineConfig\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/bin/index.ts","../../src/site/defineConfig.ts","../../src/site/FileSystemRouter.ts"],"sourcesContent":["#! /usr/bin/env node\n//import { existsSync, promises as fs } from \"node:fs\";\nimport fs from \"node:fs\";\nimport path from \"path\";\nimport defineConfig from \"../site/defineConfig\";\nimport type UserConfig from \"../types/UserConfig\";\n\n// Check for a torpor.config.js/ts file in the working directory\n// TODO: Make sure it's valid, try/catch, etc\n// TODO: There has GOT to be an easier way\nlet options: UserConfig | undefined;\nconst workingDir = process.cwd();\nconst jsConfigFile = path.join(workingDir, \"torpor.config.js\");\nconst tsConfigFile = path.join(workingDir, \"torpor.config.ts\");\nlet source: string | undefined;\nif (fs.existsSync(jsConfigFile)) {\n\t//const configFile = path.relative(\".\", tsConfigFile);\n\t//options = await import(configFile);\n\tsource = fs.readFileSync(jsConfigFile, \"utf8\");\n\tsource = source\n\t\t.replace(\n\t\t\t/import\\s+\\{\\s+defineConfig\\s+\\}\\s+from\\s+[\"']@torpor\\/build[\"']/,\n\t\t\t\"const defineConfig = (x) => x\",\n\t\t)\n\t\t.replace(\"export default\", \"\");\n} else if (fs.existsSync(tsConfigFile)) {\n\tconsole.log(\"TS config file is not supported\");\n}\n\nif (source) {\n\toptions = eval(source);\n}\n\ndefineConfig(options);\n\n// This already gets done in vinxi.createApp so we can't do it twice\n//const app = defineConfig(options);\n//if (process.argv.includes(\"--dev\")) {\n//\tawait app.dev();\n//} else if (process.argv.includes(\"--build\")) {\n//\tawait app.build();\n//}\n","import torpor from \"@torpor/unplugin/vite\";\nimport path from \"node:path\";\nimport { type AppOptions, type RouterSchemaInput, createApp } from \"vinxi\";\nimport { config } from \"vinxi/plugins/config\";\nimport type UserConfig from \"../types/UserConfig\";\nimport FileSystemRouter from \"./FileSystemRouter\";\n\nexport default function defineConfig(options?: UserConfig) {\n\t// Set the port\n\tprocess.env.PORT = (options?.port || 7059).toString();\n\n\t// Get Vinxi to create and serve the app\n\treturn createApp({\n\t\tname: \"torpor\",\n\t\trouters: [\n\t\t\t{\n\t\t\t\tname: \"assets\",\n\t\t\t\ttype: \"static\",\n\t\t\t\tdir: \"./src/assets\",\n\t\t\t},\n\t\t\t// Doesn't look like we can have two server routes?\n\t\t\t// Have to put api in /routes\n\t\t\t// Maybe we can support having /routes/api and routes/site and stripping /site from the start?\n\t\t\t//{\n\t\t\t//\tname: \"api\",\n\t\t\t//\ttype: \"http\",\n\t\t\t//\ttarget: \"server\",\n\t\t\t//\t// TODO: change this when published\n\t\t\t//\thandler: \"node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t//\troutes: apiRoutes,\n\t\t\t//\tplugins: () => [config(\"custom\", viteOptions())],\n\t\t\t//},\n\t\t\t{\n\t\t\t\tname: \"server\",\n\t\t\t\ttype: \"http\",\n\t\t\t\ttarget: \"server\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor({ server: true })],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"client\",\n\t\t\t\ttype: \"client\",\n\t\t\t\ttarget: \"browser\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/clientEntry.ts\",\n\t\t\t\tbase: \"/_build\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor()],\n\t\t\t},\n\t\t],\n\t});\n}\n\nfunction routes(router: RouterSchemaInput, app: AppOptions) {\n\treturn new FileSystemRouter(\n\t\t{\n\t\t\tdir: path.resolve(\"src/routes\"),\n\t\t\textensions: [\"js\", \"ts\"],\n\t\t},\n\t\trouter,\n\t\tapp,\n\t);\n}\n\nfunction viteOptions() {\n\treturn {\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t\"@\": path.resolve(\"src\"),\n\t\t\t},\n\t\t},\n\t};\n}\n","import { BaseFileSystemRouter, cleanPath } from \"vinxi/fs-router\";\n\nexport default class FileSystemRouter extends BaseFileSystemRouter {\n\ttoPath(src: string) {\n\t\tlet routePath = cleanPath(src, this.config)\n\t\t\t.replace(/^\\//, \"\")\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(/\\+page$/, \"\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath?.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\ttoRoute(filePath: string) {\n\t\treturn {\n\t\t\tpath: this.toPath(filePath),\n\t\t\t$handler: {\n\t\t\t\tsrc: filePath,\n\t\t\t\tpick: [\"default\"],\n\t\t\t},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ACN,MAAM;AAAA,QACN,QAAQ;AAAA;AAAA,QAER,SAAS;AAAA,QACT,MAAM;AAAA,QACN;AAAA,QACA,SAAS,MAAM,KAAC,sBAAO,UAAU,YAAY,CAAC,OAAG,YAAAA,SAAO,CAAC;AAAA,MAC1D;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAEA,SAAS,OAAO,QAA2B,KAAiB;AAC3D,SAAO,IAAI;AAAA,IACV;AAAA,MACC,KAAK,iBAAAC,QAAK,QAAQ,YAAY;AAAA,MAC9B,YAAY,CAAC,MAAM,IAAI;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,cAAc;AACtB,SAAO;AAAA,IACN,SAAS;AAAA,MACR,OAAO;AAAA,QACN,KAAK,iBAAAA,QAAK,QAAQ,KAAK;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AACD;;;ADhEA,IAAI;AACJ,IAAM,aAAa,QAAQ,IAAI;AAC/B,IAAM,eAAe,YAAAC,QAAK,KAAK,YAAY,kBAAkB;AAC7D,IAAM,eAAe,YAAAA,QAAK,KAAK,YAAY,kBAAkB;AAC7D,IAAI;AACJ,IAAI,eAAAC,QAAG,WAAW,YAAY,GAAG;AAGhC,WAAS,eAAAA,QAAG,aAAa,cAAc,MAAM;AAC7C,WAAS,OACP;AAAA,IACA;AAAA,IACA;AAAA,EACD,EACC,QAAQ,kBAAkB,EAAE;AAC/B,WAAW,eAAAA,QAAG,WAAW,YAAY,GAAG;AACvC,UAAQ,IAAI,iCAAiC;AAC9C;AAEA,IAAI,QAAQ;AACX,YAAU,KAAK,MAAM;AACtB;AAEA,aAAa,OAAO;","names":["options","torpor","path","path","fs"]}
|
package/dist/bin/index.js
CHANGED
package/dist/bin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["#! /usr/bin/env node\n//import { existsSync, promises as fs } from \"node:fs\";\nimport fs from \"node:fs\";\nimport path from \"path\";\nimport defineConfig from \"../site/defineConfig\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/bin/index.ts"],"sourcesContent":["#! /usr/bin/env node\n//import { existsSync, promises as fs } from \"node:fs\";\nimport fs from \"node:fs\";\nimport path from \"path\";\nimport defineConfig from \"../site/defineConfig\";\nimport type UserConfig from \"../types/UserConfig\";\n\n// Check for a torpor.config.js/ts file in the working directory\n// TODO: Make sure it's valid, try/catch, etc\n// TODO: There has GOT to be an easier way\nlet options: UserConfig | undefined;\nconst workingDir = process.cwd();\nconst jsConfigFile = path.join(workingDir, \"torpor.config.js\");\nconst tsConfigFile = path.join(workingDir, \"torpor.config.ts\");\nlet source: string | undefined;\nif (fs.existsSync(jsConfigFile)) {\n\t//const configFile = path.relative(\".\", tsConfigFile);\n\t//options = await import(configFile);\n\tsource = fs.readFileSync(jsConfigFile, \"utf8\");\n\tsource = source\n\t\t.replace(\n\t\t\t/import\\s+\\{\\s+defineConfig\\s+\\}\\s+from\\s+[\"']@torpor\\/build[\"']/,\n\t\t\t\"const defineConfig = (x) => x\",\n\t\t)\n\t\t.replace(\"export default\", \"\");\n} else if (fs.existsSync(tsConfigFile)) {\n\tconsole.log(\"TS config file is not supported\");\n}\n\nif (source) {\n\toptions = eval(source);\n}\n\ndefineConfig(options);\n\n// This already gets done in vinxi.createApp so we can't do it twice\n//const app = defineConfig(options);\n//if (process.argv.includes(\"--dev\")) {\n//\tawait app.dev();\n//} else if (process.argv.includes(\"--build\")) {\n//\tawait app.build();\n//}\n"],"mappings":";;;;;;AAEA,OAAO,QAAQ;AACf,OAAO,UAAU;AAOjB,IAAI;AACJ,IAAM,aAAa,QAAQ,IAAI;AAC/B,IAAM,eAAe,KAAK,KAAK,YAAY,kBAAkB;AAC7D,IAAM,eAAe,KAAK,KAAK,YAAY,kBAAkB;AAC7D,IAAI;AACJ,IAAI,GAAG,WAAW,YAAY,GAAG;AAGhC,WAAS,GAAG,aAAa,cAAc,MAAM;AAC7C,WAAS,OACP;AAAA,IACA;AAAA,IACA;AAAA,EACD,EACC,QAAQ,kBAAkB,EAAE;AAC/B,WAAW,GAAG,WAAW,YAAY,GAAG;AACvC,UAAQ,IAAI,iCAAiC;AAC9C;AAEA,IAAI,QAAQ;AACX,YAAU,KAAK,MAAM;AACtB;AAEA,aAAa,OAAO;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/site/defineConfig.ts","../src/site/FileSystemRouter.ts"],"sourcesContent":["import torpor from \"@torpor/unplugin/vite\";\nimport path from \"node:path\";\nimport { type AppOptions, type RouterSchemaInput, createApp } from \"vinxi\";\nimport { config } from \"vinxi/plugins/config\";\nimport type UserConfig from \"../types/UserConfig\";\nimport FileSystemRouter from \"./FileSystemRouter\";\n\nexport default function defineConfig(options?: UserConfig) {\n\t// Set the port\n\tprocess.env.PORT = (options?.port || 7059).toString();\n\n\t// Get Vinxi to create and serve the app\n\treturn createApp({\n\t\tname: \"torpor\",\n\t\trouters: [\n\t\t\t{\n\t\t\t\tname: \"assets\",\n\t\t\t\ttype: \"static\",\n\t\t\t\tdir: \"./src/assets\",\n\t\t\t},\n\t\t\t// Doesn't look like we can have two server routes?\n\t\t\t// Have to put api in /routes\n\t\t\t// Maybe we can support having /routes/api and routes/site and stripping /site from the start?\n\t\t\t//{\n\t\t\t//\tname: \"api\",\n\t\t\t//\ttype: \"http\",\n\t\t\t//\ttarget: \"server\",\n\t\t\t//\t// TODO: change this when published\n\t\t\t//\thandler: \"node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t//\troutes: apiRoutes,\n\t\t\t//\tplugins: () => [config(\"custom\", viteOptions())],\n\t\t\t//},\n\t\t\t{\n\t\t\t\tname: \"server\",\n\t\t\t\ttype: \"http\",\n\t\t\t\ttarget: \"server\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor({ server: true })],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"client\",\n\t\t\t\ttype: \"client\",\n\t\t\t\ttarget: \"browser\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/clientEntry.ts\",\n\t\t\t\tbase: \"/_build\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor()],\n\t\t\t},\n\t\t],\n\t});\n}\n\nfunction routes(router: RouterSchemaInput, app: AppOptions) {\n\treturn new FileSystemRouter(\n\t\t{\n\t\t\tdir: path.resolve(\"src/routes\"),\n\t\t\textensions: [\"js\", \"ts\"],\n\t\t},\n\t\trouter,\n\t\tapp,\n\t);\n}\n\nfunction viteOptions() {\n\treturn {\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t\"@\": path.resolve(\"src\"),\n\t\t\t},\n\t\t},\n\t};\n}\n","import { BaseFileSystemRouter, cleanPath } from \"vinxi/fs-router\";\n\nexport default class FileSystemRouter extends BaseFileSystemRouter {\n\ttoPath(src: string) {\n\t\tlet routePath = cleanPath(src, this.config)\n\t\t\t.replace(/^\\//, \"\")\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(/\\+page$/, \"\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath?.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\ttoRoute(filePath: string) {\n\t\treturn {\n\t\t\tpath: this.toPath(filePath),\n\t\t\t$handler: {\n\t\t\t\tsrc: filePath,\n\t\t\t\tpick: [\"default\"],\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAkD,iBAAiB;AACnE,SAAS,cAAc;;;ACHvB,SAAS,sBAAsB,iBAAiB;AA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D,CAAC;AACF;AAEA,SAAS,OAAO,QAA2B,KAAiB;AAC3D,SAAO,IAAI;AAAA,IACV;AAAA,MACC,KAAK,KAAK,QAAQ,YAAY;AAAA,MAC9B,YAAY,CAAC,MAAM,IAAI;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,cAAc;AACtB,SAAO;AAAA,IACN,SAAS;AAAA,MACR,OAAO;AAAA,QACN,KAAK,KAAK,QAAQ,KAAK;AAAA,MACxB;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/site/buildRoutePath.ts","../src/site/defineConfig.ts","../src/site/FileSystemRouter.ts"],"sourcesContent":["import buildRoutePath from \"./site/buildRoutePath\";\nimport defineConfig from \"./site/defineConfig\";\nimport
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/site/buildRoutePath.ts","../src/site/defineConfig.ts","../src/site/FileSystemRouter.ts"],"sourcesContent":["import buildRoutePath from \"./site/buildRoutePath\";\nimport defineConfig from \"./site/defineConfig\";\nimport type CookieHelper from \"./types/CookieHelper\";\nimport type PageEndPoint from \"./types/PageEndPoint\";\nimport type PageEvent from \"./types/PageEvent\";\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 ServerEvent from \"./types/ServerEvent\";\nimport type ServerHook from \"./types/ServerHook\";\nimport type ServerRequest from \"./types/ServerRequest\";\nimport type UserConfig from \"./types/UserConfig\";\n\n// NOTE: Do not export anything that relies on vinxi/vite from here, or it will\n// cause problems when they are re-imported when routes are lazily loaded\n\nexport { defineConfig, buildRoutePath };\n\nexport type {\n\tUserConfig,\n\tPageEndPoint,\n\tPageServerEndPoint,\n\tPageServerLoad,\n\tPageServerAction,\n\tServerEndPoint,\n\tServerRequest,\n\tServerHook,\n\tPageEvent,\n\tServerEvent,\n\tCookieHelper,\n};\n","type ParamsType = Record<PropertyKey, any>;\n\nexport default function buildRoutePath<RP extends ParamsType, UP extends ParamsType>(\n\tpath: string,\n\trouteParams: RP,\n\turlParams?: UP,\n) {\n\tfor (let [key, value] of Object.entries(routeParams)) {\n\t\tpath = path.replace(`[${key}]`, value);\n\t}\n\tif (urlParams) {\n\t\t// TODO: More sophisticated url params serialization\n\t\tlet params = Object.entries(urlParams)\n\t\t\t.map(([key, value]) => {\n\t\t\t\tif (value != null) {\n\t\t\t\t\treturn `${key}=${value}`;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter(Boolean);\n\t\tif (params.length) {\n\t\t\tpath += `?${params.join(\"&\")}`;\n\t\t}\n\t}\n\treturn path;\n}\n","import torpor from \"@torpor/unplugin/vite\";\nimport path from \"node:path\";\nimport { type AppOptions, type RouterSchemaInput, createApp } from \"vinxi\";\nimport { config } from \"vinxi/plugins/config\";\nimport type UserConfig from \"../types/UserConfig\";\nimport FileSystemRouter from \"./FileSystemRouter\";\n\nexport default function defineConfig(options?: UserConfig) {\n\t// Set the port\n\tprocess.env.PORT = (options?.port || 7059).toString();\n\n\t// Get Vinxi to create and serve the app\n\treturn createApp({\n\t\tname: \"torpor\",\n\t\trouters: [\n\t\t\t{\n\t\t\t\tname: \"assets\",\n\t\t\t\ttype: \"static\",\n\t\t\t\tdir: \"./src/assets\",\n\t\t\t},\n\t\t\t// Doesn't look like we can have two server routes?\n\t\t\t// Have to put api in /routes\n\t\t\t// Maybe we can support having /routes/api and routes/site and stripping /site from the start?\n\t\t\t//{\n\t\t\t//\tname: \"api\",\n\t\t\t//\ttype: \"http\",\n\t\t\t//\ttarget: \"server\",\n\t\t\t//\t// TODO: change this when published\n\t\t\t//\thandler: \"node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t//\troutes: apiRoutes,\n\t\t\t//\tplugins: () => [config(\"custom\", viteOptions())],\n\t\t\t//},\n\t\t\t{\n\t\t\t\tname: \"server\",\n\t\t\t\ttype: \"http\",\n\t\t\t\ttarget: \"server\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor({ server: true })],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"client\",\n\t\t\t\ttype: \"client\",\n\t\t\t\ttarget: \"browser\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/clientEntry.ts\",\n\t\t\t\tbase: \"/_build\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor()],\n\t\t\t},\n\t\t],\n\t});\n}\n\nfunction routes(router: RouterSchemaInput, app: AppOptions) {\n\treturn new FileSystemRouter(\n\t\t{\n\t\t\tdir: path.resolve(\"src/routes\"),\n\t\t\textensions: [\"js\", \"ts\"],\n\t\t},\n\t\trouter,\n\t\tapp,\n\t);\n}\n\nfunction viteOptions() {\n\treturn {\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t\"@\": path.resolve(\"src\"),\n\t\t\t},\n\t\t},\n\t};\n}\n","import { BaseFileSystemRouter, cleanPath } from \"vinxi/fs-router\";\n\nexport default class FileSystemRouter extends BaseFileSystemRouter {\n\ttoPath(src: string) {\n\t\tlet routePath = cleanPath(src, this.config)\n\t\t\t.replace(/^\\//, \"\")\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(/\\+page$/, \"\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath?.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\ttoRoute(filePath: string) {\n\t\treturn {\n\t\t\tpath: this.toPath(filePath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ializeOptions } from 'vinxi/http';
|
|
2
3
|
import { Component } from '@torpor/view';
|
|
3
4
|
import { ServerResponse } from 'node:http';
|
|
4
|
-
import { CookieSerializeOptions } from 'vinxi/http';
|
|
5
5
|
|
|
6
6
|
type ParamsType = Record<PropertyKey, any>;
|
|
7
7
|
declare function buildRoutePath<RP extends ParamsType, UP extends ParamsType>(path: string, routeParams: RP, urlParams?: UP): string;
|
|
@@ -12,6 +12,12 @@ type UserConfig = {
|
|
|
12
12
|
|
|
13
13
|
declare function defineConfig(options?: UserConfig): vinxi.App;
|
|
14
14
|
|
|
15
|
+
type CookieHelper = {
|
|
16
|
+
get: (name: string) => string | undefined;
|
|
17
|
+
set: (name: string, value: string, options?: CookieSerializeOptions) => void;
|
|
18
|
+
delete: (name: string, options?: CookieSerializeOptions) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
15
21
|
type PageEvent = {
|
|
16
22
|
/**
|
|
17
23
|
* The URL for the server function.
|
|
@@ -49,6 +55,7 @@ type PageEndPoint = {
|
|
|
49
55
|
*/
|
|
50
56
|
head?: HeadElement[] | ((event: PageEvent) => HeadElement[]);
|
|
51
57
|
};
|
|
58
|
+
|
|
52
59
|
type HeadElement = TitleElement | MetaElement;
|
|
53
60
|
interface TitleElement {
|
|
54
61
|
title: string;
|
|
@@ -58,12 +65,6 @@ interface MetaElement {
|
|
|
58
65
|
content: string;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
type CookieHelper = {
|
|
62
|
-
get: (name: string) => string | undefined;
|
|
63
|
-
set: (name: string, value: string, options?: CookieSerializeOptions) => void;
|
|
64
|
-
delete: (name: string, options?: CookieSerializeOptions) => void;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
68
|
type ServerEvent = {
|
|
68
69
|
/**
|
|
69
70
|
* The URL for the server function.
|
|
@@ -86,6 +87,10 @@ type ServerEvent = {
|
|
|
86
87
|
cookies: CookieHelper;
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
type PageServerAction = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
91
|
+
|
|
92
|
+
type PageServerLoad = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
93
|
+
|
|
89
94
|
/**
|
|
90
95
|
* For +page.server.
|
|
91
96
|
*/
|
|
@@ -93,14 +98,14 @@ type PageServerEndPoint = {
|
|
|
93
98
|
/**
|
|
94
99
|
* Loads data from the server for a page.
|
|
95
100
|
*/
|
|
96
|
-
load?:
|
|
101
|
+
load?: PageServerLoad;
|
|
97
102
|
/**
|
|
98
103
|
* A map of actions that can be performed on the server for a page, generally from a form submit.
|
|
99
104
|
*/
|
|
100
|
-
actions?: Record<string,
|
|
105
|
+
actions?: Record<string, PageServerAction>;
|
|
101
106
|
};
|
|
102
|
-
|
|
103
|
-
type
|
|
107
|
+
|
|
108
|
+
type ServerRequest = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
111
|
* For +server.
|
|
@@ -113,31 +118,30 @@ type ServerEndPoint = {
|
|
|
113
118
|
*/
|
|
114
119
|
get?: ServerRequest;
|
|
115
120
|
/**
|
|
116
|
-
*
|
|
121
|
+
* Performs a POST.
|
|
117
122
|
*/
|
|
118
123
|
post?: ServerRequest;
|
|
119
124
|
/**
|
|
120
|
-
*
|
|
125
|
+
* Performs a PATCH.
|
|
121
126
|
*/
|
|
122
127
|
patch?: ServerRequest;
|
|
123
128
|
/**
|
|
124
|
-
*
|
|
129
|
+
* Performs a PUT.
|
|
125
130
|
*/
|
|
126
131
|
put?: ServerRequest;
|
|
127
132
|
/**
|
|
128
|
-
*
|
|
133
|
+
* Performs a DELETE.
|
|
129
134
|
*/
|
|
130
135
|
del?: ServerRequest;
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
137
|
+
* Performs an OPTIONS request.
|
|
133
138
|
*/
|
|
134
139
|
options?: ServerRequest;
|
|
135
140
|
/**
|
|
136
|
-
*
|
|
141
|
+
* Performs a HEAD request.
|
|
137
142
|
*/
|
|
138
143
|
head?: ServerRequest;
|
|
139
144
|
};
|
|
140
|
-
type ServerRequest = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
141
145
|
|
|
142
146
|
/**
|
|
143
147
|
* For _hook.server.
|
|
@@ -148,6 +152,7 @@ type ServerHook = {
|
|
|
148
152
|
*/
|
|
149
153
|
handle?: ServerLoad;
|
|
150
154
|
};
|
|
155
|
+
|
|
151
156
|
type ServerLoad = (event: ServerEvent) => Promise<void> | void;
|
|
152
157
|
|
|
153
|
-
export { type PageEndPoint, type PageEvent, type PageServerEndPoint, type ServerEndPoint, type ServerEvent, type ServerHook, type UserConfig, buildRoutePath, defineConfig };
|
|
158
|
+
export { type CookieHelper, type PageEndPoint, type PageEvent, type PageServerAction, type PageServerEndPoint, type PageServerLoad, type ServerEndPoint, type ServerEvent, type ServerHook, type ServerRequest, type UserConfig, buildRoutePath, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vinxi from 'vinxi';
|
|
2
|
+
import { CookieSerializeOptions } from 'vinxi/http';
|
|
2
3
|
import { Component } from '@torpor/view';
|
|
3
4
|
import { ServerResponse } from 'node:http';
|
|
4
|
-
import { CookieSerializeOptions } from 'vinxi/http';
|
|
5
5
|
|
|
6
6
|
type ParamsType = Record<PropertyKey, any>;
|
|
7
7
|
declare function buildRoutePath<RP extends ParamsType, UP extends ParamsType>(path: string, routeParams: RP, urlParams?: UP): string;
|
|
@@ -12,6 +12,12 @@ type UserConfig = {
|
|
|
12
12
|
|
|
13
13
|
declare function defineConfig(options?: UserConfig): vinxi.App;
|
|
14
14
|
|
|
15
|
+
type CookieHelper = {
|
|
16
|
+
get: (name: string) => string | undefined;
|
|
17
|
+
set: (name: string, value: string, options?: CookieSerializeOptions) => void;
|
|
18
|
+
delete: (name: string, options?: CookieSerializeOptions) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
15
21
|
type PageEvent = {
|
|
16
22
|
/**
|
|
17
23
|
* The URL for the server function.
|
|
@@ -49,6 +55,7 @@ type PageEndPoint = {
|
|
|
49
55
|
*/
|
|
50
56
|
head?: HeadElement[] | ((event: PageEvent) => HeadElement[]);
|
|
51
57
|
};
|
|
58
|
+
|
|
52
59
|
type HeadElement = TitleElement | MetaElement;
|
|
53
60
|
interface TitleElement {
|
|
54
61
|
title: string;
|
|
@@ -58,12 +65,6 @@ interface MetaElement {
|
|
|
58
65
|
content: string;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
type CookieHelper = {
|
|
62
|
-
get: (name: string) => string | undefined;
|
|
63
|
-
set: (name: string, value: string, options?: CookieSerializeOptions) => void;
|
|
64
|
-
delete: (name: string, options?: CookieSerializeOptions) => void;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
68
|
type ServerEvent = {
|
|
68
69
|
/**
|
|
69
70
|
* The URL for the server function.
|
|
@@ -86,6 +87,10 @@ type ServerEvent = {
|
|
|
86
87
|
cookies: CookieHelper;
|
|
87
88
|
};
|
|
88
89
|
|
|
90
|
+
type PageServerAction = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
91
|
+
|
|
92
|
+
type PageServerLoad = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
93
|
+
|
|
89
94
|
/**
|
|
90
95
|
* For +page.server.
|
|
91
96
|
*/
|
|
@@ -93,14 +98,14 @@ type PageServerEndPoint = {
|
|
|
93
98
|
/**
|
|
94
99
|
* Loads data from the server for a page.
|
|
95
100
|
*/
|
|
96
|
-
load?:
|
|
101
|
+
load?: PageServerLoad;
|
|
97
102
|
/**
|
|
98
103
|
* A map of actions that can be performed on the server for a page, generally from a form submit.
|
|
99
104
|
*/
|
|
100
|
-
actions?: Record<string,
|
|
105
|
+
actions?: Record<string, PageServerAction>;
|
|
101
106
|
};
|
|
102
|
-
|
|
103
|
-
type
|
|
107
|
+
|
|
108
|
+
type ServerRequest = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
104
109
|
|
|
105
110
|
/**
|
|
106
111
|
* For +server.
|
|
@@ -113,31 +118,30 @@ type ServerEndPoint = {
|
|
|
113
118
|
*/
|
|
114
119
|
get?: ServerRequest;
|
|
115
120
|
/**
|
|
116
|
-
*
|
|
121
|
+
* Performs a POST.
|
|
117
122
|
*/
|
|
118
123
|
post?: ServerRequest;
|
|
119
124
|
/**
|
|
120
|
-
*
|
|
125
|
+
* Performs a PATCH.
|
|
121
126
|
*/
|
|
122
127
|
patch?: ServerRequest;
|
|
123
128
|
/**
|
|
124
|
-
*
|
|
129
|
+
* Performs a PUT.
|
|
125
130
|
*/
|
|
126
131
|
put?: ServerRequest;
|
|
127
132
|
/**
|
|
128
|
-
*
|
|
133
|
+
* Performs a DELETE.
|
|
129
134
|
*/
|
|
130
135
|
del?: ServerRequest;
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
137
|
+
* Performs an OPTIONS request.
|
|
133
138
|
*/
|
|
134
139
|
options?: ServerRequest;
|
|
135
140
|
/**
|
|
136
|
-
*
|
|
141
|
+
* Performs a HEAD request.
|
|
137
142
|
*/
|
|
138
143
|
head?: ServerRequest;
|
|
139
144
|
};
|
|
140
|
-
type ServerRequest = (event: ServerEvent) => Response | Promise<Response | undefined> | void;
|
|
141
145
|
|
|
142
146
|
/**
|
|
143
147
|
* For _hook.server.
|
|
@@ -148,6 +152,7 @@ type ServerHook = {
|
|
|
148
152
|
*/
|
|
149
153
|
handle?: ServerLoad;
|
|
150
154
|
};
|
|
155
|
+
|
|
151
156
|
type ServerLoad = (event: ServerEvent) => Promise<void> | void;
|
|
152
157
|
|
|
153
|
-
export { type PageEndPoint, type PageEvent, type PageServerEndPoint, type ServerEndPoint, type ServerEvent, type ServerHook, type UserConfig, buildRoutePath, defineConfig };
|
|
158
|
+
export { type CookieHelper, type PageEndPoint, type PageEvent, type PageServerAction, type PageServerEndPoint, type PageServerLoad, type ServerEndPoint, type ServerEvent, type ServerHook, type ServerRequest, type UserConfig, buildRoutePath, defineConfig };
|
package/dist/index.js
CHANGED
package/dist/metafile-cjs.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/site/buildRoutePath.ts":{"bytes":599,"imports":[],"format":"esm"},"src/site/FileSystemRouter.ts":{"bytes":651,"imports":[{"path":"vinxi/fs-router","kind":"import-statement","external":true}],"format":"esm"},"src/site/defineConfig.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/site/buildRoutePath.ts":{"bytes":599,"imports":[],"format":"esm"},"src/site/FileSystemRouter.ts":{"bytes":651,"imports":[{"path":"vinxi/fs-router","kind":"import-statement","external":true}],"format":"esm"},"src/site/defineConfig.ts":{"bytes":1922,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"vinxi","kind":"import-statement","external":true},{"path":"vinxi/plugins/config","kind":"import-statement","external":true},{"path":"src/site/FileSystemRouter.ts","kind":"import-statement","original":"./FileSystemRouter"}],"format":"esm"},"src/index.ts":{"bytes":1095,"imports":[{"path":"src/site/buildRoutePath.ts","kind":"import-statement","original":"./site/buildRoutePath"},{"path":"src/site/defineConfig.ts","kind":"import-statement","original":"./site/defineConfig"}],"format":"esm"},"src/response/response.ts":{"bytes":681,"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/state/$page.ts":{"bytes":166,"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/bin/index.ts":{"bytes":1367,"imports":[{"path":"fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/site/defineConfig.ts","kind":"import-statement","original":"../site/defineConfig"}],"format":"esm"}},"outputs":{"dist/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6989},"dist/index.cjs":{"imports":[{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vinxi","kind":"require-call","external":true},{"path":"vinxi/plugins/config","kind":"require-call","external":true},{"path":"vinxi/fs-router","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":175},"src/site/buildRoutePath.ts":{"bytesInOutput":436},"src/site/defineConfig.ts":{"bytesInOutput":1996},"src/site/FileSystemRouter.ts":{"bytesInOutput":647}},"bytes":4913},"dist/response.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10303},"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/state.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":577},"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/bin/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":6593},"dist/bin/index.cjs":{"imports":[{"path":"fs","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"@torpor/unplugin/vite","kind":"require-call","external":true},{"path":"path","kind":"require-call","external":true},{"path":"vinxi","kind":"require-call","external":true},{"path":"vinxi/plugins/config","kind":"require-call","external":true},{"path":"vinxi/fs-router","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/bin/index.ts","inputs":{"src/bin/index.ts":{"bytesInOutput":779},"src/site/defineConfig.ts":{"bytesInOutput":1998},"src/site/FileSystemRouter.ts":{"bytesInOutput":647}},"bytes":4754}}}
|
package/dist/metafile-esm.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/site/buildRoutePath.ts":{"bytes":599,"imports":[],"format":"esm"},"src/site/FileSystemRouter.ts":{"bytes":651,"imports":[{"path":"vinxi/fs-router","kind":"import-statement","external":true}],"format":"esm"},"src/site/defineConfig.ts":{"bytes":
|
|
1
|
+
{"inputs":{"src/site/buildRoutePath.ts":{"bytes":599,"imports":[],"format":"esm"},"src/site/FileSystemRouter.ts":{"bytes":651,"imports":[{"path":"vinxi/fs-router","kind":"import-statement","external":true}],"format":"esm"},"src/site/defineConfig.ts":{"bytes":1922,"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vinxi","kind":"import-statement","external":true},{"path":"vinxi/plugins/config","kind":"import-statement","external":true},{"path":"src/site/FileSystemRouter.ts","kind":"import-statement","original":"./FileSystemRouter"}],"format":"esm"},"src/index.ts":{"bytes":1095,"imports":[{"path":"src/site/buildRoutePath.ts","kind":"import-statement","original":"./site/buildRoutePath"},{"path":"src/site/defineConfig.ts","kind":"import-statement","original":"./site/defineConfig"}],"format":"esm"},"src/response/response.ts":{"bytes":681,"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/state/$page.ts":{"bytes":166,"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/bin/index.ts":{"bytes":1367,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true},{"path":"src/site/defineConfig.ts","kind":"import-statement","original":"../site/defineConfig"}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1199},"dist/index.js":{"imports":[{"path":"dist/chunk-IE5EKBNX.js","kind":"import-statement"}],"exports":["buildRoutePath","defineConfig"],"entryPoint":"src/index.ts","inputs":{"src/site/buildRoutePath.ts":{"bytesInOutput":431},"src/index.ts":{"bytesInOutput":0}},"bytes":561},"dist/response.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":9197},"dist/response.js":{"imports":[],"exports":["badRequest","created","forbidden","methodNotAllowed","moved","notFound","notModified","ok","redirect","response","seeOther","serverError","transfer","unauthorized","unprocessable"],"entryPoint":"src/response.ts","inputs":{"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},"src/response.ts":{"bytesInOutput":0}},"bytes":1917},"dist/state.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":452},"dist/state.js":{"imports":[{"path":"@torpor/view","kind":"import-statement","external":true}],"exports":["$page"],"entryPoint":"src/state.ts","inputs":{"src/state/$page.ts":{"bytesInOutput":171},"src/state.ts":{"bytesInOutput":0}},"bytes":229},"dist/bin/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":1992},"dist/bin/index.js":{"imports":[{"path":"dist/chunk-IE5EKBNX.js","kind":"import-statement"},{"path":"node:fs","kind":"import-statement","external":true},{"path":"path","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/bin/index.ts","inputs":{"src/bin/index.ts":{"bytesInOutput":645}},"bytes":742},"dist/chunk-IE5EKBNX.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":4590},"dist/chunk-IE5EKBNX.js":{"imports":[{"path":"@torpor/unplugin/vite","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"vinxi","kind":"import-statement","external":true},{"path":"vinxi/plugins/config","kind":"import-statement","external":true},{"path":"vinxi/fs-router","kind":"import-statement","external":true}],"exports":["defineConfig"],"inputs":{"src/site/defineConfig.ts":{"bytesInOutput":1814},"src/site/FileSystemRouter.ts":{"bytesInOutput":624}},"bytes":2556}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@torpor/build",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A framework for building sites and apps with Torpor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"license": "ISC",
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"vinxi": "^0.5.3",
|
|
37
|
-
"@torpor/
|
|
38
|
-
"@torpor/
|
|
37
|
+
"@torpor/view": "^0.0.7",
|
|
38
|
+
"@torpor/unplugin": "^0.0.6"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/site/defineConfig.ts","../src/site/FileSystemRouter.ts"],"sourcesContent":["import torpor from \"@torpor/unplugin/vite\";\nimport path from \"node:path\";\nimport { type AppOptions, type RouterSchemaInput, createApp } from \"vinxi\";\nimport { config } from \"vinxi/plugins/config\";\nimport { type UserConfig } from \"../types/UserConfig\";\nimport FileSystemRouter from \"./FileSystemRouter\";\n\nexport default function defineConfig(options?: UserConfig) {\n\t// Set the port\n\tprocess.env.PORT = (options?.port || 7059).toString();\n\n\t// Get Vinxi to create and serve the app\n\treturn createApp({\n\t\tname: \"torpor\",\n\t\trouters: [\n\t\t\t{\n\t\t\t\tname: \"assets\",\n\t\t\t\ttype: \"static\",\n\t\t\t\tdir: \"./src/assets\",\n\t\t\t},\n\t\t\t// Doesn't look like we can have two server routes?\n\t\t\t// Have to put api in /routes\n\t\t\t// Maybe we can support having /routes/api and routes/site and stripping /site from the start?\n\t\t\t//{\n\t\t\t//\tname: \"api\",\n\t\t\t//\ttype: \"http\",\n\t\t\t//\ttarget: \"server\",\n\t\t\t//\t// TODO: change this when published\n\t\t\t//\thandler: \"node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t//\troutes: apiRoutes,\n\t\t\t//\tplugins: () => [config(\"custom\", viteOptions())],\n\t\t\t//},\n\t\t\t{\n\t\t\t\tname: \"server\",\n\t\t\t\ttype: \"http\",\n\t\t\t\ttarget: \"server\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/serverEntry.ts\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor({ server: true })],\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: \"client\",\n\t\t\t\ttype: \"client\",\n\t\t\t\ttarget: \"browser\",\n\t\t\t\t// TODO: change this when published\n\t\t\t\thandler: \"./node_modules/@torpor/build/src/site/clientEntry.ts\",\n\t\t\t\tbase: \"/_build\",\n\t\t\t\troutes,\n\t\t\t\tplugins: () => [config(\"custom\", viteOptions()), torpor()],\n\t\t\t},\n\t\t],\n\t});\n}\n\nfunction routes(router: RouterSchemaInput, app: AppOptions) {\n\treturn new FileSystemRouter(\n\t\t{\n\t\t\tdir: path.resolve(\"src/routes\"),\n\t\t\textensions: [\"js\", \"ts\"],\n\t\t},\n\t\trouter,\n\t\tapp,\n\t);\n}\n\nfunction viteOptions() {\n\treturn {\n\t\tresolve: {\n\t\t\talias: {\n\t\t\t\t\"@\": path.resolve(\"src\"),\n\t\t\t},\n\t\t},\n\t};\n}\n","import { BaseFileSystemRouter, cleanPath } from \"vinxi/fs-router\";\n\nexport default class FileSystemRouter extends BaseFileSystemRouter {\n\ttoPath(src: string) {\n\t\tlet routePath = cleanPath(src, this.config)\n\t\t\t.replace(/^\\//, \"\")\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(/\\+page$/, \"\")\n\t\t\t.replace(/\\+server$/, \"\")\n\t\t\t.replace(/\\/$/, \"\");\n\t\treturn routePath?.length > 0 ? `/${routePath}` : \"/\";\n\t}\n\n\ttoRoute(filePath: string) {\n\t\treturn {\n\t\t\tpath: this.toPath(filePath),\n\t\t\t$handler: {\n\t\t\t\tsrc: filePath,\n\t\t\t\tpick: [\"default\"],\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";AAAA,OAAO,YAAY;AACnB,OAAO,UAAU;AACjB,SAAkD,iBAAiB;AACnE,SAAS,cAAc;;;ACHvB,SAAS,sBAAsB,iBAAiB;AAEhD,IAAqB,mBAArB,cAA8C,qBAAqB;AAAA,EAClE,OAAO,KAAa;AACnB,QAAI,YAAY,UAAU,KAAK,KAAK,MAAM,EACxC,QAAQ,OAAO,EAAE,EACjB,QAAQ,iBAAiB,eAAe,EACxC,QAAQ,mBAAmB,iBAAiB,EAC5C,QAAQ,kBAAkB,SAAS,EACnC,QAAQ,WAAW,EAAE,EACrB,QAAQ,aAAa,EAAE,EACvB,QAAQ,OAAO,EAAE;AACnB,WAAO,WAAW,SAAS,IAAI,IAAI,SAAS,KAAK;AAAA,EAClD;AAAA,EAEA,QAAQ,UAAkB;AACzB,WAAO;AAAA,MACN,MAAM,KAAK,OAAO,QAAQ;AAAA,MAC1B,UAAU;AAAA,QACT,KAAK;AAAA,QACL,MAAM,CAAC,SAAS;AAAA,MACjB;AAAA,IACD;AAAA,EACD;AACD;;;ADjBe,SAAR,aAA8B,SAAsB;AAE1D,UAAQ,IAAI,QAAQ,SAAS,QAAQ,MAAM,SAAS;AAGpD,SAAO,UAAU;AAAA,IAChB,MAAM;AAAA,IACN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