@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,123 +1,124 @@
1
-
2
1
  const _defaultConstructors = {
3
- string: String,
4
- array: Array,
5
- number: Number,
6
- bigint: BigInt,
7
- boolean: Boolean,
8
- symbol: Symbol,
9
- undefined: Object,
10
- object: Object,
11
- function: Function
12
- }
13
-
14
- function getType(value){
15
- return typeof value === 'object' ? Array.isArray(value) ? 'array' : typeof value : typeof value;
2
+ string: String,
3
+ array: Array,
4
+ number: Number,
5
+ bigint: BigInt,
6
+ boolean: Boolean,
7
+ symbol: Symbol,
8
+ undefined: Object,
9
+ object: Object,
10
+ function: Function,
11
+ };
12
+
13
+ function getType(value) {
14
+ return typeof value === 'object' ? (Array.isArray(value) ? 'array' : typeof value) : typeof value;
16
15
  }
17
16
 
18
17
  function typedef(value, strict = false) {
19
- return {
20
- strict,
21
- defaultValue: value,
22
- class: typeof value == 'function' ? value : typeof value === 'object' && value !== null && !Array.isArray(value) ? value.constructor : _defaultConstructors[getType(value)],
23
- type: getType(value),
24
- isConstucted: typeof value === 'object' && value !== null && !Array.isArray(value),
25
- isEmpty: typeof value == "object" ? !Object.keys(value).length : typeof value == "string" ? value == "" : typeof value !== "function"
26
- };
18
+ return {
19
+ strict,
20
+ defaultValue: value,
21
+ class:
22
+ typeof value == 'function'
23
+ ? value
24
+ : typeof value === 'object' && value !== null && !Array.isArray(value)
25
+ ? value.constructor
26
+ : _defaultConstructors[getType(value)],
27
+ type: getType(value),
28
+ isConstucted: typeof value === 'object' && value !== null && !Array.isArray(value),
29
+ isEmpty: typeof value == 'object' ? !Object.keys(value).length : typeof value == 'string' ? value == '' : typeof value !== 'function',
30
+ };
27
31
  }
28
32
 
29
33
  function typeis(obj, typeDef) {
30
- // Resolve Type
31
- if(typeof typeDef == "function" && typeDef.type) typeDef = typeDef.type;
32
-
33
- if (typeDef.isConstucted && typeDef.class && !(obj instanceof typeDef.class)) {
34
- return false;
35
- }
36
-
37
- if(getType(obj) == "object" && typeDef.type == 'function') {
38
- return (obj instanceof typeDef.class);
39
- }
40
-
41
- if(getType(obj) !== typeDef.type){
42
- return false;
43
- }
44
-
45
- if(!typeDef.isEmpty) {
46
- if(typeDef.type == 'object'){
47
- for (const key in typeDef.defaultValue) {
48
- let propTypeDef = typeDef.defaultValue[key];
49
- // Resolve type
50
- if(typeof propTypeDef == "function" && propTypeDef.type) propTypeDef = propTypeDef.type;
51
-
52
- if (typeof propTypeDef === 'object') {
53
- if (!typeis(obj[key], propTypeDef)) {
54
- return false;
55
- }
56
- } else if (typeof obj[key] !== propTypeDef) {
57
- return false;
58
- }
59
- }
60
- if(typeDef.strict) {
61
- if(Object.keys(obj).some(key => !Object.keys(typeDef.defaultValue).includes(key))) return false;
62
- }
63
- } else if(typeDef.type == 'string'){
64
- return typeDef.defaultValue == obj;
65
- } else if(typeDef.type == 'function'){
66
- return typeDef.defaultValue == obj;
67
- }
68
- }
69
-
70
- return true;
34
+ // Resolve Type
35
+ if (typeof typeDef == 'function' && typeDef.type) typeDef = typeDef.type;
36
+
37
+ if (typeDef.isConstucted && typeDef.class && !(obj instanceof typeDef.class)) {
38
+ return false;
39
+ }
40
+
41
+ if (getType(obj) == 'object' && typeDef.type == 'function') {
42
+ return obj instanceof typeDef.class;
43
+ }
44
+
45
+ if (getType(obj) !== typeDef.type) {
46
+ return false;
47
+ }
48
+
49
+ if (!typeDef.isEmpty) {
50
+ if (typeDef.type == 'object') {
51
+ for (const key in typeDef.defaultValue) {
52
+ let propTypeDef = typeDef.defaultValue[key];
53
+ // Resolve type
54
+ if (typeof propTypeDef == 'function' && propTypeDef.type) propTypeDef = propTypeDef.type;
55
+
56
+ if (typeof propTypeDef === 'object') {
57
+ if (!typeis(obj[key], propTypeDef)) {
58
+ return false;
59
+ }
60
+ } else if (typeof obj[key] !== propTypeDef) {
61
+ return false;
62
+ }
63
+ }
64
+ if (typeDef.strict) {
65
+ if (Object.keys(obj).some((key) => !Object.keys(typeDef.defaultValue).includes(key))) return false;
66
+ }
67
+ } else if (typeDef.type == 'string') {
68
+ return typeDef.defaultValue == obj;
69
+ } else if (typeDef.type == 'function') {
70
+ return typeDef.defaultValue == obj;
71
+ }
72
+ }
73
+
74
+ return true;
71
75
  }
72
76
 
73
77
  function typex(child, parent) {
74
- return child.prototype instanceof parent || child === parent;
78
+ return child.prototype instanceof parent || child === parent;
75
79
  }
76
80
 
77
81
  function typei(child, parent) {
78
- return child instanceof parent || child.constructor === parent;
82
+ return child instanceof parent || child.constructor === parent;
79
83
  }
80
84
 
81
- function int(str){
82
- return parseInt(str);
85
+ function int(str) {
86
+ return parseInt(str);
83
87
  }
84
- int.type = typedef(1)
88
+ int.type = typedef(1);
85
89
 
86
- function float(str){
87
- return parseFloat(str);
90
+ function float(str) {
91
+ return parseFloat(str);
88
92
  }
89
- float.type = typedef(1.0)
93
+ float.type = typedef(1.0);
90
94
 
91
- function num(str){
92
- return Number(str);
95
+ function num(str) {
96
+ return Number(str);
93
97
  }
94
- num.type = typedef(1)
98
+ num.type = typedef(1);
95
99
 
96
- function str(str){
97
- return str ? str.toString() : "";
100
+ function str(str) {
101
+ return str ? str.toString() : '';
98
102
  }
99
- str.type = typedef('')
103
+ str.type = typedef('');
100
104
 
101
- function bool(value){
102
- return typeof value == 'string' ? (
103
- value == 'true' ? true : false
104
- ) : value !== null && value !== undefined;
105
+ function bool(value) {
106
+ return typeof value == 'string' ? (value == 'true' ? true : false) : value !== null && value !== undefined;
105
107
  }
106
- bool.type = typedef(true)
108
+ bool.type = typedef(true);
107
109
 
108
110
  module.exports = {
109
- typex,
110
- typei,
111
- typeis,
112
- typedef,
113
-
114
- int,
115
- float,
116
- num,
117
- str,
118
- bool
119
- }
120
-
111
+ typex,
112
+ typei,
113
+ typeis,
114
+ typedef,
115
+
116
+ int,
117
+ float,
118
+ num,
119
+ str,
120
+ bool,
121
+ };
121
122
 
122
123
  // const f = typedef('');
123
124
  // const fg = typedef({ g: f });
@@ -137,4 +138,4 @@ module.exports = {
137
138
  // let tn = typedef(n)
138
139
 
139
140
  // // console.log(typeis(g, fg), typeis(1, f), typei('', String));
140
- // console.log(typeis(l, tn));
141
+ // console.log(typeis(l, tn));
@@ -1,19 +1,18 @@
1
1
  <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>$OPTIONS(title)</title>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>$OPTIONS(title)</title>
7
7
 
8
- <style>/* $OPTIONS(style) */</style>
8
+ <style>
9
+ /* $OPTIONS(style) */
10
+ </style>
9
11
 
12
+ <script>
13
+ window.onerror = () => alert('ERror');
14
+ </script>
15
+ </head>
10
16
 
11
- <script>
12
- window.onerror = () => alert('ERror');
13
- </script>
14
- </head>
15
-
16
- <body>
17
-
18
- </body>
17
+ <body></body>
19
18
  </html>
@@ -1,208 +1,245 @@
1
- try{
2
- window.execContext = $OPTIONS(json.execContext);
3
- } catch(e){
4
- window.execContext = {};
1
+ try {
2
+ window.execContext = $OPTIONS(json.execContext);
3
+ } catch (e) {
4
+ window.execContext = {};
5
5
  }
6
6
 
7
- try{
8
- window.exec = $OPTIONS(exec);
9
- } catch(e){
10
- window.exec = function(){};
7
+ try {
8
+ window.exec = $OPTIONS(exec);
9
+ } catch (e) {
10
+ window.exec = function () {};
11
11
  }
12
12
 
13
13
  const DOM = [];
14
14
 
15
- const findInDom = (id) =>
16
- DOM.find((el) => el.widgetOptions.uuid == id) ||
17
- DOM.find((el) => el.id == id);
15
+ const findInDom = (id) => DOM.find((el) => el.widgetOptions.uuid == id) || DOM.find((el) => el.id == id);
18
16
 
19
17
  const parseStyleValue = (val) => val;
20
18
 
21
19
  const addTo = (el, parent) => {
22
- if (parent == "null") {
23
- document.body.appendChild(el);
24
- } else {
25
- findInDom(parent).appendChild(el);
26
- }
20
+ if (parent == 'null') {
21
+ document.body.appendChild(el);
22
+ } else {
23
+ findInDom(parent).appendChild(el);
24
+ }
27
25
  };
28
26
 
29
27
  const initElement = (el, options, update = false) => {
30
- if(el.widgetOptions){
31
- if (el.widgetOptions.style) {
32
- for(let i in options.style){
33
- el.style.removeProperty(i, el.widgetOptions.style[i]);
34
- }
35
- }
36
- if (el.widgetOptions.attr) {
37
- for(let i in el.widgetOptions.attr){
38
- el.removeAttribute(i);
39
- }
40
- }
41
- }
42
-
43
- el.widgetOptions = options;
44
- el.id = options.id;
45
- el.textContent = options.data.text;
46
-
47
- if (options.style) {
48
- for(let i in options.style){
49
- el.style.setProperty(i, options.style[i]);
50
- }
51
- }
52
-
53
- if (options.attr) {
54
- for(let i in options.attr){
55
- el.setAttribute(i, options.attr[i]);
56
- }
57
- }
58
-
59
- if (options.children.length) {
60
- options.children.forEach((option) => {
61
- option.parent = options.uuid;
62
- if(update) updateElement(findInDom(option.uuid), option);
63
- else createElement(option);
64
- });
65
- }
66
-
67
- if (options.parent) {
68
- addTo(el, options.parent);
69
- }
70
- }
28
+ if (el.widgetOptions) {
29
+ if (el.widgetOptions.style) {
30
+ for (let i in options.style) {
31
+ el.style.removeProperty(i, el.widgetOptions.style[i]);
32
+ }
33
+ }
34
+ if (el.widgetOptions.attr) {
35
+ for (let i in el.widgetOptions.attr) {
36
+ el.removeAttribute(i);
37
+ }
38
+ }
39
+ }
40
+
41
+ el.widgetOptions = options;
42
+ el.id = options.id;
43
+ el.textContent = options.data.text;
44
+
45
+ if (options.style) {
46
+ for (let i in options.style) {
47
+ el.style.setProperty(i, options.style[i]);
48
+ }
49
+ }
50
+
51
+ if (options.attr) {
52
+ for (let i in options.attr) {
53
+ el.setAttribute(i, options.attr[i]);
54
+ }
55
+ }
56
+
57
+ if (options.children.length) {
58
+ options.children.forEach((option) => {
59
+ option.parent = options.uuid;
60
+ if (update) updateElement(findInDom(option.uuid), option);
61
+ else createElement(option);
62
+ });
63
+ }
64
+
65
+ if (options.parent) {
66
+ addTo(el, options.parent);
67
+ }
68
+ };
71
69
 
72
70
  const updateElement = (el, options) => {
73
- if(!el) return;
74
- initElement(el, options, true);
75
- return el;
76
- }
71
+ if (!el) return;
72
+ initElement(el, options, true);
73
+ return el;
74
+ };
77
75
 
78
76
  const events = [
79
- "click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout",
80
- "mousemove", "mouseenter", "mouseleave", "keydown", "keypress", "keyup",
81
- "change", "input", "submit", "focus", "blur", "copy", "cut", "paste",
82
- "scroll", "wheel", "resize", "contextmenu", "drag", "dragstart", "dragend",
83
- "dragenter", "dragleave", "dragover", "drop", "error", "load", "abort"
77
+ 'click',
78
+ 'dblclick',
79
+ 'mousedown',
80
+ 'mouseup',
81
+ 'mouseover',
82
+ 'mouseout',
83
+ 'mousemove',
84
+ 'mouseenter',
85
+ 'mouseleave',
86
+ 'keydown',
87
+ 'keypress',
88
+ 'keyup',
89
+ 'change',
90
+ 'input',
91
+ 'submit',
92
+ 'focus',
93
+ 'blur',
94
+ 'copy',
95
+ 'cut',
96
+ 'paste',
97
+ 'scroll',
98
+ 'wheel',
99
+ 'resize',
100
+ 'contextmenu',
101
+ 'drag',
102
+ 'dragstart',
103
+ 'dragend',
104
+ 'dragenter',
105
+ 'dragleave',
106
+ 'dragover',
107
+ 'drop',
108
+ 'error',
109
+ 'load',
110
+ 'abort',
84
111
  ];
85
112
  const handleListeners = (el) => {
86
- events.forEach(event => {
87
- el.addEventListener(event, (e) => {
88
- sendData({
89
- action: 'hook:eventTrigger',
90
- data: {
91
- rid: 'event_trigger',
92
- object: {
93
- uuid: el.widgetOptions.uuid,
94
- event,
95
- data: {
96
- mouse: { x: e.clientX, y: e.clientY },
97
- key: { code: e.keyCode, key: e.key }
98
- }
99
- }
100
- }
101
- });
102
- });
103
- });
104
- }
113
+ events.forEach((event) => {
114
+ el.addEventListener(event, (e) => {
115
+ sendData({
116
+ action: 'hook:eventTrigger',
117
+ data: {
118
+ rid: 'event_trigger',
119
+ object: {
120
+ uuid: el.widgetOptions.uuid,
121
+ event,
122
+ data: {
123
+ mouse: { x: e.clientX, y: e.clientY },
124
+ key: { code: e.keyCode, key: e.key },
125
+ },
126
+ },
127
+ },
128
+ });
129
+ });
130
+ });
131
+ };
105
132
 
106
- function eventHandlerFunction({ uuid, hookID, event }){
107
- return function(e){
108
- sendData({
109
- action: 'hook:event_'+event,
110
- data: {
111
- rid: hookID,
112
- object: {
113
- uuid,
114
- event,
115
- data: {
116
- mouse: { x: e.clientX, y: e.clientY },
117
- key: { code: e.keyCode, key: e.key }
118
- }
119
- }
120
- }
121
- });
122
- }
133
+ function eventHandlerFunction({ uuid, hookID, event }) {
134
+ return function (e) {
135
+ sendData({
136
+ action: 'hook:event_' + event,
137
+ data: {
138
+ rid: hookID,
139
+ object: {
140
+ uuid,
141
+ event,
142
+ data: {
143
+ mouse: { x: e.clientX, y: e.clientY },
144
+ key: { code: e.keyCode, key: e.key },
145
+ },
146
+ },
147
+ },
148
+ });
149
+ };
123
150
  }
124
151
 
125
152
  const createElement = (options) => {
126
- const el = document.createElement(options.element);
127
- DOM.push(el);
128
- initElement(el, options);
129
- return el;
153
+ const el = document.createElement(options.element);
154
+ DOM.push(el);
155
+ initElement(el, options);
156
+ return el;
130
157
  };
131
158
 
132
159
  const stringifyJSON = (json) => {
133
- try {
134
- return JSON.stringify(json, null, 4);
135
- } catch (e) {
136
- return json.toString();
137
- }
160
+ try {
161
+ return JSON.stringify(json, null, 4);
162
+ } catch (e) {
163
+ return json.toString();
164
+ }
138
165
  };
139
166
 
140
167
  const log = (...strings) => {
141
- window.webkit.messageHandlers.external.postMessage(
142
- JSON.stringify({"action": "log", "data": strings
143
- .map((r) =>
144
- typeof r == "object" ? stringifyJSON(r) : `${r.toString()}`,
145
- )
146
- // .map((i) => i.replace(/\"/g, '\\\\"').replace(/\n/g, "\\\\n"))
147
- .join("\n")}, null, 4)
148
- );
168
+ window.webkit.messageHandlers.external.postMessage(
169
+ JSON.stringify(
170
+ {
171
+ action: 'log',
172
+ data: strings
173
+ .map((r) => (typeof r == 'object' ? stringifyJSON(r) : `${r.toString()}`))
174
+ // .map((i) => i.replace(/\"/g, '\\\\"').replace(/\n/g, "\\\\n"))
175
+ .join('\n'),
176
+ },
177
+ null,
178
+ 4,
179
+ ),
180
+ );
149
181
  };
150
182
 
151
183
  const sendData = (data) => {
152
- log("RESPONSE::"+stringifyJSON(data));
153
- }
184
+ log('RESPONSE::' + stringifyJSON(data));
185
+ };
154
186
 
155
187
  function process_data(data) {
156
- return JSON.parse(data);
188
+ return JSON.parse(data);
157
189
  }
158
190
 
159
191
  window.recieveMessage = (data) => {
160
- const edata = data;
161
- if(edata.action == 'eventListen') {
162
- const el = findInDom(edata.data.uuid);
163
- if(el){
164
- el.addEventListener(edata.data.event, eventHandlerFunction(edata.data))
165
- }
166
- } else if (edata.action == "createElement") {
167
- const options = edata.data;
168
- try {
169
- createElement(options);
170
- } catch (e) {
171
- log(e.toString());
172
- }
173
- } else if (edata.action == "addStyleSheet") {
174
- const style = document.createElement('style');
175
- style.textContent = edata.data;
176
- document.head.appendChild(style);
177
- } else if (edata.action == "updateElement") {
178
- const options = edata.data;
179
- try {
180
- updateElement(findInDom(options.uuid), options);
181
- } catch (e) {
182
- log(e.toString());
183
- }
184
- } else if (edata.action == "findElement") {
185
- const id = edata.data.id;
186
- const rid = edata.data.rid;
187
- try {
188
- sendData({ action: 'hook:findElement', data: { rid, object: findInDom(id)?.widgetOptions } });
189
- } catch (e) {
190
- log(e.toString());
191
- }
192
- } else if(edata.action == 'message') {
193
- window.dispatchEvent(new CustomEvent('message', {
194
- detail: edata.data
195
- }));
196
- }
192
+ const edata = data;
193
+ if (edata.action == 'eventListen') {
194
+ const el = findInDom(edata.data.uuid);
195
+ if (el) {
196
+ el.addEventListener(edata.data.event, eventHandlerFunction(edata.data));
197
+ }
198
+ } else if (edata.action == 'createElement') {
199
+ const options = edata.data;
200
+ try {
201
+ createElement(options);
202
+ } catch (e) {
203
+ log(e.toString());
204
+ }
205
+ } else if (edata.action == 'addStyleSheet') {
206
+ const style = document.createElement('style');
207
+ style.textContent = edata.data;
208
+ document.head.appendChild(style);
209
+ } else if (edata.action == 'updateElement') {
210
+ const options = edata.data;
211
+ try {
212
+ updateElement(findInDom(options.uuid), options);
213
+ } catch (e) {
214
+ log(e.toString());
215
+ }
216
+ } else if (edata.action == 'findElement') {
217
+ const id = edata.data.id;
218
+ const rid = edata.data.rid;
219
+ try {
220
+ sendData({
221
+ action: 'hook:findElement',
222
+ data: { rid, object: findInDom(id)?.widgetOptions },
223
+ });
224
+ } catch (e) {
225
+ log(e.toString());
226
+ }
227
+ } else if (edata.action == 'message') {
228
+ window.dispatchEvent(
229
+ new CustomEvent('message', {
230
+ detail: edata.data,
231
+ }),
232
+ );
233
+ }
197
234
  };
198
235
 
199
236
  window.addEventListener('load', () => {
200
- window.exec({
201
- ...window.execContext,
202
- window,
203
- log,
204
- send: (data) => sendData({ action: 'message', data }),
205
- onRecieve: (cb) => window.addEventListener('message', (e) => cb(e.detail || {}))
206
- });
207
- log('SETUP::READY');
208
- });
237
+ window.exec({
238
+ ...window.execContext,
239
+ window,
240
+ log,
241
+ send: (data) => sendData({ action: 'message', data }),
242
+ onRecieve: (cb) => window.addEventListener('message', (e) => cb(e.detail || {})),
243
+ });
244
+ log('SETUP::READY');
245
+ });