goblin-laboratory 2.2.0 → 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 -541
  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
package/lib/carnotzet.js CHANGED
@@ -1,118 +1,118 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const Goblin = require('xcraft-core-goblin');
5
- const goblinName = path.basename(module.parent.filename, '.js');
6
-
7
- // Define initial logic values
8
- const logicState = {};
9
-
10
- // Define logic handlers according rc.json
11
- const logicHandlers = {
12
- 'create': (state, action) => {
13
- const conf = action.get('config');
14
- const id = action.get('id');
15
- return state.set('', {
16
- id: id,
17
- feed: conf.feed,
18
- root: null,
19
- rootId: null,
20
- clientSessionId: action.get('clientSessionId'),
21
- theme: conf.theme || 'default',
22
- themeContext: conf.themeContexts ? conf.themeContexts[0] : 'theme',
23
- });
24
- },
25
- 'set-root': (state, action) => {
26
- const widgetId = action.get('widgetId');
27
- let widget = action.get('widget');
28
- if (!widget) {
29
- widget = widgetId;
30
- }
31
- return state.set('rootId', widgetId).set('root', widget);
32
- },
33
- };
34
-
35
- // Register quest's according rc.json
36
- Goblin.registerQuest(goblinName, 'create', function* (
37
- quest,
38
- clientSessionId,
39
- config
40
- ) {
41
- quest.do({id: quest.goblin.id, config, clientSessionId});
42
-
43
- const feed = config.feed;
44
- if (!feed) {
45
- throw new Error(`config.feed is mandatory`);
46
- }
47
-
48
- const themeContexts = config.themeContexts || ['theme'];
49
-
50
- for (const ctx of themeContexts) {
51
- const composerId = `theme-composer@${ctx}`;
52
- yield quest.create('theme-composer', {
53
- id: composerId,
54
- desktopId: feed,
55
- });
56
- config.feeds.push(composerId);
57
- }
58
-
59
- yield quest.warehouse.subscribe({feed, branches: config.feeds});
60
-
61
- quest.goblin.defer(
62
- quest.sub('goblin.released', function* (err, {msg}) {
63
- yield quest.me.del({widgetId: msg.data.id});
64
- })
65
- );
66
-
67
- quest.log.info(`Carnotzet ${quest.goblin.id} created!`);
68
- return quest.goblin.id;
69
- });
70
-
71
- Goblin.registerQuest(goblinName, 'get-feed', function (quest) {
72
- return quest.goblin.feed;
73
- });
74
-
75
- Goblin.registerQuest(goblinName, 'set-root', function (
76
- quest,
77
- widget,
78
- widgetId
79
- ) {
80
- quest.do();
81
- });
82
-
83
- Goblin.registerQuest(goblinName, 'del', function* (quest, widgetId) {
84
- const state = quest.goblin.getState();
85
- const feed = state.get('feed');
86
- const branch = widgetId;
87
- const labId = quest.goblin.id;
88
- quest.log.info(`Carnotzet deleting widget ${widgetId} from feed ${feed}`);
89
- yield quest.warehouse.feedSubscriptionDel({feed, branch, parents: labId});
90
- });
91
-
92
- Goblin.registerQuest(goblinName, 'when-ui-crash', function (
93
- quest,
94
- desktopId,
95
- error,
96
- info
97
- ) {
98
- quest.log.err(
99
- `UI generate errors ! ${
100
- (error && error.stack) || ''
101
- }\nStack :${info.componentStack.replace(/\\n/g, '\n')}`
102
- );
103
- });
104
-
105
- Goblin.registerQuest(goblinName, 'delete', function* (quest) {
106
- quest.log.info(`Deleting carnotzet`);
107
- const state = quest.goblin.getState();
108
- const feed = state.get('feed');
109
- yield quest.cmd('warehouse.unsubscribe', {
110
- feed,
111
- });
112
- yield quest.cmd('warehouse.release', {
113
- branch: quest.goblin.id,
114
- });
115
- });
116
-
117
- // Create a Goblin with initial state and handlers
118
- module.exports = Goblin.configure(goblinName, logicState, logicHandlers);
1
+ 'use strict';
2
+
3
+ const path = require('path');
4
+ const Goblin = require('xcraft-core-goblin');
5
+ const goblinName = path.basename(module.parent.filename, '.js');
6
+
7
+ // Define initial logic values
8
+ const logicState = {};
9
+
10
+ // Define logic handlers according rc.json
11
+ const logicHandlers = {
12
+ 'create': (state, action) => {
13
+ const conf = action.get('config');
14
+ const id = action.get('id');
15
+ return state.set('', {
16
+ id: id,
17
+ feed: conf.feed,
18
+ root: null,
19
+ rootId: null,
20
+ clientSessionId: action.get('clientSessionId'),
21
+ theme: conf.theme || 'default',
22
+ themeContext: conf.themeContexts ? conf.themeContexts[0] : 'theme',
23
+ });
24
+ },
25
+ 'set-root': (state, action) => {
26
+ const widgetId = action.get('widgetId');
27
+ let widget = action.get('widget');
28
+ if (!widget) {
29
+ widget = widgetId;
30
+ }
31
+ return state.set('rootId', widgetId).set('root', widget);
32
+ },
33
+ };
34
+
35
+ // Register quest's according rc.json
36
+ Goblin.registerQuest(goblinName, 'create', function* (
37
+ quest,
38
+ clientSessionId,
39
+ config
40
+ ) {
41
+ quest.do({id: quest.goblin.id, config, clientSessionId});
42
+
43
+ const feed = config.feed;
44
+ if (!feed) {
45
+ throw new Error(`config.feed is mandatory`);
46
+ }
47
+
48
+ const themeContexts = config.themeContexts || ['theme'];
49
+
50
+ for (const ctx of themeContexts) {
51
+ const composerId = `theme-composer@${ctx}`;
52
+ yield quest.create('theme-composer', {
53
+ id: composerId,
54
+ desktopId: feed,
55
+ });
56
+ config.feeds.push(composerId);
57
+ }
58
+
59
+ yield quest.warehouse.subscribe({feed, branches: config.feeds});
60
+
61
+ quest.goblin.defer(
62
+ quest.sub('goblin.released', function* (err, {msg}) {
63
+ yield quest.me.del({widgetId: msg.data.id});
64
+ })
65
+ );
66
+
67
+ quest.log.info(`Carnotzet ${quest.goblin.id} created!`);
68
+ return quest.goblin.id;
69
+ });
70
+
71
+ Goblin.registerQuest(goblinName, 'get-feed', function (quest) {
72
+ return quest.goblin.feed;
73
+ });
74
+
75
+ Goblin.registerQuest(goblinName, 'set-root', function (
76
+ quest,
77
+ widget,
78
+ widgetId
79
+ ) {
80
+ quest.do();
81
+ });
82
+
83
+ Goblin.registerQuest(goblinName, 'del', function* (quest, widgetId) {
84
+ const state = quest.goblin.getState();
85
+ const feed = state.get('feed');
86
+ const branch = widgetId;
87
+ const labId = quest.goblin.id;
88
+ quest.log.info(`Carnotzet deleting widget ${widgetId} from feed ${feed}`);
89
+ yield quest.warehouse.feedSubscriptionDel({feed, branch, parents: labId});
90
+ });
91
+
92
+ Goblin.registerQuest(goblinName, 'when-ui-crash', function (
93
+ quest,
94
+ desktopId,
95
+ error,
96
+ info
97
+ ) {
98
+ quest.log.err(
99
+ `UI generate errors ! ${
100
+ (error && error.stack) || ''
101
+ }\nStack :${info.componentStack.replace(/\\n/g, '\n')}`
102
+ );
103
+ });
104
+
105
+ Goblin.registerQuest(goblinName, 'delete', function* (quest) {
106
+ quest.log.info(`Deleting carnotzet`);
107
+ const state = quest.goblin.getState();
108
+ const feed = state.get('feed');
109
+ yield quest.cmd('warehouse.unsubscribe', {
110
+ feed,
111
+ });
112
+ yield quest.cmd('warehouse.release', {
113
+ branch: quest.goblin.id,
114
+ });
115
+ });
116
+
117
+ // Create a Goblin with initial state and handlers
118
+ module.exports = Goblin.configure(goblinName, logicState, logicHandlers);
package/lib/helpers.js CHANGED
@@ -1,16 +1,16 @@
1
- module.exports = {
2
- getParameter: (search, name) => {
3
- if (!search) {
4
- return null;
5
- }
6
- const query = search.substring(1);
7
- const vars = query.split('&');
8
- for (const v of vars) {
9
- const pair = v.split('=');
10
- if (decodeURIComponent(pair[0]) === name) {
11
- return decodeURIComponent(pair[1]);
12
- }
13
- }
14
- return null;
15
- },
16
- };
1
+ module.exports = {
2
+ getParameter: (search, name) => {
3
+ if (!search) {
4
+ return null;
5
+ }
6
+ const query = search.substring(1);
7
+ const vars = query.split('&');
8
+ for (const v of vars) {
9
+ const pair = v.split('=');
10
+ if (decodeURIComponent(pair[0]) === name) {
11
+ return decodeURIComponent(pair[1]);
12
+ }
13
+ }
14
+ return null;
15
+ },
16
+ };
package/lib/index.js CHANGED
@@ -1,66 +1,66 @@
1
- const helpers = require('xcraft-core-transport/lib/helpers.js');
2
- const xProbe = require('xcraft-core-probe');
3
-
4
- class Channel {
5
- constructor(send) {
6
- this._send = send;
7
- }
8
-
9
- _probe(topic, id, handler) {
10
- if (!xProbe.isAvailable()) {
11
- handler();
12
- return;
13
- }
14
-
15
- const end = xProbe.push(topic, id);
16
- handler();
17
- end();
18
- }
19
-
20
- _prepareMsg(msg) {
21
- return helpers.toXcraftJSON(msg)[0];
22
- }
23
-
24
- sendBackendState(msg) {
25
- const transitState = this._prepareMsg(msg);
26
- this._send('NEW_BACKEND_STATE', {transitState, _data: transitState});
27
- }
28
-
29
- sendPushPath(path) {
30
- this._send('PUSH_PATH', {path, _data: path});
31
- }
32
-
33
- sendAction(action) {
34
- this._send('DISPATCH_IN_APP', {action, _data: action});
35
- }
36
-
37
- beginRender(labId, tokens) {
38
- this._send('BEGIN_RENDER', {labId, tokens, _data: labId});
39
- }
40
- }
41
-
42
- class ElectronChannel extends Channel {
43
- constructor(win) {
44
- const send = win.webContents.send.bind(win.webContents);
45
- super((type, data) =>
46
- this._probe('wm/ipc/send', data._data.id, () => send(type, data._data))
47
- );
48
- }
49
- }
50
-
51
- class WebSocketChannel extends Channel {
52
- constructor(win) {
53
- const send = win.send.bind(win);
54
- super((type, data) =>
55
- this._probe('wm/ws/send', data._data.id, () => {
56
- delete data._data;
57
- send(JSON.stringify(Object.assign({type}, data)));
58
- })
59
- );
60
- }
61
- }
62
-
63
- module.exports = {
64
- ElectronChannel,
65
- WebSocketChannel,
66
- };
1
+ const helpers = require('xcraft-core-transport/lib/helpers.js');
2
+ const xProbe = require('xcraft-core-probe');
3
+
4
+ class Channel {
5
+ constructor(send) {
6
+ this._send = send;
7
+ }
8
+
9
+ _probe(topic, id, handler) {
10
+ if (!xProbe.isAvailable()) {
11
+ handler();
12
+ return;
13
+ }
14
+
15
+ const end = xProbe.push(topic, id);
16
+ handler();
17
+ end();
18
+ }
19
+
20
+ _prepareMsg(msg) {
21
+ return helpers.toXcraftJSON(msg)[0];
22
+ }
23
+
24
+ sendBackendState(msg) {
25
+ const transitState = this._prepareMsg(msg);
26
+ this._send('NEW_BACKEND_STATE', {transitState, _data: transitState});
27
+ }
28
+
29
+ sendPushPath(path) {
30
+ this._send('PUSH_PATH', {path, _data: path});
31
+ }
32
+
33
+ sendAction(action) {
34
+ this._send('DISPATCH_IN_APP', {action, _data: action});
35
+ }
36
+
37
+ beginRender(labId, tokens) {
38
+ this._send('BEGIN_RENDER', {labId, tokens, _data: labId});
39
+ }
40
+ }
41
+
42
+ class ElectronChannel extends Channel {
43
+ constructor(win) {
44
+ const send = win.webContents.send.bind(win.webContents);
45
+ super((type, data) =>
46
+ this._probe('wm/ipc/send', data._data.id, () => send(type, data._data))
47
+ );
48
+ }
49
+ }
50
+
51
+ class WebSocketChannel extends Channel {
52
+ constructor(win) {
53
+ const send = win.send.bind(win);
54
+ super((type, data) =>
55
+ this._probe('wm/ws/send', data._data.id, () => {
56
+ delete data._data;
57
+ send(JSON.stringify(Object.assign({type}, data)));
58
+ })
59
+ );
60
+ }
61
+ }
62
+
63
+ module.exports = {
64
+ ElectronChannel,
65
+ WebSocketChannel,
66
+ };
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
- {
2
- "name": "goblin-laboratory",
3
- "version": "2.2.0",
4
- "description": "Laboratory",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
7
- },
8
- "main": "lib/index.js",
9
- "author": "",
10
- "license": "MIT",
11
- "config": {
12
- "xcraft": {
13
- "commands": true
14
- }
15
- },
16
- "dependencies": {
17
- "goblin-theme": "^2.0.0",
18
- "immutablepatch": "github:Xcraft-Inc/immutable-js-patch",
19
- "xcraft-core-goblin": "^5.0.0",
20
- "xcraft-core-probe": "^2.0.0",
21
- "xcraft-core-transport": "^4.0.0"
22
- },
23
- "devDependencies": {
24
- "aphrodite": "^2.2.2",
25
- "connected-react-router": "^6.3.2",
26
- "css-key": "^1.0.0",
27
- "faster-stable-stringify": "^1.0.0",
28
- "@fortawesome/react-fontawesome": "^0.1.9",
29
- "history": "^4.6.1",
30
- "immutable": "4.0.0-rc.14",
31
- "immutable-devtools": "0.0.7",
32
- "linked-list": "^1.0.4",
33
- "obj-to-css": "^1.0.1",
34
- "prettier": "2.0.4",
35
- "prop-types": "^15.5.10",
36
- "react": "^17.0.1",
37
- "react-dom": "^17.0.1",
38
- "react-redux": "^7.1.0",
39
- "react-router": "^5.0.0",
40
- "redux-thunk": "^2.3.0",
41
- "traverse": "^0.6.6",
42
- "xcraft-core-shredder": "^5.0.0",
43
- "xcraft-dev-prettier": "^2.0.0",
44
- "xcraft-dev-rules": "^2.0.0"
45
- },
46
- "prettier": "xcraft-dev-prettier"
47
- }
1
+ {
2
+ "name": "goblin-laboratory",
3
+ "version": "2.2.2",
4
+ "description": "Laboratory",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "main": "lib/index.js",
9
+ "author": "",
10
+ "license": "MIT",
11
+ "config": {
12
+ "xcraft": {
13
+ "commands": true
14
+ }
15
+ },
16
+ "dependencies": {
17
+ "goblin-theme": "^2.0.0",
18
+ "immutablepatch": "github:Xcraft-Inc/immutable-js-patch",
19
+ "xcraft-core-goblin": "^5.0.0",
20
+ "xcraft-core-probe": "^2.0.0",
21
+ "xcraft-core-transport": "^4.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "aphrodite": "^2.2.2",
25
+ "connected-react-router": "^6.3.2",
26
+ "css-key": "^1.0.0",
27
+ "faster-stable-stringify": "^1.0.0",
28
+ "@fortawesome/react-fontawesome": "^0.1.9",
29
+ "history": "^4.6.1",
30
+ "immutable": "4.0.0-rc.14",
31
+ "immutable-devtools": "0.0.7",
32
+ "linked-list": "^1.0.4",
33
+ "obj-to-css": "^1.0.1",
34
+ "prettier": "2.0.4",
35
+ "prop-types": "^15.5.10",
36
+ "react": "^17.0.1",
37
+ "react-dom": "^17.0.1",
38
+ "react-redux": "^7.1.0",
39
+ "react-router": "^5.0.0",
40
+ "redux-thunk": "^2.3.0",
41
+ "traverse": "^0.6.6",
42
+ "xcraft-core-shredder": "^5.0.0",
43
+ "xcraft-dev-prettier": "^2.0.0",
44
+ "xcraft-dev-rules": "^2.0.0"
45
+ },
46
+ "prettier": "xcraft-dev-prettier"
47
+ }
@@ -1,5 +1,5 @@
1
- import arraysEquals from './arraysEquals.js';
2
-
3
- export default function arrayEquals(a) {
4
- return arraysEquals(this, a);
5
- }
1
+ import arraysEquals from './arraysEquals.js';
2
+
3
+ export default function arrayEquals(a) {
4
+ return arraysEquals(this, a);
5
+ }
@@ -1,24 +1,24 @@
1
- function is(x, y) {
2
- if (x && typeof x.equals === 'function') {
3
- return x.equals(y);
4
- }
5
- return Object.is(x, y);
6
- }
7
-
8
- export default function arraysEquals(a1, a2) {
9
- if (a1 === a2) {
10
- return true;
11
- }
12
- if (!Array.isArray(a2)) {
13
- return false;
14
- }
15
- if (a1.length !== a2.length) {
16
- return false;
17
- }
18
- for (let i = 0; i < a1.length; i++) {
19
- if (!is(a1[i], a2[i])) {
20
- return false;
21
- }
22
- }
23
- return true;
24
- }
1
+ function is(x, y) {
2
+ if (x && typeof x.equals === 'function') {
3
+ return x.equals(y);
4
+ }
5
+ return Object.is(x, y);
6
+ }
7
+
8
+ export default function arraysEquals(a1, a2) {
9
+ if (a1 === a2) {
10
+ return true;
11
+ }
12
+ if (!Array.isArray(a2)) {
13
+ return false;
14
+ }
15
+ if (a1.length !== a2.length) {
16
+ return false;
17
+ }
18
+ for (let i = 0; i < a1.length; i++) {
19
+ if (!is(a1[i], a2[i])) {
20
+ return false;
21
+ }
22
+ }
23
+ return true;
24
+ }