vaderjs 1.3.3-alpha-24 → 1.3.3-alpha-26
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/runtime/vader.js +6 -3
- package/vader.js +16 -6
package/package.json
CHANGED
package/runtime/vader.js
CHANGED
|
@@ -360,7 +360,7 @@ export class Component {
|
|
|
360
360
|
} else {
|
|
361
361
|
const targetElement = document.querySelector(`[key="${this.key}"]`);
|
|
362
362
|
if (targetElement) {
|
|
363
|
-
targetElement.
|
|
363
|
+
targetElement.outerHTML = this.render();
|
|
364
364
|
} else {
|
|
365
365
|
console.error('Target element not found.');
|
|
366
366
|
}
|
|
@@ -659,6 +659,7 @@ export const require = async (path, noresolve = false) => {
|
|
|
659
659
|
let file = ''
|
|
660
660
|
try {
|
|
661
661
|
file = await fetch(path).then((res) => res.text());
|
|
662
|
+
cache
|
|
662
663
|
} catch (error) {
|
|
663
664
|
console.error(error)
|
|
664
665
|
}
|
|
@@ -683,9 +684,11 @@ export const require = async (path, noresolve = false) => {
|
|
|
683
684
|
file = file.replaceAll(exports, "");
|
|
684
685
|
}
|
|
685
686
|
|
|
686
|
-
|
|
687
|
+
cache[path] = new Function(`return (async () => { ${file} })()`)();
|
|
688
|
+
return cache[path]
|
|
687
689
|
case filetype === "jsx":
|
|
688
|
-
|
|
690
|
+
cache[path] = new Function(`return (async () => { ${file} })()`)();
|
|
691
|
+
return cache[path]
|
|
689
692
|
|
|
690
693
|
}
|
|
691
694
|
};
|
package/vader.js
CHANGED
|
@@ -180,7 +180,10 @@ function Compiler(func) {
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
if(isJSXComponent){
|
|
184
|
+
continue
|
|
185
|
+
}
|
|
186
|
+
let replacement = `this.useFunction(${name},
|
|
184
187
|
} ${params || null}${isJSXComponent ? "" : ","} true ${isJSXComponent ? "" : ","
|
|
185
188
|
} '${ref}')`;
|
|
186
189
|
|
|
@@ -227,7 +230,7 @@ function Compiler(func) {
|
|
|
227
230
|
let paramString = params ? params.split(' ').map(param => param + ',').join('') : "";
|
|
228
231
|
|
|
229
232
|
paramString = paramString.replaceAll(',,', ',')
|
|
230
|
-
let jsxAttribute = `${attributeName}=function(${paramString}){${newvalue}},`
|
|
233
|
+
let jsxAttribute = `${attributeName}=function(${paramString}){${newvalue}}.bind(this),`
|
|
231
234
|
let newatribute = `${attributeName}="\${this.bind(\`${newvalue}\`, ${isJSXComponent ? true : false}, '${ref}', "${paramString}", ${params || null})}",`
|
|
232
235
|
|
|
233
236
|
attribute[attributeName] = {
|
|
@@ -265,7 +268,7 @@ function Compiler(func) {
|
|
|
265
268
|
newvalue = newvalue.split('\n').map(line => line.trim() ? line.trim() + ';' : line).join('\n');
|
|
266
269
|
let paramString = params ? params.split(' ').map(param => param + ',').join('') : "";
|
|
267
270
|
paramString = paramString.replaceAll(',,', ',')
|
|
268
|
-
let jsxAttribute = `${attributeName}=function(${paramString}){${newvalue}},`
|
|
271
|
+
let jsxAttribute = `${attributeName}=function(${paramString}){${newvalue}}.bind(this),`
|
|
269
272
|
let newattribute = `${attributeName}="\${this.bind(\`${newvalue}\`, ${isJSXComponent ? true : false}, '${ref}', "${paramString}", ${params || null})}",`
|
|
270
273
|
newattribute = newattribute.replace(/\s+/g, " ")
|
|
271
274
|
string = string.replace(old, isJSXComponent ? jsxAttribute : newattribute);
|
|
@@ -335,7 +338,7 @@ function Compiler(func) {
|
|
|
335
338
|
if (value && value.includes("={")) {
|
|
336
339
|
value = value.replace("=", "");
|
|
337
340
|
value == "undefined" ? (value = '"') : (value = value);
|
|
338
|
-
|
|
341
|
+
|
|
339
342
|
key == 'style' ? value = `{this.parseStyle({${value.split('{{')[1].split('}}')[0]}})}` : null
|
|
340
343
|
|
|
341
344
|
|
|
@@ -655,11 +658,12 @@ async function Build() {
|
|
|
655
658
|
let obj = {
|
|
656
659
|
url: isBasePath ? '/' : aburl,
|
|
657
660
|
pathname: `/pages/${origin.split('pages/')[1].split('.jsx')[0].replace('.jsx', '')}.jsx`,
|
|
661
|
+
fullpath: origin,
|
|
658
662
|
};
|
|
659
663
|
|
|
660
664
|
// Read and compile file content
|
|
661
665
|
let data = await fs.readFileSync(origin, "utf8");
|
|
662
|
-
data = Compiler(data)
|
|
666
|
+
data = Compiler(data)
|
|
663
667
|
|
|
664
668
|
await writer(process.cwd() + "/dist/pages/" + fileName, data);
|
|
665
669
|
|
|
@@ -677,6 +681,12 @@ async function Build() {
|
|
|
677
681
|
if (!before.includes(`//@desc ${obj.pathname}`)) {
|
|
678
682
|
await writer(process.cwd() + "/dist/app.js", newfile);
|
|
679
683
|
}
|
|
684
|
+
|
|
685
|
+
let beforeHTML = fs.existsSync(process.cwd() + "/dist/index.html") ? await reader(process.cwd() + "/dist/index.html") : '';
|
|
686
|
+
if(!beforeHTML.includes(`<link rel="prefetch" href="/pages/${origin.split('pages/')[1] }" as="fetch">`)){
|
|
687
|
+
let newHTML = beforeHTML + `\n<link rel="prefetch" href="/pages/${origin.split('pages/')[1] }" as="fetch">`
|
|
688
|
+
await writer(process.cwd() + "/dist/index.html", newHTML);
|
|
689
|
+
}
|
|
680
690
|
}
|
|
681
691
|
|
|
682
692
|
|
|
@@ -709,7 +719,7 @@ async function Build() {
|
|
|
709
719
|
|
|
710
720
|
let data = await reader(process.cwd() + "/src/" + name)
|
|
711
721
|
if (name.includes('.jsx')) {
|
|
712
|
-
data = Compiler(data)
|
|
722
|
+
data = Compiler(data)
|
|
713
723
|
}
|
|
714
724
|
bundleSize += fs.statSync(process.cwd() + "/src/" + name).size;
|
|
715
725
|
await writer(process.cwd() + "/dist/src/" + name, data);
|