vaderjs 1.4.2-bml56 → 1.4.2-jpiml56
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 +17 -12
- package/binaries/compiler/main.js +99 -20
- package/binaries/watcher/hmr.js +1 -0
- 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/tailwindcss/index.ts +93 -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){
|
|
@@ -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(){
|
|
@@ -382,9 +387,11 @@ export async function Compile(){
|
|
|
382
387
|
'jsxDev':JSON.stringify('this.Element'),
|
|
383
388
|
'jsx': JSON.stringify('this.Element'),
|
|
384
389
|
}
|
|
385
|
-
})
|
|
386
|
-
|
|
387
|
-
|
|
390
|
+
})
|
|
391
|
+
let contents = await Bun.file(process.cwd() + file).text()
|
|
392
|
+
contents = data.transformSync(await main(contents, file))
|
|
393
|
+
contents = contents.split('\n').filter((line) => !line.includes('vaderjs/client') && !line.includes('vaderjs')).join('\n')
|
|
394
|
+
let variables = grabVariables(contents, file)
|
|
388
395
|
|
|
389
396
|
variables.forEach((variable) => {
|
|
390
397
|
contents.split('\n').forEach((line, index) => {
|
|
@@ -408,10 +415,14 @@ export async function Compile(){
|
|
|
408
415
|
fs.mkdirSync(process.cwd() + '/build/pages/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
409
416
|
file = '/build/pages/' + file.replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
410
417
|
break;
|
|
418
|
+
case isUsingProvider === 'vercel':
|
|
419
|
+
fs.mkdirSync(process.cwd() + '/build/pages/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
420
|
+
file = '/build/pages/' + file.replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
421
|
+
break;
|
|
411
422
|
default:
|
|
412
423
|
file = '/build/' + file.replace('./', '').replace('.tsx', '.js').replace('.ts', '.js').replace('.jsx', '.js')
|
|
413
424
|
}
|
|
414
|
-
}
|
|
425
|
+
}
|
|
415
426
|
fs.writeFileSync(process.cwd() + file, contents)
|
|
416
427
|
|
|
417
428
|
|
|
@@ -425,6 +436,74 @@ export async function Compile(){
|
|
|
425
436
|
await Bun.write(process.cwd() + '/build/src/router.js', await Bun.file(process.cwd() + '/node_modules/vaderjs/client/runtime/router.js').text())
|
|
426
437
|
}
|
|
427
438
|
|
|
439
|
+
// handle src files
|
|
440
|
+
const src = new Glob("/src/**/*.{ts,tsx,js,jsx}", {
|
|
441
|
+
absolute: true,
|
|
442
|
+
ignore: ["**/node_modules/**"]
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const publics = new Glob("/public/**/*", {
|
|
446
|
+
absolute: true,
|
|
447
|
+
ignore: ["**/node_modules/**"]
|
|
448
|
+
})
|
|
449
|
+
let srcArray = await Array.fromAsync(src.scan())
|
|
450
|
+
srcArray = srcArray.map((file) => {
|
|
451
|
+
file = file.replaceAll('\\', '/')
|
|
452
|
+
file ='./' + file
|
|
453
|
+
return file
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
for(var file of srcArray){
|
|
457
|
+
let data = new Bun.Transpiler({
|
|
458
|
+
loader: "tsx",
|
|
459
|
+
tsconfig: {
|
|
460
|
+
'compilerOptions':{
|
|
461
|
+
'jsx':'react',
|
|
462
|
+
'jsxFactory': 'this.Element'
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
define:{
|
|
466
|
+
|
|
467
|
+
'jsxDev':JSON.stringify('this.Element'),
|
|
468
|
+
'jsx': JSON.stringify('this.Element'),
|
|
469
|
+
}
|
|
470
|
+
}).transformSync(await Bun.file(process.cwd() + file).text())
|
|
471
|
+
let variables = grabVariables(data, file)
|
|
472
|
+
let contents = await main(data, file)
|
|
473
|
+
variables.forEach((variable) => {
|
|
474
|
+
contents.split('\n').forEach((line, index) => {
|
|
475
|
+
if(line.includes(variable) && !line.includes('import') && !line.includes('let') && !line.includes('var') && !line.includes('const')
|
|
476
|
+
&& !line.includes(variable + '()') &&
|
|
477
|
+
!line.includes('.' + variable) &&
|
|
478
|
+
// not an occurence like variable1, variable2, variable3 or variabless
|
|
479
|
+
!line.match(new RegExp(variable + '[0-9]')) && !line.match(new RegExp(variable + '(w+)'))
|
|
480
|
+
&& !line.includes(variable + ':')
|
|
481
|
+
){
|
|
482
|
+
let newLine = line.replaceAll(variable, variable + '()')
|
|
483
|
+
contents = contents.replace(line, newLine)
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
})
|
|
487
|
+
file = file.split('/src')[1]
|
|
488
|
+
fs.mkdirSync(process.cwd() + '/build/src/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
489
|
+
fs.writeFileSync(process.cwd() + '/build/src' + file, contents)
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
let publicArray = await Array.fromAsync(publics.scan())
|
|
493
|
+
publicArray = publicArray.map((file) => {
|
|
494
|
+
file = file.replaceAll('\\', '/')
|
|
495
|
+
file ='./' + file
|
|
496
|
+
return file
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
for(var file of publicArray){
|
|
500
|
+
file = file.split('/public')[1]
|
|
501
|
+
fs.mkdirSync(process.cwd() + '/build/public/' + file.split('/').slice(0, -1).join('/'), { recursive: true })
|
|
502
|
+
let out = `/build/public${file}`
|
|
503
|
+
let contents = await Bun.file(process.cwd() + '/public' + file).text()
|
|
504
|
+
fs.writeFileSync(process.cwd() + out, contents)
|
|
505
|
+
|
|
506
|
+
}
|
|
428
507
|
|
|
429
508
|
resolve()
|
|
430
509
|
})
|
package/binaries/watcher/hmr.js
CHANGED
|
@@ -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
|