@makano/rew 1.1.7 → 1.1.9
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/bin/ui +0 -0
- package/build.sh +3 -1
- 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 +245 -186
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +248 -175
- 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 +104 -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/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -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 +228 -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 +422 -0
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/meson.build +13 -0
- package/package.json +9 -2
package/lib/rew/pkgs/ui.js
CHANGED
@@ -1,145 +1,157 @@
|
|
1
|
-
const path = require(
|
2
|
-
const { spawn, exec } = require(
|
3
|
-
const fs = require(
|
4
|
-
const { uiClasses } = require(
|
5
|
-
const { generateRandomID } = require(
|
6
|
-
const { THEME_PATH } = require(
|
1
|
+
const path = require('path');
|
2
|
+
const { spawn, exec } = require('child_process');
|
3
|
+
const fs = require('fs');
|
4
|
+
const { uiClasses } = require('./modules/ui/classes');
|
5
|
+
const { generateRandomID } = require('../functions/id');
|
6
|
+
const { THEME_PATH } = require('../const/files');
|
7
7
|
const readline = require('readline');
|
8
|
-
const emitter = require(
|
8
|
+
const emitter = require('../functions/emitter');
|
9
9
|
|
10
|
-
const BIN_PATH = path.resolve(__dirname,
|
11
|
-
const HTML_STRING = fs.readFileSync(
|
12
|
-
|
13
|
-
|
14
|
-
);
|
15
|
-
const JS_STRING = fs.readFileSync(
|
16
|
-
path.resolve(__dirname, "../html/ui.js"),
|
17
|
-
{ encoding: "utf-8" },
|
18
|
-
);
|
10
|
+
const BIN_PATH = path.resolve(__dirname, '../../../bin/ui');
|
11
|
+
const HTML_STRING = fs.readFileSync(path.resolve(__dirname, '../html/ui.html'), { encoding: 'utf-8' });
|
12
|
+
const JS_STRING = fs.readFileSync(path.resolve(__dirname, '../html/ui.js'), {
|
13
|
+
encoding: 'utf-8',
|
14
|
+
});
|
19
15
|
|
20
|
-
const replaceString = (string, options) =>
|
16
|
+
const replaceString = (string, options) =>
|
17
|
+
string.replace(/\$OPTIONS\(([^)]+)\)/g, (_, n) =>
|
18
|
+
n.startsWith('json.') ? JSON.stringify(options[n.split('json.')[1]] || '{}') : options[n] || _,
|
19
|
+
);
|
21
20
|
|
22
21
|
const defaultOptions = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
title: 'Title',
|
23
|
+
onExit: () => process.exit(),
|
24
|
+
style: '',
|
25
|
+
stylePath: THEME_PATH,
|
26
|
+
exec: () => {},
|
27
|
+
execContext: {},
|
29
28
|
};
|
30
29
|
|
31
30
|
module.exports = (context) => ({
|
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
|
-
|
31
|
+
start: (o = {}) => {
|
32
|
+
const options = {
|
33
|
+
...defaultOptions,
|
34
|
+
...o,
|
35
|
+
};
|
36
|
+
|
37
|
+
const hookedSocketListeners = {};
|
38
|
+
|
39
|
+
const runId = generateRandomID();
|
40
|
+
const tmpFile = '/tmp/' + runId + '.ruw.ui.socket';
|
41
|
+
|
42
|
+
options.runId = runId;
|
43
|
+
|
44
|
+
if (fs.existsSync(options.stylePath)) options.style = fs.readFileSync(options.stylePath, { encoding: 'utf-8' }) + '\n' + options.style;
|
45
|
+
|
46
|
+
options.style = ' */\n' + options.style + '\n/* ';
|
47
|
+
|
48
|
+
const HTML = replaceString(HTML_STRING, options);
|
49
|
+
const JS = replaceString(JS_STRING, options);
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Queue for future writes
|
53
|
+
* @type {string[]}
|
54
|
+
* */
|
55
|
+
const queue = [];
|
56
|
+
|
57
|
+
const send = (data) => {
|
58
|
+
const content = fs.readFileSync(tmpFile, { encoding: 'utf-8' });
|
59
|
+
if (content) {
|
60
|
+
queue.push(data);
|
61
|
+
} else {
|
62
|
+
fs.writeFileSync(tmpFile, typeof data !== 'string' ? JSON.stringify(data) : data);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
const sendEvent = (data) => {
|
67
|
+
send({
|
68
|
+
action: 'JS',
|
69
|
+
data: `window.recieveMessage(${JSON.stringify(data)})`,
|
70
|
+
});
|
71
|
+
};
|
72
|
+
|
73
|
+
const g_emitter = emitter();
|
74
|
+
|
75
|
+
const recieve = (data) => {
|
76
|
+
g_emitter.emit('recieve', data);
|
77
|
+
};
|
78
|
+
|
79
|
+
const rl = readline.createInterface({
|
80
|
+
input: process.stdin,
|
81
|
+
output: process.stdout,
|
82
|
+
});
|
83
|
+
|
84
|
+
rl.question('', () => {});
|
85
|
+
|
86
|
+
fs.writeFileSync(tmpFile, '');
|
87
|
+
|
88
|
+
fs.watch(tmpFile, { encoding: 'utf-8' }).on('change', () => {
|
89
|
+
if (queue.length) {
|
90
|
+
send(queue.pop());
|
91
|
+
}
|
92
|
+
});
|
93
|
+
|
94
|
+
const p = spawn(options.bin || BIN_PATH, [runId]);
|
95
|
+
|
96
|
+
p.on('close', (code) => {
|
97
|
+
rl.close();
|
98
|
+
options.onExit(code);
|
99
|
+
});
|
100
|
+
|
101
|
+
process.on('beforeExit', () => {
|
102
|
+
p.kill();
|
103
|
+
fs.unlinkSync(tmpFile);
|
104
|
+
});
|
105
|
+
|
106
|
+
g_emitter.on('recieve', (edata) => {
|
107
|
+
if (edata.action.startsWith('hook:')) {
|
108
|
+
const hook = hookedSocketListeners[edata.data.rid];
|
109
|
+
const type = edata.action.split('hook:')[1];
|
110
|
+
if (hook && hook.type == type) {
|
111
|
+
hookedSocketListeners[edata.data.rid].cb(edata.data.object);
|
112
|
+
if (hook.once) delete hookedSocketListeners[edata.data.rid];
|
113
|
+
}
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
return new Promise((r) => {
|
118
|
+
p.stdout.on('data', (data) => {
|
119
|
+
if (data.toString().startsWith('RESPONSE::')) {
|
120
|
+
const d = data.toString().split('RESPONSE::')[1];
|
121
|
+
const jd = JSON.parse(d);
|
122
|
+
recieve(jd);
|
123
|
+
} else if (data.toString().trim().endsWith('SETUP::READY')) {
|
124
|
+
console.log('READY');
|
125
|
+
r(
|
126
|
+
uiClasses(
|
127
|
+
context,
|
128
|
+
options,
|
129
|
+
sendEvent,
|
130
|
+
(cb) => {
|
131
|
+
g_emitter.on('recieve', cb);
|
132
|
+
},
|
133
|
+
(rid, type, cb, once = true) => {
|
134
|
+
// Add hook
|
135
|
+
hookedSocketListeners[rid] = { type, cb, once };
|
136
|
+
},
|
137
|
+
(rid) => {
|
138
|
+
// Remove hook
|
139
|
+
delete hookedSocketListeners[rid];
|
140
|
+
},
|
141
|
+
),
|
142
|
+
);
|
143
|
+
} else if (data.toString().endsWith('SETUP::HTML')) {
|
144
|
+
send({ action: 'JS2', data: JS, isSetup: true });
|
145
|
+
} else if (data.toString() == 'INIT::READY') {
|
146
|
+
send({ action: 'HTML', data: HTML });
|
147
|
+
} else {
|
148
|
+
console.log(data.toString());
|
149
|
+
}
|
150
|
+
});
|
151
|
+
|
152
|
+
p.stderr.on('data', (data) => {
|
153
|
+
console.error(data.toString());
|
154
|
+
});
|
155
|
+
});
|
156
|
+
},
|
145
157
|
});
|
package/meson.build
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
project('rew', 'cpp',
|
2
|
+
version : '0.1',
|
3
|
+
default_options : ['warning_level=3', 'cpp_std=c++14'])
|
4
|
+
|
5
|
+
gtk3 = dependency('gtk+-3.0', method : 'pkg-config')
|
6
|
+
webkit2gtk = dependency('webkit2gtk-4.0', method : 'pkg-config')
|
7
|
+
libwebsockets = dependency('libwebsockets', method : 'pkg-config')
|
8
|
+
jsoncpp = dependency('jsoncpp', method : 'pkg-config')
|
9
|
+
|
10
|
+
executable('ui',
|
11
|
+
'cpp/ui.cpp',
|
12
|
+
install : true,
|
13
|
+
dependencies : [gtk3, webkit2gtk, libwebsockets, jsoncpp])
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@makano/rew",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.9",
|
4
4
|
"description": "A simple coffescript runtime",
|
5
5
|
"main": "lib/rew/main.js",
|
6
6
|
"directories": {
|
@@ -13,6 +13,7 @@
|
|
13
13
|
"lib/",
|
14
14
|
"cpp/",
|
15
15
|
"bin/",
|
16
|
+
"meson.build",
|
16
17
|
"build.sh",
|
17
18
|
"README.md"
|
18
19
|
],
|
@@ -23,7 +24,11 @@
|
|
23
24
|
"type": "git",
|
24
25
|
"url": "git+https://github.com/kevinj045/rew.git"
|
25
26
|
},
|
26
|
-
"keywords": [
|
27
|
+
"keywords": [
|
28
|
+
"coffescript",
|
29
|
+
"rew",
|
30
|
+
"runtime"
|
31
|
+
],
|
27
32
|
"author": "makano",
|
28
33
|
"license": "ISC",
|
29
34
|
"dependencies": {
|
@@ -33,6 +38,8 @@
|
|
33
38
|
"chalk": "^5.3.0",
|
34
39
|
"chokidar": "^3.6.0",
|
35
40
|
"js-yaml": "^4.1.0",
|
41
|
+
"tiny-msgpack": "^2.2.0",
|
42
|
+
"uuid": "^9.0.1",
|
36
43
|
"vm": "^0.1.0",
|
37
44
|
"yargs": "^17.7.2"
|
38
45
|
},
|