@vyckr/tachyon 1.1.6 → 1.1.8
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/dev.html +1 -1
- package/src/client/dist.ts +1 -1
- package/src/client/prod.html +1 -1
- package/src/serve.ts +20 -32
- package/src/server/tach.ts +1 -1
package/package.json
CHANGED
package/src/client/dev.html
CHANGED
package/src/client/dist.ts
CHANGED
|
@@ -12,7 +12,7 @@ for(const route in Router.reqRoutes) {
|
|
|
12
12
|
|
|
13
13
|
const res = await Router.reqRoutes[route][`GET`]()
|
|
14
14
|
|
|
15
|
-
await Bun.write(Bun.file(`${process.cwd()}/dist/${route}`), await res.
|
|
15
|
+
await Bun.write(Bun.file(`${process.cwd()}/dist/${route}`), await res.blob())
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
await Bun.write(Bun.file(`${process.cwd()}/dist/index.html`), await Bun.file(`${import.meta.dir}/prod.html`).text())
|
package/src/client/prod.html
CHANGED
package/src/serve.ts
CHANGED
|
@@ -87,6 +87,10 @@ const server = Bun.serve({
|
|
|
87
87
|
|
|
88
88
|
if(server.development) {
|
|
89
89
|
|
|
90
|
+
let timeout: Timer
|
|
91
|
+
|
|
92
|
+
let websocket: ServerWebSocket<unknown>;
|
|
93
|
+
|
|
90
94
|
const socket = Bun.serve({
|
|
91
95
|
fetch(req) {
|
|
92
96
|
socket.upgrade(req)
|
|
@@ -95,30 +99,7 @@ if(server.development) {
|
|
|
95
99
|
websocket: {
|
|
96
100
|
async open(ws) {
|
|
97
101
|
console.info("HMR Enabled")
|
|
98
|
-
|
|
99
|
-
if(await exists(Router.routesPath)) {
|
|
100
|
-
|
|
101
|
-
watcher(Router.routesPath, { recursive: true }, () => {
|
|
102
|
-
queueMicrotask(async () => {
|
|
103
|
-
console.info("HMR Update")
|
|
104
|
-
await configureRoutes()
|
|
105
|
-
server.reload({ routes: Router.reqRoutes })
|
|
106
|
-
ws.send('')
|
|
107
|
-
})
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if(await exists(Router.componentsPath)) {
|
|
112
|
-
|
|
113
|
-
watcher(Router.componentsPath, { recursive: true }, () => {
|
|
114
|
-
queueMicrotask(async () => {
|
|
115
|
-
console.info("HMR Update")
|
|
116
|
-
await configureRoutes()
|
|
117
|
-
server.reload({ routes: Router.reqRoutes })
|
|
118
|
-
ws.send('')
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
}
|
|
102
|
+
websocket = ws
|
|
122
103
|
},
|
|
123
104
|
message(ws, message) {
|
|
124
105
|
|
|
@@ -130,30 +111,37 @@ if(server.development) {
|
|
|
130
111
|
port: 9876
|
|
131
112
|
})
|
|
132
113
|
|
|
133
|
-
|
|
134
114
|
if(await exists(Router.routesPath)) {
|
|
135
115
|
|
|
136
116
|
watcher(Router.routesPath, { recursive: true }, () => {
|
|
137
|
-
|
|
117
|
+
|
|
118
|
+
if(timeout) clearTimeout(timeout)
|
|
119
|
+
|
|
120
|
+
timeout = setTimeout(async () => {
|
|
121
|
+
console.info("HMR Update")
|
|
138
122
|
await configureRoutes()
|
|
139
123
|
server.reload({ routes: Router.reqRoutes })
|
|
140
|
-
|
|
124
|
+
if(websocket) websocket.send('')
|
|
125
|
+
}, 1500)
|
|
141
126
|
})
|
|
142
127
|
}
|
|
143
128
|
|
|
144
129
|
if(await exists(Router.componentsPath)) {
|
|
145
130
|
|
|
146
131
|
watcher(Router.componentsPath, { recursive: true }, () => {
|
|
147
|
-
|
|
132
|
+
|
|
133
|
+
if(timeout) clearTimeout(timeout)
|
|
134
|
+
|
|
135
|
+
timeout = setTimeout(async () => {
|
|
136
|
+
console.info("HMR Update")
|
|
148
137
|
await configureRoutes()
|
|
149
138
|
server.reload({ routes: Router.reqRoutes })
|
|
150
|
-
|
|
139
|
+
if(websocket) websocket.send('')
|
|
140
|
+
}, 1500)
|
|
151
141
|
})
|
|
152
142
|
}
|
|
153
143
|
}
|
|
154
144
|
|
|
155
145
|
const elapsed = Date.now() - start
|
|
156
146
|
|
|
157
|
-
console.info(`Live Server is running on http://${server.hostname}:${server.port} (Press CTRL+C to quit) - ${elapsed.toFixed(2)}ms`)
|
|
158
|
-
|
|
159
|
-
// console.info(`Available Routes:\n\t${Object.keys(Router.reqRoutes).join('\n\t')}`)
|
|
147
|
+
console.info(`Live Server is running on http://${server.hostname}:${server.port} (Press CTRL+C to quit) - ${elapsed.toFixed(2)}ms`)
|
package/src/server/tach.ts
CHANGED
|
@@ -222,7 +222,7 @@ export default class Tach {
|
|
|
222
222
|
|
|
223
223
|
if(method !== 'HTML' && method !== 'SOCKET') {
|
|
224
224
|
|
|
225
|
-
if(!Router.reqRoutes[route]) {
|
|
225
|
+
if(!Router.reqRoutes[route] || !Router.reqRoutes[`${route}/*`]) {
|
|
226
226
|
Router.reqRoutes[route] = {}
|
|
227
227
|
Router.reqRoutes[`${route}/*`] = {}
|
|
228
228
|
}
|