vaderjs 1.6.1 → 1.6.3

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 (3) hide show
  1. package/README.md +2 -2
  2. package/main.js +29 -14
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <a href="https://vader-js.pages.dev">
3
3
  <picture>
4
4
  <source media="(prefers-color-scheme: dark)" srcset="/icon.jpeg">
5
- <img src="./logo.png" height="128">
5
+ <img src="https://github.com/Postr-Inc/Vader.js/blob/main/logo.png" height="128">
6
6
  </picture>
7
7
  <h1 align="center">Vader.js</h1>
8
8
  </a>
@@ -86,4 +86,4 @@ export default defineConfig({
86
86
  plugins: [cloudflare, tailwindcss],
87
87
  });
88
88
 
89
- ```
89
+ ```
package/main.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import ansiColors from 'ansi-colors'
4
4
  import { Glob } from 'bun'
5
5
  const args = Bun.argv.slice(2)
6
+ globalThis.isBuilding = false;
6
7
  import fs from 'fs'
7
8
  import path from 'path'
8
9
  if (!fs.existsSync(process.cwd() + '/app') && !args.includes('init')) {
@@ -23,10 +24,11 @@ export default defineConfig({
23
24
  host_provider: 'apache'
24
25
  })`)
25
26
  }
26
- const mode = args.includes('dev') ? 'development' : args.includes('prod') || args.includes('build') ? 'production' : args.includes('init') ? 'init' : null
27
+ const mode = args.includes('dev') ? 'development' : args.includes('prod') || args.includes('build') ? 'production' : args.includes('init') ? 'init' : args.includes('serve') ? 'serve' : null;
27
28
  if (!mode) {
28
29
  console.log(`
29
30
  Usage:
31
+ bun vaderjs serve - Start the server
30
32
  bun vaderjs dev - Start development server output in dist/
31
33
  bun vaderjs prod - Build for production output in dist/
32
34
  bun vaderjs init - Initialize a new vaderjs project
@@ -39,7 +41,7 @@ if (mode === 'init') {
39
41
  console.error('App directory already exists: just run `bun vaderjs dev` to start the development server')
40
42
  process.exit(1)
41
43
  }
42
- fs.mkdirSync(process.cwd() + '/app')
44
+ fs.mkdirSync(process.cwd() + '/app')
43
45
  fs.copyFileSync(path.join(process.cwd(), "/node_modules/vaderjs/example/counter/index.jsx"), path.join(process.cwd(), "/app/index.jsx"))
44
46
 
45
47
  console.log('Initialized new vaderjs project: run `bun vaderjs dev` to start the development server')
@@ -51,13 +53,11 @@ console.log(
51
53
  Mode: ${mode}
52
54
  SSR: ${require(process.cwd() + '/vader.config.ts').default.ssr ? 'Enabled' : 'Disabled'}
53
55
  PORT: ${require(process.cwd() + '/vader.config.ts').default.port || 8080}
56
+ ${mode == 'serve' ? `SSL: ${require(process.cwd() + '/vader.config.ts').default?.ssl?.enabled ? 'Enabled' : 'Disabled'} ` : ``}
54
57
  `
55
58
  )
56
59
 
57
60
 
58
- console.log(ansiColors.green('Building...'))
59
- let start = Date.now()
60
- console.log(`Starting build at ${new Date().toLocaleTimeString()}`)
61
61
  let { port, host, host_provider } = require(process.cwd() + '/vader.config.ts').default
62
62
  if (host_provider === 'apache' && mode === 'development') {
63
63
  console.warn('Note: SSR will not work with Apache')
@@ -140,7 +140,11 @@ const handleReplacements = (code) => {
140
140
  }
141
141
 
142
142
 
143
+ let start = Date.now()
143
144
  async function generateApp() {
145
+ globalThis.isBuilding = true;
146
+ console.log(ansiColors.green('Building...'))
147
+ console.log(`Starting build at ${new Date().toLocaleTimeString()}`)
144
148
  // remove files from dist
145
149
  if (mode === 'development') {
146
150
  fs.rmdirSync(process.cwd() + '/dist', { recursive: true })
@@ -240,14 +244,13 @@ async function generateApp() {
240
244
  break;
241
245
  case 'apache':
242
246
  let data = ''
243
-
247
+
244
248
  }
245
249
 
246
250
  })
247
251
 
248
252
  }
249
253
 
250
- await generateApp()
251
254
  function handleFiles() {
252
255
  return new Promise(async (resolve, reject) => {
253
256
  try {
@@ -331,10 +334,11 @@ function handleFiles() {
331
334
  }
332
335
  })
333
336
  }
334
- await handleFiles()
335
337
  globalThis.clients = []
336
338
 
337
339
  if (mode === 'development') {
340
+ await generateApp()
341
+ await handleFiles()
338
342
  const watcher = fs.watch(path.join(process.cwd() + '/'), { recursive: true })
339
343
  let isBuilding = false; // Flag to track build status
340
344
 
@@ -370,6 +374,19 @@ if (mode === 'development') {
370
374
 
371
375
  // Event listeners with debounced handling
372
376
  watcher.on('change', handleFileChangeDebounced);
377
+
378
+ }
379
+ else if(mode == 'production'){
380
+ await handleFiles()
381
+ await generateApp()
382
+ }
383
+ else {
384
+ if (isBuilding) console.log(`Build complete in ${Date.now() - start}ms at ${new Date().toLocaleTimeString()}`);
385
+
386
+ }
387
+
388
+
389
+ if (mode == 'development' || mode == 'serve') {
373
390
  let server = Bun.serve({
374
391
  port: port || 8080,
375
392
  websocket: {
@@ -426,6 +443,7 @@ if (mode === 'development') {
426
443
  let ws = new WebSocket('ws://localhost:${server.port}')
427
444
  ws.onmessage = (e) => {
428
445
  if(e.data === 'reload'){
446
+ console.log('Reloading to display changes from server')
429
447
  window.location.reload()
430
448
  }
431
449
  }
@@ -445,9 +463,6 @@ if (mode === 'development') {
445
463
 
446
464
  }
447
465
  })
448
- } else {
449
- console.log(`Build complete in ${Date.now() - start}ms at ${new Date().toLocaleTimeString()}`)
450
- process.exit(0)
451
- }
452
-
453
- console.log(ansiColors.green('Server started at http://localhost:' + port || 8080))
466
+
467
+ console.log(ansiColors.green('Server started at http://localhost:' + port || 8080))
468
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"
@@ -9,6 +9,7 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/Postr-Inc/Vader.js"
11
11
  },
12
+ "license":"MIT",
12
13
  "dependencies": {
13
14
  "ansi-colors": "latest"
14
15
  }