@makano/rew 1.1.81 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +296 -239
- package/lib/rew/cli/log.js +27 -27
- package/lib/rew/cli/run.js +8 -8
- package/lib/rew/cli/utils.js +353 -199
- package/lib/rew/const/config_path.js +2 -2
- package/lib/rew/const/default.js +38 -53
- package/lib/rew/const/files.js +11 -14
- package/lib/rew/const/opt.js +6 -6
- package/lib/rew/css/theme.css +1 -1
- package/lib/rew/functions/core.js +55 -55
- package/lib/rew/functions/curl.js +23 -0
- package/lib/rew/functions/emitter.js +52 -55
- package/lib/rew/functions/exec.js +25 -25
- package/lib/rew/functions/export.js +17 -17
- package/lib/rew/functions/fs.js +57 -59
- package/lib/rew/functions/future.js +29 -21
- package/lib/rew/functions/id.js +8 -9
- package/lib/rew/functions/import.js +106 -122
- package/lib/rew/functions/map.js +10 -10
- package/lib/rew/functions/match.js +35 -42
- package/lib/rew/functions/path.js +8 -8
- package/lib/rew/functions/require.js +32 -36
- package/lib/rew/functions/sleep.js +2 -2
- package/lib/rew/functions/stdout.js +18 -18
- package/lib/rew/functions/types.js +82 -106
- package/lib/rew/html/ui.html +12 -12
- package/lib/rew/html/ui.js +196 -201
- package/lib/rew/main.js +14 -14
- package/lib/rew/misc/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +13 -13
- package/lib/rew/misc/findAppPath.js +15 -15
- package/lib/rew/misc/req.js +7 -0
- package/lib/rew/misc/seededid.js +8 -8
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +237 -209
- 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 -92
- package/lib/rew/pkgs/data.js +10 -10
- package/lib/rew/pkgs/date.js +27 -27
- package/lib/rew/pkgs/env.js +5 -5
- package/lib/rew/pkgs/modules/data/bintree.js +51 -51
- package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
- package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
- package/lib/rew/pkgs/modules/data/queue.js +18 -18
- package/lib/rew/pkgs/modules/data/stack.js +18 -18
- package/lib/rew/pkgs/modules/threads/worker.js +36 -36
- package/lib/rew/pkgs/modules/ui/classes.js +181 -184
- package/lib/rew/pkgs/pkgs.js +9 -9
- package/lib/rew/pkgs/rune.js +373 -410
- package/lib/rew/pkgs/threads.js +62 -66
- package/lib/rew/pkgs/ui.js +148 -160
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +4 -3
@@ -1,147 +1,123 @@
|
|
1
1
|
const _defaultConstructors = {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
string: String,
|
3
|
+
array: Array,
|
4
|
+
number: Number,
|
5
|
+
bigint: BigInt,
|
6
|
+
boolean: Boolean,
|
7
|
+
symbol: Symbol,
|
8
|
+
undefined: Object,
|
9
|
+
object: Object,
|
10
|
+
function: Function,
|
11
11
|
};
|
12
12
|
|
13
13
|
function getType(value) {
|
14
|
-
|
15
|
-
? Array.isArray(value)
|
16
|
-
? "array"
|
17
|
-
: typeof value
|
18
|
-
: typeof value;
|
14
|
+
return typeof value === 'object' ? (Array.isArray(value) ? 'array' : typeof value) : typeof value;
|
19
15
|
}
|
20
16
|
|
21
17
|
function typedef(value, strict = false) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
typeof value == "object"
|
36
|
-
? !Object.keys(value).length
|
37
|
-
: typeof value == "string"
|
38
|
-
? value == ""
|
39
|
-
: typeof value !== "function",
|
40
|
-
};
|
18
|
+
return {
|
19
|
+
strict,
|
20
|
+
defaultValue: value,
|
21
|
+
class:
|
22
|
+
typeof value == 'function'
|
23
|
+
? value
|
24
|
+
: typeof value === 'object' && value !== null && !Array.isArray(value)
|
25
|
+
? value.constructor
|
26
|
+
: _defaultConstructors[getType(value)],
|
27
|
+
type: getType(value),
|
28
|
+
isConstucted: typeof value === 'object' && value !== null && !Array.isArray(value),
|
29
|
+
isEmpty: typeof value == 'object' ? !Object.keys(value).length : typeof value == 'string' ? value == '' : typeof value !== 'function',
|
30
|
+
};
|
41
31
|
}
|
42
32
|
|
43
33
|
function typeis(obj, typeDef) {
|
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
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
return false;
|
86
|
-
}
|
87
|
-
} else if (typeDef.type == "string") {
|
88
|
-
return typeDef.defaultValue == obj;
|
89
|
-
} else if (typeDef.type == "function") {
|
90
|
-
return typeDef.defaultValue == obj;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
return true;
|
34
|
+
// Resolve Type
|
35
|
+
if (typeof typeDef == 'function' && typeDef.type) typeDef = typeDef.type;
|
36
|
+
|
37
|
+
if (typeDef.isConstucted && typeDef.class && !(obj instanceof typeDef.class)) {
|
38
|
+
return false;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (getType(obj) == 'object' && typeDef.type == 'function') {
|
42
|
+
return obj instanceof typeDef.class;
|
43
|
+
}
|
44
|
+
|
45
|
+
if (getType(obj) !== typeDef.type) {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
|
49
|
+
if (!typeDef.isEmpty) {
|
50
|
+
if (typeDef.type == 'object') {
|
51
|
+
for (const key in typeDef.defaultValue) {
|
52
|
+
let propTypeDef = typeDef.defaultValue[key];
|
53
|
+
// Resolve type
|
54
|
+
if (typeof propTypeDef == 'function' && propTypeDef.type) propTypeDef = propTypeDef.type;
|
55
|
+
|
56
|
+
if (typeof propTypeDef === 'object') {
|
57
|
+
if (!typeis(obj[key], propTypeDef)) {
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
} else if (typeof obj[key] !== propTypeDef) {
|
61
|
+
return false;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
if (typeDef.strict) {
|
65
|
+
if (Object.keys(obj).some((key) => !Object.keys(typeDef.defaultValue).includes(key))) return false;
|
66
|
+
}
|
67
|
+
} else if (typeDef.type == 'string') {
|
68
|
+
return typeDef.defaultValue == obj;
|
69
|
+
} else if (typeDef.type == 'function') {
|
70
|
+
return typeDef.defaultValue == obj;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
return true;
|
95
75
|
}
|
96
76
|
|
97
77
|
function typex(child, parent) {
|
98
|
-
|
78
|
+
return child.prototype instanceof parent || child === parent;
|
99
79
|
}
|
100
80
|
|
101
81
|
function typei(child, parent) {
|
102
|
-
|
82
|
+
return child instanceof parent || child.constructor === parent;
|
103
83
|
}
|
104
84
|
|
105
85
|
function int(str) {
|
106
|
-
|
86
|
+
return parseInt(str);
|
107
87
|
}
|
108
88
|
int.type = typedef(1);
|
109
89
|
|
110
90
|
function float(str) {
|
111
|
-
|
91
|
+
return parseFloat(str);
|
112
92
|
}
|
113
93
|
float.type = typedef(1.0);
|
114
94
|
|
115
95
|
function num(str) {
|
116
|
-
|
96
|
+
return Number(str);
|
117
97
|
}
|
118
98
|
num.type = typedef(1);
|
119
99
|
|
120
100
|
function str(str) {
|
121
|
-
|
101
|
+
return str ? str.toString() : '';
|
122
102
|
}
|
123
|
-
str.type = typedef(
|
103
|
+
str.type = typedef('');
|
124
104
|
|
125
105
|
function bool(value) {
|
126
|
-
|
127
|
-
? value == "true"
|
128
|
-
? true
|
129
|
-
: false
|
130
|
-
: value !== null && value !== undefined;
|
106
|
+
return typeof value == 'string' ? (value == 'true' ? true : false) : value !== null && value !== undefined;
|
131
107
|
}
|
132
108
|
bool.type = typedef(true);
|
133
109
|
|
134
110
|
module.exports = {
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
111
|
+
typex,
|
112
|
+
typei,
|
113
|
+
typeis,
|
114
|
+
typedef,
|
115
|
+
|
116
|
+
int,
|
117
|
+
float,
|
118
|
+
num,
|
119
|
+
str,
|
120
|
+
bool,
|
145
121
|
};
|
146
122
|
|
147
123
|
// const f = typedef('');
|
package/lib/rew/html/ui.html
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
<!doctype html>
|
2
2
|
<html lang="en">
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8" />
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
|
+
<title>$OPTIONS(title)</title>
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
<style>
|
9
|
+
/* $OPTIONS(style) */
|
10
|
+
</style>
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
<script>
|
13
|
+
window.onerror = () => alert('ERror');
|
14
|
+
</script>
|
15
|
+
</head>
|
16
16
|
|
17
|
-
|
17
|
+
<body></body>
|
18
18
|
</html>
|