@makano/rew 1.2.62 → 1.2.64
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/rew/cli/utils.js +3 -3
- package/lib/rew/modules/compiler.js +82 -64
- package/lib/rew/pkgs/web.js +1 -1
- package/package.json +1 -1
package/lib/rew/cli/utils.js
CHANGED
@@ -263,12 +263,12 @@ module.exports = {
|
|
263
263
|
}
|
264
264
|
}
|
265
265
|
}
|
266
|
-
if (c.install.file) {
|
267
|
-
this.runFileWithArgv(path.join(installPath, c.exec[c.install.file] || c.install.file), {}, []);
|
268
|
-
}
|
269
266
|
if (c.install.requirements) {
|
270
267
|
this.installReq(c, opts);
|
271
268
|
}
|
269
|
+
if (c.install.file) {
|
270
|
+
this.runFileWithArgv(path.join(installPath, c.exec[c.install.file] || c.install.file), {}, [installPath]);
|
271
|
+
}
|
272
272
|
if (c.install.exec) {
|
273
273
|
// this.installReq(c);
|
274
274
|
if(conf({}).create('').get('executables') == false){
|
@@ -11,72 +11,86 @@ const { wait } = require('../functions/wait');
|
|
11
11
|
const { REW_FILE_TYPE } = require('../const/ext');
|
12
12
|
const { USING_DEFAULT } = require('../const/usage');
|
13
13
|
|
14
|
+
|
15
|
+
|
14
16
|
function tokenizeCoffeeScript(code) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
17
|
+
const tokens = [];
|
18
|
+
let currentToken = '';
|
19
|
+
let i = 0;
|
20
|
+
|
21
|
+
while (i < code.length) {
|
22
|
+
const char = code[i];
|
23
|
+
const nextChar = code[i + 1];
|
24
|
+
const nextNextChar = code[i + 2];
|
25
|
+
|
26
|
+
if (char === '#') {
|
27
|
+
// Comment
|
28
|
+
const commentEnd = code.indexOf('\n', i);
|
29
|
+
const comment = code.substring(i, commentEnd < 0 ? code.length : commentEnd + 1);
|
30
|
+
tokens.push({ type: 'COMMENT', value: comment });
|
31
|
+
i += comment.length - 1;
|
32
|
+
} else if (char === '"' && nextChar === '"' && nextNextChar === '"') {
|
33
|
+
// Triple-quoted string
|
34
|
+
let string = '"""';
|
35
|
+
i += 3;
|
36
|
+
while (i < code.length && !(code[i] === '"' && code[i + 1] === '"' && code[i + 2] === '"')) {
|
37
|
+
string += code[i];
|
38
|
+
i++;
|
39
|
+
}
|
40
|
+
string += '"""'; // Include closing triple quotes
|
41
|
+
tokens.push({ type: 'TRIPLE_STRING', value: string });
|
42
|
+
i += 2; // Skip past the closing triple quotes
|
43
|
+
} else if (char === '"' || char === "'") {
|
44
|
+
// Single or double-quoted string
|
45
|
+
let string = char;
|
46
|
+
let escaped = false;
|
47
|
+
i++;
|
48
|
+
while (i < code.length && (code[i] !== char || escaped)) {
|
49
|
+
string += code[i];
|
50
|
+
if (code[i] === '\\' && !escaped) {
|
51
|
+
escaped = true;
|
52
|
+
} else {
|
53
|
+
escaped = false;
|
54
|
+
}
|
55
|
+
i++;
|
56
|
+
}
|
57
|
+
string += char; // Include closing quote
|
58
|
+
tokens.push({ type: 'STRING', value: string });
|
59
|
+
} else if (char === '/' && nextChar !== ' ' && nextChar !== '/' && nextChar !== '*') {
|
60
|
+
// Regular expression
|
61
|
+
let regex = char;
|
62
|
+
i++;
|
63
|
+
while (i < code.length && (code[i] !== '/' || regex.endsWith('\\'))) {
|
64
|
+
regex += code[i];
|
65
|
+
i++;
|
66
|
+
}
|
67
|
+
regex += '/';
|
68
|
+
tokens.push({ type: 'REGEX', value: regex });
|
69
|
+
} else if (/\s/.test(char)) {
|
70
|
+
// Whitespace
|
71
|
+
if (tokens[tokens.length - 1]?.type === 'WHITESPACE') {
|
72
|
+
tokens[tokens.length - 1].value += char;
|
73
|
+
} else {
|
74
|
+
tokens.push({ type: 'WHITESPACE', value: char });
|
75
|
+
}
|
76
|
+
} else if (/[a-zA-Z_$]/.test(char)) {
|
77
|
+
// Identifier
|
78
|
+
let identifier = char;
|
79
|
+
i++;
|
80
|
+
while (i < code.length && /[a-zA-Z0-9_$]/.test(code[i])) {
|
81
|
+
identifier += code[i];
|
82
|
+
i++;
|
83
|
+
}
|
84
|
+
tokens.push({ type: 'IDENTIFIER', value: identifier });
|
85
|
+
i--; // Move back one character to recheck
|
86
|
+
} else {
|
87
|
+
// Other characters
|
88
|
+
tokens.push({ type: 'OTHER', value: char });
|
89
|
+
}
|
90
|
+
i++;
|
91
|
+
}
|
78
92
|
|
79
|
-
|
93
|
+
return tokens;
|
80
94
|
}
|
81
95
|
|
82
96
|
const ValueIfy = (val) => {
|
@@ -255,6 +269,10 @@ function compileRewStuff(content, options) {
|
|
255
269
|
});
|
256
270
|
}
|
257
271
|
|
272
|
+
// if(token.type === 'TRIPLE_STRING'){
|
273
|
+
// token.value = '```'+token.value.slice(3).slice(0, -3).replace(/\#\{/g, '${')+'```';
|
274
|
+
// }
|
275
|
+
|
258
276
|
result += token.value;
|
259
277
|
if (hooks.length) {
|
260
278
|
hooks.forEach((hook, ind) => {
|
package/lib/rew/pkgs/web.js
CHANGED
@@ -487,7 +487,7 @@ module.exports = (context, importOptions) => {
|
|
487
487
|
},
|
488
488
|
async transform(code, id) {
|
489
489
|
if (id.endsWith(REW_FILE_TYPE.EXTENSION) || id.endsWith('.coffee')) {
|
490
|
-
const result = compile({ content: code, path: filepath }, { jsx: true, async: true, keepImports: true });
|
490
|
+
const result = compile({ content: code, path: filepath }, { type: id.endsWith('.coffee') ? "coffee" : undefined, jsx: true, async: true, keepImports: true });
|
491
491
|
return {
|
492
492
|
code: await result,
|
493
493
|
map: null,
|