@makano/rew 1.1.73 → 1.2.0
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/lib/coffeescript/browser.js +144 -139
- package/lib/coffeescript/cake.js +132 -133
- package/lib/coffeescript/coffeescript.js +437 -381
- package/lib/coffeescript/command.js +806 -724
- package/lib/coffeescript/grammar.js +1908 -2474
- package/lib/coffeescript/helpers.js +509 -473
- package/lib/coffeescript/index.js +228 -215
- package/lib/coffeescript/lexer.js +2282 -1909
- package/lib/coffeescript/nodes.js +9782 -9202
- package/lib/coffeescript/optparse.js +255 -227
- package/lib/coffeescript/parser.js +20305 -1265
- package/lib/coffeescript/register.js +107 -87
- package/lib/coffeescript/repl.js +307 -284
- package/lib/coffeescript/rewriter.js +1389 -1079
- package/lib/coffeescript/scope.js +176 -172
- package/lib/coffeescript/sourcemap.js +242 -227
- package/lib/rew/cli/cli.js +288 -186
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +344 -176
- package/lib/rew/const/config_path.js +4 -0
- package/lib/rew/const/default.js +38 -35
- package/lib/rew/const/files.js +9 -9
- package/lib/rew/const/opt.js +8 -8
- package/lib/rew/css/theme.css +2 -2
- package/lib/rew/functions/core.js +55 -57
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -21
- package/lib/rew/functions/export.js +18 -20
- package/lib/rew/functions/fs.js +55 -54
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +107 -93
- package/lib/rew/functions/map.js +13 -16
- package/lib/rew/functions/match.js +35 -26
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -33
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +20 -20
- package/lib/rew/functions/types.js +96 -95
- package/lib/rew/html/ui.html +12 -13
- package/lib/rew/html/ui.js +205 -168
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -0
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +13 -0
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -177
- package/lib/rew/modules/context.js +35 -22
- package/lib/rew/modules/fs.js +10 -10
- package/lib/rew/modules/runtime.js +17 -21
- package/lib/rew/modules/yaml.js +27 -30
- package/lib/rew/pkgs/conf.js +82 -75
- package/lib/rew/pkgs/data.js +12 -7
- package/lib/rew/pkgs/date.js +27 -28
- package/lib/rew/pkgs/env.js +6 -8
- package/lib/rew/pkgs/modules/data/bintree.js +52 -52
- package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
- package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
- package/lib/rew/pkgs/modules/data/queue.js +19 -20
- package/lib/rew/pkgs/modules/data/stack.js +19 -19
- package/lib/rew/pkgs/modules/threads/worker.js +36 -26
- package/lib/rew/pkgs/modules/ui/classes.js +182 -178
- package/lib/rew/pkgs/pkgs.js +9 -10
- package/lib/rew/pkgs/rune.js +400 -0
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +11 -4
package/lib/rew/const/opt.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
const execOptions = {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
}
|
2
|
+
sharedContext: true,
|
3
|
+
resolveExtensions: [{ ext: '.js', options: { type: 'js' } }, { ext: '.qrew', options: { qrew: true } }, '.coffee'],
|
4
|
+
nativeRequire: false,
|
5
|
+
cwdAlias: '$',
|
6
|
+
jsxPragma: 'createElement',
|
7
|
+
jsx: false,
|
8
|
+
};
|
9
9
|
|
10
|
-
module.exports.execOptions = execOptions;
|
10
|
+
module.exports.execOptions = execOptions;
|
package/lib/rew/css/theme.css
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
body {
|
2
|
-
|
3
|
-
}
|
2
|
+
background-color: #1c2541;
|
3
|
+
}
|
@@ -1,86 +1,84 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
function isEmpty(value) {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
if (Array.isArray(value) || typeof value === 'string') {
|
3
|
+
return value.length === 0;
|
4
|
+
} else if (typeof value === 'object') {
|
5
|
+
return Object.keys(value).length === 0;
|
6
|
+
} else {
|
7
|
+
return true;
|
8
|
+
}
|
11
9
|
}
|
12
10
|
|
13
11
|
function clone(value) {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
if (Array.isArray(value)) {
|
13
|
+
return value.slice();
|
14
|
+
} else if (typeof value === 'object') {
|
15
|
+
return Object.assign({}, value);
|
16
|
+
} else {
|
17
|
+
return value;
|
18
|
+
}
|
21
19
|
}
|
22
20
|
|
23
21
|
function deepClone(value) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
22
|
+
if (Array.isArray(value)) {
|
23
|
+
return value.map((item) => deepClone(item));
|
24
|
+
} else if (typeof value === 'object') {
|
25
|
+
const obj = {};
|
26
|
+
for (const key in value) {
|
27
|
+
if (value.hasOwnProperty(key)) {
|
28
|
+
obj[key] = deepClone(value[key]);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
return obj;
|
32
|
+
} else {
|
33
|
+
return value;
|
34
|
+
}
|
37
35
|
}
|
38
36
|
|
39
37
|
function merge(obj1, obj2) {
|
40
|
-
|
38
|
+
return Object.assign({}, obj1, obj2);
|
41
39
|
}
|
42
40
|
|
43
41
|
const uniqueId = (() => {
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
42
|
+
let id = 0;
|
43
|
+
return () => {
|
44
|
+
id += 1;
|
45
|
+
return `id-${id}`;
|
46
|
+
};
|
49
47
|
})();
|
50
48
|
|
51
49
|
function filter(arr, fn) {
|
52
|
-
|
50
|
+
return arr.filter(fn);
|
53
51
|
}
|
54
52
|
|
55
53
|
function reduce(arr, fn, initial) {
|
56
|
-
|
54
|
+
return arr.reduce(fn, initial);
|
57
55
|
}
|
58
56
|
|
59
57
|
function compose(...fns) {
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
return (initialValue) => {
|
59
|
+
return fns.reduceRight((acc, fn) => fn(acc), initialValue);
|
60
|
+
};
|
63
61
|
}
|
64
62
|
|
65
63
|
function curry(fn) {
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
64
|
+
const curried = (...args) => {
|
65
|
+
if (args.length >= fn.length) {
|
66
|
+
return fn.apply(null, args);
|
67
|
+
} else {
|
68
|
+
return (...moreArgs) => curried.apply(null, args.concat(moreArgs));
|
69
|
+
}
|
70
|
+
};
|
71
|
+
return curried;
|
74
72
|
}
|
75
73
|
|
76
74
|
module.exports = {
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
75
|
+
isEmpty,
|
76
|
+
clone,
|
77
|
+
deepClone,
|
78
|
+
merge,
|
79
|
+
uniqueId,
|
80
|
+
filter,
|
81
|
+
reduce,
|
82
|
+
compose,
|
83
|
+
curry,
|
86
84
|
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const future = require("./future");
|
2
|
+
const fs = require('fs');
|
3
|
+
|
4
|
+
module.exports.curl = function curl(options, url){
|
5
|
+
if(typeof options == 'string'){
|
6
|
+
let newurl = options;
|
7
|
+
options = typeof url == "object" ? url : {};
|
8
|
+
url = newurl;
|
9
|
+
}
|
10
|
+
if(options.url && !url){
|
11
|
+
url = options.url
|
12
|
+
}
|
13
|
+
const method = options.x || "GET";
|
14
|
+
const f = future.promise(fetch(url, {
|
15
|
+
...options,
|
16
|
+
method
|
17
|
+
}).then(async r => {
|
18
|
+
if(options.o) fs.writeFileSync(options.o, Buffer.from(await r.clone().arrayBuffer()));
|
19
|
+
return r;
|
20
|
+
}).then(r => options.json ? r.clone().json() : r));
|
21
|
+
if(options.a) return f.wait();
|
22
|
+
else return f;
|
23
|
+
}
|
@@ -1,57 +1,54 @@
|
|
1
1
|
module.exports = function emitter() {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
const listener = { on, off, emit };
|
56
|
-
return listener;
|
2
|
+
const events = [];
|
3
|
+
const on = (event, callback, props = {}) => {
|
4
|
+
const addEvent = (event) => events.push({ ...props, event, callback });
|
5
|
+
if (Array.isArray(event)) {
|
6
|
+
event.forEach(addEvent);
|
7
|
+
} else {
|
8
|
+
addEvent(event);
|
9
|
+
}
|
10
|
+
return listener;
|
11
|
+
};
|
12
|
+
const off = (event, callback, removable = null) => {
|
13
|
+
const rm = (event) => {
|
14
|
+
if (removable) {
|
15
|
+
removable(event);
|
16
|
+
}
|
17
|
+
events.splice(events.indexOf(event), 1);
|
18
|
+
};
|
19
|
+
const rmEvent = (event) => {
|
20
|
+
if (callback) {
|
21
|
+
const _events = events.filter(({ callback: c }) => c == callback);
|
22
|
+
_events.forEach((e) => {
|
23
|
+
if (Array.isArray(event)) {
|
24
|
+
if (event.includes(e.event)) rm(e);
|
25
|
+
} else {
|
26
|
+
if (e.event == event) rm(e);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
} else {
|
30
|
+
const _events = events.filter(({ event: e }) => e == event);
|
31
|
+
_events.forEach((e) => {
|
32
|
+
rm(e);
|
33
|
+
});
|
34
|
+
}
|
35
|
+
};
|
36
|
+
if (Array.isArray(event)) {
|
37
|
+
event.forEach(rmEvent);
|
38
|
+
} else {
|
39
|
+
rmEvent(event);
|
40
|
+
}
|
41
|
+
return listener;
|
42
|
+
};
|
43
|
+
const emit = (event, ...data) => {
|
44
|
+
const emitEvent = (event) => events.filter(({ event: e }) => e == event).forEach(({ callback }) => callback(...data));
|
45
|
+
if (Array.isArray(event)) {
|
46
|
+
event.forEach(emitEvent);
|
47
|
+
} else {
|
48
|
+
emitEvent(event);
|
49
|
+
}
|
50
|
+
return listener;
|
51
|
+
};
|
52
|
+
const listener = { on, off, emit };
|
53
|
+
return listener;
|
57
54
|
};
|
@@ -1,27 +1,31 @@
|
|
1
1
|
const shell = require('child_process');
|
2
2
|
|
3
|
-
|
4
3
|
module.exports = (currentFile) => {
|
4
|
+
function exec(command, options) {
|
5
|
+
return shell.execSync(command, {
|
6
|
+
stdio: options?.output == false ? null : 'inherit',
|
7
|
+
});
|
8
|
+
}
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
exec.background = function execAsync(command, options, callback) {
|
11
|
+
if (typeof options == 'function' && !callback) {
|
12
|
+
callback = options;
|
13
|
+
options = {};
|
14
|
+
}
|
15
|
+
if (!options) options = {};
|
16
|
+
if (!callback) callback = () => {};
|
17
|
+
return shell.exec(
|
18
|
+
command,
|
19
|
+
{
|
20
|
+
...options,
|
21
|
+
},
|
22
|
+
callback,
|
23
|
+
);
|
24
|
+
};
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
26
|
+
function spawn(command, options) {
|
27
|
+
return shell.spawn(command, options);
|
28
|
+
}
|
25
29
|
|
26
|
-
|
27
|
-
}
|
30
|
+
return { exec, spawn };
|
31
|
+
};
|
@@ -1,27 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
1
|
+
function exportsThe(item, name, context) {
|
2
|
+
if (name) {
|
3
|
+
if (!context.module.exports) context.module.exports = {};
|
4
|
+
context.module.exports[name] = item;
|
5
|
+
} else {
|
6
|
+
if (context.module.exports) context.module.exports.default = item;
|
7
|
+
else context.module.exports = item;
|
8
|
+
}
|
10
9
|
}
|
11
10
|
|
12
11
|
module.exports.pubFunction = function (context) {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
return function (name, item) {
|
13
|
+
if (name && !item) {
|
14
|
+
item = name;
|
15
|
+
name = null;
|
16
|
+
}
|
17
|
+
exportsThe(item, name, context);
|
18
|
+
};
|
20
19
|
};
|
21
20
|
|
22
21
|
module.exports.exportsFunction = function (context) {
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
return function (item, name) {
|
23
|
+
exportsThe(item, name, context);
|
24
|
+
};
|
26
25
|
};
|
27
|
-
|
package/lib/rew/functions/fs.js
CHANGED
@@ -2,58 +2,59 @@ const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
3
3
|
const { execOptions } = require('../const/opt');
|
4
4
|
|
5
|
-
|
6
5
|
module.exports = (currentFile) => {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
6
|
+
function gp(filepath) {
|
7
|
+
return path.resolve(
|
8
|
+
filepath.startsWith(execOptions.cwdAlias) ? process.cwd() : path.dirname(currentFile),
|
9
|
+
filepath.replaceAll(execOptions.cwdAlias + '/', ''),
|
10
|
+
);
|
11
|
+
}
|
12
|
+
|
13
|
+
function read(filepath, options = { encoding: 'utf-8' }) {
|
14
|
+
return fs.readFileSync(gp(filepath), options);
|
15
|
+
}
|
16
|
+
|
17
|
+
function realpath(filepath, options = { encoding: 'utf-8' }) {
|
18
|
+
return gp(filepath);
|
19
|
+
}
|
20
|
+
|
21
|
+
function write(filepath, content, options) {
|
22
|
+
return fs.writeFileSync(gp(filepath), content, options);
|
23
|
+
}
|
24
|
+
|
25
|
+
function exists(filepath, options) {
|
26
|
+
return fs.existsSync(gp(filepath));
|
27
|
+
}
|
28
|
+
|
29
|
+
function fstat(filepath, options) {
|
30
|
+
return fs.statSync(gp(filepath), options);
|
31
|
+
}
|
32
|
+
|
33
|
+
function rm(filepath, options) {
|
34
|
+
return fs.unlinkSync(filepath);
|
35
|
+
}
|
36
|
+
|
37
|
+
function chmod(filepath, mode, options) {
|
38
|
+
return fs.chmodSync(gp(filepath), mode);
|
39
|
+
}
|
40
|
+
|
41
|
+
function mkdir(filepath, options) {
|
42
|
+
return fs.mkdirSync(gp(filepath), options);
|
43
|
+
}
|
44
|
+
|
45
|
+
function ls(filepath, options) {
|
46
|
+
return fs.readdirSync(gp(filepath), options);
|
47
|
+
}
|
48
|
+
|
49
|
+
return {
|
50
|
+
ls,
|
51
|
+
mkdir,
|
52
|
+
chmod,
|
53
|
+
rm,
|
54
|
+
fstat,
|
55
|
+
exists,
|
56
|
+
write,
|
57
|
+
read,
|
58
|
+
realpath,
|
59
|
+
};
|
60
|
+
};
|
@@ -1,23 +1,31 @@
|
|
1
|
-
const emitter = require(
|
1
|
+
const emitter = require('./emitter');
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
3
|
+
function future(callback, timeout = 0, defData = null) {
|
4
|
+
const listener = emitter();
|
5
|
+
const promise = new Promise((resolve, reject) => {
|
6
|
+
listener.on('resolve', (data) => {
|
7
|
+
resolve(data);
|
8
|
+
});
|
9
|
+
listener.on('reject', (data) => {
|
10
|
+
reject(data);
|
11
|
+
});
|
12
|
+
callback(resolve, reject);
|
13
|
+
if (timeout) setTimeout(() => resolve(defData), timeout);
|
14
|
+
});
|
15
|
+
return {
|
16
|
+
pipe: (callback) => promise.then(callback),
|
17
|
+
last: (callback) => promise.finally(callback),
|
18
|
+
catch: (callback) => promise.catch(callback),
|
19
|
+
resolve: (data) => listener.emit('resolve', data),
|
20
|
+
reject: (data) => listener.emit('reject', data),
|
21
|
+
wait: async () => await promise,
|
22
|
+
};
|
23
23
|
};
|
24
|
+
|
25
|
+
future.promise = (promse, timeout = 0, defData = null) => {
|
26
|
+
return future((resolve, reject) => {
|
27
|
+
promse.then(resolve).catch(reject);
|
28
|
+
}, timeout, defData);
|
29
|
+
}
|
30
|
+
|
31
|
+
module.exports = future;
|
package/lib/rew/functions/id.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
module.exports.generateRandomID = function generateRandomID(length = 12) {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
let randomID = "";
|
2
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
3
|
+
const charactersLength = characters.length;
|
4
|
+
let randomID = '';
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
for (let i = 0; i < length; i++) {
|
7
|
+
const randomIndex = Math.floor(Math.random() * charactersLength);
|
8
|
+
randomID += characters.charAt(randomIndex);
|
9
|
+
}
|
11
10
|
|
12
|
-
|
11
|
+
return randomID;
|
13
12
|
};
|