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,54 +1,54 @@
1
- //T:2019-02-27
2
-
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
5
-
6
- import {Provider} from 'react-redux';
7
- import {ConnectedRouter} from 'connected-react-router/immutable';
8
- import Widget from 'goblin-laboratory/widgets/widget';
9
- import Laboratory from '../laboratory/widget';
10
-
11
- class Root extends React.PureComponent {
12
- getChildContext() {
13
- return {
14
- labId: this.props.labId,
15
- dispatch: this.props.store.dispatch,
16
- store: this.props.store,
17
- };
18
- }
19
-
20
- static get childContextTypes() {
21
- return {
22
- labId: PropTypes.string,
23
- dispatch: PropTypes.func,
24
- store: PropTypes.object,
25
- };
26
- }
27
-
28
- renderLabWithRouter() {
29
- const {history, labId} = this.props;
30
- const LabWithRoute = Widget.withRoute('/')(Laboratory);
31
- return (
32
- <ConnectedRouter history={history}>
33
- <LabWithRoute id={labId} />
34
- </ConnectedRouter>
35
- );
36
- }
37
-
38
- renderLab() {
39
- return <Laboratory id={this.props.labId} />;
40
- }
41
-
42
- renderContent() {
43
- if (this.props.useRouter) {
44
- return this.renderLabWithRouter();
45
- }
46
- return this.renderLab();
47
- }
48
-
49
- render() {
50
- return <Provider store={this.props.store}>{this.renderContent()}</Provider>;
51
- }
52
- }
53
-
54
- export default Root;
1
+ //T:2019-02-27
2
+
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+
6
+ import {Provider} from 'react-redux';
7
+ import {ConnectedRouter} from 'connected-react-router/immutable';
8
+ import Widget from 'goblin-laboratory/widgets/widget';
9
+ import Laboratory from '../laboratory/widget';
10
+
11
+ class Root extends React.PureComponent {
12
+ getChildContext() {
13
+ return {
14
+ labId: this.props.labId,
15
+ dispatch: this.props.store.dispatch,
16
+ store: this.props.store,
17
+ };
18
+ }
19
+
20
+ static get childContextTypes() {
21
+ return {
22
+ labId: PropTypes.string,
23
+ dispatch: PropTypes.func,
24
+ store: PropTypes.object,
25
+ };
26
+ }
27
+
28
+ renderLabWithRouter() {
29
+ const {history, labId} = this.props;
30
+ const LabWithRoute = Widget.withRoute('/')(Laboratory);
31
+ return (
32
+ <ConnectedRouter history={history}>
33
+ <LabWithRoute id={labId} />
34
+ </ConnectedRouter>
35
+ );
36
+ }
37
+
38
+ renderLab() {
39
+ return <Laboratory id={this.props.labId} />;
40
+ }
41
+
42
+ renderContent() {
43
+ if (this.props.useRouter) {
44
+ return this.renderLabWithRouter();
45
+ }
46
+ return this.renderLab();
47
+ }
48
+
49
+ render() {
50
+ return <Provider store={this.props.store}>{this.renderContent()}</Provider>;
51
+ }
52
+ }
53
+
54
+ export default Root;
@@ -1,68 +1,68 @@
1
- //T:2019-02-27
2
- import React from 'react';
3
- import Widget from 'goblin-laboratory/widgets/widget';
4
- import {
5
- SearchkitManager,
6
- SearchkitProvider,
7
- SearchBox,
8
- HitsStats,
9
- Hits,
10
- } from 'searchkit';
11
-
12
- class SearchKit extends Widget {
13
- constructor() {
14
- super(...arguments);
15
- }
16
- renderHits(props) {
17
- console.dir(props.hits);
18
- return (
19
- <div>
20
- {props.hits.map((h, i) => (
21
- <div key={i}>
22
- {Object.keys(h._source).map((k, i) => (
23
- <div key={i}>
24
- {k}: {h._source[k]}
25
- </div>
26
- ))}
27
- <hr />
28
- </div>
29
- ))}
30
- </div>
31
- );
32
- }
33
-
34
- render() {
35
- const {index, fields} = this.props;
36
- this.searchkit = new SearchkitManager(`http://localhost:9200/${index}/`);
37
- this.searchkit.setQueryProcessor((q) => {
38
- if (!q.query) {
39
- return q;
40
- }
41
- const query = {
42
- query: {
43
- multi_match: {
44
- query: q.query.simple_query_string.query,
45
- fields: q.query.simple_query_string.fields,
46
- },
47
- },
48
- };
49
- console.dir(query);
50
- return query;
51
- });
52
- return (
53
- <SearchkitProvider searchkit={this.searchkit}>
54
- <div>
55
- <SearchBox searchOnChange={true} queryFields={fields} />
56
- <HitsStats />
57
- <Hits
58
- hitsPerPage={50}
59
- listComponent={this.renderHits}
60
- highlightFields={fields}
61
- />
62
- </div>
63
- </SearchkitProvider>
64
- );
65
- }
66
- }
67
-
68
- export default SearchKit;
1
+ //T:2019-02-27
2
+ import React from 'react';
3
+ import Widget from 'goblin-laboratory/widgets/widget';
4
+ import {
5
+ SearchkitManager,
6
+ SearchkitProvider,
7
+ SearchBox,
8
+ HitsStats,
9
+ Hits,
10
+ } from 'searchkit';
11
+
12
+ class SearchKit extends Widget {
13
+ constructor() {
14
+ super(...arguments);
15
+ }
16
+ renderHits(props) {
17
+ console.dir(props.hits);
18
+ return (
19
+ <div>
20
+ {props.hits.map((h, i) => (
21
+ <div key={i}>
22
+ {Object.keys(h._source).map((k, i) => (
23
+ <div key={i}>
24
+ {k}: {h._source[k]}
25
+ </div>
26
+ ))}
27
+ <hr />
28
+ </div>
29
+ ))}
30
+ </div>
31
+ );
32
+ }
33
+
34
+ render() {
35
+ const {index, fields} = this.props;
36
+ this.searchkit = new SearchkitManager(`http://localhost:9200/${index}/`);
37
+ this.searchkit.setQueryProcessor((q) => {
38
+ if (!q.query) {
39
+ return q;
40
+ }
41
+ const query = {
42
+ query: {
43
+ multi_match: {
44
+ query: q.query.simple_query_string.query,
45
+ fields: q.query.simple_query_string.fields,
46
+ },
47
+ },
48
+ };
49
+ console.dir(query);
50
+ return query;
51
+ });
52
+ return (
53
+ <SearchkitProvider searchkit={this.searchkit}>
54
+ <div>
55
+ <SearchBox searchOnChange={true} queryFields={fields} />
56
+ <HitsStats />
57
+ <Hits
58
+ hitsPerPage={50}
59
+ listComponent={this.renderHits}
60
+ highlightFields={fields}
61
+ />
62
+ </div>
63
+ </SearchkitProvider>
64
+ );
65
+ }
66
+ }
67
+
68
+ export default SearchKit;
@@ -1,116 +1,116 @@
1
- //T:2019-02-27
2
- import patch from 'immutablepatch';
3
- import {fromJS} from 'immutable';
4
- import Shredder from 'xcraft-core-shredder';
5
- import importer from 'goblin_importer';
6
-
7
- const compensatorImporter = importer('compensator');
8
-
9
- function injectActionDataGetter(action) {
10
- action.get = (key) => {
11
- if (action.data) {
12
- if (Shredder.isImmutable(action.data[key])) {
13
- return new Shredder(action.data[key]);
14
- }
15
- return action.data[key];
16
- }
17
- return null;
18
- };
19
- }
20
-
21
- let prevState = fromJS({});
22
-
23
- /* Apply compensators with a debounce of 500ms */
24
- function applyCompensators(state, action) {
25
- const ids = Object.keys(action.compensatorStates);
26
- if (!ids.length) {
27
- return state;
28
- }
29
-
30
- const timestamp = new Date().getTime() - 500;
31
-
32
- ids.forEach((id) => {
33
- const comp = action.compensatorStates[id];
34
- if (timestamp > comp.timestamp) {
35
- delete action.compensatorStates[id];
36
- }
37
-
38
- if (!action.data) {
39
- return;
40
- }
41
-
42
- const serviceState = state.get(id);
43
- const newServiceState = comp.reducer(
44
- new Shredder(serviceState),
45
- comp.action
46
- );
47
-
48
- state = state.set(id, newServiceState.state);
49
- });
50
-
51
- return state;
52
- }
53
-
54
- export default (state = fromJS({}), action = {}) => {
55
- // Compensate field change
56
- if (action.type === 'FIELD-CHANGED' && action.path.startsWith('backend.')) {
57
- const path = action.path.split('.').slice(1);
58
- return state.setIn(path, Shredder.toImmutable(action.value));
59
- }
60
-
61
- if (action.type === 'COMPENSATORS') {
62
- return applyCompensators(prevState, action);
63
- }
64
-
65
- if (action.type === 'NEW_BACKEND_STATE') {
66
- if (!action.data) {
67
- return state;
68
- }
69
-
70
- const generation = action.data.get('generation');
71
- const nextGeneration = action.nextGeneration;
72
-
73
- if (generation === nextGeneration) {
74
- state = action.data.get('_xcraftPatch')
75
- ? patch(prevState, action.data.get('state'))
76
- : action.data.get('state');
77
- prevState = state;
78
- }
79
-
80
- return applyCompensators(state, action);
81
- }
82
-
83
- if (action.type === 'QUEST') {
84
- const info = action.cmd.split('.');
85
- const widget = info[0];
86
- const _type = info[1];
87
- let reducer = null;
88
-
89
- if (widget.endsWith('-plugin')) {
90
- reducer = compensatorImporter('plugin');
91
- } else {
92
- reducer = compensatorImporter(widget);
93
- }
94
-
95
- if (reducer) {
96
- state = new Shredder(state);
97
- const backendState = state.get(action.data.id);
98
- const newAction = {
99
- type: _type,
100
- data: action.data,
101
- };
102
- injectActionDataGetter(newAction);
103
- const newServiceState = reducer(backendState, newAction);
104
- action.compensatorStates[action.data.id] = {
105
- action: newAction,
106
- reducer,
107
- timestamp: new Date().getTime(),
108
- };
109
- const newBackendState = state.set(action.data.id, newServiceState);
110
- return newBackendState.state;
111
- }
112
- return state;
113
- }
114
-
115
- return state;
116
- };
1
+ //T:2019-02-27
2
+ import patch from 'immutablepatch';
3
+ import {fromJS} from 'immutable';
4
+ import Shredder from 'xcraft-core-shredder';
5
+ import importer from 'goblin_importer';
6
+
7
+ const compensatorImporter = importer('compensator');
8
+
9
+ function injectActionDataGetter(action) {
10
+ action.get = (key) => {
11
+ if (action.data) {
12
+ if (Shredder.isImmutable(action.data[key])) {
13
+ return new Shredder(action.data[key]);
14
+ }
15
+ return action.data[key];
16
+ }
17
+ return null;
18
+ };
19
+ }
20
+
21
+ let prevState = fromJS({});
22
+
23
+ /* Apply compensators with a debounce of 500ms */
24
+ function applyCompensators(state, action) {
25
+ const ids = Object.keys(action.compensatorStates);
26
+ if (!ids.length) {
27
+ return state;
28
+ }
29
+
30
+ const timestamp = new Date().getTime() - 500;
31
+
32
+ ids.forEach((id) => {
33
+ const comp = action.compensatorStates[id];
34
+ if (timestamp > comp.timestamp) {
35
+ delete action.compensatorStates[id];
36
+ }
37
+
38
+ if (!action.data) {
39
+ return;
40
+ }
41
+
42
+ const serviceState = state.get(id);
43
+ const newServiceState = comp.reducer(
44
+ new Shredder(serviceState),
45
+ comp.action
46
+ );
47
+
48
+ state = state.set(id, newServiceState.state);
49
+ });
50
+
51
+ return state;
52
+ }
53
+
54
+ export default (state = fromJS({}), action = {}) => {
55
+ // Compensate field change
56
+ if (action.type === 'FIELD-CHANGED' && action.path.startsWith('backend.')) {
57
+ const path = action.path.split('.').slice(1);
58
+ return state.setIn(path, Shredder.toImmutable(action.value));
59
+ }
60
+
61
+ if (action.type === 'COMPENSATORS') {
62
+ return applyCompensators(prevState, action);
63
+ }
64
+
65
+ if (action.type === 'NEW_BACKEND_STATE') {
66
+ if (!action.data) {
67
+ return state;
68
+ }
69
+
70
+ const generation = action.data.get('generation');
71
+ const nextGeneration = action.nextGeneration;
72
+
73
+ if (generation === nextGeneration) {
74
+ state = action.data.get('_xcraftPatch')
75
+ ? patch(prevState, action.data.get('state'))
76
+ : action.data.get('state');
77
+ prevState = state;
78
+ }
79
+
80
+ return applyCompensators(state, action);
81
+ }
82
+
83
+ if (action.type === 'QUEST') {
84
+ const info = action.cmd.split('.');
85
+ const widget = info[0];
86
+ const _type = info[1];
87
+ let reducer = null;
88
+
89
+ if (widget.endsWith('-plugin')) {
90
+ reducer = compensatorImporter('plugin');
91
+ } else {
92
+ reducer = compensatorImporter(widget);
93
+ }
94
+
95
+ if (reducer) {
96
+ state = new Shredder(state);
97
+ const backendState = state.get(action.data.id);
98
+ const newAction = {
99
+ type: _type,
100
+ data: action.data,
101
+ };
102
+ injectActionDataGetter(newAction);
103
+ const newServiceState = reducer(backendState, newAction);
104
+ action.compensatorStates[action.data.id] = {
105
+ action: newAction,
106
+ reducer,
107
+ timestamp: new Date().getTime(),
108
+ };
109
+ const newBackendState = state.set(action.data.id, newServiceState);
110
+ return newBackendState.state;
111
+ }
112
+ return state;
113
+ }
114
+
115
+ return state;
116
+ };
@@ -1,14 +1,14 @@
1
- //T:2019-02-27
2
- import {fromJS} from 'immutable';
3
-
4
- const initialState = fromJS({
5
- registry: {},
6
- });
7
-
8
- export default (state = initialState, action = {}) => {
9
- if (action.type === 'COMMANDS_REGISTRY') {
10
- return state.set('registry', action.commands);
11
- }
12
-
13
- return state;
14
- };
1
+ //T:2019-02-27
2
+ import {fromJS} from 'immutable';
3
+
4
+ const initialState = fromJS({
5
+ registry: {},
6
+ });
7
+
8
+ export default (state = initialState, action = {}) => {
9
+ if (action.type === 'COMMANDS_REGISTRY') {
10
+ return state.set('registry', action.commands);
11
+ }
12
+
13
+ return state;
14
+ };