vaderjs 1.9.7 → 1.9.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/README.MD CHANGED
@@ -42,6 +42,8 @@ bun install vaderjs @latest
42
42
  # Project Setup
43
43
  Create a pages folder - which allows you to have nextjs page like routing via buns file based router
44
44
 
45
+ > Note only use this when using production server - not supported by cloudflare, github or vercel
46
+
45
47
  Tip: Each folder can be deep nested up to 4 levels!
46
48
 
47
49
  ```md
package/bundler/index.js CHANGED
@@ -197,15 +197,18 @@ const generatePage = async (
197
197
  await Bun.write(
198
198
  process.cwd() + "/dist/" + route + "/index.html",
199
199
  `<!DOCTYPE html>
200
-
201
- ${process.env.bindes}
202
- ${h}
203
- <script type="module">
200
+ <head>
201
+ <script defer type="module">
204
202
  import c from '${process.env.filePath}'
205
203
  import {render, e} from '/src/vader/index.js'
206
204
  window.e = e
207
205
  render(c, document.body)
208
206
  </script>
207
+
208
+ ${process.env.bindes}
209
+ </head>
210
+ ${h}
211
+
209
212
  `
210
213
  );
211
214
  console.log(
package/document/index.ts CHANGED
@@ -45,7 +45,10 @@ export const document = (element: any) => {
45
45
  });
46
46
  }
47
47
  if(typeof child === "function"){
48
- el += document(child())
48
+ let out = document(child());
49
+ if(out !== null || out !== false || out !== undefined){
50
+ el += out;
51
+ }
49
52
  }else
50
53
  if (typeof child === "object") {
51
54
  el += document(child);
@@ -7,4 +7,4 @@ export default function App() {
7
7
  <button onClick={() => setCount(count + 1)}>Increment</button>
8
8
  </div>
9
9
  );
10
- }
10
+ }
package/main.js CHANGED
@@ -217,16 +217,28 @@ async function generateApp() {
217
217
  r = r.replace('.jsx', '.js').replace('.tsx', '.js')
218
218
  fs.mkdirSync(path.join(process.cwd() + '/dist', path.dirname(r)), { recursive: true })
219
219
  let params = routes.match(route).params || {}
220
- // handle route params multiple and
221
- fs.writeFileSync(process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r), `
222
- let route = window.location.pathname.split('/').filter(v => v !== '')
223
- let params = {
224
- ${Object.keys(routes.match(route).params || {}).length > 0 ? Object.keys(routes.match(route).params || {}).map(p => {
225
- return `${p}: route[${Object.keys(routes.match(route).params || {}).indexOf(p)}]`
226
- }).join(',') : ""}
227
- }
228
- \n${code}
229
- `)
220
+ let base = routes.match(route)
221
+ let paramIndexes = []
222
+ console.log(base)
223
+ for (let param in params) {
224
+ let routes = base.pathname.split('/')
225
+ let index = routes.indexOf('[' + param + ']')
226
+ paramIndexes.push(index)
227
+ }
228
+
229
+ // dont return
230
+
231
+ fs.writeFileSync(
232
+ process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r),
233
+ `
234
+ let route = window.location.pathname.split('/').filter(Boolean)
235
+ let params = {
236
+ ${Object.keys(params).map(p => `${p}: route[${paramIndexes[Object.keys(params).indexOf(p)]}]`).join(',\n')}
237
+ }
238
+
239
+ \n${code}
240
+ `
241
+ );
230
242
  fs.mkdirSync(process.cwd() + '/dev', { recursive: true })
231
243
 
232
244
 
@@ -521,12 +533,12 @@ if (mode == 'development' || mode == 'serve') {
521
533
  <meta http-equiv="refresh" content="5">
522
534
  </head>
523
535
  <body>
524
- <h1>404 Not Found</h1>
525
- <p>Route not found</p>
536
+ <p>Rerouting to display changes from server</p>
526
537
  </body>
527
- `, { status: 404 }, {
538
+ `, {
528
539
  headers: {
529
- 'Content-Type': 'text/html'
540
+ 'Content-Type': 'text/html',
541
+ 'Cache-Control': 'no-cache'
530
542
  }
531
543
  })
532
544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"
@@ -13,4 +13,4 @@
13
13
  "dependencies": {
14
14
  "ansi-colors": "latest"
15
15
  }
16
- }
16
+ }