vaderjs 1.9.7 → 1.9.9

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,35 @@ 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
+ for (let param in params) {
223
+ let routes = base.pathname.split('/')
224
+ let index = routes.indexOf('[' + param + ']')
225
+ paramIndexes.push(index)
226
+ }
227
+
228
+ // dont return
229
+
230
+ fs.writeFileSync(
231
+ process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r),
232
+ `
233
+ let route = window.location.pathname.split('/').filter(Boolean)
234
+ let params = {
235
+ // get index tehn do route[index]
236
+ ${Object.keys(params).map((param, i) => {
237
+ if (paramIndexes[i] !== -1) {
238
+ var r_copy = r;
239
+ r_copy = r_copy.split('/').filter(Boolean)
240
+ var index = paramIndexes[i] - 1
241
+ return `${param}: route[${index}]`
242
+ }
243
+ }).join(',\n')}
244
+ }
245
+
246
+ \n${code}
247
+ `
248
+ );
230
249
  fs.mkdirSync(process.cwd() + '/dev', { recursive: true })
231
250
 
232
251
 
@@ -312,8 +331,7 @@ async function generateApp() {
312
331
 
313
332
  function handleFiles() {
314
333
  return new Promise(async (resolve, reject) => {
315
- try {
316
- console.log(Glob)
334
+ try {
317
335
  let glob = new Glob('public/**/*')
318
336
  for await (var i of glob.scan()) {
319
337
  let file = i
@@ -521,12 +539,12 @@ if (mode == 'development' || mode == 'serve') {
521
539
  <meta http-equiv="refresh" content="5">
522
540
  </head>
523
541
  <body>
524
- <h1>404 Not Found</h1>
525
- <p>Route not found</p>
542
+ <p>Rerouting to display changes from server</p>
526
543
  </body>
527
- `, { status: 404 }, {
544
+ `, {
528
545
  headers: {
529
- 'Content-Type': 'text/html'
546
+ 'Content-Type': 'text/html',
547
+ 'Cache-Control': 'no-cache'
530
548
  }
531
549
  })
532
550
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.9.7",
3
+ "version": "1.9.9",
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
+ }