vaderjs 1.4.2-bml56 → 1.4.2-jpbvml56
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 +14 -4
- package/binaries/Kalix/index.js +21 -12
- package/binaries/compiler/main.js +71 -30
- package/binaries/watcher/hmr.js +3 -2
- package/client/runtime/index.js +1 -417
- package/client/runtime/router.js +1 -235
- package/config/index.ts +20 -1
- package/package.json +1 -2
- package/plugins/cloudflare/functions/index.js +4 -0
- package/plugins/cloudflare/toCopy/@server/Kalix/index.js +62 -14
- package/plugins/cloudflare/toCopy/src/client.js +1 -432
- package/plugins/cloudflare/toCopy/src/router.js +1 -235
- package/plugins/ssg/index.js +89 -19
- package/plugins/tailwind/index.ts +102 -0
- package/router/index.ts +37 -10
- package/server/index.js +15 -1
package/README.md
CHANGED
|
@@ -39,8 +39,8 @@ Keyword folders - all files are passed from these folders to the build folder
|
|
|
39
39
|
|
|
40
40
|
```md
|
|
41
41
|
1. pages - used for jsx route files
|
|
42
|
-
2. src - used for your jsx components / javascript files
|
|
43
|
-
3. public - used for anything
|
|
42
|
+
2. src - used for your jsx components / javascript -typescript files
|
|
43
|
+
3. public - used for anything / css / json etc
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
|
|
@@ -49,18 +49,28 @@ Keyword folders - all files are passed from these folders to the build folder
|
|
|
49
49
|
```ts
|
|
50
50
|
import { defineConfig } from "vaderjs/config";
|
|
51
51
|
import cloudflare from "vaderjs/plugins/cloudflare/functions"
|
|
52
|
+
import tailwindcss from "vaderjs/plugins/tailwindcss"
|
|
52
53
|
export default defineConfig({
|
|
53
54
|
target: "web",
|
|
54
55
|
host: {
|
|
55
56
|
hostname: "localhost",
|
|
56
|
-
provider:'cloudflare'
|
|
57
|
+
provider:'cloudflare' // used for ssg or ssr
|
|
57
58
|
},
|
|
58
59
|
env: {
|
|
59
60
|
PORT: 3000,
|
|
60
61
|
SSR: true,
|
|
61
62
|
apiRoute: "https://api.example.com"
|
|
62
63
|
},
|
|
63
|
-
|
|
64
|
+
Router: {
|
|
65
|
+
tls: {
|
|
66
|
+
cert: "cert.pem",
|
|
67
|
+
key: "key.pem"
|
|
68
|
+
},
|
|
69
|
+
headers: {
|
|
70
|
+
"cache-control": "public, max-age=0, must-revalidate"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
plugins: [cloudflare, tailwindcss],
|
|
64
74
|
});
|
|
65
75
|
|
|
66
76
|
```
|
package/binaries/Kalix/index.js
CHANGED
|
@@ -67,7 +67,7 @@ export class HTMLTextNode {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
insertBefore(node) {
|
|
70
|
-
this.nodeValue = `${node.
|
|
70
|
+
this.nodeValue = `${node.nodeValue}${this.nodeValue}`;
|
|
71
71
|
return this;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -111,7 +111,7 @@ export class HTMLElement {
|
|
|
111
111
|
if (key !== 'style' && key !== 'ref' && !key.startsWith('on')) {
|
|
112
112
|
props += `${key}="${this.props[key]}" `
|
|
113
113
|
}
|
|
114
|
-
}
|
|
114
|
+
}
|
|
115
115
|
let children = this.children
|
|
116
116
|
.map((child) => {
|
|
117
117
|
return child.toString();
|
|
@@ -155,12 +155,7 @@ export class HTMLElement {
|
|
|
155
155
|
.join("");
|
|
156
156
|
return string;
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
return this.children
|
|
160
|
-
.map((child) => {
|
|
161
|
-
return child.toString();
|
|
162
|
-
})
|
|
163
|
-
.join("");
|
|
158
|
+
|
|
164
159
|
default:
|
|
165
160
|
break;
|
|
166
161
|
}
|
|
@@ -187,8 +182,8 @@ export class HTMLElement {
|
|
|
187
182
|
* @returns {HTMLElement}
|
|
188
183
|
*/
|
|
189
184
|
setContent(content) {
|
|
190
|
-
let textNode = new
|
|
191
|
-
this.children = [textNode];
|
|
185
|
+
let textNode = new HTMLTextNode(content)
|
|
186
|
+
this.children = [textNode];
|
|
192
187
|
this.outerHTML = this.toString("outerHTML");
|
|
193
188
|
this.innerHTML = this.toString("innerHTML");
|
|
194
189
|
return this;
|
|
@@ -356,7 +351,7 @@ export class HTMLElement {
|
|
|
356
351
|
this.textContent = this.toString("innerText");
|
|
357
352
|
this.children.forEach((c) => {
|
|
358
353
|
if (c.children) {
|
|
359
|
-
child = c.children.find((child) => {
|
|
354
|
+
child = c.children.find((child) => {
|
|
360
355
|
child.outerHTML = child.toString("outerHTML");
|
|
361
356
|
child.innerHTML = child.toString("innerHTML");
|
|
362
357
|
return child.tagName === selector;
|
|
@@ -566,7 +561,17 @@ function handleStyles(styles, nodeEl) {
|
|
|
566
561
|
*/
|
|
567
562
|
export function Element(tag, props = {}, ...children) {
|
|
568
563
|
if(typeof tag === 'function'){
|
|
569
|
-
let
|
|
564
|
+
let childObj = children.map((child) => {
|
|
565
|
+
if (child.tagName === "TEXT_ELEMENT") {
|
|
566
|
+
return new HTMLTextNode(child);
|
|
567
|
+
}
|
|
568
|
+
if (child instanceof HTMLElement) {
|
|
569
|
+
return child;
|
|
570
|
+
}
|
|
571
|
+
return new HTMLElement(child.tagName, child.props, child.children);
|
|
572
|
+
})
|
|
573
|
+
childObj = childObj[0]
|
|
574
|
+
let el = tag({...props, children: childObj})
|
|
570
575
|
return el
|
|
571
576
|
}
|
|
572
577
|
if(props === null){
|
|
@@ -633,6 +638,10 @@ export function Element(tag, props = {}, ...children) {
|
|
|
633
638
|
node.children = children
|
|
634
639
|
delete props.children
|
|
635
640
|
}
|
|
641
|
+
if(props?.className){
|
|
642
|
+
props['class'] = props.className
|
|
643
|
+
delete props.className
|
|
644
|
+
}
|
|
636
645
|
for (var i = 0; i < children.length; i++) {
|
|
637
646
|
if(typeof children[i] === 'undefined'){
|
|
638
647
|
delete children[i]
|
|
@@ -147,7 +147,7 @@ export async function Compile(){
|
|
|
147
147
|
return obj
|
|
148
148
|
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
function main(contents, filePath){
|
|
151
151
|
let copy = contents
|
|
152
152
|
|
|
153
153
|
for (var i in contents.split('\n')){
|
|
@@ -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];
|
|
@@ -331,27 +331,32 @@ export async function Compile(){
|
|
|
331
331
|
old = line;
|
|
332
332
|
copy = copy.replace(old, newStatereducer);
|
|
333
333
|
break;
|
|
334
|
+
case line.includes('vaderjs/client') && line.includes('import') || line.includes('vaderjs') && line.includes('import'):
|
|
335
|
+
let b4 = line
|
|
336
|
+
copy = copy.replace(b4, '')
|
|
337
|
+
break;
|
|
334
338
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
339
|
+
case line.includes('import') && !line.includes('vaderjs/client') && !line.includes('vaderjs') && !line.includes('import.meta') && !line.includes('import.meta.url') && !line.includes('import.meta.env'):
|
|
340
|
+
|
|
341
|
+
let filePath = line.split('from')[1].trim().replace(/'/g, '').replace(/"/g, '').replace(';', '').replaceAll('../','').replace(/\\/g, '/')
|
|
342
|
+
let contents = fs.readFileSync(filePath, 'utf8')
|
|
343
|
+
// remove default exports
|
|
344
|
+
|
|
345
|
+
if(contents.match(/export\s+default\s+/g)){
|
|
346
|
+
contents = contents.replace(/export\s+default\s+/g, '')
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
copy = copy.replace(line, contents)
|
|
350
|
+
|
|
351
|
+
break;
|
|
352
|
+
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
355
|
+
|
|
352
356
|
return copy
|
|
353
357
|
}
|
|
354
358
|
|
|
359
|
+
|
|
355
360
|
|
|
356
361
|
|
|
357
362
|
async function gen(){
|
|
@@ -370,21 +375,19 @@ export async function Compile(){
|
|
|
370
375
|
|
|
371
376
|
for(var file of array){
|
|
372
377
|
let data = new Bun.Transpiler({
|
|
373
|
-
|
|
378
|
+
loader: "tsx",
|
|
374
379
|
tsconfig: {
|
|
375
380
|
'compilerOptions':{
|
|
376
|
-
'jsx':'react',
|
|
377
|
-
|
|
381
|
+
'jsx':'react',
|
|
382
|
+
"jsxFactory": "this.Element"
|
|
378
383
|
}
|
|
379
|
-
},
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
let variables = grabVariables(data, file)
|
|
387
|
-
let contents = await main(data, file)
|
|
384
|
+
},
|
|
385
|
+
})
|
|
386
|
+
let contents = await Bun.file(process.cwd() + file).text()
|
|
387
|
+
contents = main(contents, file)
|
|
388
|
+
contents = data.transformSync(contents)
|
|
389
|
+
contents = contents.split('\n').filter((line) => !line.includes('vaderjs/client') && !line.includes('vaderjs')).join('\n')
|
|
390
|
+
let variables = grabVariables(contents, file)
|
|
388
391
|
|
|
389
392
|
variables.forEach((variable) => {
|
|
390
393
|
contents.split('\n').forEach((line, index) => {
|
|
@@ -408,10 +411,14 @@ export async function Compile(){
|
|
|
408
411
|
fs.mkdirSync(process.cwd() + '/build/pages/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
409
412
|
file = '/build/pages/' + file.replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
410
413
|
break;
|
|
414
|
+
case isUsingProvider === 'vercel':
|
|
415
|
+
fs.mkdirSync(process.cwd() + '/build/pages/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
416
|
+
file = '/build/pages/' + file.replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
417
|
+
break;
|
|
411
418
|
default:
|
|
412
419
|
file = '/build/' + file.replace('./', '').replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
413
420
|
}
|
|
414
|
-
}
|
|
421
|
+
}
|
|
415
422
|
fs.writeFileSync(process.cwd() + file, contents)
|
|
416
423
|
|
|
417
424
|
|
|
@@ -425,6 +432,40 @@ export async function Compile(){
|
|
|
425
432
|
await Bun.write(process.cwd() + '/build/src/router.js', await Bun.file(process.cwd() + '/node_modules/vaderjs/client/runtime/router.js').text())
|
|
426
433
|
}
|
|
427
434
|
|
|
435
|
+
// handle src files
|
|
436
|
+
const src = new Glob("/src/**/*.{ts,tsx,js,jsx}", {
|
|
437
|
+
absolute: true,
|
|
438
|
+
ignore: ["**/node_modules/**"]
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const publics = new Glob("/public/**/*", {
|
|
442
|
+
absolute: true,
|
|
443
|
+
ignore: ["**/node_modules/**"]
|
|
444
|
+
})
|
|
445
|
+
let srcArray = await Array.fromAsync(src.scan())
|
|
446
|
+
srcArray = srcArray.map((file) => {
|
|
447
|
+
file = file.replaceAll('\\', '/')
|
|
448
|
+
file ='./' + file
|
|
449
|
+
return file
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
let publicArray = await Array.fromAsync(publics.scan())
|
|
455
|
+
publicArray = publicArray.map((file) => {
|
|
456
|
+
file = file.replaceAll('\\', '/')
|
|
457
|
+
file ='./' + file
|
|
458
|
+
return file
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
for(var file of publicArray){
|
|
462
|
+
file = file.split('/public')[1]
|
|
463
|
+
fs.mkdirSync(process.cwd() + '/build/public/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
464
|
+
let out = `/build/public${file}`
|
|
465
|
+
let contents = await Bun.file(process.cwd() + '/public' + file).text()
|
|
466
|
+
fs.writeFileSync(process.cwd() + out, contents)
|
|
467
|
+
|
|
468
|
+
}
|
|
428
469
|
|
|
429
470
|
resolve()
|
|
430
471
|
})
|
package/binaries/watcher/hmr.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { watch } from 'fs'
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
globalThis.hasLogged = false
|
|
4
|
-
export function watchDir(cwd, _){
|
|
4
|
+
export async function watchDir(cwd, _){
|
|
5
5
|
process.chdir(cwd)
|
|
6
6
|
let p = Bun.spawn(['bun', "run", process.cwd() + '/node_modules/vaderjs/binaries/compiler/main.js'], {
|
|
7
7
|
cwd: process.cwd(),
|
|
@@ -9,7 +9,7 @@ export function watchDir(cwd, _){
|
|
|
9
9
|
hmr: true
|
|
10
10
|
},
|
|
11
11
|
stdout: 'inherit',
|
|
12
|
-
})
|
|
12
|
+
})
|
|
13
13
|
let paths = ['src', 'pages', 'public', 'routes', 'vader.config.ts']
|
|
14
14
|
for(var i in paths){
|
|
15
15
|
let path = paths[i]
|
|
@@ -17,6 +17,7 @@ export function watchDir(cwd, _){
|
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
watch(process.cwd() + '/' + path, { recursive: true, absolute:true }, (event, filename) => {
|
|
20
|
+
if(!filename.endsWith('.ts') && !filename.endsWith('.tsx') && !filename.endsWith('.js') && !filename.endsWith('.jsx')) return
|
|
20
21
|
if(filename && !filename.includes('node_modules') && !globalThis.hasLogged){
|
|
21
22
|
console.log(`\x1b[36mwait \x1b[0m - compiling (client and server)`)
|
|
22
23
|
globalThis.hasLogged = true
|