@makano/rew 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/bin/ui +0 -0
  3. package/build.sh +3 -1
  4. package/lib/coffeescript/browser.js +144 -139
  5. package/lib/coffeescript/cake.js +132 -133
  6. package/lib/coffeescript/coffeescript.js +437 -381
  7. package/lib/coffeescript/command.js +806 -724
  8. package/lib/coffeescript/grammar.js +1908 -2474
  9. package/lib/coffeescript/helpers.js +509 -473
  10. package/lib/coffeescript/index.js +228 -215
  11. package/lib/coffeescript/lexer.js +2282 -1909
  12. package/lib/coffeescript/nodes.js +9782 -9202
  13. package/lib/coffeescript/optparse.js +255 -227
  14. package/lib/coffeescript/parser.js +20305 -1265
  15. package/lib/coffeescript/register.js +107 -87
  16. package/lib/coffeescript/repl.js +307 -284
  17. package/lib/coffeescript/rewriter.js +1389 -1079
  18. package/lib/coffeescript/scope.js +176 -172
  19. package/lib/coffeescript/sourcemap.js +242 -227
  20. package/lib/rew/cli/cli.js +245 -186
  21. package/lib/rew/cli/log.js +31 -32
  22. package/lib/rew/cli/run.js +10 -12
  23. package/lib/rew/cli/utils.js +248 -175
  24. package/lib/rew/const/config_path.js +4 -0
  25. package/lib/rew/const/default.js +38 -35
  26. package/lib/rew/const/files.js +9 -9
  27. package/lib/rew/const/opt.js +8 -8
  28. package/lib/rew/css/theme.css +2 -2
  29. package/lib/rew/functions/core.js +55 -57
  30. package/lib/rew/functions/curl.js +23 -0
  31. package/lib/rew/functions/emitter.js +52 -55
  32. package/lib/rew/functions/exec.js +25 -21
  33. package/lib/rew/functions/export.js +18 -20
  34. package/lib/rew/functions/fs.js +55 -54
  35. package/lib/rew/functions/future.js +29 -21
  36. package/lib/rew/functions/id.js +8 -9
  37. package/lib/rew/functions/import.js +104 -93
  38. package/lib/rew/functions/map.js +13 -16
  39. package/lib/rew/functions/match.js +35 -26
  40. package/lib/rew/functions/path.js +8 -8
  41. package/lib/rew/functions/require.js +32 -33
  42. package/lib/rew/functions/sleep.js +2 -2
  43. package/lib/rew/functions/stdout.js +20 -20
  44. package/lib/rew/functions/types.js +96 -95
  45. package/lib/rew/html/ui.html +12 -13
  46. package/lib/rew/html/ui.js +205 -168
  47. package/lib/rew/main.js +14 -14
  48. package/lib/rew/misc/findAppInfo.js +16 -0
  49. package/lib/rew/misc/findAppPath.js +21 -0
  50. package/lib/rew/misc/seededid.js +13 -0
  51. package/lib/rew/models/enum.js +12 -12
  52. package/lib/rew/models/struct.js +30 -32
  53. package/lib/rew/modules/compiler.js +228 -177
  54. package/lib/rew/modules/context.js +35 -22
  55. package/lib/rew/modules/fs.js +10 -10
  56. package/lib/rew/modules/runtime.js +17 -21
  57. package/lib/rew/modules/yaml.js +27 -30
  58. package/lib/rew/pkgs/conf.js +82 -75
  59. package/lib/rew/pkgs/data.js +12 -7
  60. package/lib/rew/pkgs/date.js +27 -28
  61. package/lib/rew/pkgs/env.js +6 -8
  62. package/lib/rew/pkgs/modules/data/bintree.js +52 -52
  63. package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
  64. package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
  65. package/lib/rew/pkgs/modules/data/queue.js +19 -20
  66. package/lib/rew/pkgs/modules/data/stack.js +19 -19
  67. package/lib/rew/pkgs/modules/threads/worker.js +36 -26
  68. package/lib/rew/pkgs/modules/ui/classes.js +182 -178
  69. package/lib/rew/pkgs/pkgs.js +9 -10
  70. package/lib/rew/pkgs/rune.js +422 -0
  71. package/lib/rew/pkgs/threads.js +57 -53
  72. package/lib/rew/pkgs/ui.js +148 -136
  73. package/meson.build +13 -0
  74. package/package.json +9 -2
@@ -1,66 +1,66 @@
1
1
  class TreeNode {
2
- constructor(value) {
3
- this.value = value;
4
- this.left = null;
5
- this.right = null;
6
- }
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.left = null;
5
+ this.right = null;
6
+ }
7
7
  }
8
8
 
9
9
  class BinaryTree {
10
- constructor() {
11
- this.root = null;
12
- }
10
+ constructor() {
11
+ this.root = null;
12
+ }
13
13
 
14
- insert(value) {
15
- const newNode = new TreeNode(value);
16
- if (!this.root) {
17
- this.root = newNode;
18
- return;
19
- }
14
+ insert(value) {
15
+ const newNode = new TreeNode(value);
16
+ if (!this.root) {
17
+ this.root = newNode;
18
+ return;
19
+ }
20
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
- };
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
36
 
37
- insertNode(this.root);
38
- }
37
+ insertNode(this.root);
38
+ }
39
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
- };
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
47
 
48
- return findNode(this.root);
49
- }
48
+ return findNode(this.root);
49
+ }
50
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
- }
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
62
  }
63
63
 
64
64
  BinaryTree.Node = TreeNode;
65
65
 
66
- module.exports = { BinaryTree };
66
+ module.exports = { BinaryTree };
@@ -1,100 +1,100 @@
1
1
  class DoublyNode {
2
- constructor(value) {
3
- this.value = value;
4
- this.next = null;
5
- this.prev = null;
6
- }
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.next = null;
5
+ this.prev = null;
6
+ }
7
7
  }
8
8
 
9
9
  class DoublyLinkedList {
10
- constructor() {
11
- this.head = null;
12
- this.tail = null;
13
- this.length = 0;
14
- }
10
+ constructor() {
11
+ this.head = null;
12
+ this.tail = null;
13
+ this.length = 0;
14
+ }
15
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
- }
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
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
- }
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
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
- }
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
52
 
53
- delete(value) {
54
- if (!this.head) {
55
- return null;
56
- }
53
+ delete(value) {
54
+ if (!this.head) {
55
+ return null;
56
+ }
57
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
- }
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
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
- }
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
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
- }
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
96
  }
97
97
 
98
98
  DoublyLinkedList.Node = DoublyNode;
99
99
 
100
- module.exports = { DoublyLinkedList };
100
+ module.exports = { DoublyLinkedList };
@@ -1,88 +1,88 @@
1
1
  class Node {
2
- constructor(value) {
3
- this.value = value;
4
- this.next = null;
5
- }
2
+ constructor(value) {
3
+ this.value = value;
4
+ this.next = null;
5
+ }
6
6
  }
7
7
 
8
8
  class LinkedList {
9
- constructor() {
10
- this.head = null;
11
- this.tail = null;
12
- this.length = 0;
13
- }
9
+ constructor() {
10
+ this.head = null;
11
+ this.tail = null;
12
+ this.length = 0;
13
+ }
14
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
- }
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
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
- }
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
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
- }
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
49
 
50
- delete(value) {
51
- if (!this.head) {
52
- return null;
53
- }
50
+ delete(value) {
51
+ if (!this.head) {
52
+ return null;
53
+ }
54
54
 
55
- if (this.head.value === value) {
56
- this.head = this.head.next;
57
- this.length--;
58
- return;
59
- }
55
+ if (this.head.value === value) {
56
+ this.head = this.head.next;
57
+ this.length--;
58
+ return;
59
+ }
60
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
- }
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
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
- }
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
84
  }
85
85
 
86
86
  LinkedList.Node = Node;
87
87
 
88
- module.exports = { LinkedList };
88
+ module.exports = { LinkedList };
@@ -1,28 +1,27 @@
1
1
  class Queue {
2
- constructor() {
3
- this.items = [];
4
- }
2
+ constructor() {
3
+ this.items = [];
4
+ }
5
5
 
6
- enqueue(item) {
7
- this.items.push(item);
8
- }
6
+ enqueue(item) {
7
+ this.items.push(item);
8
+ }
9
9
 
10
- dequeue() {
11
- return this.items.shift();
12
- }
10
+ dequeue() {
11
+ return this.items.shift();
12
+ }
13
13
 
14
- isEmpty() {
15
- return this.items.length === 0;
16
- }
14
+ isEmpty() {
15
+ return this.items.length === 0;
16
+ }
17
17
 
18
- peek() {
19
- return this.items[0];
20
- }
18
+ peek() {
19
+ return this.items[0];
20
+ }
21
21
 
22
- toArray() {
23
- return this.items.slice();
24
- }
22
+ toArray() {
23
+ return this.items.slice();
24
+ }
25
25
  }
26
26
 
27
-
28
- module.exports = { Queue };
27
+ module.exports = { Queue };
@@ -1,27 +1,27 @@
1
1
  class Stack {
2
- constructor() {
3
- this.items = [];
4
- }
2
+ constructor() {
3
+ this.items = [];
4
+ }
5
5
 
6
- push(item) {
7
- this.items.push(item);
8
- }
6
+ push(item) {
7
+ this.items.push(item);
8
+ }
9
9
 
10
- pop() {
11
- return this.items.pop();
12
- }
10
+ pop() {
11
+ return this.items.pop();
12
+ }
13
13
 
14
- isEmpty() {
15
- return this.items.length === 0;
16
- }
14
+ isEmpty() {
15
+ return this.items.length === 0;
16
+ }
17
17
 
18
- peek() {
19
- return this.items[this.items.length - 1];
20
- }
18
+ peek() {
19
+ return this.items[this.items.length - 1];
20
+ }
21
21
 
22
- toArray() {
23
- return this.items.slice();
24
- }
22
+ toArray() {
23
+ return this.items.slice();
24
+ }
25
25
  }
26
26
 
27
- module.exports = { Stack };
27
+ module.exports = { Stack };
@@ -4,34 +4,44 @@ const { exec } = require('../../../modules/runtime');
4
4
  const target = {};
5
5
  target.events = [];
6
6
  target.on = (e, cb) => {
7
- target.events.push({ e, cb });
8
- }
7
+ target.events.push({ e, cb });
8
+ };
9
9
  target.off = (e) => {
10
- target.events = target.events.filter(i => i.e !== e);
11
- }
10
+ target.events = target.events.filter((i) => i.e !== e);
11
+ };
12
12
  target.emit = (e, data) => {
13
- target.events.filter(i => i.e == e).forEach(i => i.cb(data));
14
- }
13
+ target.events.filter((i) => i.e == e).forEach((i) => i.cb(data));
14
+ };
15
15
 
16
16
  parentPort.on('message', (data) => {
17
- if (data.type === 'event') {
18
- target.emit(data.event, data.data);
19
- } else if (data.type === 'start') {
20
- (async () => {
21
- try {
22
- exec(`(${workerData.cb}).call({ process }, context)`, { print: (...a) => console.log(...a), process: {
23
- on: (e, cb) => { target.on(e, cb) },
24
- off: (e) => { target.off(e) },
25
- emit: (e, data) => { parentPort.postMessage({ type: 'event', event: e, data }) },
26
- exit: (code) => process.exit(code),
27
- finish: (data) => {
28
- parentPort.postMessage({ type: 'result', result: data });
29
- process.exit(0)
30
- }
31
- }, context: workerData.context })
32
- } catch (e) {
33
- parentPort.postMessage({ type: 'error', error: e.message });
34
- }
35
- })();
36
- }
17
+ if (data.type === 'event') {
18
+ target.emit(data.event, data.data);
19
+ } else if (data.type === 'start') {
20
+ (async () => {
21
+ try {
22
+ exec(`(${workerData.cb}).call({ process }, context)`, {
23
+ print: (...a) => console.log(...a),
24
+ process: {
25
+ on: (e, cb) => {
26
+ target.on(e, cb);
27
+ },
28
+ off: (e) => {
29
+ target.off(e);
30
+ },
31
+ emit: (e, data) => {
32
+ parentPort.postMessage({ type: 'event', event: e, data });
33
+ },
34
+ exit: (code) => process.exit(code),
35
+ finish: (data) => {
36
+ parentPort.postMessage({ type: 'result', result: data });
37
+ process.exit(0);
38
+ },
39
+ },
40
+ context: workerData.context,
41
+ });
42
+ } catch (e) {
43
+ parentPort.postMessage({ type: 'error', error: e.message });
44
+ }
45
+ })();
46
+ }
37
47
  });