vaderjs 1.3.3-alpha-15 → 1.3.3-alpha-17
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 +18 -11
package/package.json
CHANGED
package/vader.js
CHANGED
|
@@ -25,17 +25,18 @@ function Compiler(func) {
|
|
|
25
25
|
let savedfuncnames = [];
|
|
26
26
|
let functions = string
|
|
27
27
|
.match(
|
|
28
|
-
/(?:const|let)
|
|
28
|
+
/(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*(?:=|function)\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)|(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*=\s*\(([^)]*)\)/gs
|
|
29
29
|
)
|
|
30
30
|
?.map((match) => match.trim());
|
|
31
31
|
|
|
32
|
+
|
|
32
33
|
let functionNames = [];
|
|
33
34
|
|
|
34
35
|
if (functions) {
|
|
35
36
|
functions.forEach((func) => {
|
|
36
37
|
if (
|
|
37
38
|
!func.match(
|
|
38
|
-
/(?:const|let)
|
|
39
|
+
/(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*(?:=|function)\s*\(([^)]*)\)|function\s*([a-zA-Z0-9_-]+)\s*\(([^)]*)\)|(?:const|let|var)?\s*([a-zA-Z0-9_-]+)\s*=\s*\(([^)]*)\)/gs
|
|
39
40
|
)
|
|
40
41
|
) {
|
|
41
42
|
return;
|
|
@@ -133,11 +134,12 @@ function Compiler(func) {
|
|
|
133
134
|
if (functionNames.length > 0) {
|
|
134
135
|
functionNames.forEach((name) => {
|
|
135
136
|
string.split("\n").forEach((line) => {
|
|
136
|
-
if (line.includes(name) && line.includes("function")) {
|
|
137
|
+
if (line.includes(name) && line.includes("function") || line.includes(name) && line.includes("=>")) {
|
|
137
138
|
line = line.trim();
|
|
138
139
|
line = line.replace(/\s+/g, " ");
|
|
139
140
|
|
|
140
|
-
let ps =
|
|
141
|
+
let ps = line.split("(")[1].split(")")[0].trim();
|
|
142
|
+
|
|
141
143
|
|
|
142
144
|
// remove comments
|
|
143
145
|
ps = ps.match(/\/\*.*\*\//gs)
|
|
@@ -158,6 +160,7 @@ function Compiler(func) {
|
|
|
158
160
|
let params = hasParams
|
|
159
161
|
? line.split("(")[1].split(")")[0].trim()
|
|
160
162
|
: null;
|
|
163
|
+
|
|
161
164
|
|
|
162
165
|
if (
|
|
163
166
|
functionparams.length > 0 &&
|
|
@@ -184,8 +187,9 @@ function Compiler(func) {
|
|
|
184
187
|
} ${params || null}${isJSXComponent ? "" : ","} true ${isJSXComponent ? "" : ","
|
|
185
188
|
} '${ref}')`;
|
|
186
189
|
|
|
190
|
+
console.log(replacement)
|
|
187
191
|
newvalue = newvalue.replace(
|
|
188
|
-
|
|
192
|
+
line,
|
|
189
193
|
`this.callFunction(\${${replacement}}, ${isJSXComponent ? true : false
|
|
190
194
|
}, event,${params || null})`
|
|
191
195
|
);
|
|
@@ -219,9 +223,9 @@ function Compiler(func) {
|
|
|
219
223
|
otherdata["ref"] = ref;
|
|
220
224
|
|
|
221
225
|
newvalue = newvalue.split('\n').map(line => line.trim() ? line.trim() + ';' : line).join('\n');
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
newvalue = newvalue.replaceAll('"', "'")
|
|
227
|
+
otherdata = JSON.stringify(otherdata).replaceAll('"', "'")
|
|
228
|
+
let newatribute = `${attributeName}="\${this.bind(\`${newvalue}\`${isJSXComponent ? "" : ","}${otherdata} )}"`;
|
|
225
229
|
|
|
226
230
|
|
|
227
231
|
attribute[attributeName] = {
|
|
@@ -532,10 +536,13 @@ function Compiler(func) {
|
|
|
532
536
|
});
|
|
533
537
|
|
|
534
538
|
|
|
535
|
-
// turn props into object
|
|
536
|
-
props = props.
|
|
539
|
+
// turn props into object
|
|
540
|
+
props = props.replaceAll('=', ':').replaceAll('/', '')
|
|
537
541
|
|
|
538
|
-
|
|
542
|
+
// class="text-red-500" => class:"text-red-500", omit quotes if value is a variable
|
|
543
|
+
props = props.replaceAll(/([a-zA-Z0-9_-]+)\s*:\s*("([^"\\]*(\\.[^"\\]*)*)"|'([^'\\]*(\\.[^'\\]*)*)')/gs, (match, p1, p2) => {
|
|
544
|
+
return match + ','
|
|
545
|
+
});
|
|
539
546
|
let replace = "";
|
|
540
547
|
replace = isChild
|
|
541
548
|
? `this.memoize(this.createComponent(${savedname.replaceAll('/', '')}, {${props}}, [${myChildrens.length > 0 ? myChildrens.join(",") : ""
|