vaderjs 1.5.3 → 1.5.4

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.
Files changed (2) hide show
  1. package/main.js +11 -12
  2. package/package.json +2 -3
package/main.js CHANGED
@@ -267,17 +267,16 @@ await handleFiles()
267
267
  globalThis.clients = []
268
268
 
269
269
  if (mode === 'development') {
270
- const watcher = fs.watch(path.join(process.cwd() + '/app'), { recursive: true })
271
- const publicWatcher = fs.watch(path.join(process.cwd() + '/public'), { recursive: true })
272
- const srcWatcher = fs.watch(path.join(process.cwd() + '/src'), { recursive: true })
270
+ const watcher = fs.watch(path.join(process.cwd() + '/'), { recursive: true })
273
271
  let isBuilding = false; // Flag to track build status
274
272
 
275
273
  // Initialize a variable to hold the timeout ID
276
274
  let debounceTimeout;
277
275
 
278
276
  // Function to handle file changes with debounce
279
- const handleFileChangeDebounced = async () => {
280
- clearTimeout(debounceTimeout);
277
+ const handleFileChangeDebounced = async (change, file) => {
278
+ if(file.endsWith('.tsx') || file.endsWith('.jsx')){
279
+ clearTimeout(debounceTimeout);
281
280
  debounceTimeout = setTimeout(async () => {
282
281
  if (!isBuilding) { // Check if not already building
283
282
  isBuilding = true; // Set build flag to true
@@ -294,12 +293,11 @@ if (mode === 'development') {
294
293
  }
295
294
  }
296
295
  }, 500);
296
+ }
297
297
  };
298
298
 
299
- // Event listeners with debounced handling
300
- publicWatcher.on('change', handleFileChangeDebounced);
301
- watcher.on('change', handleFileChangeDebounced);
302
- srcWatcher.on('change', handleFileChangeDebounced);
299
+ // Event listeners with debounced handling
300
+ watcher.on('change', handleFileChangeDebounced);
303
301
  let server = Bun.serve({
304
302
  port: port || 8080,
305
303
  websocket: {
@@ -321,7 +319,7 @@ if (mode === 'development') {
321
319
 
322
320
  let url = new URL(req.url)
323
321
  if (url.pathname.includes('.')) {
324
- let p = url.pathname.replaceAll("%5B", "[").replaceAll("%5D", "]")
322
+ let p = url.pathname.replaceAll("%5B", "[").replaceAll("%5D", "]")
325
323
  let file = await Bun.file(path.join(process.cwd() + '/dist' + p))
326
324
  if (!await file.exists()) return new Response('Not found', { status: 404 })
327
325
  return new Response(await file.text(), {
@@ -343,9 +341,10 @@ if (mode === 'development') {
343
341
  }
344
342
  let p = route.pathname;
345
343
  let base = path.dirname(route.filePath)
346
- base = base.replace(path.join(process.cwd() + '/app'), '')
344
+ base = base.replace(/\\/g, '/')
345
+ base = base.replace(path.join(process.cwd() + '/app').replace(/\\/g, '/'), '')
347
346
  base = base.replace(/\\/g, '/').replace('/app', '/dist')
348
- base = process.cwd() + "/dist/" + base
347
+ base = process.cwd() + "/dist/" + base
349
348
  let data = await Bun.file(path.join(base, 'index.html')).text()
350
349
  if (mode == "development") {
351
350
  return new Response(data + `
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.5.3",
4
- "description": "A simple and powerful JavaScript library for building modern web applications.",
5
- "main": "./main.js",
3
+ "version": "1.5.4",
4
+ "description": "A simple and powerful JavaScript library for building modern web applications.",
6
5
  "bin": {
7
6
  "vaderjs": "./main.js"
8
7
  },