goblin-laboratory 2.2.1 → 2.2.2
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/.editorconfig +9 -9
- package/.eslintrc.js +28 -28
- package/.zou-flow +3 -3
- package/README.md +107 -107
- package/carnotzet.js +10 -10
- package/config.js +13 -13
- package/laboratory.js +13 -13
- package/lib/.webpack-config.js +53 -53
- package/lib/carnotzet.js +118 -118
- package/lib/helpers.js +16 -16
- package/lib/index.js +66 -66
- package/package.json +47 -47
- package/widgets/connect-helpers/arrayEquals.js +5 -5
- package/widgets/connect-helpers/arraysEquals.js +24 -24
- package/widgets/connect-helpers/c.js +99 -99
- package/widgets/connect-helpers/join-models.js +16 -16
- package/widgets/connect-helpers/with-c.js +276 -276
- package/widgets/devtools.js +5 -5
- package/widgets/disconnect-overlay/styles.js +50 -50
- package/widgets/disconnect-overlay/widget.js +40 -40
- package/widgets/fields-view/widget.js +34 -34
- package/widgets/form/index.js +79 -79
- package/widgets/frame/widget.js +47 -47
- package/widgets/frontend-form/reducer.js +18 -18
- package/widgets/frontend-form/widget.js +15 -15
- package/widgets/importer/default.js +14 -14
- package/widgets/importer/importer.js +54 -53
- package/widgets/importer/index.js +4 -4
- package/widgets/index-browsers.js +195 -195
- package/widgets/index-electron-ws.js +153 -153
- package/widgets/index-electron.js +69 -69
- package/widgets/index.js +1 -1
- package/widgets/laboratory/service.js +542 -542
- package/widgets/laboratory/widget.js +98 -98
- package/widgets/maintenance/styles.js +38 -38
- package/widgets/maintenance/widget.js +65 -65
- package/widgets/props-binder/widget.js +48 -48
- package/widgets/renderer.js +85 -85
- package/widgets/root/index.js +54 -54
- package/widgets/searchkit/index.js +68 -68
- package/widgets/store/backend-reducer.js +116 -116
- package/widgets/store/commands-reducer.js +14 -14
- package/widgets/store/middlewares.js +171 -171
- package/widgets/store/network-reducer.js +23 -23
- package/widgets/store/root-reducer.js +35 -35
- package/widgets/store/store.js +40 -40
- package/widgets/store/widgets-reducer.js +95 -95
- package/widgets/theme-context/js-to-css.js +20 -20
- package/widgets/theme-context/widget.js +130 -130
- package/widgets/view/index.js +31 -31
- package/widgets/widget/index.js +1205 -1205
- package/widgets/widget/utils/connect.js +47 -47
- package/widgets/widget/utils/connectBackend.js +48 -48
- package/widgets/widget/utils/connectWidget.js +31 -31
- package/widgets/widget/utils/manifest.txt +134 -134
- package/widgets/widget/utils/shallowEqualShredder.js +36 -36
- package/widgets/widget/utils/widgets-actions.js +21 -21
- package/widgets/widget/utils/wrapMapStateToProps.js +26 -26
- package/widgets/with-desktop-id/widget.js +20 -20
- package/widgets/with-model/context.js +5 -5
- package/widgets/with-model/widget.js +42 -42
- package/widgets/with-workitem/widget.js +30 -30
|
@@ -1,195 +1,195 @@
|
|
|
1
|
-
import Renderer from './renderer.js';
|
|
2
|
-
|
|
3
|
-
const WT = `
|
|
4
|
-
function () {
|
|
5
|
-
self.onmessage = function(e){
|
|
6
|
-
self.postMessage(JSON.parse(e.data));
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
const parser = URL.createObjectURL(
|
|
12
|
-
new Blob(['(' + WT + ')()'], {type: 'text/javascript'})
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
function webWorkerJSONParse(worker, data, callback) {
|
|
16
|
-
// Bad payload case...
|
|
17
|
-
if (typeof data !== 'string' || data.charAt(0) !== '{') {
|
|
18
|
-
callback(data);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//No webworker API case...
|
|
23
|
-
if (!worker) {
|
|
24
|
-
callback(JSON.parse(data));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
worker.postMessage(data);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class BrowsersRenderer extends Renderer {
|
|
32
|
-
constructor(options = {}) {
|
|
33
|
-
const send = (type, data) => {
|
|
34
|
-
const socket = this._socket;
|
|
35
|
-
if (socket.readyState === WebSocket.OPEN) {
|
|
36
|
-
socket.send(JSON.stringify({type, data}));
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
super(send, options);
|
|
41
|
-
|
|
42
|
-
window.isBrowser = true;
|
|
43
|
-
|
|
44
|
-
const callback = (data) => {
|
|
45
|
-
switch (data.type) {
|
|
46
|
-
case 'PUSH_PATH':
|
|
47
|
-
this.store.dispatch(this.push(data.path));
|
|
48
|
-
break;
|
|
49
|
-
case 'DISPATCH_IN_APP':
|
|
50
|
-
this.store.dispatch(data.action);
|
|
51
|
-
break;
|
|
52
|
-
case 'NEW_BACKEND_STATE':
|
|
53
|
-
this.newBackendState(data.transitState);
|
|
54
|
-
break;
|
|
55
|
-
case 'BEGIN_RENDER':
|
|
56
|
-
super.main(data.labId);
|
|
57
|
-
//persist for future handshaking
|
|
58
|
-
this.storeTokens(data.tokens);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const worker = Worker ? new Worker(parser) : null;
|
|
64
|
-
if (worker) {
|
|
65
|
-
worker.onmessage = (e) => {
|
|
66
|
-
callback(e.data);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
this._handleWebSocketMessage = (data) => {
|
|
71
|
-
webWorkerJSONParse(worker, data, callback);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
this.reconnectTimeout = 125; // 125ms / 250ms / 500ms / 1000ms / ...
|
|
75
|
-
this.connect = this.connect.bind(this);
|
|
76
|
-
this.connect();
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
connect() {
|
|
80
|
-
const {
|
|
81
|
-
protocol = 'ws',
|
|
82
|
-
hostname = 'localhost',
|
|
83
|
-
port = '8000',
|
|
84
|
-
destination = '',
|
|
85
|
-
} = this.options;
|
|
86
|
-
|
|
87
|
-
const {clientToken, sessionToken} = this.getTokens();
|
|
88
|
-
|
|
89
|
-
const socket = new WebSocket(
|
|
90
|
-
`${protocol}://${hostname}:${port}/${clientToken}/${sessionToken}/${destination}/`
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
socket.onmessage = (event) => {
|
|
94
|
-
this._handleWebSocketMessage(event.data);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
let resetTimeoutHandle;
|
|
98
|
-
|
|
99
|
-
socket.onopen = (event) => {
|
|
100
|
-
console.log('Websocket is open:', event);
|
|
101
|
-
this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'open'});
|
|
102
|
-
resetTimeoutHandle = setTimeout(() => {
|
|
103
|
-
this.reconnectTimeout = 125;
|
|
104
|
-
}, 10000);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
socket.onclose = (event) => {
|
|
108
|
-
console.log('Websocket closed:', event);
|
|
109
|
-
this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'closed'});
|
|
110
|
-
|
|
111
|
-
// Do not reconnect immediately in case of error while opening the connection
|
|
112
|
-
if (event.code === 4001 && this.reconnectTimeout < 16000) {
|
|
113
|
-
this.reconnectTimeout = 16000;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (!event.wasClean) {
|
|
117
|
-
clearTimeout(resetTimeoutHandle);
|
|
118
|
-
setTimeout(this.connect, this.reconnectTimeout);
|
|
119
|
-
this.reconnectTimeout *= 2;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
socket.onerror = (event) => {
|
|
124
|
-
console.error('WebSocket error observed:', event);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
this._socket = socket;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
getCookie(name) {
|
|
131
|
-
let cookies = {};
|
|
132
|
-
document.cookie.split(';').forEach((cookie) => {
|
|
133
|
-
let [k, v] = cookie.split('=');
|
|
134
|
-
cookies[k.trim()] = v;
|
|
135
|
-
});
|
|
136
|
-
return cookies[name];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
getTokens() {
|
|
140
|
-
let clientToken;
|
|
141
|
-
let sessionToken;
|
|
142
|
-
|
|
143
|
-
try {
|
|
144
|
-
clientToken = window.localStorage.getItem('epsitec/zeppelin/clientToken');
|
|
145
|
-
sessionToken = window.sessionStorage.getItem(
|
|
146
|
-
'epsitec/zeppelin/sessionToken'
|
|
147
|
-
);
|
|
148
|
-
} catch (e) {
|
|
149
|
-
if (e.name !== 'SecurityError') {
|
|
150
|
-
throw e;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (!clientToken) {
|
|
155
|
-
if (window.navigator.userAgent === 'Epsitec.Cresus.Shell') {
|
|
156
|
-
const cookie = this.getCookie('epsitec-client-token');
|
|
157
|
-
clientToken = cookie;
|
|
158
|
-
} else {
|
|
159
|
-
clientToken = 'new-client';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (!sessionToken) {
|
|
164
|
-
sessionToken = 'new-session';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return {clientToken, sessionToken};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
storeTokens(tokens) {
|
|
171
|
-
if (!tokens) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
try {
|
|
175
|
-
if (tokens.clientToken) {
|
|
176
|
-
window.localStorage.setItem(
|
|
177
|
-
'epsitec/zeppelin/clientToken',
|
|
178
|
-
tokens.clientToken
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
if (tokens.sessionToken) {
|
|
182
|
-
window.sessionStorage.setItem(
|
|
183
|
-
'epsitec/zeppelin/sessionToken',
|
|
184
|
-
tokens.sessionToken
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
} catch (e) {
|
|
188
|
-
if (e.name !== 'SecurityError') {
|
|
189
|
-
throw e;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
window.Renderer = BrowsersRenderer;
|
|
1
|
+
import Renderer from './renderer.js';
|
|
2
|
+
|
|
3
|
+
const WT = `
|
|
4
|
+
function () {
|
|
5
|
+
self.onmessage = function(e){
|
|
6
|
+
self.postMessage(JSON.parse(e.data));
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const parser = URL.createObjectURL(
|
|
12
|
+
new Blob(['(' + WT + ')()'], {type: 'text/javascript'})
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
function webWorkerJSONParse(worker, data, callback) {
|
|
16
|
+
// Bad payload case...
|
|
17
|
+
if (typeof data !== 'string' || data.charAt(0) !== '{') {
|
|
18
|
+
callback(data);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//No webworker API case...
|
|
23
|
+
if (!worker) {
|
|
24
|
+
callback(JSON.parse(data));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
worker.postMessage(data);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class BrowsersRenderer extends Renderer {
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
const send = (type, data) => {
|
|
34
|
+
const socket = this._socket;
|
|
35
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
36
|
+
socket.send(JSON.stringify({type, data}));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
super(send, options);
|
|
41
|
+
|
|
42
|
+
window.isBrowser = true;
|
|
43
|
+
|
|
44
|
+
const callback = (data) => {
|
|
45
|
+
switch (data.type) {
|
|
46
|
+
case 'PUSH_PATH':
|
|
47
|
+
this.store.dispatch(this.push(data.path));
|
|
48
|
+
break;
|
|
49
|
+
case 'DISPATCH_IN_APP':
|
|
50
|
+
this.store.dispatch(data.action);
|
|
51
|
+
break;
|
|
52
|
+
case 'NEW_BACKEND_STATE':
|
|
53
|
+
this.newBackendState(data.transitState);
|
|
54
|
+
break;
|
|
55
|
+
case 'BEGIN_RENDER':
|
|
56
|
+
super.main(data.labId);
|
|
57
|
+
//persist for future handshaking
|
|
58
|
+
this.storeTokens(data.tokens);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const worker = Worker ? new Worker(parser) : null;
|
|
64
|
+
if (worker) {
|
|
65
|
+
worker.onmessage = (e) => {
|
|
66
|
+
callback(e.data);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
this._handleWebSocketMessage = (data) => {
|
|
71
|
+
webWorkerJSONParse(worker, data, callback);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
this.reconnectTimeout = 125; // 125ms / 250ms / 500ms / 1000ms / ...
|
|
75
|
+
this.connect = this.connect.bind(this);
|
|
76
|
+
this.connect();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
connect() {
|
|
80
|
+
const {
|
|
81
|
+
protocol = 'ws',
|
|
82
|
+
hostname = 'localhost',
|
|
83
|
+
port = '8000',
|
|
84
|
+
destination = '',
|
|
85
|
+
} = this.options;
|
|
86
|
+
|
|
87
|
+
const {clientToken, sessionToken} = this.getTokens();
|
|
88
|
+
|
|
89
|
+
const socket = new WebSocket(
|
|
90
|
+
`${protocol}://${hostname}:${port}/${clientToken}/${sessionToken}/${destination}/`
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
socket.onmessage = (event) => {
|
|
94
|
+
this._handleWebSocketMessage(event.data);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
let resetTimeoutHandle;
|
|
98
|
+
|
|
99
|
+
socket.onopen = (event) => {
|
|
100
|
+
console.log('Websocket is open:', event);
|
|
101
|
+
this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'open'});
|
|
102
|
+
resetTimeoutHandle = setTimeout(() => {
|
|
103
|
+
this.reconnectTimeout = 125;
|
|
104
|
+
}, 10000);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
socket.onclose = (event) => {
|
|
108
|
+
console.log('Websocket closed:', event);
|
|
109
|
+
this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'closed'});
|
|
110
|
+
|
|
111
|
+
// Do not reconnect immediately in case of error while opening the connection
|
|
112
|
+
if (event.code === 4001 && this.reconnectTimeout < 16000) {
|
|
113
|
+
this.reconnectTimeout = 16000;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!event.wasClean) {
|
|
117
|
+
clearTimeout(resetTimeoutHandle);
|
|
118
|
+
setTimeout(this.connect, this.reconnectTimeout);
|
|
119
|
+
this.reconnectTimeout *= 2;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
socket.onerror = (event) => {
|
|
124
|
+
console.error('WebSocket error observed:', event);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
this._socket = socket;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getCookie(name) {
|
|
131
|
+
let cookies = {};
|
|
132
|
+
document.cookie.split(';').forEach((cookie) => {
|
|
133
|
+
let [k, v] = cookie.split('=');
|
|
134
|
+
cookies[k.trim()] = v;
|
|
135
|
+
});
|
|
136
|
+
return cookies[name];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
getTokens() {
|
|
140
|
+
let clientToken;
|
|
141
|
+
let sessionToken;
|
|
142
|
+
|
|
143
|
+
try {
|
|
144
|
+
clientToken = window.localStorage.getItem('epsitec/zeppelin/clientToken');
|
|
145
|
+
sessionToken = window.sessionStorage.getItem(
|
|
146
|
+
'epsitec/zeppelin/sessionToken'
|
|
147
|
+
);
|
|
148
|
+
} catch (e) {
|
|
149
|
+
if (e.name !== 'SecurityError') {
|
|
150
|
+
throw e;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!clientToken) {
|
|
155
|
+
if (window.navigator.userAgent === 'Epsitec.Cresus.Shell') {
|
|
156
|
+
const cookie = this.getCookie('epsitec-client-token');
|
|
157
|
+
clientToken = cookie;
|
|
158
|
+
} else {
|
|
159
|
+
clientToken = 'new-client';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (!sessionToken) {
|
|
164
|
+
sessionToken = 'new-session';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {clientToken, sessionToken};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
storeTokens(tokens) {
|
|
171
|
+
if (!tokens) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
if (tokens.clientToken) {
|
|
176
|
+
window.localStorage.setItem(
|
|
177
|
+
'epsitec/zeppelin/clientToken',
|
|
178
|
+
tokens.clientToken
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (tokens.sessionToken) {
|
|
182
|
+
window.sessionStorage.setItem(
|
|
183
|
+
'epsitec/zeppelin/sessionToken',
|
|
184
|
+
tokens.sessionToken
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
} catch (e) {
|
|
188
|
+
if (e.name !== 'SecurityError') {
|
|
189
|
+
throw e;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
window.Renderer = BrowsersRenderer;
|