vaderjs 1.3.3-777562-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 +101 -52
package/package.json
CHANGED
package/vader.js
CHANGED
|
@@ -143,9 +143,6 @@ function Compiler(func, file) {
|
|
|
143
143
|
isJSXComponent = elementTag.match(/^[A-Z]/) ? true : false;
|
|
144
144
|
}
|
|
145
145
|
});
|
|
146
|
-
if(isJSXComponent){
|
|
147
|
-
continue
|
|
148
|
-
}
|
|
149
146
|
// add ; after newlines
|
|
150
147
|
|
|
151
148
|
|
|
@@ -482,17 +479,12 @@ function Compiler(func, file) {
|
|
|
482
479
|
|
|
483
480
|
let name = component.split("<")[1].split(">")[0].split(" ")[0].replace("/", "");
|
|
484
481
|
let componentAttributes = component.split("<")[1].split(">")[0].split(" ").join(" ").replace(name, "").trim();
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const dynamicAttributesRegex = /([a-zA-Z0-9_-]+)\s*=\s*("(?:[^"\\]*(?:\\.[^"\\]*)*)"|'(?:[^'\\]*(?:\\.[^'\\]*)*)'|\{(?:[^{}]|(?:\{(?:[^{}]|(?:\{.*.*\})*)*\})*)*\}|(?:\([^)]*\)|()\s*=>\s*(?:\{.*\})?|\{[^}]*\})|\[[^\]]*\])/gs;
|
|
482
|
+
const dynamicAttributesRegex = /(\w+)(?:="([^"]*?)"|='([^']*?)'|(?:=\{([^}]*?)\})?|(?:=\{(.*?)*\})?|(?:={([^}]*?)})?|(?:{([^}]*?)})?|(?:}))?|\$=\s*\{\s*\{\s*([^]*?)\s*\}\s*\}/gs;
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
let props = component.match(dynamicAttributesRegex)
|
|
492
487
|
|
|
493
|
-
const attributeObject = {};
|
|
494
|
-
|
|
495
|
-
|
|
496
488
|
let filteredProps = [];
|
|
497
489
|
let isWithinComponent = false;
|
|
498
490
|
let componentName = name
|
|
@@ -500,32 +492,79 @@ function Compiler(func, file) {
|
|
|
500
492
|
|
|
501
493
|
let $_ternaryprops = []
|
|
502
494
|
|
|
503
|
-
let
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
495
|
+
for (let prop of props) {
|
|
496
|
+
|
|
497
|
+
if (prop === componentName) {
|
|
498
|
+
|
|
499
|
+
isWithinComponent = true;
|
|
500
|
+
filteredProps.push(prop);
|
|
501
|
+
} else if (isWithinComponent && prop.includes('=')) {
|
|
502
|
+
|
|
503
|
+
if (prop.startsWith('$=')) {
|
|
504
|
+
let old = prop
|
|
505
|
+
let match = prop.replace(/\$\s*=\s*\{\s*\{\s*([^]*?)\s*\}\s*\}/gs, '$1')
|
|
506
|
+
match = match.replace('$:', '$_ternary:')
|
|
507
|
+
component = component.replace(old, '')
|
|
508
|
+
componentAttributes = componentAttributes.replace(old, match)
|
|
509
|
+
|
|
510
|
+
$_ternaryprops.push(prop)
|
|
511
|
+
|
|
512
|
+
}
|
|
513
|
+
else if (prop.includes('${')) {
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
prop = prop.replace('="', ':')
|
|
517
|
+
if (prop.includes('${')) {
|
|
518
|
+
prop = prop.replace('="', ':')
|
|
519
|
+
prop = prop.replace('${', '')
|
|
520
|
+
}
|
|
521
|
+
if (prop.includes('="${{')) {
|
|
522
|
+
prop = prop.replace('${{', '{')
|
|
523
|
+
prop = prop.replace('}}', '}')
|
|
524
|
+
prop = prop.replace('="', ':')
|
|
525
|
+
prop = prop.replace('}"', '}')
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
}
|
|
529
|
+
if (prop.includes('={')) {
|
|
530
|
+
let value = prop.split('={')
|
|
531
|
+
let isObj = value[1].match(/^{.*}$/gs) ? true : false
|
|
532
|
+
if (!isObj) {
|
|
533
|
+
// remove trailing }
|
|
534
|
+
value[1] = value[1].replace(/}\s*$/, '')
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (value[0] == 'style' && isObj) {
|
|
538
|
+
value[1] = `this.parseStyle(${value[1]})`
|
|
539
|
+
}
|
|
540
|
+
prop = `${value[0]}:${value[1]}`
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if (prop.includes('function') || prop.includes('=>')) {
|
|
544
|
+
// parse 'function' to function
|
|
545
|
+
prop = prop.replace("'", '')
|
|
546
|
+
|
|
547
|
+
if (prop.endsWith("}'")) {
|
|
548
|
+
prop = prop.replace("}'", '}')
|
|
549
|
+
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
prop = prop.replace('=function', ':function')
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
filteredProps.push(prop);
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
} else if (isWithinComponent && prop.includes('}')) {
|
|
560
|
+
|
|
510
561
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|| value.startsWith('`') && !value.endsWith('`')){
|
|
516
|
-
// wrap in respective quotes
|
|
517
|
-
value = value + value[0]
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
else {
|
|
565
|
+
isWithinComponent = false;
|
|
518
566
|
}
|
|
519
|
-
|
|
520
|
-
if(isObject){
|
|
521
|
-
value = value.split('{{')[1].split('}}')[0].trim()
|
|
522
|
-
value = `{${value}}`
|
|
523
|
-
} else{
|
|
524
|
-
// remove starting { and ending } using regex
|
|
525
|
-
value = value.replace(/^{/, '').replace(/}$/, '')
|
|
526
|
-
}
|
|
527
|
-
propstring += `${key}:${value},`
|
|
528
|
-
}
|
|
567
|
+
}
|
|
529
568
|
component = component.replaceAll(/\s+/g, " ");
|
|
530
569
|
|
|
531
570
|
component = component.replace(componentAttributes, '')
|
|
@@ -535,8 +574,8 @@ function Compiler(func, file) {
|
|
|
535
574
|
|
|
536
575
|
let children = new RegExp(`<${name}[^>]*>([^]*)<\/${name}>`, 'gs').exec(component)?.[1] || null;
|
|
537
576
|
|
|
538
|
-
|
|
539
|
-
|
|
577
|
+
props = filteredProps.join(',').replace(/\s+/g, " ").trim().replace(/,$/, '')
|
|
578
|
+
|
|
540
579
|
let savedname = name;
|
|
541
580
|
|
|
542
581
|
|
|
@@ -566,17 +605,26 @@ function Compiler(func, file) {
|
|
|
566
605
|
}
|
|
567
606
|
});
|
|
568
607
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
propstring = propstring.replace(/,$/, '')
|
|
572
608
|
|
|
573
|
-
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
props = props.replaceAll(`,${savedname}`, '').replaceAll(savedname, '')
|
|
612
|
+
if (props.startsWith(',')) {
|
|
613
|
+
props = props.replace(',', '')
|
|
614
|
+
}
|
|
615
|
+
props = props.replaceAll("='", ":'")
|
|
616
|
+
.replaceAll('=`', ':`')
|
|
617
|
+
.replaceAll('="', ':"')
|
|
618
|
+
.replaceAll('={', ':')
|
|
619
|
+
|
|
620
|
+
|
|
574
621
|
/**
|
|
575
622
|
* @memoize - memoize a component to be remembered on each render and replace the old jsx
|
|
576
|
-
*/
|
|
623
|
+
*/
|
|
624
|
+
|
|
577
625
|
|
|
578
626
|
let replace = "";
|
|
579
|
-
replace = `\${this.memoize(this.createComponent(${savedname}, {${
|
|
627
|
+
replace = `\${this.memoize(this.createComponent(${savedname}, {${props}}, [\`${myChildrens.join('')}\`]))}`;
|
|
580
628
|
|
|
581
629
|
|
|
582
630
|
body = body.replace(before, replace);
|
|
@@ -1185,7 +1233,7 @@ async function Build() {
|
|
|
1185
1233
|
await writer(process.cwd() + "/dist/src/" + name, data);
|
|
1186
1234
|
})
|
|
1187
1235
|
|
|
1188
|
-
const scannedPublicFiles = await glob("
|
|
1236
|
+
const scannedPublicFiles = await glob("**/**.{css,js,html,mjs,cjs}", {
|
|
1189
1237
|
ignore: ["node_modules/**/*", "dist/**/*"],
|
|
1190
1238
|
cwd: process.cwd() + '/public/',
|
|
1191
1239
|
absolute: true,
|
|
@@ -1193,7 +1241,7 @@ async function Build() {
|
|
|
1193
1241
|
scannedPublicFiles.forEach(async (file) => {
|
|
1194
1242
|
file = file.replace(/\\/g, '/');
|
|
1195
1243
|
file = file.split('/public/')[1]
|
|
1196
|
-
let data =
|
|
1244
|
+
let data = await reader(process.cwd() + "/public/" + file)
|
|
1197
1245
|
bundleSize += fs.statSync(process.cwd() + "/public/" + file).size;
|
|
1198
1246
|
await writer(process.cwd() + "/dist/public/" + file, data);
|
|
1199
1247
|
})
|
|
@@ -1226,7 +1274,7 @@ async function Build() {
|
|
|
1226
1274
|
}
|
|
1227
1275
|
|
|
1228
1276
|
globalThis.isBuilding = false
|
|
1229
|
-
console.log(`\nTotal bundle size: ${Math.round(bundleSize / 1000)}kb`)
|
|
1277
|
+
globalThis.isProduction ? console.log(`\nTotal bundle size: ${Math.round(bundleSize / 1000)}kb`) : null
|
|
1230
1278
|
|
|
1231
1279
|
bundleSize = 0;
|
|
1232
1280
|
|
|
@@ -1334,7 +1382,7 @@ switch (true) {
|
|
|
1334
1382
|
globalThis.devMode = true
|
|
1335
1383
|
globalThis.isProduction = false
|
|
1336
1384
|
console.log(`
|
|
1337
|
-
Vader.js
|
|
1385
|
+
Vader.js v1.3.3
|
|
1338
1386
|
- Watching for changes in ./pages
|
|
1339
1387
|
- Watching for changes in ./src
|
|
1340
1388
|
- Watching for changes in ./public
|
|
@@ -1374,7 +1422,7 @@ Vader.js v${fs.readFileSync(process.cwd() + '/node_modules/vaderjs/package.json'
|
|
|
1374
1422
|
globalThis.isProduction = true
|
|
1375
1423
|
globalThis.routeStates = []
|
|
1376
1424
|
console.log(`
|
|
1377
|
-
Vader.js
|
|
1425
|
+
Vader.js v1.3.3
|
|
1378
1426
|
Building to ./dist
|
|
1379
1427
|
`)
|
|
1380
1428
|
if (fs.existsSync(process.cwd() + '/dist/src/maps')) {
|
|
@@ -1388,7 +1436,7 @@ Building to ./dist
|
|
|
1388
1436
|
process.env.PORT = port
|
|
1389
1437
|
globalThis.devMode = false
|
|
1390
1438
|
console.log(`
|
|
1391
|
-
Vader.js
|
|
1439
|
+
Vader.js v1.3.3
|
|
1392
1440
|
Serving ./dist on port ${port}
|
|
1393
1441
|
url: http://localhost:${port}
|
|
1394
1442
|
`)
|
|
@@ -1397,7 +1445,7 @@ url: http://localhost:${port}
|
|
|
1397
1445
|
default:
|
|
1398
1446
|
// add color
|
|
1399
1447
|
console.log(`
|
|
1400
|
-
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!
|
|
1401
1449
|
|
|
1402
1450
|
Usage: vader <command>
|
|
1403
1451
|
|
|
@@ -1415,3 +1463,4 @@ Learn more about vader: https://vader-js.pages.dev/
|
|
|
1415
1463
|
break;
|
|
1416
1464
|
|
|
1417
1465
|
}
|
|
1466
|
+
|