@makano/rew 1.1.81 → 1.2.0

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