@makano/rew 1.1.8 → 1.1.9
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 +243 -202
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +248 -176
- package/lib/rew/const/config_path.js +2 -3
- 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 +116 -110
- 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/findAppInfo.js +14 -14
- package/lib/rew/misc/findAppPath.js +16 -16
- package/lib/rew/misc/seededid.js +9 -11
- package/lib/rew/models/enum.js +12 -12
- package/lib/rew/models/struct.js +30 -32
- package/lib/rew/modules/compiler.js +228 -177
- package/lib/rew/modules/context.js +33 -21
- 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 +80 -80
- 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 +391 -345
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/package.json +1 -1
@@ -1,180 +1,184 @@
|
|
1
|
-
const emitter = require(
|
2
|
-
const { struct } = require(
|
3
|
-
const { generateRandomID } = require(
|
1
|
+
const emitter = require('../../../functions/emitter');
|
2
|
+
const { struct } = require('../../../models/struct');
|
3
|
+
const { generateRandomID } = require('../../../functions/id');
|
4
4
|
|
5
5
|
module.exports.uiClasses = (context, options, send, recieve, hook, rmHook) => {
|
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
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
6
|
+
const _sanitizeOptions = (options) => {
|
7
|
+
return {
|
8
|
+
...options,
|
9
|
+
children: options.children.map((i) => i.options),
|
10
|
+
};
|
11
|
+
};
|
12
|
+
const RemWidgetOptions = struct({
|
13
|
+
element: 'div',
|
14
|
+
class: '',
|
15
|
+
attr: {},
|
16
|
+
id: '',
|
17
|
+
data: {
|
18
|
+
text: '',
|
19
|
+
},
|
20
|
+
children: [],
|
21
|
+
uuid: '',
|
22
|
+
parent: '!any',
|
23
|
+
style: {},
|
24
|
+
});
|
25
|
+
|
26
|
+
const CreatedElements = [];
|
27
|
+
|
28
|
+
class RewWidget {
|
29
|
+
_emitter = emitter();
|
30
|
+
on(event, callback) {
|
31
|
+
const hookID = this.uuid + '_' + generateRandomID(4);
|
32
|
+
this._emitter.on(event, callback, { hookID });
|
33
|
+
hook(
|
34
|
+
hookID,
|
35
|
+
'event_' + event,
|
36
|
+
(data) => {
|
37
|
+
this.emit(event, data);
|
38
|
+
},
|
39
|
+
false,
|
40
|
+
);
|
41
|
+
send({ action: 'eventListen', data: { uuid: this.uuid, event, hookID } });
|
42
|
+
return this;
|
43
|
+
}
|
44
|
+
off(event, callback) {
|
45
|
+
this._emitter.off(event, callback, (e) => rmHook(e.hookID));
|
46
|
+
return this;
|
47
|
+
}
|
48
|
+
emit(event, callback) {
|
49
|
+
this._emitter.emit(event, callback);
|
50
|
+
return this;
|
51
|
+
}
|
52
|
+
|
53
|
+
options = RemWidgetOptions();
|
54
|
+
constructor(options = RemWidgetOptions()) {
|
55
|
+
const config = RemWidgetOptions(options);
|
56
|
+
config.uuid = generateRandomID();
|
57
|
+
this.options = config;
|
58
|
+
this.options.children.forEach((child) => (child.parent = this));
|
59
|
+
this.init();
|
60
|
+
CreatedElements.push(this);
|
61
|
+
}
|
62
|
+
|
63
|
+
init() {
|
64
|
+
send({ action: 'createElement', data: _sanitizeOptions(this.options) });
|
65
|
+
}
|
66
|
+
|
67
|
+
parent = null;
|
68
|
+
|
69
|
+
get uuid() {
|
70
|
+
return this.options.uuid;
|
71
|
+
}
|
72
|
+
|
73
|
+
get id() {
|
74
|
+
return this.options.id;
|
75
|
+
}
|
76
|
+
|
77
|
+
get children() {
|
78
|
+
return this.options.children;
|
79
|
+
}
|
80
|
+
|
81
|
+
find(id, recursive = true) {
|
82
|
+
let childFound = this.children.find((e) => e.id == id) || this.children.find((e) => e.uuid == id);
|
83
|
+
if (childFound) return childFound;
|
84
|
+
else if (!recursive) return null;
|
85
|
+
for (let child of this.children) {
|
86
|
+
let subchild = child.find(id);
|
87
|
+
if (subchild) {
|
88
|
+
return subchild;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
update() {
|
94
|
+
send({ action: 'updateElement', data: _sanitizeOptions(this.options) });
|
95
|
+
return this;
|
96
|
+
}
|
97
|
+
|
98
|
+
text(text) {
|
99
|
+
this.options.data.text = text;
|
100
|
+
return this.update();
|
101
|
+
}
|
102
|
+
|
103
|
+
data(key, value) {
|
104
|
+
if (!value) return this.options.data[key];
|
105
|
+
this.options.data[key] = value;
|
106
|
+
return this.update();
|
107
|
+
}
|
108
|
+
|
109
|
+
attr(attr, reset = false) {
|
110
|
+
if (reset) this.options.attr = attr;
|
111
|
+
else this.options.attr = { ...this.options.attr, ...attr };
|
112
|
+
return this.update();
|
113
|
+
}
|
114
|
+
|
115
|
+
style(style, reset = false) {
|
116
|
+
if (reset) this.options.style = style;
|
117
|
+
else this.options.style = { ...this.options.style, ...style };
|
118
|
+
return this.update();
|
119
|
+
}
|
120
|
+
|
121
|
+
add(child) {
|
122
|
+
this.options.children.push(child);
|
123
|
+
return this.update();
|
124
|
+
}
|
125
|
+
|
126
|
+
remove(childId, recursive = true) {
|
127
|
+
const child = typeof childId == 'string' ? this.find(childId, recursive) : childId;
|
128
|
+
if (!child) return this;
|
129
|
+
if (recursive && child.parent !== this) {
|
130
|
+
child.parent.remove(child);
|
131
|
+
} else {
|
132
|
+
this.options.children.splice(this.options.children.indexOf(child), 1);
|
133
|
+
this.update();
|
134
|
+
}
|
135
|
+
return this;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
class RewTextWidget extends RewWidget {
|
140
|
+
constructor(text = '', options = RemWidgetOptions({})) {
|
141
|
+
super({
|
142
|
+
...options,
|
143
|
+
data: { ...options.data, text },
|
144
|
+
});
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
class StyleSheet {
|
149
|
+
constructor(css = '') {
|
150
|
+
send({ action: 'addStyleSheet', data: css });
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
function findElement(id) {
|
155
|
+
return new Promise((r) => {
|
156
|
+
const rid = generateRandomID();
|
157
|
+
hook(rid, 'findElement', (data) => {
|
158
|
+
r(CreatedElements.find((e) => e.uuid == data.uuid) || data);
|
159
|
+
});
|
160
|
+
send({ action: 'findElement', data: { id, rid } });
|
161
|
+
});
|
162
|
+
}
|
163
|
+
|
164
|
+
// hook('event_trigger', 'eventTrigger', (data) => {
|
165
|
+
// const el = CreatedElements.find(e => e.uuid = data.uuid);
|
166
|
+
// if(el){
|
167
|
+
// el.emit(data.event, data.data);
|
168
|
+
// }
|
169
|
+
// }, false);
|
170
|
+
|
171
|
+
const Transmitter = {
|
172
|
+
send: (data) => send({ action: 'message', data }),
|
173
|
+
recieve: (cb) => recieve((data) => cb(data.data)),
|
174
|
+
};
|
175
|
+
|
176
|
+
return {
|
177
|
+
Widget: RewWidget,
|
178
|
+
Text: RewTextWidget,
|
179
|
+
WidgetOptions: RemWidgetOptions,
|
180
|
+
findElement,
|
181
|
+
StyleSheet: StyleSheet,
|
182
|
+
Transmitter,
|
183
|
+
};
|
184
|
+
};
|
package/lib/rew/pkgs/pkgs.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
const path = require(
|
2
|
-
const fs = require(
|
3
|
-
|
1
|
+
const path = require('path');
|
2
|
+
const fs = require('fs');
|
4
3
|
|
5
4
|
module.exports = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
findPackage(pkg) {
|
6
|
+
if (pkg == 'pkgs') return false;
|
7
|
+
return fs.existsSync(path.resolve(__dirname, './' + pkg + '.js'));
|
8
|
+
},
|
9
|
+
getPackage(pkg) {
|
10
|
+
return require('./' + pkg);
|
11
|
+
},
|
13
12
|
};
|