@vyckr/tachyon 1.1.0 → 1.1.1
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 +30 -20
package/package.json
CHANGED
package/src/client/yon.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { JSDOM } from 'jsdom'
|
|
|
2
2
|
import Router from "../router.js";
|
|
3
3
|
import { EventEmitter } from 'node:stream';
|
|
4
4
|
import { BunRequest } from 'bun';
|
|
5
|
+
import { exists } from 'node:fs/promises';
|
|
5
6
|
|
|
6
7
|
export default class Yon {
|
|
7
8
|
|
|
@@ -246,29 +247,35 @@ export default class Yon {
|
|
|
246
247
|
|
|
247
248
|
private static async bundleAssets() {
|
|
248
249
|
|
|
249
|
-
|
|
250
|
+
if(await exists(Router.assetsPath)) {
|
|
250
251
|
|
|
251
|
-
|
|
252
|
+
const routes = Array.from(new Bun.Glob(`**/*`).scanSync({ cwd: Router.assetsPath }))
|
|
252
253
|
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
for(const route of routes) {
|
|
255
|
+
|
|
256
|
+
Router.reqRoutes[`/assets/${route}`] = {
|
|
257
|
+
GET: async () => new Response(await Bun.file(`${Router.assetsPath}/${route}`).text())
|
|
258
|
+
}
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
private static async bundlePages() {
|
|
260
264
|
|
|
261
|
-
|
|
265
|
+
if(await exists(Router.routesPath)) {
|
|
266
|
+
|
|
267
|
+
const routes = Array.from(new Bun.Glob(`**/${Yon.htmlMethod}`).scanSync({ cwd: Router.routesPath }))
|
|
262
268
|
|
|
263
|
-
|
|
269
|
+
for(const route of routes) {
|
|
264
270
|
|
|
265
|
-
|
|
271
|
+
await Router.validateRoute(route)
|
|
266
272
|
|
|
267
|
-
|
|
273
|
+
const data = await Bun.file(`${Router.routesPath}/${route}`).text()
|
|
268
274
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
275
|
+
const { html, script, style } = Yon.extractComponents(data)
|
|
276
|
+
|
|
277
|
+
await Yon.addToStatix(html, script, style, `${route}.${script.lang || 'js'}`, 'pages')
|
|
278
|
+
}
|
|
272
279
|
}
|
|
273
280
|
|
|
274
281
|
const nfFile = Bun.file(`${process.cwd()}/404.html`)
|
|
@@ -282,21 +289,24 @@ export default class Yon {
|
|
|
282
289
|
|
|
283
290
|
private static async bundleComponents() {
|
|
284
291
|
|
|
285
|
-
|
|
292
|
+
if(await exists(Router.componentsPath)) {
|
|
286
293
|
|
|
287
|
-
|
|
294
|
+
const components = Array.from(new Bun.Glob(`**/*.html`).scanSync({ cwd: Router.componentsPath }))
|
|
288
295
|
|
|
289
|
-
|
|
296
|
+
for(let comp of components) {
|
|
290
297
|
|
|
291
|
-
|
|
298
|
+
const folders = comp.split('/')
|
|
292
299
|
|
|
293
|
-
|
|
300
|
+
const filename = folders[folders.length - 1].replace('.html', '')
|
|
294
301
|
|
|
295
|
-
|
|
302
|
+
Yon.compMapping.set(filename, comp.replace('.html', '.js'))
|
|
296
303
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
304
|
+
const data = await Bun.file(`${Router.componentsPath}/${comp}`).text()
|
|
305
|
+
|
|
306
|
+
const { html, script, style } = Yon.extractComponents(data)
|
|
307
|
+
|
|
308
|
+
await Yon.addToStatix(html, script, style, comp, 'components')
|
|
309
|
+
}
|
|
300
310
|
}
|
|
301
311
|
}
|
|
302
312
|
|