@vyckr/tachyon 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/yon.ts +13 -1
- package/src/router.ts +1 -0
package/package.json
CHANGED
package/src/client/yon.ts
CHANGED
|
@@ -48,7 +48,7 @@ export default class Yon {
|
|
|
48
48
|
styles += `${msg}\n`
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
await Promise.all([Yon.bundleDependencies(), Yon.bundleComponents(), Yon.bundlePages()])
|
|
51
|
+
await Promise.all([Yon.bundleDependencies(), Yon.bundleComponents(), Yon.bundlePages(), Yon.bundleAssets()])
|
|
52
52
|
|
|
53
53
|
await Bun.write(Bun.file(`${import.meta.dir}/routes.json`), JSON.stringify(Router.routeSlugs))
|
|
54
54
|
|
|
@@ -244,6 +244,18 @@ export default class Yon {
|
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
private static async bundleAssets() {
|
|
248
|
+
|
|
249
|
+
const routes = Array.from(new Bun.Glob(`**/*`).scanSync({ cwd: Router.assetsPath }))
|
|
250
|
+
|
|
251
|
+
for(const route of routes) {
|
|
252
|
+
|
|
253
|
+
Router.reqRoutes[`/assets/${route}`] = {
|
|
254
|
+
GET: async () => new Response(await Bun.file(`${Router.assetsPath}/${route}`).text())
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
247
259
|
private static async bundlePages() {
|
|
248
260
|
|
|
249
261
|
const routes = Array.from(new Bun.Glob(`**/${Yon.htmlMethod}`).scanSync({ cwd: Router.routesPath }))
|
package/src/router.ts
CHANGED
|
@@ -19,6 +19,7 @@ export default class Router {
|
|
|
19
19
|
|
|
20
20
|
static readonly routesPath = `${process.cwd()}/routes`
|
|
21
21
|
static readonly componentsPath = `${process.cwd()}/components`
|
|
22
|
+
static readonly assetsPath = `${process.cwd()}/assets`
|
|
22
23
|
|
|
23
24
|
private static readonly allMethods = process.env.ALLOW_METHODS ? process.env.ALLOW_METHODS.split(',') : ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']
|
|
24
25
|
|