vaderjs 1.9.6 → 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 +2 -0
- package/bundler/index.js +7 -4
- package/document/index.ts +4 -1
- package/examples/counter/index.jsx +1 -1
- package/main.js +27 -13
- package/package.json +2 -2
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
|
-
|
|
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
|
-
|
|
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);
|
package/main.js
CHANGED
|
@@ -216,15 +216,29 @@ async function generateApp() {
|
|
|
216
216
|
r = r.replace(process.cwd().replace(/\\/g, '/') + '/app', '')
|
|
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
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
let params = routes.match(route).params || {}
|
|
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
|
+
);
|
|
228
242
|
fs.mkdirSync(process.cwd() + '/dev', { recursive: true })
|
|
229
243
|
|
|
230
244
|
|
|
@@ -519,12 +533,12 @@ if (mode == 'development' || mode == 'serve') {
|
|
|
519
533
|
<meta http-equiv="refresh" content="5">
|
|
520
534
|
</head>
|
|
521
535
|
<body>
|
|
522
|
-
|
|
523
|
-
<p>Route not found</p>
|
|
536
|
+
<p>Rerouting to display changes from server</p>
|
|
524
537
|
</body>
|
|
525
|
-
`, {
|
|
538
|
+
`, {
|
|
526
539
|
headers: {
|
|
527
|
-
'Content-Type': 'text/html'
|
|
540
|
+
'Content-Type': 'text/html',
|
|
541
|
+
'Cache-Control': 'no-cache'
|
|
528
542
|
}
|
|
529
543
|
})
|
|
530
544
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaderjs",
|
|
3
|
-
"version": "1.9.
|
|
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
|
+
}
|