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,40 +1,40 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
4
|
-
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
5
|
-
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
|
6
|
-
|
|
7
|
-
class DisconnectOverlay extends Widget {
|
|
8
|
-
constructor() {
|
|
9
|
-
super(...arguments);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
render() {
|
|
13
|
-
const {message} = this.props;
|
|
14
|
-
|
|
15
|
-
const fullScreenClass = this.styles.classNames.fullScreen;
|
|
16
|
-
const blinkClass = this.styles.classNames.blink;
|
|
17
|
-
const messageClass = this.styles.classNames.message;
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
<div className={fullScreenClass}>
|
|
22
|
-
<div className={blinkClass}>
|
|
23
|
-
<FontAwesomeIcon icon={['fas', 'network-wired']} size="10x" />
|
|
24
|
-
</div>
|
|
25
|
-
<Label
|
|
26
|
-
className={messageClass}
|
|
27
|
-
height="200px"
|
|
28
|
-
justify="center"
|
|
29
|
-
kind="footer"
|
|
30
|
-
fontSize="300%"
|
|
31
|
-
text={message}
|
|
32
|
-
/>
|
|
33
|
-
</div>
|
|
34
|
-
{this.props.children}
|
|
35
|
-
</>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default DisconnectOverlay;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
4
|
+
import Label from 'goblin-gadgets/widgets/label/widget';
|
|
5
|
+
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
|
6
|
+
|
|
7
|
+
class DisconnectOverlay extends Widget {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
const {message} = this.props;
|
|
14
|
+
|
|
15
|
+
const fullScreenClass = this.styles.classNames.fullScreen;
|
|
16
|
+
const blinkClass = this.styles.classNames.blink;
|
|
17
|
+
const messageClass = this.styles.classNames.message;
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<div className={fullScreenClass}>
|
|
22
|
+
<div className={blinkClass}>
|
|
23
|
+
<FontAwesomeIcon icon={['fas', 'network-wired']} size="10x" />
|
|
24
|
+
</div>
|
|
25
|
+
<Label
|
|
26
|
+
className={messageClass}
|
|
27
|
+
height="200px"
|
|
28
|
+
justify="center"
|
|
29
|
+
kind="footer"
|
|
30
|
+
fontSize="300%"
|
|
31
|
+
text={message}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
{this.props.children}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default DisconnectOverlay;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
4
|
-
|
|
5
|
-
export default class FieldsView extends Widget {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.view = {};
|
|
9
|
-
this.register = this.register.bind(this);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
register(fieldPath) {
|
|
13
|
-
this.view[fieldPath] = true;
|
|
14
|
-
console.table(this.view);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
getChildContext() {
|
|
18
|
-
return {
|
|
19
|
-
model: this.props.model,
|
|
20
|
-
register: this.register,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static get childContextTypes() {
|
|
25
|
-
return {
|
|
26
|
-
model: PropTypes.string,
|
|
27
|
-
register: PropTypes.func,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
return <>{this.props.children}</>;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
4
|
+
|
|
5
|
+
export default class FieldsView extends Widget {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.view = {};
|
|
9
|
+
this.register = this.register.bind(this);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
register(fieldPath) {
|
|
13
|
+
this.view[fieldPath] = true;
|
|
14
|
+
console.table(this.view);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getChildContext() {
|
|
18
|
+
return {
|
|
19
|
+
model: this.props.model,
|
|
20
|
+
register: this.register,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static get childContextTypes() {
|
|
25
|
+
return {
|
|
26
|
+
model: PropTypes.string,
|
|
27
|
+
register: PropTypes.func,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
return <>{this.props.children}</>;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/widgets/form/index.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
//T:2019-02-27
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
5
|
-
import WithModel from '../with-model/widget';
|
|
6
|
-
|
|
7
|
-
/******************************************************************************/
|
|
8
|
-
|
|
9
|
-
// TODO: Adapt code that use it and remove it
|
|
10
|
-
const FormComponent = (props) => {
|
|
11
|
-
const {
|
|
12
|
-
component: Component,
|
|
13
|
-
model,
|
|
14
|
-
children,
|
|
15
|
-
validateOn,
|
|
16
|
-
...otherProps
|
|
17
|
-
} = props;
|
|
18
|
-
return (
|
|
19
|
-
<WithModel model={model}>
|
|
20
|
-
<Component {...otherProps}>{children}</Component>
|
|
21
|
-
</WithModel>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/******************************************************************************/
|
|
26
|
-
|
|
27
|
-
class Form extends Widget {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
get Form() {
|
|
33
|
-
return FormComponent;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get formConfig() {
|
|
37
|
-
const style = {
|
|
38
|
-
display: 'flex',
|
|
39
|
-
flexDirection: 'column',
|
|
40
|
-
};
|
|
41
|
-
const id = this.props.id ? this.props.id : this.context.id;
|
|
42
|
-
return {
|
|
43
|
-
component: 'div',
|
|
44
|
-
validateOn: 'submit',
|
|
45
|
-
model: `backend.${id}`,
|
|
46
|
-
style,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
get formConfigWithoutStyle() {
|
|
51
|
-
const id = this.props.id ? this.props.id : this.context.id;
|
|
52
|
-
return {
|
|
53
|
-
component: React.Fragment,
|
|
54
|
-
validateOn: 'submit',
|
|
55
|
-
model: `backend.${id}`,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
formConfigWithComponent(component) {
|
|
60
|
-
// FIXME: use aphrodite
|
|
61
|
-
const style = {
|
|
62
|
-
display: 'flex',
|
|
63
|
-
flexDirection: 'column',
|
|
64
|
-
};
|
|
65
|
-
const id = this.props.id ? this.props.id : this.context.id;
|
|
66
|
-
return {
|
|
67
|
-
component: component,
|
|
68
|
-
validateOn: 'submit',
|
|
69
|
-
model: `backend.${id}`,
|
|
70
|
-
style,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
render() {
|
|
75
|
-
return <div>Missing widget implementation</div>;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default Form;
|
|
1
|
+
//T:2019-02-27
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
5
|
+
import WithModel from '../with-model/widget';
|
|
6
|
+
|
|
7
|
+
/******************************************************************************/
|
|
8
|
+
|
|
9
|
+
// TODO: Adapt code that use it and remove it
|
|
10
|
+
const FormComponent = (props) => {
|
|
11
|
+
const {
|
|
12
|
+
component: Component,
|
|
13
|
+
model,
|
|
14
|
+
children,
|
|
15
|
+
validateOn,
|
|
16
|
+
...otherProps
|
|
17
|
+
} = props;
|
|
18
|
+
return (
|
|
19
|
+
<WithModel model={model}>
|
|
20
|
+
<Component {...otherProps}>{children}</Component>
|
|
21
|
+
</WithModel>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/******************************************************************************/
|
|
26
|
+
|
|
27
|
+
class Form extends Widget {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get Form() {
|
|
33
|
+
return FormComponent;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get formConfig() {
|
|
37
|
+
const style = {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
};
|
|
41
|
+
const id = this.props.id ? this.props.id : this.context.id;
|
|
42
|
+
return {
|
|
43
|
+
component: 'div',
|
|
44
|
+
validateOn: 'submit',
|
|
45
|
+
model: `backend.${id}`,
|
|
46
|
+
style,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get formConfigWithoutStyle() {
|
|
51
|
+
const id = this.props.id ? this.props.id : this.context.id;
|
|
52
|
+
return {
|
|
53
|
+
component: React.Fragment,
|
|
54
|
+
validateOn: 'submit',
|
|
55
|
+
model: `backend.${id}`,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
formConfigWithComponent(component) {
|
|
60
|
+
// FIXME: use aphrodite
|
|
61
|
+
const style = {
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'column',
|
|
64
|
+
};
|
|
65
|
+
const id = this.props.id ? this.props.id : this.context.id;
|
|
66
|
+
return {
|
|
67
|
+
component: component,
|
|
68
|
+
validateOn: 'submit',
|
|
69
|
+
model: `backend.${id}`,
|
|
70
|
+
style,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
render() {
|
|
75
|
+
return <div>Missing widget implementation</div>;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export default Form;
|
package/widgets/frame/widget.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
//T:2019-02-27
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
import ThemeContext from '../theme-context/widget';
|
|
6
|
-
import {Provider} from 'react-redux';
|
|
7
|
-
|
|
8
|
-
class Frame extends React.PureComponent {
|
|
9
|
-
getChildContext() {
|
|
10
|
-
return {
|
|
11
|
-
labId: this.props.labId,
|
|
12
|
-
dispatch: this.props.store.dispatch,
|
|
13
|
-
store: this.props.store,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static get childContextTypes() {
|
|
18
|
-
return {
|
|
19
|
-
labId: PropTypes.string,
|
|
20
|
-
dispatch: PropTypes.func,
|
|
21
|
-
store: PropTypes.object,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
render() {
|
|
26
|
-
const {labId, store, currentTheme, themeContext, desktopId} = this.props;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<div
|
|
30
|
-
className={`root-${labId.replace(/@/g, '-')}`}
|
|
31
|
-
style={this.props.style}
|
|
32
|
-
>
|
|
33
|
-
<Provider store={store}>
|
|
34
|
-
<ThemeContext
|
|
35
|
-
labId={labId}
|
|
36
|
-
themeContext={themeContext}
|
|
37
|
-
currentTheme={currentTheme}
|
|
38
|
-
>
|
|
39
|
-
{this.props.children}
|
|
40
|
-
</ThemeContext>
|
|
41
|
-
</Provider>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default Frame;
|
|
1
|
+
//T:2019-02-27
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import ThemeContext from '../theme-context/widget';
|
|
6
|
+
import {Provider} from 'react-redux';
|
|
7
|
+
|
|
8
|
+
class Frame extends React.PureComponent {
|
|
9
|
+
getChildContext() {
|
|
10
|
+
return {
|
|
11
|
+
labId: this.props.labId,
|
|
12
|
+
dispatch: this.props.store.dispatch,
|
|
13
|
+
store: this.props.store,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static get childContextTypes() {
|
|
18
|
+
return {
|
|
19
|
+
labId: PropTypes.string,
|
|
20
|
+
dispatch: PropTypes.func,
|
|
21
|
+
store: PropTypes.object,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
const {labId, store, currentTheme, themeContext, desktopId} = this.props;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className={`root-${labId.replace(/@/g, '-')}`}
|
|
31
|
+
style={this.props.style}
|
|
32
|
+
>
|
|
33
|
+
<Provider store={store}>
|
|
34
|
+
<ThemeContext
|
|
35
|
+
labId={labId}
|
|
36
|
+
themeContext={themeContext}
|
|
37
|
+
currentTheme={currentTheme}
|
|
38
|
+
>
|
|
39
|
+
{this.props.children}
|
|
40
|
+
</ThemeContext>
|
|
41
|
+
</Provider>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Frame;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import Shredder from 'xcraft-core-shredder';
|
|
2
|
-
|
|
3
|
-
const initialState = new Shredder({});
|
|
4
|
-
|
|
5
|
-
export default (state = initialState, action = {}) => {
|
|
6
|
-
switch (action.type) {
|
|
7
|
-
case 'INIT': {
|
|
8
|
-
if (state.equals(initialState) && action.initialState !== undefined) {
|
|
9
|
-
return state.set('', action.initialState);
|
|
10
|
-
}
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
13
|
-
case 'CHANGE': {
|
|
14
|
-
return state.set(action.path, action.newValue);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return state;
|
|
18
|
-
};
|
|
1
|
+
import Shredder from 'xcraft-core-shredder';
|
|
2
|
+
|
|
3
|
+
const initialState = new Shredder({});
|
|
4
|
+
|
|
5
|
+
export default (state = initialState, action = {}) => {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case 'INIT': {
|
|
8
|
+
if (state.equals(initialState) && action.initialState !== undefined) {
|
|
9
|
+
return state.set('', action.initialState);
|
|
10
|
+
}
|
|
11
|
+
return state;
|
|
12
|
+
}
|
|
13
|
+
case 'CHANGE': {
|
|
14
|
+
return state.set(action.path, action.newValue);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return state;
|
|
18
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Widget from 'goblin-laboratory/widgets/widget';
|
|
3
|
-
import WithModel from '../with-model/widget';
|
|
4
|
-
|
|
5
|
-
export default class FrontendForm extends Widget {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
render() {
|
|
11
|
-
const path = `widgets.${this.props.widgetId}`;
|
|
12
|
-
|
|
13
|
-
return <WithModel model={path}>{this.props.children}</WithModel>;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Widget from 'goblin-laboratory/widgets/widget';
|
|
3
|
+
import WithModel from '../with-model/widget';
|
|
4
|
+
|
|
5
|
+
export default class FrontendForm extends Widget {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
render() {
|
|
11
|
+
const path = `widgets.${this.props.widgetId}`;
|
|
12
|
+
|
|
13
|
+
return <WithModel model={path}>{this.props.children}</WithModel>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// prettier-ignore
|
|
2
|
-
const defaultConfig = {
|
|
3
|
-
'tasks': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/tasks\.js$/),
|
|
4
|
-
'view': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/view\.js$/),
|
|
5
|
-
'partial': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/partial\.js$/),
|
|
6
|
-
'styles': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/styles\.js$/),
|
|
7
|
-
'widget': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/widget\.js$/),
|
|
8
|
-
'ui': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/ui\.js$/),
|
|
9
|
-
'reducer': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/reducer\.js$/),
|
|
10
|
-
'compensator': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/compensator\.js$/),
|
|
11
|
-
'theme-context': require.context('../../../../node_modules/', true, /\/widgets\/theme-context\/index\.js$/),
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default defaultConfig;
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
const defaultConfig = {
|
|
3
|
+
'tasks': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/tasks\.js$/),
|
|
4
|
+
'view': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/view\.js$/),
|
|
5
|
+
'partial': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/partial\.js$/),
|
|
6
|
+
'styles': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/styles\.js$/),
|
|
7
|
+
'widget': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/widget\.js$/),
|
|
8
|
+
'ui': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/ui\.js$/),
|
|
9
|
+
'reducer': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/reducer\.js$/),
|
|
10
|
+
'compensator': require.context('../../../../node_modules/', true, /\/widgets\/[^/]+\/compensator\.js$/),
|
|
11
|
+
'theme-context': require.context('../../../../node_modules/', true, /\/widgets\/theme-context\/index\.js$/),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default defaultConfig;
|
|
@@ -1,53 +1,54 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
export default function importer(config) {
|
|
4
|
-
const cache = {};
|
|
5
|
-
|
|
6
|
-
const importAll = (kind, r) => {
|
|
7
|
-
cache[kind] = {};
|
|
8
|
-
|
|
9
|
-
if (r) {
|
|
10
|
-
const files = r.keys();
|
|
11
|
-
files.forEach((file) => {
|
|
12
|
-
let nameSpace;
|
|
13
|
-
switch (kind) {
|
|
14
|
-
case '
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
export default function importer(config) {
|
|
4
|
+
const cache = {};
|
|
5
|
+
|
|
6
|
+
const importAll = (kind, r) => {
|
|
7
|
+
cache[kind] = {};
|
|
8
|
+
|
|
9
|
+
if (r) {
|
|
10
|
+
const files = r.keys();
|
|
11
|
+
files.forEach((file) => {
|
|
12
|
+
let nameSpace;
|
|
13
|
+
switch (kind) {
|
|
14
|
+
case 'tutorials':
|
|
15
|
+
case 'file':
|
|
16
|
+
nameSpace = file.replace(/^[\\/.]+/, '').replace(/\\/g, '/');
|
|
17
|
+
break;
|
|
18
|
+
case 'theme-context':
|
|
19
|
+
nameSpace = file.replace(/.*[\\/.]goblin-([^\\/]+).*/, '$1');
|
|
20
|
+
break;
|
|
21
|
+
default:
|
|
22
|
+
nameSpace = path.basename(path.dirname(file));
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
cache[kind][nameSpace] = r(file);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getter = (kind) => (name, key) => {
|
|
31
|
+
if (!cache[kind][name]) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (key) {
|
|
35
|
+
return cache[kind][name][key];
|
|
36
|
+
}
|
|
37
|
+
return cache[kind][name].default ?? cache[kind][name];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (kind) => {
|
|
41
|
+
if (cache[kind]) {
|
|
42
|
+
return getter(kind);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!(kind in config)) {
|
|
46
|
+
throw new Error(`Unsupported kind: ${kind} for importer`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const r = config[kind];
|
|
50
|
+
importAll(kind, r);
|
|
51
|
+
|
|
52
|
+
return getter(kind);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import importer from './importer.js';
|
|
2
|
-
import defaultConfig from './default.js';
|
|
3
|
-
|
|
4
|
-
export default importer(defaultConfig);
|
|
1
|
+
import importer from './importer.js';
|
|
2
|
+
import defaultConfig from './default.js';
|
|
3
|
+
|
|
4
|
+
export default importer(defaultConfig);
|