vaderjs 1.4.2-kml56 → 1.4.2-yml56
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/binaries/Kalix/index.js +3 -0
- package/binaries/compiler/main.js +1 -1
- package/binaries/vader.js +0 -0
- package/binaries/watcher/hmr.js +4 -0
- package/package.json +2 -3
- package/plugins/ssg/index.js +31 -3
- package/router/index.ts +1 -1
- package/server/index.js +1 -1
- /package/{vader.js → vader_dev.js} +0 -0
package/binaries/Kalix/index.js
CHANGED
|
@@ -261,7 +261,7 @@ export async function Compile(){
|
|
|
261
261
|
}
|
|
262
262
|
copy = copy.replace(old, newLine)
|
|
263
263
|
break;
|
|
264
|
-
case !line.includes('import') && line.includes('useState') && !line.includes('let useState'):
|
|
264
|
+
case !line.includes('import') && line.includes('useState') && !line.includes('let useState') && !line.includes('var useState') && !line.includes('console'):
|
|
265
265
|
let varType = line.split('[', 1)[0];
|
|
266
266
|
let before = line.split('useState(')[1].split(',')[0];
|
|
267
267
|
let key = line.split('[')[1].split(',')[0];
|
package/binaries/vader.js
CHANGED
|
File without changes
|
package/binaries/watcher/hmr.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watch } from 'fs'
|
|
2
|
+
import fs from 'fs'
|
|
2
3
|
globalThis.hasLogged = false
|
|
3
4
|
export function watchDir(cwd, _){
|
|
4
5
|
process.chdir(cwd)
|
|
@@ -12,6 +13,9 @@ export function watchDir(cwd, _){
|
|
|
12
13
|
let paths = ['src', 'pages', 'public', 'routes', 'vader.config.ts']
|
|
13
14
|
for(var i in paths){
|
|
14
15
|
let path = paths[i]
|
|
16
|
+
if(!fs.existsSync(process.cwd() + '/' + path)){
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
15
19
|
watch(process.cwd() + '/' + path, { recursive: true, absolute:true }, (event, filename) => {
|
|
16
20
|
if(filename && !filename.includes('node_modules') && !globalThis.hasLogged){
|
|
17
21
|
console.log(`\x1b[36mwait \x1b[0m - compiling (client and server)`)
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vaderjs",
|
|
3
3
|
"description": "A reactive framework for building fast and scalable web applications",
|
|
4
|
-
"version": "1.4.2-
|
|
5
|
-
"main": "vader.js",
|
|
4
|
+
"version": "1.4.2-yml56",
|
|
6
5
|
"author": {
|
|
7
6
|
"name": "Malikwhitten67",
|
|
8
7
|
"email": "malikwhitterb@gmail.com"
|
|
@@ -14,7 +13,7 @@
|
|
|
14
13
|
},
|
|
15
14
|
"type": "module",
|
|
16
15
|
"bin":{
|
|
17
|
-
"vader":"./
|
|
16
|
+
"vader":"./vader_dev.js"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
19
|
"ws": "latest"
|
package/plugins/ssg/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Bun from 'bun'
|
|
2
|
-
import {
|
|
2
|
+
import { Document, DOMParser} from 'vaderjs/binaries/Kalix/index.js'
|
|
3
3
|
import { renderToString } from '../../server'
|
|
4
4
|
import fs from 'fs'
|
|
5
5
|
let routes = new Bun.FileSystemRouter({
|
|
@@ -15,7 +15,10 @@ async function generate(){
|
|
|
15
15
|
for(var i in routes){
|
|
16
16
|
let path = i
|
|
17
17
|
let file = routes[i]
|
|
18
|
-
let comp = require(file).default
|
|
18
|
+
let comp = require(file).default
|
|
19
|
+
if(!comp){
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
19
22
|
let document = new Document()
|
|
20
23
|
let div = document.createElement('div')
|
|
21
24
|
div.setAttribute('id', 'root')
|
|
@@ -24,7 +27,7 @@ async function generate(){
|
|
|
24
27
|
dom = div.toString("outerHTML")
|
|
25
28
|
let folder = path.split('/pages')[0]
|
|
26
29
|
let newPath = process.cwd() + '/build' + folder + '/index.html'
|
|
27
|
-
let name = comp.name
|
|
30
|
+
let name = comp.name || 'App'
|
|
28
31
|
file = file.replace(/\\/g, '/').replace('\/\/', '/').replace(process.cwd().replace(/\\/g, '/'), '').split('/pages')[1].replace('.tsx', '.js').replace('.jsx', '.js')
|
|
29
32
|
let isParamRoute = path.includes('[')
|
|
30
33
|
let baseFolder = ''
|
|
@@ -33,6 +36,11 @@ async function generate(){
|
|
|
33
36
|
let providerPath;
|
|
34
37
|
switch(true){
|
|
35
38
|
case provider === 'vercel':
|
|
39
|
+
if(path.includes('[[catchall]]')){
|
|
40
|
+
providerPath = `${baseFolder}/${path.replace('[[catchall]]', '*')}`
|
|
41
|
+
providerRoutes.push({source: providerPath, destination: `${path}/index.html`})
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
36
44
|
providerPath = `${baseFolder}:${path.split('[')[1].split(']')[0]}`
|
|
37
45
|
providerRoutes.push({source: providerPath, dest: `${path}/index.html`})
|
|
38
46
|
break;
|
|
@@ -40,6 +48,15 @@ async function generate(){
|
|
|
40
48
|
providerPath = `RewriteRule ^${baseFolder.replace('/', '')}.*$ ${path}/index.html [L]`
|
|
41
49
|
providerRoutes.push(providerPath)
|
|
42
50
|
break;
|
|
51
|
+
case provider === 'cloudflare':
|
|
52
|
+
if(path.includes('[[catchall]]')){
|
|
53
|
+
providerPath = `${baseFolder}/${path.replace('[[catchall]]', '*')}`
|
|
54
|
+
providerRoutes.push({source: providerPath, destination: `${path}/index.html`})
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
providerPath = `${baseFolder}/:${path.split('[')[1].split(']')[0]}`
|
|
58
|
+
providerRoutes.push({source: providerPath, destination: `${path}/index.html`})
|
|
59
|
+
break;
|
|
43
60
|
}
|
|
44
61
|
}else{
|
|
45
62
|
let providerPath;
|
|
@@ -55,6 +72,10 @@ async function generate(){
|
|
|
55
72
|
providerPath = `RewriteRule ^${path.replace('/', '')}/$ ${path}/index.html [L]`
|
|
56
73
|
providerRoutes.push(providerPath)
|
|
57
74
|
break;
|
|
75
|
+
case provider === 'cloudflare':
|
|
76
|
+
providerPath = `${path}`
|
|
77
|
+
providerRoutes.push({source: providerPath, destination: `${path === '/' ? '' : '/'}/index.html`})
|
|
78
|
+
break;
|
|
58
79
|
|
|
59
80
|
}
|
|
60
81
|
}
|
|
@@ -101,6 +122,13 @@ Header add x-powered-by "vaderjs"
|
|
|
101
122
|
`
|
|
102
123
|
fs.writeFileSync(process.cwd() + '/.htaccess', full)
|
|
103
124
|
break;
|
|
125
|
+
case provider === 'cloudflare':
|
|
126
|
+
let cloudflare = process.cwd() + '/build/_redirects'
|
|
127
|
+
let data = providerRoutes.map((route) => {
|
|
128
|
+
return `${route.source} ${route.destination}`
|
|
129
|
+
}).join('\n')
|
|
130
|
+
fs.writeFileSync(cloudflare, data)
|
|
131
|
+
break;
|
|
104
132
|
}
|
|
105
133
|
console.log(`\x1b[32mSuccess\x1b[0m - Static files generated`)
|
|
106
134
|
|
package/router/index.ts
CHANGED
|
@@ -171,7 +171,7 @@ export default {
|
|
|
171
171
|
if(!globalThis.isListening){
|
|
172
172
|
let config = require(process.cwd() + '/vader.config.js').default
|
|
173
173
|
if(process.env.mode === 'production'){
|
|
174
|
-
console.log(
|
|
174
|
+
console.log(`\x1b[32msuccess \x1b[0m- listening on port ${config.env.PORT || 3000}`)
|
|
175
175
|
spawnServer(config)
|
|
176
176
|
}
|
|
177
177
|
config?.env?.SSR ? spawn_ssr_server(config ) : spawnServer(config)
|
package/server/index.js
CHANGED
|
@@ -47,7 +47,7 @@ class Component {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
}
|
|
50
|
-
export async function renderToString(element, args = []) {
|
|
50
|
+
export async function renderToString(element, args = []) {
|
|
51
51
|
let data = typeof element === 'function' ? await element(args) : element
|
|
52
52
|
let doc = new Document()
|
|
53
53
|
let el = doc.createElement(data)
|
|
File without changes
|