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.
Files changed (62) hide show
  1. package/.editorconfig +9 -9
  2. package/.eslintrc.js +28 -28
  3. package/.zou-flow +3 -3
  4. package/README.md +107 -107
  5. package/carnotzet.js +10 -10
  6. package/config.js +13 -13
  7. package/laboratory.js +13 -13
  8. package/lib/.webpack-config.js +53 -53
  9. package/lib/carnotzet.js +118 -118
  10. package/lib/helpers.js +16 -16
  11. package/lib/index.js +66 -66
  12. package/package.json +47 -47
  13. package/widgets/connect-helpers/arrayEquals.js +5 -5
  14. package/widgets/connect-helpers/arraysEquals.js +24 -24
  15. package/widgets/connect-helpers/c.js +99 -99
  16. package/widgets/connect-helpers/join-models.js +16 -16
  17. package/widgets/connect-helpers/with-c.js +276 -276
  18. package/widgets/devtools.js +5 -5
  19. package/widgets/disconnect-overlay/styles.js +50 -50
  20. package/widgets/disconnect-overlay/widget.js +40 -40
  21. package/widgets/fields-view/widget.js +34 -34
  22. package/widgets/form/index.js +79 -79
  23. package/widgets/frame/widget.js +47 -47
  24. package/widgets/frontend-form/reducer.js +18 -18
  25. package/widgets/frontend-form/widget.js +15 -15
  26. package/widgets/importer/default.js +14 -14
  27. package/widgets/importer/importer.js +54 -53
  28. package/widgets/importer/index.js +4 -4
  29. package/widgets/index-browsers.js +195 -195
  30. package/widgets/index-electron-ws.js +153 -153
  31. package/widgets/index-electron.js +69 -69
  32. package/widgets/index.js +1 -1
  33. package/widgets/laboratory/service.js +542 -542
  34. package/widgets/laboratory/widget.js +98 -98
  35. package/widgets/maintenance/styles.js +38 -38
  36. package/widgets/maintenance/widget.js +65 -65
  37. package/widgets/props-binder/widget.js +48 -48
  38. package/widgets/renderer.js +85 -85
  39. package/widgets/root/index.js +54 -54
  40. package/widgets/searchkit/index.js +68 -68
  41. package/widgets/store/backend-reducer.js +116 -116
  42. package/widgets/store/commands-reducer.js +14 -14
  43. package/widgets/store/middlewares.js +171 -171
  44. package/widgets/store/network-reducer.js +23 -23
  45. package/widgets/store/root-reducer.js +35 -35
  46. package/widgets/store/store.js +40 -40
  47. package/widgets/store/widgets-reducer.js +95 -95
  48. package/widgets/theme-context/js-to-css.js +20 -20
  49. package/widgets/theme-context/widget.js +130 -130
  50. package/widgets/view/index.js +31 -31
  51. package/widgets/widget/index.js +1205 -1205
  52. package/widgets/widget/utils/connect.js +47 -47
  53. package/widgets/widget/utils/connectBackend.js +48 -48
  54. package/widgets/widget/utils/connectWidget.js +31 -31
  55. package/widgets/widget/utils/manifest.txt +134 -134
  56. package/widgets/widget/utils/shallowEqualShredder.js +36 -36
  57. package/widgets/widget/utils/widgets-actions.js +21 -21
  58. package/widgets/widget/utils/wrapMapStateToProps.js +26 -26
  59. package/widgets/with-desktop-id/widget.js +20 -20
  60. package/widgets/with-model/context.js +5 -5
  61. package/widgets/with-model/widget.js +42 -42
  62. package/widgets/with-workitem/widget.js +30 -30
@@ -1,153 +1,153 @@
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 ElectronRendererWS extends Renderer {
32
- constructor(options = {}) {
33
- const electron = require('electron');
34
- const {webFrame} = electron;
35
-
36
- const send = (type, data) => {
37
- const socket = this._socket;
38
- if (socket.readyState === WebSocket.OPEN) {
39
- socket.send(JSON.stringify({type, data}));
40
- }
41
- };
42
-
43
- const port = new URL(window.location.href).searchParams.get('wss');
44
- const labId = new URL(window.location.href).searchParams.get('labId');
45
- if (!port) {
46
- throw new Error(`ElectronRendererWS: unable to find wss= in url`);
47
- }
48
- if (!labId) {
49
- throw new Error(`ElectronRendererWS: unable to find labId= in url`);
50
- }
51
-
52
- super(send, options);
53
-
54
- let zoom = webFrame.getZoomFactor();
55
- this.store.subscribe(() => {
56
- if (!labId) {
57
- return;
58
- }
59
- const state = this.store.getState();
60
- if (!state || !state.backend) {
61
- return;
62
- }
63
- const lab = state.backend.get(labId);
64
- if (!lab) {
65
- return;
66
- }
67
- const zoomState = lab.get('zoom');
68
- if (zoomState && zoomState !== zoom) {
69
- zoom = zoomState;
70
- webFrame.setZoomFactor(zoom);
71
- }
72
- });
73
-
74
- window.zoomable = true;
75
-
76
- const callback = (data) => {
77
- switch (data.type) {
78
- case 'PUSH_PATH':
79
- this.store.dispatch(this.push(data.path));
80
- break;
81
- case 'DISPATCH_IN_APP':
82
- this.store.dispatch(data.action);
83
- break;
84
- case 'NEW_BACKEND_STATE':
85
- this.newBackendState(data.transitState);
86
- break;
87
- case 'BEGIN_RENDER':
88
- super.main(labId);
89
- break;
90
- }
91
- };
92
-
93
- const worker = Worker ? new Worker(parser) : null;
94
- if (worker) {
95
- worker.onmessage = (e) => {
96
- callback(e.data);
97
- };
98
- }
99
-
100
- this._handleWebSocketMessage = (data) => {
101
- webWorkerJSONParse(worker, data, callback);
102
- };
103
-
104
- this.reconnectTimeout = 125; // 125ms / 250ms / 500ms / 1000ms / ...
105
- this.connect = this.connect.bind(this);
106
- this.connect(port);
107
- if (module.hot) {
108
- this.send(`RESEND`);
109
- }
110
- }
111
-
112
- connect(port) {
113
- const {protocol = 'ws', hostname = 'localhost'} = this.options;
114
-
115
- const socket = new WebSocket(`${protocol}://${hostname}:${port}/`);
116
-
117
- socket.onmessage = (event) => {
118
- this._handleWebSocketMessage(event.data);
119
- };
120
-
121
- let resetTimeoutHandle;
122
-
123
- socket.onopen = (event) => {
124
- console.log('Websocket is open:', event);
125
- this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'open'});
126
- resetTimeoutHandle = setTimeout(() => {
127
- this.reconnectTimeout = 125;
128
- }, 10000);
129
- };
130
-
131
- socket.onclose = (event) => {
132
- console.log('Websocket closed:', event);
133
- this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'closed'});
134
-
135
- // Do not reconnect immediately in case of error while opening the connection
136
- if (event.code === 4001 && this.reconnectTimeout < 16000) {
137
- this.reconnectTimeout = 16000;
138
- }
139
-
140
- clearTimeout(resetTimeoutHandle);
141
- setTimeout(this.connect, this.reconnectTimeout);
142
- this.reconnectTimeout *= 2;
143
- };
144
-
145
- socket.onerror = (event) => {
146
- console.error('WebSocket error observed:', event);
147
- };
148
-
149
- this._socket = socket;
150
- }
151
- }
152
-
153
- window.Renderer = ElectronRendererWS;
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 ElectronRendererWS extends Renderer {
32
+ constructor(options = {}) {
33
+ const electron = require('electron');
34
+ const {webFrame} = electron;
35
+
36
+ const send = (type, data) => {
37
+ const socket = this._socket;
38
+ if (socket.readyState === WebSocket.OPEN) {
39
+ socket.send(JSON.stringify({type, data}));
40
+ }
41
+ };
42
+
43
+ const port = new URL(window.location.href).searchParams.get('wss');
44
+ const labId = new URL(window.location.href).searchParams.get('labId');
45
+ if (!port) {
46
+ throw new Error(`ElectronRendererWS: unable to find wss= in url`);
47
+ }
48
+ if (!labId) {
49
+ throw new Error(`ElectronRendererWS: unable to find labId= in url`);
50
+ }
51
+
52
+ super(send, options);
53
+
54
+ let zoom = webFrame.getZoomFactor();
55
+ this.store.subscribe(() => {
56
+ if (!labId) {
57
+ return;
58
+ }
59
+ const state = this.store.getState();
60
+ if (!state || !state.backend) {
61
+ return;
62
+ }
63
+ const lab = state.backend.get(labId);
64
+ if (!lab) {
65
+ return;
66
+ }
67
+ const zoomState = lab.get('zoom');
68
+ if (zoomState && zoomState !== zoom) {
69
+ zoom = zoomState;
70
+ webFrame.setZoomFactor(zoom);
71
+ }
72
+ });
73
+
74
+ window.zoomable = true;
75
+
76
+ const callback = (data) => {
77
+ switch (data.type) {
78
+ case 'PUSH_PATH':
79
+ this.store.dispatch(this.push(data.path));
80
+ break;
81
+ case 'DISPATCH_IN_APP':
82
+ this.store.dispatch(data.action);
83
+ break;
84
+ case 'NEW_BACKEND_STATE':
85
+ this.newBackendState(data.transitState);
86
+ break;
87
+ case 'BEGIN_RENDER':
88
+ super.main(labId);
89
+ break;
90
+ }
91
+ };
92
+
93
+ const worker = Worker ? new Worker(parser) : null;
94
+ if (worker) {
95
+ worker.onmessage = (e) => {
96
+ callback(e.data);
97
+ };
98
+ }
99
+
100
+ this._handleWebSocketMessage = (data) => {
101
+ webWorkerJSONParse(worker, data, callback);
102
+ };
103
+
104
+ this.reconnectTimeout = 125; // 125ms / 250ms / 500ms / 1000ms / ...
105
+ this.connect = this.connect.bind(this);
106
+ this.connect(port);
107
+ if (module.hot) {
108
+ this.send(`RESEND`);
109
+ }
110
+ }
111
+
112
+ connect(port) {
113
+ const {protocol = 'ws', hostname = 'localhost'} = this.options;
114
+
115
+ const socket = new WebSocket(`${protocol}://${hostname}:${port}/`);
116
+
117
+ socket.onmessage = (event) => {
118
+ this._handleWebSocketMessage(event.data);
119
+ };
120
+
121
+ let resetTimeoutHandle;
122
+
123
+ socket.onopen = (event) => {
124
+ console.log('Websocket is open:', event);
125
+ this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'open'});
126
+ resetTimeoutHandle = setTimeout(() => {
127
+ this.reconnectTimeout = 125;
128
+ }, 10000);
129
+ };
130
+
131
+ socket.onclose = (event) => {
132
+ console.log('Websocket closed:', event);
133
+ this.store.dispatch({type: 'SET_WEBSOCKET_STATUS', status: 'closed'});
134
+
135
+ // Do not reconnect immediately in case of error while opening the connection
136
+ if (event.code === 4001 && this.reconnectTimeout < 16000) {
137
+ this.reconnectTimeout = 16000;
138
+ }
139
+
140
+ clearTimeout(resetTimeoutHandle);
141
+ setTimeout(this.connect, this.reconnectTimeout);
142
+ this.reconnectTimeout *= 2;
143
+ };
144
+
145
+ socket.onerror = (event) => {
146
+ console.error('WebSocket error observed:', event);
147
+ };
148
+
149
+ this._socket = socket;
150
+ }
151
+ }
152
+
153
+ window.Renderer = ElectronRendererWS;
@@ -1,69 +1,69 @@
1
- import Renderer from './renderer.js';
2
-
3
- class ElectronRenderer extends Renderer {
4
- constructor(options) {
5
- const electron = require('electron');
6
- const {ipcRenderer, webFrame} = electron;
7
-
8
- const url = new URL(window.location.href);
9
- const wid = url.searchParams.get('wid');
10
- const labId = url.searchParams.get('labId');
11
-
12
- if (!wid) {
13
- throw 'ElectronRenderer: unable to find wid= in url';
14
- }
15
- if (!labId) {
16
- throw new Error(`ElectronRenderer: unable to find labId= in url`);
17
- }
18
-
19
- const send = (verb, ...args) => {
20
- ipcRenderer.send(`${wid}-${verb}`, ...args);
21
- };
22
-
23
- super(send, options);
24
-
25
- let zoom = webFrame.getZoomFactor();
26
- this.store.subscribe(() => {
27
- if (!labId) {
28
- return;
29
- }
30
- const state = this.store.getState();
31
- if (!state || !state.backend) {
32
- return;
33
- }
34
- const lab = state.backend.get(labId);
35
- if (!lab) {
36
- return;
37
- }
38
- const zoomState = lab.get('zoom');
39
- if (zoomState && zoomState !== zoom) {
40
- zoom = zoomState;
41
- webFrame.setZoomFactor(zoom);
42
- }
43
- });
44
-
45
- window.zoomable = true;
46
-
47
- ipcRenderer.on('PUSH_PATH', (event, path) =>
48
- this.store.dispatch(this.push(path))
49
- );
50
-
51
- ipcRenderer.on('DISPATCH_IN_APP', (event, action) =>
52
- this.store.dispatch(action)
53
- );
54
-
55
- ipcRenderer.on('NEW_BACKEND_STATE', (event, transitState) =>
56
- this.newBackendState(transitState)
57
- );
58
-
59
- ipcRenderer.on('BEGIN_RENDER', () => {
60
- return super.main(labId);
61
- });
62
-
63
- if (module.hot) {
64
- this.send(`RESEND`, wid);
65
- }
66
- }
67
- }
68
-
69
- window.Renderer = ElectronRenderer;
1
+ import Renderer from './renderer.js';
2
+
3
+ class ElectronRenderer extends Renderer {
4
+ constructor(options) {
5
+ const electron = require('electron');
6
+ const {ipcRenderer, webFrame} = electron;
7
+
8
+ const url = new URL(window.location.href);
9
+ const wid = url.searchParams.get('wid');
10
+ const labId = url.searchParams.get('labId');
11
+
12
+ if (!wid) {
13
+ throw 'ElectronRenderer: unable to find wid= in url';
14
+ }
15
+ if (!labId) {
16
+ throw new Error(`ElectronRenderer: unable to find labId= in url`);
17
+ }
18
+
19
+ const send = (verb, ...args) => {
20
+ ipcRenderer.send(`${wid}-${verb}`, ...args);
21
+ };
22
+
23
+ super(send, options);
24
+
25
+ let zoom = webFrame.getZoomFactor();
26
+ this.store.subscribe(() => {
27
+ if (!labId) {
28
+ return;
29
+ }
30
+ const state = this.store.getState();
31
+ if (!state || !state.backend) {
32
+ return;
33
+ }
34
+ const lab = state.backend.get(labId);
35
+ if (!lab) {
36
+ return;
37
+ }
38
+ const zoomState = lab.get('zoom');
39
+ if (zoomState && zoomState !== zoom) {
40
+ zoom = zoomState;
41
+ webFrame.setZoomFactor(zoom);
42
+ }
43
+ });
44
+
45
+ window.zoomable = true;
46
+
47
+ ipcRenderer.on('PUSH_PATH', (event, path) =>
48
+ this.store.dispatch(this.push(path))
49
+ );
50
+
51
+ ipcRenderer.on('DISPATCH_IN_APP', (event, action) =>
52
+ this.store.dispatch(action)
53
+ );
54
+
55
+ ipcRenderer.on('NEW_BACKEND_STATE', (event, transitState) =>
56
+ this.newBackendState(transitState)
57
+ );
58
+
59
+ ipcRenderer.on('BEGIN_RENDER', () => {
60
+ return super.main(labId);
61
+ });
62
+
63
+ if (module.hot) {
64
+ this.send(`RESEND`, wid);
65
+ }
66
+ }
67
+ }
68
+
69
+ window.Renderer = ElectronRenderer;
package/widgets/index.js CHANGED
@@ -1 +1 @@
1
- import './index-electron.js';
1
+ import './index-electron.js';