@vyckr/tachyon 1.1.6 → 1.1.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vyckr/tachyon",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "author": "Chidelma",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  <script src="/main.js"></script>
9
9
  <script src="/render.js"></script>
10
10
  <script src="/hmr.js"></script>
11
- <link rel="stylesheet" href="/styles.css">
11
+ <link rel="stylesheet" href="/styles.css" />
12
12
  </head>
13
13
  <body></body>
14
14
  </html>
@@ -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.text())
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())
@@ -7,7 +7,7 @@
7
7
  <title></title>
8
8
  <script src="/main.js"></script>
9
9
  <script src="/render.js"></script>
10
- <link rel="stylesheet" href="/styles.css">
10
+ <link rel="stylesheet" href="/styles.css" />
11
11
  </head>
12
12
  <body></body>
13
13
  </html>
package/src/serve.ts CHANGED
@@ -87,6 +87,8 @@ const server = Bun.serve({
87
87
 
88
88
  if(server.development) {
89
89
 
90
+ let websocket: ServerWebSocket<unknown>;
91
+
90
92
  const socket = Bun.serve({
91
93
  fetch(req) {
92
94
  socket.upgrade(req)
@@ -95,30 +97,7 @@ if(server.development) {
95
97
  websocket: {
96
98
  async open(ws) {
97
99
  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
- }
100
+ websocket = ws
122
101
  },
123
102
  message(ws, message) {
124
103
 
@@ -130,13 +109,14 @@ if(server.development) {
130
109
  port: 9876
131
110
  })
132
111
 
133
-
134
112
  if(await exists(Router.routesPath)) {
135
113
 
136
114
  watcher(Router.routesPath, { recursive: true }, () => {
137
115
  queueMicrotask(async () => {
116
+ console.info("HMR Update")
138
117
  await configureRoutes()
139
118
  server.reload({ routes: Router.reqRoutes })
119
+ if(websocket) websocket.send('')
140
120
  })
141
121
  })
142
122
  }
@@ -147,6 +127,7 @@ if(server.development) {
147
127
  queueMicrotask(async () => {
148
128
  await configureRoutes()
149
129
  server.reload({ routes: Router.reqRoutes })
130
+ if(websocket) websocket.send('')
150
131
  })
151
132
  })
152
133
  }
@@ -154,6 +135,4 @@ if(server.development) {
154
135
 
155
136
  const elapsed = Date.now() - start
156
137
 
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')}`)
138
+ console.info(`Live Server is running on http://${server.hostname}:${server.port} (Press CTRL+C to quit) - ${elapsed.toFixed(2)}ms`)