@makano/rew 1.1.73 → 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.
- 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 +288 -186
- package/lib/rew/cli/log.js +31 -32
- package/lib/rew/cli/run.js +10 -12
- package/lib/rew/cli/utils.js +344 -176
- 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 +107 -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/bin.js +37 -0
- package/lib/rew/misc/findAppInfo.js +16 -0
- package/lib/rew/misc/findAppPath.js +21 -0
- package/lib/rew/misc/req.js +7 -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 +237 -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 +400 -0
- package/lib/rew/pkgs/threads.js +57 -53
- package/lib/rew/pkgs/ui.js +148 -136
- package/lib/rew/qrew/compile.js +12 -0
- package/package.json +11 -4
@@ -1,123 +1,124 @@
|
|
1
|
-
|
2
1
|
const _defaultConstructors = {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
function getType(value){
|
15
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
31
|
-
|
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
|
-
|
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
|
-
|
78
|
+
return child.prototype instanceof parent || child === parent;
|
75
79
|
}
|
76
80
|
|
77
81
|
function typei(child, parent) {
|
78
|
-
|
82
|
+
return child instanceof parent || child.constructor === parent;
|
79
83
|
}
|
80
84
|
|
81
|
-
function int(str){
|
82
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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));
|
package/lib/rew/html/ui.html
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
<!doctype html>
|
2
2
|
<html lang="en">
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
8
|
+
<style>
|
9
|
+
/* $OPTIONS(style) */
|
10
|
+
</style>
|
9
11
|
|
12
|
+
<script>
|
13
|
+
window.onerror = () => alert('ERror');
|
14
|
+
</script>
|
15
|
+
</head>
|
10
16
|
|
11
|
-
|
12
|
-
window.onerror = () => alert('ERror');
|
13
|
-
</script>
|
14
|
-
</head>
|
15
|
-
|
16
|
-
<body>
|
17
|
-
|
18
|
-
</body>
|
17
|
+
<body></body>
|
19
18
|
</html>
|
package/lib/rew/html/ui.js
CHANGED
@@ -1,208 +1,245 @@
|
|
1
|
-
try{
|
2
|
-
|
3
|
-
} catch(e){
|
4
|
-
|
1
|
+
try {
|
2
|
+
window.execContext = $OPTIONS(json.execContext);
|
3
|
+
} catch (e) {
|
4
|
+
window.execContext = {};
|
5
5
|
}
|
6
6
|
|
7
|
-
try{
|
8
|
-
|
9
|
-
} catch(e){
|
10
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
31
|
-
|
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
|
-
}
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
71
|
+
if (!el) return;
|
72
|
+
initElement(el, options, true);
|
73
|
+
return el;
|
74
|
+
};
|
77
75
|
|
78
76
|
const events = [
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
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
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
-
|
153
|
-
}
|
184
|
+
log('RESPONSE::' + stringifyJSON(data));
|
185
|
+
};
|
154
186
|
|
155
187
|
function process_data(data) {
|
156
|
-
|
188
|
+
return JSON.parse(data);
|
157
189
|
}
|
158
190
|
|
159
191
|
window.recieveMessage = (data) => {
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
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
|
+
});
|