@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.
Files changed (72) hide show
  1. package/lib/coffeescript/browser.js +144 -139
  2. package/lib/coffeescript/cake.js +132 -133
  3. package/lib/coffeescript/coffeescript.js +437 -381
  4. package/lib/coffeescript/command.js +806 -724
  5. package/lib/coffeescript/grammar.js +1908 -2474
  6. package/lib/coffeescript/helpers.js +509 -473
  7. package/lib/coffeescript/index.js +228 -215
  8. package/lib/coffeescript/lexer.js +2282 -1909
  9. package/lib/coffeescript/nodes.js +9782 -9202
  10. package/lib/coffeescript/optparse.js +255 -227
  11. package/lib/coffeescript/parser.js +20305 -1265
  12. package/lib/coffeescript/register.js +107 -87
  13. package/lib/coffeescript/repl.js +307 -284
  14. package/lib/coffeescript/rewriter.js +1389 -1079
  15. package/lib/coffeescript/scope.js +176 -172
  16. package/lib/coffeescript/sourcemap.js +242 -227
  17. package/lib/rew/cli/cli.js +296 -239
  18. package/lib/rew/cli/log.js +27 -27
  19. package/lib/rew/cli/run.js +8 -8
  20. package/lib/rew/cli/utils.js +353 -199
  21. package/lib/rew/const/config_path.js +2 -2
  22. package/lib/rew/const/default.js +38 -53
  23. package/lib/rew/const/files.js +11 -14
  24. package/lib/rew/const/opt.js +6 -6
  25. package/lib/rew/css/theme.css +1 -1
  26. package/lib/rew/functions/core.js +55 -55
  27. package/lib/rew/functions/curl.js +23 -0
  28. package/lib/rew/functions/emitter.js +52 -55
  29. package/lib/rew/functions/exec.js +25 -25
  30. package/lib/rew/functions/export.js +17 -17
  31. package/lib/rew/functions/fs.js +57 -59
  32. package/lib/rew/functions/future.js +29 -21
  33. package/lib/rew/functions/id.js +8 -9
  34. package/lib/rew/functions/import.js +106 -122
  35. package/lib/rew/functions/map.js +10 -10
  36. package/lib/rew/functions/match.js +35 -42
  37. package/lib/rew/functions/path.js +8 -8
  38. package/lib/rew/functions/require.js +32 -36
  39. package/lib/rew/functions/sleep.js +2 -2
  40. package/lib/rew/functions/stdout.js +18 -18
  41. package/lib/rew/functions/types.js +82 -106
  42. package/lib/rew/html/ui.html +12 -12
  43. package/lib/rew/html/ui.js +196 -201
  44. package/lib/rew/main.js +14 -14
  45. package/lib/rew/misc/bin.js +37 -0
  46. package/lib/rew/misc/findAppInfo.js +13 -13
  47. package/lib/rew/misc/findAppPath.js +15 -15
  48. package/lib/rew/misc/req.js +7 -0
  49. package/lib/rew/misc/seededid.js +8 -8
  50. package/lib/rew/models/enum.js +12 -12
  51. package/lib/rew/models/struct.js +30 -32
  52. package/lib/rew/modules/compiler.js +237 -209
  53. package/lib/rew/modules/fs.js +10 -10
  54. package/lib/rew/modules/runtime.js +17 -21
  55. package/lib/rew/modules/yaml.js +27 -30
  56. package/lib/rew/pkgs/conf.js +82 -92
  57. package/lib/rew/pkgs/data.js +10 -10
  58. package/lib/rew/pkgs/date.js +27 -27
  59. package/lib/rew/pkgs/env.js +5 -5
  60. package/lib/rew/pkgs/modules/data/bintree.js +51 -51
  61. package/lib/rew/pkgs/modules/data/doublylinked.js +84 -84
  62. package/lib/rew/pkgs/modules/data/linkedList.js +72 -72
  63. package/lib/rew/pkgs/modules/data/queue.js +18 -18
  64. package/lib/rew/pkgs/modules/data/stack.js +18 -18
  65. package/lib/rew/pkgs/modules/threads/worker.js +36 -36
  66. package/lib/rew/pkgs/modules/ui/classes.js +181 -184
  67. package/lib/rew/pkgs/pkgs.js +9 -9
  68. package/lib/rew/pkgs/rune.js +373 -410
  69. package/lib/rew/pkgs/threads.js +62 -66
  70. package/lib/rew/pkgs/ui.js +148 -160
  71. package/lib/rew/qrew/compile.js +12 -0
  72. package/package.json +4 -3
@@ -1,147 +1,123 @@
1
1
  const _defaultConstructors = {
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,
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
- return typeof value === "object"
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
- return {
23
- strict,
24
- defaultValue: value,
25
- class:
26
- typeof value == "function"
27
- ? value
28
- : typeof value === "object" && value !== null && !Array.isArray(value)
29
- ? value.constructor
30
- : _defaultConstructors[getType(value)],
31
- type: getType(value),
32
- isConstucted:
33
- typeof value === "object" && value !== null && !Array.isArray(value),
34
- isEmpty:
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
- // Resolve Type
45
- if (typeof typeDef == "function" && typeDef.type) typeDef = typeDef.type;
46
-
47
- if (
48
- typeDef.isConstucted &&
49
- typeDef.class &&
50
- !(obj instanceof typeDef.class)
51
- ) {
52
- return false;
53
- }
54
-
55
- if (getType(obj) == "object" && typeDef.type == "function") {
56
- return obj instanceof typeDef.class;
57
- }
58
-
59
- if (getType(obj) !== typeDef.type) {
60
- return false;
61
- }
62
-
63
- if (!typeDef.isEmpty) {
64
- if (typeDef.type == "object") {
65
- for (const key in typeDef.defaultValue) {
66
- let propTypeDef = typeDef.defaultValue[key];
67
- // Resolve type
68
- if (typeof propTypeDef == "function" && propTypeDef.type)
69
- propTypeDef = propTypeDef.type;
70
-
71
- if (typeof propTypeDef === "object") {
72
- if (!typeis(obj[key], propTypeDef)) {
73
- return false;
74
- }
75
- } else if (typeof obj[key] !== propTypeDef) {
76
- return false;
77
- }
78
- }
79
- if (typeDef.strict) {
80
- if (
81
- Object.keys(obj).some(
82
- (key) => !Object.keys(typeDef.defaultValue).includes(key),
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
- return child.prototype instanceof parent || child === parent;
78
+ return child.prototype instanceof parent || child === parent;
99
79
  }
100
80
 
101
81
  function typei(child, parent) {
102
- return child instanceof parent || child.constructor === parent;
82
+ return child instanceof parent || child.constructor === parent;
103
83
  }
104
84
 
105
85
  function int(str) {
106
- return parseInt(str);
86
+ return parseInt(str);
107
87
  }
108
88
  int.type = typedef(1);
109
89
 
110
90
  function float(str) {
111
- return parseFloat(str);
91
+ return parseFloat(str);
112
92
  }
113
93
  float.type = typedef(1.0);
114
94
 
115
95
  function num(str) {
116
- return Number(str);
96
+ return Number(str);
117
97
  }
118
98
  num.type = typedef(1);
119
99
 
120
100
  function str(str) {
121
- return str ? str.toString() : "";
101
+ return str ? str.toString() : '';
122
102
  }
123
- str.type = typedef("");
103
+ str.type = typedef('');
124
104
 
125
105
  function bool(value) {
126
- return typeof value == "string"
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
- typex,
136
- typei,
137
- typeis,
138
- typedef,
139
-
140
- int,
141
- float,
142
- num,
143
- str,
144
- bool,
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('');
@@ -1,18 +1,18 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>$OPTIONS(title)</title>
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
- <style>
9
- /* $OPTIONS(style) */
10
- </style>
8
+ <style>
9
+ /* $OPTIONS(style) */
10
+ </style>
11
11
 
12
- <script>
13
- window.onerror = () => alert("ERror");
14
- </script>
15
- </head>
12
+ <script>
13
+ window.onerror = () => alert('ERror');
14
+ </script>
15
+ </head>
16
16
 
17
- <body></body>
17
+ <body></body>
18
18
  </html>