@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.
Files changed (70) 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 +243 -202
  18. package/lib/rew/cli/log.js +31 -32
  19. package/lib/rew/cli/run.js +10 -12
  20. package/lib/rew/cli/utils.js +248 -176
  21. package/lib/rew/const/config_path.js +2 -3
  22. package/lib/rew/const/default.js +38 -35
  23. package/lib/rew/const/files.js +9 -9
  24. package/lib/rew/const/opt.js +8 -8
  25. package/lib/rew/css/theme.css +2 -2
  26. package/lib/rew/functions/core.js +55 -57
  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 -21
  30. package/lib/rew/functions/export.js +18 -20
  31. package/lib/rew/functions/fs.js +55 -54
  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 +116 -110
  35. package/lib/rew/functions/map.js +13 -16
  36. package/lib/rew/functions/match.js +35 -26
  37. package/lib/rew/functions/path.js +8 -8
  38. package/lib/rew/functions/require.js +32 -33
  39. package/lib/rew/functions/sleep.js +2 -2
  40. package/lib/rew/functions/stdout.js +20 -20
  41. package/lib/rew/functions/types.js +96 -95
  42. package/lib/rew/html/ui.html +12 -13
  43. package/lib/rew/html/ui.js +205 -168
  44. package/lib/rew/main.js +14 -14
  45. package/lib/rew/misc/findAppInfo.js +14 -14
  46. package/lib/rew/misc/findAppPath.js +16 -16
  47. package/lib/rew/misc/seededid.js +9 -11
  48. package/lib/rew/models/enum.js +12 -12
  49. package/lib/rew/models/struct.js +30 -32
  50. package/lib/rew/modules/compiler.js +228 -177
  51. package/lib/rew/modules/context.js +33 -21
  52. package/lib/rew/modules/fs.js +10 -10
  53. package/lib/rew/modules/runtime.js +17 -21
  54. package/lib/rew/modules/yaml.js +27 -30
  55. package/lib/rew/pkgs/conf.js +80 -80
  56. package/lib/rew/pkgs/data.js +12 -7
  57. package/lib/rew/pkgs/date.js +27 -28
  58. package/lib/rew/pkgs/env.js +6 -8
  59. package/lib/rew/pkgs/modules/data/bintree.js +52 -52
  60. package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
  61. package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
  62. package/lib/rew/pkgs/modules/data/queue.js +19 -20
  63. package/lib/rew/pkgs/modules/data/stack.js +19 -19
  64. package/lib/rew/pkgs/modules/threads/worker.js +36 -26
  65. package/lib/rew/pkgs/modules/ui/classes.js +182 -178
  66. package/lib/rew/pkgs/pkgs.js +9 -10
  67. package/lib/rew/pkgs/rune.js +391 -345
  68. package/lib/rew/pkgs/threads.js +57 -53
  69. package/lib/rew/pkgs/ui.js +148 -136
  70. package/package.json +1 -1
@@ -1,180 +1,184 @@
1
- const emitter = require("../../../functions/emitter");
2
- const { struct } = require("../../../models/struct");
3
- const { generateRandomID } = require("../../../functions/id");
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
- 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({ 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({ 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({ 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
- if(!value) return this.options.data[key];
100
- this.options.data[key] = value;
101
- return this.update();
102
- }
103
-
104
- attr(attr, reset = false){
105
- if(reset) this.options.attr = attr;
106
- else this.options.attr = { ...this.options.attr, ...attr };
107
- return this.update();
108
- }
109
-
110
- style(style, reset = false){
111
- if(reset) this.options.style = style;
112
- else this.options.style = { ...this.options.style, ...style };
113
- return this.update();
114
- }
115
-
116
- add(child){
117
- this.options.children.push(child);
118
- return this.update();
119
- }
120
-
121
- remove(childId, recursive = true){
122
- const child = typeof childId == "string" ? this.find(childId, recursive) : childId;
123
- if(!child) return this;
124
- if(recursive && child.parent !== this){
125
- child.parent.remove(child);
126
- } else {
127
- this.options.children.splice(this.options.children.indexOf(child), 1);
128
- this.update();
129
- }
130
- return this;
131
- }
132
-
133
- }
134
-
135
- class RewTextWidget extends RewWidget {
136
- constructor(text = '', options = RemWidgetOptions({})){
137
- super({
138
- ...options,
139
- data: { ...(options.data), text }
140
- });
141
- }
142
- }
143
-
144
- class StyleSheet {
145
- constructor(css = ''){
146
- send({ action: 'addStyleSheet', data: css });
147
- }
148
- }
149
-
150
- function findElement(id){
151
- return new Promise((r) => {
152
- const rid = generateRandomID();
153
- hook(rid, 'findElement', (data) => {
154
- r(CreatedElements.find(e => e.uuid == data.uuid) || data);
155
- });
156
- send({ action: 'findElement', data: { id, rid } });
157
- });
158
- }
159
-
160
- // hook('event_trigger', 'eventTrigger', (data) => {
161
- // const el = CreatedElements.find(e => e.uuid = data.uuid);
162
- // if(el){
163
- // el.emit(data.event, data.data);
164
- // }
165
- // }, false);
166
-
167
- const Transmitter = {
168
- send: (data) => send({ action: 'message', data }),
169
- recieve: (cb) => recieve((data) => cb(data.data))
170
- }
171
-
172
- return {
173
- Widget: RewWidget,
174
- Text: RewTextWidget,
175
- WidgetOptions: RemWidgetOptions,
176
- findElement,
177
- StyleSheet: StyleSheet,
178
- Transmitter
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
+ };
@@ -1,13 +1,12 @@
1
- const path = require("path");
2
- const fs = require("fs");
3
-
1
+ const path = require('path');
2
+ const fs = require('fs');
4
3
 
5
4
  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
- }
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
  };