vaderjs 1.3.3-773562-hotfix → 1.3.3-7775642-hotfix
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/package.json +1 -1
- package/vader.js +176 -193
package/package.json
CHANGED
package/vader.js
CHANGED
|
@@ -239,34 +239,34 @@ function Compiler(func, file) {
|
|
|
239
239
|
continue;
|
|
240
240
|
}
|
|
241
241
|
let old = spread;
|
|
242
|
-
spread = spread.trim().replace(/\s+/g, " ");
|
|
242
|
+
spread = spread.trim().replace(/\s+/g, " ");
|
|
243
243
|
// re,pve $={ and }
|
|
244
244
|
spread = spread.replace(/\s*\$\s*=\s*{\s*{/gs, '')
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
// replace trailing }
|
|
247
|
-
spread = spread.replace(/}}\s*$/, '').replace(/}\s*}$/, '')
|
|
248
|
-
let splitByCommas =
|
|
247
|
+
spread = spread.replace(/}}\s*$/, '').replace(/}\s*}$/, '')
|
|
248
|
+
let splitByCommas = spread.split(/,(?![^{}]*})/gs)
|
|
249
249
|
// remove empty strings
|
|
250
250
|
splitByCommas = splitByCommas.filter((e) => e.split(':')[0].trim().length > 0)
|
|
251
|
-
splitByCommas = splitByCommas.map((e, index) => {
|
|
251
|
+
splitByCommas = splitByCommas.map((e, index) => {
|
|
252
252
|
let key = e.split(':')[0].trim()
|
|
253
253
|
switch (true) {
|
|
254
254
|
case e.includes('function') && !e.includes('this.bind') || e && e.includes('=>') && !e.includes('this.bind'):
|
|
255
255
|
let value = e.split(':')[1].trim()
|
|
256
|
-
let ref = Math.random().toString(36).substring(2).split('').filter((e) => !Number(e)).join('');
|
|
256
|
+
let ref = Math.random().toString(36).substring(2).split('').filter((e) => !Number(e)).join('');
|
|
257
257
|
value = `this.bind(${value}, false, "${ref}", "")`
|
|
258
258
|
e = `${key}="\${${value}}"`
|
|
259
259
|
break;
|
|
260
|
-
case
|
|
261
|
-
let v2 = e.split('style:')[1].trim().replace(/,$/, '')
|
|
262
|
-
v2 = v2.replace(/,$/, '')
|
|
260
|
+
case e.includes('style:'):
|
|
261
|
+
let v2 = e.split('style:')[1].trim().replace(/,$/, '')
|
|
262
|
+
v2 = v2.replace(/,$/, '')
|
|
263
263
|
e = `${key}="\${this.parseStyle(${v2})}"`
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
default:
|
|
267
|
-
let v = e.split(':')
|
|
264
|
+
break;
|
|
265
|
+
|
|
266
|
+
default:
|
|
267
|
+
let v = e.split(':')
|
|
268
268
|
key = v[0].trim()
|
|
269
|
-
|
|
269
|
+
// remove key from v
|
|
270
270
|
v.shift()
|
|
271
271
|
v = v.join(' ')
|
|
272
272
|
e = `${key}="\${${v}}"`
|
|
@@ -277,7 +277,7 @@ function Compiler(func, file) {
|
|
|
277
277
|
|
|
278
278
|
return e;
|
|
279
279
|
});
|
|
280
|
-
|
|
280
|
+
|
|
281
281
|
|
|
282
282
|
let newSpread = splitByCommas.join(' ').trim().replace(/,$/, '');
|
|
283
283
|
|
|
@@ -348,7 +348,7 @@ function Compiler(func, file) {
|
|
|
348
348
|
newAttributes.push(attribute);
|
|
349
349
|
for (let key in attributes) {
|
|
350
350
|
|
|
351
|
-
let value = attributes[key];
|
|
351
|
+
let value = attributes[key];
|
|
352
352
|
let oldvalue = value;
|
|
353
353
|
if (value && !value.new) {
|
|
354
354
|
|
|
@@ -502,10 +502,10 @@ function Compiler(func, file) {
|
|
|
502
502
|
|
|
503
503
|
if (prop.startsWith('$=')) {
|
|
504
504
|
let old = prop
|
|
505
|
-
let match = prop.replace(/\$\s*=\s*\{\s*\{\s*([^]*?)\s*\}\s*\}/gs, '$1')
|
|
505
|
+
let match = prop.replace(/\$\s*=\s*\{\s*\{\s*([^]*?)\s*\}\s*\}/gs, '$1')
|
|
506
506
|
match = match.replace('$:', '$_ternary:')
|
|
507
507
|
component = component.replace(old, '')
|
|
508
|
-
componentAttributes = componentAttributes.replace(old,
|
|
508
|
+
componentAttributes = componentAttributes.replace(old, match)
|
|
509
509
|
|
|
510
510
|
$_ternaryprops.push(prop)
|
|
511
511
|
|
|
@@ -635,54 +635,52 @@ function Compiler(func, file) {
|
|
|
635
635
|
|
|
636
636
|
string = string.replaceAll('vaderjs/client', '/vader.js')
|
|
637
637
|
|
|
638
|
-
const importRegex = /import\s*([^\s,]+|\{[^}]+\})\s*from\s*(['"])(.*?)\2/
|
|
638
|
+
const importRegex = /import\s*([^\s,]+|\{[^}]+\})\s*from\s*(['"])(.*?)\2/g;
|
|
639
639
|
const imports = string.match(importRegex);
|
|
640
640
|
let replaceMents = [];
|
|
641
641
|
|
|
642
642
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
}
|
|
643
|
+
for (let match of imports) {
|
|
644
|
+
let path = match.split('from')[1].trim().replace(/'/g, '').replace(/"/g, '').trim()
|
|
645
|
+
switch (true) {
|
|
646
|
+
case path && !path.includes('./') && !path.includes('/vader.js') && !path.includes('/vaderjs/client') && !path.startsWith('src') && !path.startsWith('public') && !path.includes('http') && !path.includes('https'):
|
|
647
|
+
let componentFolder = fs.existsSync(process.cwd() + '/node_modules/' + path) ? process.cwd() + '/node_modules/' + path : process.cwd() + '/node_modules/' + path.split('/')[0]
|
|
648
|
+
componentFolder = componentFolder.split(process.cwd())[1]
|
|
649
|
+
if (!fs.existsSync(process.cwd() + componentFolder)) {
|
|
650
|
+
throw new Error('Could not find ' + path + ' at ' + match + ' in file ' + file)
|
|
651
|
+
}
|
|
653
652
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
653
|
+
if (!fs.existsSync(process.cwd() + '/dist/src/' + componentFolder.split('/').slice(2).join('/'))) {
|
|
654
|
+
fs.mkdirSync(process.cwd() + '/dist/src/' + componentFolder.split('/').slice(2).join('/'), { recursive: true })
|
|
655
|
+
}
|
|
657
656
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
657
|
+
let baseFolder = componentFolder.split('node_modules')[1].split('/')[1]
|
|
658
|
+
let glp = globSync('**/**/**/**.{jsx,js}', {
|
|
659
|
+
cwd: process.cwd() + '/node_modules/' + baseFolder + '/',
|
|
660
|
+
absolute: true,
|
|
661
|
+
recursive: true
|
|
662
|
+
})
|
|
663
|
+
for (let file of glp) {
|
|
664
|
+
let text = fs.readFileSync(file, "utf8");
|
|
665
|
+
if (!file.endsWith('.js') && file.endsWith('.jsx')) {
|
|
666
|
+
text = Compiler(text, file);
|
|
668
667
|
|
|
669
|
-
}
|
|
670
|
-
let dest = file.split('node_modules')[1]
|
|
671
|
-
dest = dest.split(baseFolder)[1]
|
|
672
|
-
writer(process.cwd() + '/dist/src/' + baseFolder + dest, text)
|
|
673
|
-
let importname = match.split('import')[1].split('from')[0].trim()
|
|
674
|
-
let oldImportstring = match.split('from')[1].trim().replace(/'/g, '').replace(/"/g, '').trim()
|
|
675
|
-
let newImport = `/src/${baseFolder + dest}`
|
|
676
|
-
newImport = newImport.replaceAll('.jsx', '.js').replaceAll('\\', '/')
|
|
677
|
-
replaceMents.push({ match: oldImportstring, replace: newImport })
|
|
678
|
-
console.log(`📦 imported Node Package ${baseFolder} `)
|
|
679
668
|
}
|
|
669
|
+
let dest = file.split('node_modules')[1]
|
|
670
|
+
dest = dest.split(baseFolder)[1]
|
|
671
|
+
writer(process.cwd() + '/dist/src/' + baseFolder + dest, text)
|
|
672
|
+
let importname = match.split('import')[1].split('from')[0].trim()
|
|
673
|
+
let oldImportstring = match.split('from')[1].trim().replace(/'/g, '').replace(/"/g, '').trim()
|
|
674
|
+
let newImport = `/src/${baseFolder + dest}`
|
|
675
|
+
newImport = newImport.replaceAll('.jsx', '.js').replaceAll('\\', '/')
|
|
676
|
+
replaceMents.push({ match: oldImportstring, replace: newImport })
|
|
677
|
+
console.log(`📦 imported Node Package ${baseFolder} `)
|
|
678
|
+
}
|
|
680
679
|
|
|
681
680
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
681
|
+
break;
|
|
682
|
+
default:
|
|
683
|
+
break;
|
|
686
684
|
}
|
|
687
685
|
}
|
|
688
686
|
|
|
@@ -875,7 +873,6 @@ const glb = await glob("**/**/**/**.{jsx,js}", {
|
|
|
875
873
|
absolute: true,
|
|
876
874
|
recursive: true
|
|
877
875
|
});
|
|
878
|
-
let hasRendered = []
|
|
879
876
|
async function Build() {
|
|
880
877
|
globalThis.isBuilding = true
|
|
881
878
|
console.log(globalThis.isProduction ? 'Creating Optimized Production Build\n' : '')
|
|
@@ -890,49 +887,119 @@ async function Build() {
|
|
|
890
887
|
|
|
891
888
|
function ssg(routes = []) {
|
|
892
889
|
globalThis.isBuilding = true
|
|
893
|
-
let server = http.createServer((req, res) => {
|
|
894
|
-
let route = routes.find((e) => e.url === req.url)
|
|
895
|
-
if (route) {
|
|
896
|
-
let document = globalThis.routeDocuments.find((e) => e.url === req.url)
|
|
897
|
-
console.log(`\x1b[32m%s\x1b[0m`, `Prerendering ${req.url}...`)
|
|
898
|
-
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
899
|
-
res.end(document.document);
|
|
900
|
-
} else {
|
|
901
|
-
const filePath = process.cwd() + '/dist/' + req.url
|
|
902
|
-
|
|
903
|
-
fs.readFile(filePath, (err, data) => {
|
|
904
|
-
if (err) {
|
|
905
|
-
res.writeHead(404, { 'Content-Type': filePath.includes('js') ? 'text/javascript' : 'text/html' });
|
|
906
|
-
res.end('File not found');
|
|
907
|
-
} else {
|
|
908
|
-
res.writeHead(200, { 'Content-Type': filePath.includes('js') ? 'text/javascript' : 'text/html' });
|
|
909
|
-
res.end(data);
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
});
|
|
914
|
-
|
|
915
|
-
let port = 12000
|
|
916
|
-
server.on('error', (err) => {
|
|
917
|
-
if (err.code === 'EADDRINUSE') {
|
|
918
|
-
setTimeout(() => {
|
|
919
|
-
server.close();
|
|
920
|
-
server.listen(++port);
|
|
921
|
-
}, 1000);
|
|
922
|
-
}
|
|
923
|
-
})
|
|
924
|
-
|
|
925
|
-
server.listen(port);
|
|
926
890
|
routes.forEach(async (route) => {
|
|
927
891
|
if (route.url.includes(':')) {
|
|
928
892
|
return
|
|
929
893
|
}
|
|
894
|
+
let equalparamroute = routes.map((e) => {
|
|
895
|
+
if (e.url.includes(':')) {
|
|
896
|
+
let url = e.url.split('/:')[0]
|
|
897
|
+
if (url && route.url === url) {
|
|
898
|
+
return e
|
|
899
|
+
} else {
|
|
900
|
+
return null
|
|
930
901
|
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
return null
|
|
905
|
+
}).filter(Boolean)
|
|
906
|
+
let document = `
|
|
907
|
+
<!DOCTYPE html>
|
|
908
|
+
<html lang="en">
|
|
909
|
+
<head>
|
|
910
|
+
<script>
|
|
911
|
+
window.routes = JSON.parse('${JSON.stringify(routes)}')
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
</script>
|
|
915
|
+
<script id="isServer">
|
|
916
|
+
window.isServer = true
|
|
917
|
+
</script>
|
|
918
|
+
<meta charset="UTF-8">
|
|
919
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
920
|
+
<script type="module" id="meta">
|
|
921
|
+
window.history.pushState({}, '', '${route.url}')
|
|
922
|
+
|
|
923
|
+
</script>
|
|
924
|
+
<script type="module" id="router">
|
|
925
|
+
import VaderRouter from '/router.js'
|
|
926
|
+
const router = new VaderRouter('${route.url}', 3000)
|
|
927
|
+
router.get('${route.url}', async (req, res) => {
|
|
928
|
+
try{
|
|
929
|
+
let module = await import('/${route.fileName.replace('.jsx', '.js')}')
|
|
930
|
+
if(Object.keys(module).includes('$prerender') && !module.$prerender){
|
|
931
|
+
document.head.setAttribute('prerender', 'false')
|
|
932
|
+
}
|
|
933
|
+
res.render(module, req, res, module.$metadata)
|
|
934
|
+
}
|
|
935
|
+
catch(error){
|
|
936
|
+
let errorMessage = {
|
|
937
|
+
message: error.message,
|
|
938
|
+
name: error.name,
|
|
939
|
+
stack: error.stack,
|
|
940
|
+
path: window.location.pathname
|
|
941
|
+
};
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
document.documentElement.setAttribute('error', JSON.stringify(errorMessage));
|
|
945
|
+
throw new Error(error)
|
|
946
|
+
}
|
|
947
|
+
})
|
|
948
|
+
${equalparamroute.length > 0 ? equalparamroute.map((e) => {
|
|
931
949
|
|
|
932
950
|
|
|
933
951
|
|
|
952
|
+
return `router.get('${e.url}', async (req, res) => {
|
|
953
|
+
let module = await import('/${e.fileName.replace('.jsx', '.js')}')
|
|
954
|
+
res.render(module, req, res, module.$metadata)
|
|
955
|
+
})\n`
|
|
956
|
+
}) : ''}
|
|
957
|
+
router.listen(3000)
|
|
958
|
+
|
|
959
|
+
</script>
|
|
960
|
+
</head>
|
|
961
|
+
<body>
|
|
962
|
+
<div id="root"></div>
|
|
963
|
+
</body>
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
</html>
|
|
967
|
+
`;
|
|
934
968
|
|
|
969
|
+
// generate random but common ports
|
|
970
|
+
let port = Math.floor(Math.random() * (65535 - 49152 + 1) + 49152)
|
|
935
971
|
|
|
972
|
+
const server = http.createServer((req, res) => {
|
|
973
|
+
|
|
974
|
+
if (req.url === '/') {
|
|
975
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
976
|
+
res.end(document);
|
|
977
|
+
} else {
|
|
978
|
+
// Serve static files (adjust the file paths based on your project structure)
|
|
979
|
+
const filePath = process.cwd() + '/dist/' + req.url
|
|
980
|
+
|
|
981
|
+
fs.readFile(filePath, (err, data) => {
|
|
982
|
+
if (err) {
|
|
983
|
+
res.writeHead(404, { 'Content-Type': filePath.includes('js') ? 'text/javascript' : 'text/html' });
|
|
984
|
+
res.end('File not found');
|
|
985
|
+
} else {
|
|
986
|
+
res.writeHead(200, { 'Content-Type': filePath.includes('js') ? 'text/javascript' : 'text/html' });
|
|
987
|
+
res.end(data);
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
|
|
993
|
+
server.listen(port)
|
|
994
|
+
server.on('error', (err) => {
|
|
995
|
+
if (err.code === 'EADDRINUSE') {
|
|
996
|
+
console.log(`Port ${port} is in use, trying another port...`);
|
|
997
|
+
setTimeout(() => {
|
|
998
|
+
server.close();
|
|
999
|
+
server.listen(++port);
|
|
1000
|
+
}, 1000);
|
|
1001
|
+
}
|
|
1002
|
+
})
|
|
936
1003
|
|
|
937
1004
|
globalThis.listen = true;
|
|
938
1005
|
|
|
@@ -948,16 +1015,14 @@ async function Build() {
|
|
|
948
1015
|
page.on('error', (err) => {
|
|
949
1016
|
console.error('BROWSER ERROR:', JSON.parse(err));
|
|
950
1017
|
});
|
|
951
|
-
|
|
1018
|
+
|
|
952
1019
|
try {
|
|
953
|
-
page.on('pageerror', async err => {
|
|
954
|
-
let errorObj =
|
|
955
|
-
console.log('\x1b[31m%s\x1b[0m', 'Compiler Error:',
|
|
1020
|
+
page.on('pageerror', async err => {
|
|
1021
|
+
let errorObj = JSON.parse(await page.evaluate(() => document.documentElement.getAttribute('error')) || '{}')
|
|
1022
|
+
console.log('\x1b[31m%s\x1b[0m', 'Compiler Error:', errorObj)
|
|
956
1023
|
|
|
957
|
-
console.log('\x1b[31m%s\x1b[0m', 'Error:', err)
|
|
958
1024
|
});
|
|
959
1025
|
} catch (error) {
|
|
960
|
-
console.log(error)
|
|
961
1026
|
browser.close()
|
|
962
1027
|
}
|
|
963
1028
|
// Handle page crashes
|
|
@@ -967,10 +1032,16 @@ async function Build() {
|
|
|
967
1032
|
page.on('requestfailed', request => {
|
|
968
1033
|
console.error('REQUEST FAILED:', request.url(), request.failure().errorText);
|
|
969
1034
|
});
|
|
970
|
-
await page.goto(`http://localhost:${port}
|
|
1035
|
+
await page.goto(`http://localhost:${port}/`, { waitUntil: 'networkidle2' });
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
971
1042
|
|
|
972
1043
|
await page.evaluate(() => {
|
|
973
|
-
document.
|
|
1044
|
+
document.getElementById('meta').remove()
|
|
974
1045
|
document.querySelector('#isServer').innerHTML = 'window.isServer = false'
|
|
975
1046
|
if (document.head.getAttribute('prerender') === 'false') {
|
|
976
1047
|
document.querySelector('#root').innerHTML = ''
|
|
@@ -986,26 +1057,19 @@ async function Build() {
|
|
|
986
1057
|
|
|
987
1058
|
|
|
988
1059
|
} catch (error) {
|
|
989
|
-
|
|
1060
|
+
console.log(error)
|
|
990
1061
|
}
|
|
991
1062
|
|
|
992
1063
|
finally {
|
|
993
1064
|
browser.close()
|
|
994
1065
|
server.close()
|
|
995
|
-
hasRendered.push(route.url)
|
|
996
|
-
console.log(`\x1b[32m%s\x1b[0m`, `Prerendered ${route.url}...`)
|
|
997
1066
|
}
|
|
998
1067
|
})
|
|
999
1068
|
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
if (hasRendered.length === routes.length) {
|
|
1003
|
-
server.close()
|
|
1004
|
-
hasRendered = []
|
|
1069
|
+
let timeout = setTimeout(() => {
|
|
1005
1070
|
globalThis.isBuilding = false
|
|
1006
1071
|
clearTimeout(timeout)
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1072
|
+
}, 1000)
|
|
1009
1073
|
}
|
|
1010
1074
|
|
|
1011
1075
|
globalThis.routes = []
|
|
@@ -1107,7 +1171,6 @@ async function Build() {
|
|
|
1107
1171
|
}
|
|
1108
1172
|
|
|
1109
1173
|
|
|
1110
|
-
|
|
1111
1174
|
globalThis.routes.push({ fileName: fileName, url: obj.url, html: '/' + (isBasePath ? 'index.html' : `${obj.url}/` + 'index.html') })
|
|
1112
1175
|
|
|
1113
1176
|
|
|
@@ -1125,87 +1188,6 @@ async function Build() {
|
|
|
1125
1188
|
globalThis.isProduction ? console.log(string) : null
|
|
1126
1189
|
}
|
|
1127
1190
|
|
|
1128
|
-
|
|
1129
|
-
globalThis.routeDocuments = []
|
|
1130
|
-
globalThis.routes.map((route) => {
|
|
1131
|
-
let equalparamroute = globalThis.routes.map((e) => {
|
|
1132
|
-
if (e.url.includes(':')) {
|
|
1133
|
-
let url = e.url.split('/:')[0]
|
|
1134
|
-
if (url && route.url === url) {
|
|
1135
|
-
return e
|
|
1136
|
-
} else {
|
|
1137
|
-
return null
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
return null
|
|
1142
|
-
}).filter(Boolean)
|
|
1143
|
-
let document = `
|
|
1144
|
-
<!DOCTYPE html>
|
|
1145
|
-
<html lang="en">
|
|
1146
|
-
<head>
|
|
1147
|
-
<script>
|
|
1148
|
-
window.routes = JSON.parse('${JSON.stringify(globalThis.routes)}')
|
|
1149
|
-
</script>
|
|
1150
|
-
<script type="module" id="meta">
|
|
1151
|
-
window.history.pushState({}, '', '${route.url}')
|
|
1152
|
-
|
|
1153
|
-
</script>
|
|
1154
|
-
<script id="isServer">
|
|
1155
|
-
window.isServer = true
|
|
1156
|
-
</script>
|
|
1157
|
-
<meta charset="UTF-8">
|
|
1158
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
1159
|
-
|
|
1160
|
-
<script type="module" id="router">
|
|
1161
|
-
import VaderRouter from '/router.js'
|
|
1162
|
-
const router = new VaderRouter('${route.url}')
|
|
1163
|
-
router.get('${route.url}', async (req, res) => {
|
|
1164
|
-
try{
|
|
1165
|
-
let module = await import('/${route.fileName.replace('.jsx', '.js')}')
|
|
1166
|
-
if(Object.keys(module).includes('$prerender') && !module.$prerender){
|
|
1167
|
-
document.head.setAttribute('prerender', 'false')
|
|
1168
|
-
}
|
|
1169
|
-
res.render(module, req, res, module.$metadata)
|
|
1170
|
-
}
|
|
1171
|
-
catch(error){
|
|
1172
|
-
let errorMessage = {
|
|
1173
|
-
message: error.message,
|
|
1174
|
-
name: error.name,
|
|
1175
|
-
stack: error.stack,
|
|
1176
|
-
path: window.location.pathname
|
|
1177
|
-
};
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
document.documentElement.setAttribute('error', JSON.stringify(errorMessage));
|
|
1181
|
-
throw new Error(error)
|
|
1182
|
-
}
|
|
1183
|
-
})
|
|
1184
|
-
${equalparamroute.length > 0 ? equalparamroute.map((e) => {
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
return `router.get('${e.url}', async (req, res) => {
|
|
1189
|
-
let module = await import('/${e.fileName.replace('.jsx', '.js')}')
|
|
1190
|
-
res.render(module, req, res, module.$metadata)
|
|
1191
|
-
})\n`
|
|
1192
|
-
}) : ''}
|
|
1193
|
-
router.listen(3000)
|
|
1194
|
-
|
|
1195
|
-
</script>
|
|
1196
|
-
</head>
|
|
1197
|
-
<body>
|
|
1198
|
-
<div id="root"></div>
|
|
1199
|
-
</body>
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
</html>
|
|
1203
|
-
`;
|
|
1204
|
-
globalThis.routeDocuments.push({ url: route.url, document: document })
|
|
1205
|
-
})
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
1191
|
ssg(globalThis.routes)
|
|
1210
1192
|
|
|
1211
1193
|
|
|
@@ -1238,7 +1220,7 @@ async function Build() {
|
|
|
1238
1220
|
|
|
1239
1221
|
let data = await reader(process.cwd() + "/src/" + name)
|
|
1240
1222
|
if (name.includes('.jsx')) {
|
|
1241
|
-
let origin = process.cwd() + "/src/" + name
|
|
1223
|
+
let origin = process.cwd() + "/src/" + name
|
|
1242
1224
|
if (!globalThis.isProduction) {
|
|
1243
1225
|
let { sourceMap } = sourceMapGen({ origin: origin, fileName: name }, await Compiler(data, origin))
|
|
1244
1226
|
data = data + `\n//# sourceMappingURL=/src/maps/${name.replace('.jsx', '.js.map')}\n //#sourceURL=${origin}`
|
|
@@ -1292,7 +1274,7 @@ async function Build() {
|
|
|
1292
1274
|
}
|
|
1293
1275
|
|
|
1294
1276
|
globalThis.isBuilding = false
|
|
1295
|
-
|
|
1277
|
+
globalThis.isProduction ? console.log(`\nTotal bundle size: ${Math.round(bundleSize / 1000)}kb`) : null
|
|
1296
1278
|
|
|
1297
1279
|
bundleSize = 0;
|
|
1298
1280
|
|
|
@@ -1463,7 +1445,7 @@ url: http://localhost:${port}
|
|
|
1463
1445
|
default:
|
|
1464
1446
|
// add color
|
|
1465
1447
|
console.log(`
|
|
1466
|
-
Vader.js is a reactive framework for building interactive applications for the web
|
|
1448
|
+
Vader.js is a reactive framework for building interactive applications for the web!
|
|
1467
1449
|
|
|
1468
1450
|
Usage: vader <command>
|
|
1469
1451
|
|
|
@@ -1481,3 +1463,4 @@ Learn more about vader: https://vader-js.pages.dev/
|
|
|
1481
1463
|
break;
|
|
1482
1464
|
|
|
1483
1465
|
}
|
|
1466
|
+
|