@makano/rew 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/rew +9 -0
- package/bin/ui +0 -0
- package/bin/webkit_app +0 -0
- package/lib/coffeescript/browser.js +151 -0
- package/lib/coffeescript/cake.js +135 -0
- package/lib/coffeescript/coffeescript.js +409 -0
- package/lib/coffeescript/command.js +750 -0
- package/lib/coffeescript/grammar.js +2496 -0
- package/lib/coffeescript/helpers.js +477 -0
- package/lib/coffeescript/index.js +217 -0
- package/lib/coffeescript/lexer.js +1943 -0
- package/lib/coffeescript/nodes.js +9204 -0
- package/lib/coffeescript/optparse.js +230 -0
- package/lib/coffeescript/parser.js +1344 -0
- package/lib/coffeescript/register.js +100 -0
- package/lib/coffeescript/repl.js +305 -0
- package/lib/coffeescript/rewriter.js +1138 -0
- package/lib/coffeescript/scope.js +187 -0
- package/lib/coffeescript/sourcemap.js +229 -0
- package/lib/rew/cli/cli.js +117 -0
- package/lib/rew/cli/log.js +40 -0
- package/lib/rew/cli/run.js +20 -0
- package/lib/rew/cli/utils.js +122 -0
- package/lib/rew/const/default.js +35 -0
- package/lib/rew/const/files.js +15 -0
- package/lib/rew/css/theme.css +3 -0
- package/lib/rew/functions/core.js +85 -0
- package/lib/rew/functions/emitter.js +57 -0
- package/lib/rew/functions/export.js +9 -0
- package/lib/rew/functions/future.js +22 -0
- package/lib/rew/functions/id.js +13 -0
- package/lib/rew/functions/import.js +57 -0
- package/lib/rew/functions/map.js +17 -0
- package/lib/rew/functions/match.js +34 -0
- package/lib/rew/functions/sleep.js +5 -0
- package/lib/rew/functions/types.js +96 -0
- package/lib/rew/html/ui.html +223 -0
- package/lib/rew/main.js +17 -0
- package/lib/rew/models/enum.js +14 -0
- package/lib/rew/models/struct.js +41 -0
- package/lib/rew/modules/compiler.js +17 -0
- package/lib/rew/modules/context.js +50 -0
- package/lib/rew/modules/fs.js +19 -0
- package/lib/rew/modules/runtime.js +24 -0
- package/lib/rew/modules/utils.js +0 -0
- package/lib/rew/modules/yaml.js +36 -0
- package/lib/rew/pkgs/conf.js +92 -0
- package/lib/rew/pkgs/data.js +8 -0
- package/lib/rew/pkgs/date.js +98 -0
- package/lib/rew/pkgs/modules/data/bintree.js +66 -0
- package/lib/rew/pkgs/modules/data/doublylinked.js +100 -0
- package/lib/rew/pkgs/modules/data/linkedList.js +88 -0
- package/lib/rew/pkgs/modules/data/queue.js +28 -0
- package/lib/rew/pkgs/modules/data/stack.js +27 -0
- package/lib/rew/pkgs/modules/ui/classes.js +171 -0
- package/lib/rew/pkgs/pkgs.js +13 -0
- package/lib/rew/pkgs/ui.js +108 -0
- package/package.json +41 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
class TreeNode {
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.left = null;
|
5
|
+
this.right = null;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
class BinaryTree {
|
10
|
+
constructor() {
|
11
|
+
this.root = null;
|
12
|
+
}
|
13
|
+
|
14
|
+
insert(value) {
|
15
|
+
const newNode = new TreeNode(value);
|
16
|
+
if (!this.root) {
|
17
|
+
this.root = newNode;
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
|
21
|
+
const insertNode = (node) => {
|
22
|
+
if (value < node.value) {
|
23
|
+
if (!node.left) {
|
24
|
+
node.left = newNode;
|
25
|
+
} else {
|
26
|
+
insertNode(node.left);
|
27
|
+
}
|
28
|
+
} else {
|
29
|
+
if (!node.right) {
|
30
|
+
node.right = newNode;
|
31
|
+
} else {
|
32
|
+
insertNode(node.right);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
insertNode(this.root);
|
38
|
+
}
|
39
|
+
|
40
|
+
find(value) {
|
41
|
+
const findNode = (node) => {
|
42
|
+
if (!node) return null;
|
43
|
+
if (node.value === value) return node;
|
44
|
+
if (value < node.value) return findNode(node.left);
|
45
|
+
return findNode(node.right);
|
46
|
+
};
|
47
|
+
|
48
|
+
return findNode(this.root);
|
49
|
+
}
|
50
|
+
|
51
|
+
toArray() {
|
52
|
+
const elements = [];
|
53
|
+
const traverse = (node) => {
|
54
|
+
if (!node) return;
|
55
|
+
traverse(node.left);
|
56
|
+
elements.push(node.value);
|
57
|
+
traverse(node.right);
|
58
|
+
};
|
59
|
+
traverse(this.root);
|
60
|
+
return elements;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
BinaryTree.Node = TreeNode;
|
65
|
+
|
66
|
+
module.exports = { BinaryTree };
|
@@ -0,0 +1,100 @@
|
|
1
|
+
class DoublyNode {
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.next = null;
|
5
|
+
this.prev = null;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
class DoublyLinkedList {
|
10
|
+
constructor() {
|
11
|
+
this.head = null;
|
12
|
+
this.tail = null;
|
13
|
+
this.length = 0;
|
14
|
+
}
|
15
|
+
|
16
|
+
append(value) {
|
17
|
+
const newNode = new DoublyNode(value);
|
18
|
+
if (!this.head) {
|
19
|
+
this.head = newNode;
|
20
|
+
this.tail = newNode;
|
21
|
+
} else {
|
22
|
+
this.tail.next = newNode;
|
23
|
+
newNode.prev = this.tail;
|
24
|
+
this.tail = newNode;
|
25
|
+
}
|
26
|
+
this.length++;
|
27
|
+
}
|
28
|
+
|
29
|
+
prepend(value) {
|
30
|
+
const newNode = new DoublyNode(value);
|
31
|
+
if (!this.head) {
|
32
|
+
this.head = newNode;
|
33
|
+
this.tail = newNode;
|
34
|
+
} else {
|
35
|
+
newNode.next = this.head;
|
36
|
+
this.head.prev = newNode;
|
37
|
+
this.head = newNode;
|
38
|
+
}
|
39
|
+
this.length++;
|
40
|
+
}
|
41
|
+
|
42
|
+
find(value) {
|
43
|
+
let current = this.head;
|
44
|
+
while (current) {
|
45
|
+
if (current.value === value) {
|
46
|
+
return current;
|
47
|
+
}
|
48
|
+
current = current.next;
|
49
|
+
}
|
50
|
+
return null;
|
51
|
+
}
|
52
|
+
|
53
|
+
delete(value) {
|
54
|
+
if (!this.head) {
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
|
58
|
+
if (this.head.value === value) {
|
59
|
+
this.head = this.head.next;
|
60
|
+
if (this.head) {
|
61
|
+
this.head.prev = null;
|
62
|
+
} else {
|
63
|
+
this.tail = null;
|
64
|
+
}
|
65
|
+
this.length--;
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
let current = this.head;
|
70
|
+
while (current) {
|
71
|
+
if (current.value === value) {
|
72
|
+
if (current.next) {
|
73
|
+
current.next.prev = current.prev;
|
74
|
+
} else {
|
75
|
+
this.tail = current.prev;
|
76
|
+
}
|
77
|
+
if (current.prev) {
|
78
|
+
current.prev.next = current.next;
|
79
|
+
}
|
80
|
+
this.length--;
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
current = current.next;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
toArray() {
|
88
|
+
const elements = [];
|
89
|
+
let current = this.head;
|
90
|
+
while (current) {
|
91
|
+
elements.push(current.value);
|
92
|
+
current = current.next;
|
93
|
+
}
|
94
|
+
return elements;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
DoublyLinkedList.Node = DoublyNode;
|
99
|
+
|
100
|
+
module.exports = { DoublyLinkedList };
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class Node {
|
2
|
+
constructor(value) {
|
3
|
+
this.value = value;
|
4
|
+
this.next = null;
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
class LinkedList {
|
9
|
+
constructor() {
|
10
|
+
this.head = null;
|
11
|
+
this.tail = null;
|
12
|
+
this.length = 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
append(value) {
|
16
|
+
const newNode = new Node(value);
|
17
|
+
if (!this.head) {
|
18
|
+
this.head = newNode;
|
19
|
+
this.tail = newNode;
|
20
|
+
} else {
|
21
|
+
this.tail.next = newNode;
|
22
|
+
this.tail = newNode;
|
23
|
+
}
|
24
|
+
this.length++;
|
25
|
+
}
|
26
|
+
|
27
|
+
prepend(value) {
|
28
|
+
const newNode = new Node(value);
|
29
|
+
if (!this.head) {
|
30
|
+
this.head = newNode;
|
31
|
+
this.tail = newNode;
|
32
|
+
} else {
|
33
|
+
newNode.next = this.head;
|
34
|
+
this.head = newNode;
|
35
|
+
}
|
36
|
+
this.length++;
|
37
|
+
}
|
38
|
+
|
39
|
+
find(value) {
|
40
|
+
let current = this.head;
|
41
|
+
while (current) {
|
42
|
+
if (current.value === value) {
|
43
|
+
return current;
|
44
|
+
}
|
45
|
+
current = current.next;
|
46
|
+
}
|
47
|
+
return null;
|
48
|
+
}
|
49
|
+
|
50
|
+
delete(value) {
|
51
|
+
if (!this.head) {
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
|
55
|
+
if (this.head.value === value) {
|
56
|
+
this.head = this.head.next;
|
57
|
+
this.length--;
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
|
61
|
+
let current = this.head;
|
62
|
+
while (current.next) {
|
63
|
+
if (current.next.value === value) {
|
64
|
+
current.next = current.next.next;
|
65
|
+
if (current.next === null) {
|
66
|
+
this.tail = current;
|
67
|
+
}
|
68
|
+
this.length--;
|
69
|
+
return;
|
70
|
+
}
|
71
|
+
current = current.next;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
toArray() {
|
76
|
+
const elements = [];
|
77
|
+
let current = this.head;
|
78
|
+
while (current) {
|
79
|
+
elements.push(current.value);
|
80
|
+
current = current.next;
|
81
|
+
}
|
82
|
+
return elements;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
LinkedList.Node = Node;
|
87
|
+
|
88
|
+
module.exports = { LinkedList };
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Queue {
|
2
|
+
constructor() {
|
3
|
+
this.items = [];
|
4
|
+
}
|
5
|
+
|
6
|
+
enqueue(item) {
|
7
|
+
this.items.push(item);
|
8
|
+
}
|
9
|
+
|
10
|
+
dequeue() {
|
11
|
+
return this.items.shift();
|
12
|
+
}
|
13
|
+
|
14
|
+
isEmpty() {
|
15
|
+
return this.items.length === 0;
|
16
|
+
}
|
17
|
+
|
18
|
+
peek() {
|
19
|
+
return this.items[0];
|
20
|
+
}
|
21
|
+
|
22
|
+
toArray() {
|
23
|
+
return this.items.slice();
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
module.exports = { Queue };
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class Stack {
|
2
|
+
constructor() {
|
3
|
+
this.items = [];
|
4
|
+
}
|
5
|
+
|
6
|
+
push(item) {
|
7
|
+
this.items.push(item);
|
8
|
+
}
|
9
|
+
|
10
|
+
pop() {
|
11
|
+
return this.items.pop();
|
12
|
+
}
|
13
|
+
|
14
|
+
isEmpty() {
|
15
|
+
return this.items.length === 0;
|
16
|
+
}
|
17
|
+
|
18
|
+
peek() {
|
19
|
+
return this.items[this.items.length - 1];
|
20
|
+
}
|
21
|
+
|
22
|
+
toArray() {
|
23
|
+
return this.items.slice();
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
module.exports = { Stack };
|
@@ -0,0 +1,171 @@
|
|
1
|
+
const emitter = require("../../../functions/emitter");
|
2
|
+
const { struct } = require("../../../models/struct");
|
3
|
+
const { generateRandomID } = require("../../../functions/id");
|
4
|
+
|
5
|
+
module.exports.uiClasses = (context, options, svr, send, hook, rmHook) => {
|
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(hookID, 'event_'+event, (data) => {
|
34
|
+
this.emit(event, data);
|
35
|
+
}, false);
|
36
|
+
send(JSON.stringify({ action: 'eventListen', data: { uuid: this.uuid, event, hookID } }))
|
37
|
+
return this;
|
38
|
+
}
|
39
|
+
off(event, callback){
|
40
|
+
this._emitter.off(event, callback, (e) => rmHook(e.hookID));
|
41
|
+
return this;
|
42
|
+
}
|
43
|
+
emit(event, callback){
|
44
|
+
this._emitter.emit(event, callback);
|
45
|
+
return this;
|
46
|
+
}
|
47
|
+
|
48
|
+
options = RemWidgetOptions();
|
49
|
+
constructor(options = RemWidgetOptions()){
|
50
|
+
const config = RemWidgetOptions(options);
|
51
|
+
config.uuid = generateRandomID();
|
52
|
+
this.options = config;
|
53
|
+
this.options.children.forEach(child => child.parent = this);
|
54
|
+
this.init();
|
55
|
+
CreatedElements.push(this);
|
56
|
+
}
|
57
|
+
|
58
|
+
init(){
|
59
|
+
send(JSON.stringify({ action: 'createElement', data: _sanitizeOptions(this.options) }))
|
60
|
+
}
|
61
|
+
|
62
|
+
parent = null;
|
63
|
+
|
64
|
+
get uuid(){
|
65
|
+
return this.options.uuid;
|
66
|
+
}
|
67
|
+
|
68
|
+
get id(){
|
69
|
+
return this.options.id;
|
70
|
+
}
|
71
|
+
|
72
|
+
get children(){
|
73
|
+
return this.options.children;
|
74
|
+
}
|
75
|
+
|
76
|
+
find(id, recursive = true){
|
77
|
+
let childFound = this.children.find(e => e.id == id) || this.children.find(e => e.uuid == id);
|
78
|
+
if(childFound) return childFound;
|
79
|
+
else if(!recursive) return null;
|
80
|
+
for(let child of this.children){
|
81
|
+
let subchild = child.find(id);
|
82
|
+
if(subchild) {
|
83
|
+
return subchild;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
update(){
|
89
|
+
send(JSON.stringify({ action: 'updateElement', data: _sanitizeOptions(this.options) }));
|
90
|
+
return this;
|
91
|
+
}
|
92
|
+
|
93
|
+
text(text){
|
94
|
+
this.options.data.text = text;
|
95
|
+
return this.update();
|
96
|
+
}
|
97
|
+
|
98
|
+
data(key, value){
|
99
|
+
this.options.data[key] = value;
|
100
|
+
return this.update();
|
101
|
+
}
|
102
|
+
|
103
|
+
attr(attr){
|
104
|
+
this.options.attr = attr;
|
105
|
+
return this.update();
|
106
|
+
}
|
107
|
+
|
108
|
+
style(style){
|
109
|
+
this.options.style = style;
|
110
|
+
return this.update();
|
111
|
+
}
|
112
|
+
|
113
|
+
add(child){
|
114
|
+
this.options.children.push(child);
|
115
|
+
return this.update();
|
116
|
+
}
|
117
|
+
|
118
|
+
remove(childId, recursive = true){
|
119
|
+
const child = typeof childId == "string" ? this.find(childId, recursive) : childId;
|
120
|
+
if(!child) return this;
|
121
|
+
if(recursive && child.parent !== this){
|
122
|
+
child.parent.remove(child);
|
123
|
+
} else {
|
124
|
+
this.options.children.splice(this.options.children.indexOf(child), 1);
|
125
|
+
this.update();
|
126
|
+
}
|
127
|
+
return this;
|
128
|
+
}
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
class RewTextWidget extends RewWidget {
|
133
|
+
constructor(text = '', options = RemWidgetOptions({})){
|
134
|
+
super({
|
135
|
+
...options,
|
136
|
+
data: { ...(options.data), text }
|
137
|
+
});
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
class StyleSheet {
|
142
|
+
constructor(css = ''){
|
143
|
+
send(JSON.stringify({ action: 'addStyleSheet', data: css }));
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
function findElement(id){
|
148
|
+
return new Promise((r) => {
|
149
|
+
const rid = generateRandomID();
|
150
|
+
hook(rid, 'findElement', (data) => {
|
151
|
+
r(CreatedElements.find(e => e.uuid == data.uuid) || data);
|
152
|
+
});
|
153
|
+
send(JSON.stringify({ action: 'findElement', data: { id, rid } }));
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
// hook('event_trigger', 'eventTrigger', (data) => {
|
158
|
+
// const el = CreatedElements.find(e => e.uuid = data.uuid);
|
159
|
+
// if(el){
|
160
|
+
// el.emit(data.event, data.data);
|
161
|
+
// }
|
162
|
+
// }, false);
|
163
|
+
|
164
|
+
return {
|
165
|
+
Widget: RewWidget,
|
166
|
+
Text: RewTextWidget,
|
167
|
+
WidgetOptions: RemWidgetOptions,
|
168
|
+
findElement,
|
169
|
+
StyleSheet: StyleSheet
|
170
|
+
}
|
171
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
const fs = require("fs");
|
3
|
+
|
4
|
+
|
5
|
+
module.exports = {
|
6
|
+
findPackage(pkg) {
|
7
|
+
if(pkg == 'pkgs') return false;
|
8
|
+
return fs.existsSync(path.resolve(__dirname, './'+pkg+'.js'));
|
9
|
+
},
|
10
|
+
getPackage(pkg){
|
11
|
+
return require('./'+pkg);
|
12
|
+
}
|
13
|
+
};
|
@@ -0,0 +1,108 @@
|
|
1
|
+
const path = require("path");
|
2
|
+
const { spawn, exec } = require("child_process");
|
3
|
+
const WebSocket = require("ws");
|
4
|
+
const http = require("http");
|
5
|
+
const fs = require("fs");
|
6
|
+
const { uiClasses } = require("./modules/ui/classes");
|
7
|
+
const { generateRandomID } = require("../functions/id");
|
8
|
+
const { THEME_PATH } = require("../const/files");
|
9
|
+
|
10
|
+
|
11
|
+
const BIN_PATH = path.resolve(__dirname, "../../bin/ui");
|
12
|
+
const HTML_STRING = fs.readFileSync(
|
13
|
+
path.resolve(__dirname, "../html/ui.html"),
|
14
|
+
{ encoding: "utf-8" },
|
15
|
+
);
|
16
|
+
|
17
|
+
const defaultOptions = {
|
18
|
+
port: 14473,
|
19
|
+
title: "Title",
|
20
|
+
onExit: () => process.exit(),
|
21
|
+
style: '',
|
22
|
+
stylePath: THEME_PATH,
|
23
|
+
exec: () => {},
|
24
|
+
execContext: {}
|
25
|
+
};
|
26
|
+
|
27
|
+
module.exports = (context) => ({
|
28
|
+
start: (o = {}) => {
|
29
|
+
const options = {
|
30
|
+
...defaultOptions,
|
31
|
+
...o
|
32
|
+
};
|
33
|
+
|
34
|
+
const hookedSocketListeners = {};
|
35
|
+
|
36
|
+
const runId = generateRandomID();
|
37
|
+
|
38
|
+
options.runId = runId;
|
39
|
+
|
40
|
+
if(fs.existsSync(options.stylePath)) options.style = fs.readFileSync(options.stylePath, { encoding: 'utf-8' }) + '\n' + options.style;
|
41
|
+
|
42
|
+
options.style = ' */\n'+options.style+'\n/* ';
|
43
|
+
|
44
|
+
const svr = http.createServer((req, res) => {
|
45
|
+
res.write(
|
46
|
+
HTML_STRING
|
47
|
+
.replace(/\$OPTIONS\(([^)]+)\)/g, (_, n) => n.startsWith('json.') ? JSON.stringify(options[n.split('json.')[1]] || '{}') : options[n] || _)
|
48
|
+
);
|
49
|
+
res.end();
|
50
|
+
});
|
51
|
+
|
52
|
+
const wss = new WebSocket.Server({ server: svr });
|
53
|
+
const sockets = [];
|
54
|
+
|
55
|
+
wss.on("connection", (ws) => {
|
56
|
+
ws.send(JSON.stringify({ action: "init", data: options }));
|
57
|
+
sockets.push(ws);
|
58
|
+
ws.on('message', (event) => {
|
59
|
+
const edata = JSON.parse(event.toString());
|
60
|
+
if(edata.action.startsWith('hook:')){
|
61
|
+
const hook = hookedSocketListeners[edata.data.rid];
|
62
|
+
const type = edata.action.split('hook:')[1];
|
63
|
+
if(hook && hook.type == type) {
|
64
|
+
hookedSocketListeners[edata.data.rid].cb(edata.data.object);
|
65
|
+
if(hook.once) delete hookedSocketListeners[edata.data.rid];
|
66
|
+
}
|
67
|
+
}
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
svr.listen(options.port);
|
72
|
+
|
73
|
+
const url = new URL(`http://localhost:${options.port}`);
|
74
|
+
|
75
|
+
const p = spawn(BIN_PATH, [url.toString(), runId]);
|
76
|
+
|
77
|
+
p.on("close", (code) => {
|
78
|
+
options.onExit(code);
|
79
|
+
});
|
80
|
+
|
81
|
+
process.on("beforeExit", () => p.kill());
|
82
|
+
|
83
|
+
// p.on('message', console.log);
|
84
|
+
// p.on('error', console.log);
|
85
|
+
// exec(BIN_PATH+' '+'http://localhost:' + port, console.log)
|
86
|
+
return new Promise((r) => {
|
87
|
+
p.stdout.on("data", (data) => {
|
88
|
+
if (data.toString().trim() == "INIT::READY") {
|
89
|
+
r(
|
90
|
+
uiClasses(context, options, svr, (message, cb) => { // Send message
|
91
|
+
sockets.forEach((socket) => socket.send(message, cb));
|
92
|
+
}, (rid, type, cb, once = true) => { // Add hook
|
93
|
+
hookedSocketListeners[rid] = { type, cb, once };
|
94
|
+
}, (rid) => { // Remove hook
|
95
|
+
delete hookedSocketListeners[rid];
|
96
|
+
}),
|
97
|
+
);
|
98
|
+
} else {
|
99
|
+
console.log(data.toString());
|
100
|
+
}
|
101
|
+
});
|
102
|
+
|
103
|
+
p.stderr.on("data", (data) => {
|
104
|
+
console.error(data.toString());
|
105
|
+
});
|
106
|
+
});
|
107
|
+
},
|
108
|
+
});
|
package/package.json
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "@makano/rew",
|
3
|
+
"version": "1.0.01",
|
4
|
+
"description": "",
|
5
|
+
"main": "lib/rew/main.js",
|
6
|
+
"directories": {
|
7
|
+
"lib": "lib"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"test": "node test/test.js",
|
11
|
+
"docs:dev": "vitepress dev docs",
|
12
|
+
"docs:build": "vitepress build docs",
|
13
|
+
"docs:preview": "vitepress preview docs"
|
14
|
+
},
|
15
|
+
"files": [
|
16
|
+
"lib/",
|
17
|
+
"bin/"
|
18
|
+
],
|
19
|
+
"bin": {
|
20
|
+
"rew": "bin/rew"
|
21
|
+
},
|
22
|
+
"repository": {
|
23
|
+
"type": "git",
|
24
|
+
"url": "git+https://github.com/kevinj045/rew.git"
|
25
|
+
},
|
26
|
+
"keywords": [],
|
27
|
+
"author": "makano",
|
28
|
+
"license": "ISC",
|
29
|
+
"dependencies": {
|
30
|
+
"chalk": "^5.3.0",
|
31
|
+
"chokidar": "^3.6.0",
|
32
|
+
"js-yaml": "^4.1.0",
|
33
|
+
"vm": "^0.1.0",
|
34
|
+
"ws": "^8.17.0",
|
35
|
+
"yargs": "^17.7.2"
|
36
|
+
},
|
37
|
+
"devDependencies": {
|
38
|
+
"pkg": "^5.8.1",
|
39
|
+
"vitepress": "^1.2.2"
|
40
|
+
}
|
41
|
+
}
|