@modern-js/plugin-state 1.1.3 → 1.1.4-rc.0
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @modern-js/plugin-state
|
|
2
2
|
|
|
3
|
+
## 1.1.4-rc.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4a281912: fix: app init function not work
|
|
8
|
+
- Updated dependencies [4a281912]
|
|
9
|
+
- Updated dependencies [4a281912]
|
|
10
|
+
- Updated dependencies [eb026119]
|
|
11
|
+
- @modern-js/runtime-core@1.1.3-rc.0
|
|
12
|
+
- @modern-js/core@1.2.1-rc.0
|
|
13
|
+
|
|
3
14
|
## 1.1.3
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -9,21 +9,25 @@ import { useContext } from 'react';
|
|
|
9
9
|
import { createPlugin, RuntimeReactContext } from '@modern-js/runtime-core';
|
|
10
10
|
import { createStore } from '@modern-js-reduck/store';
|
|
11
11
|
import { Provider } from '@modern-js-reduck/react';
|
|
12
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
|
|
14
15
|
const state = config => createPlugin(() => ({
|
|
15
16
|
hoc({
|
|
16
17
|
App
|
|
17
18
|
}, next) {
|
|
19
|
+
const getStateApp = props => {
|
|
20
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
21
|
+
const context = useContext(RuntimeReactContext);
|
|
22
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
23
|
+
store: context.store,
|
|
24
|
+
config: config,
|
|
25
|
+
children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
18
29
|
return next({
|
|
19
|
-
App:
|
|
20
|
-
const context = useContext(RuntimeReactContext);
|
|
21
|
-
return /*#__PURE__*/_jsx(Provider, {
|
|
22
|
-
store: context.store,
|
|
23
|
-
config: config,
|
|
24
|
-
children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
|
|
25
|
-
});
|
|
26
|
-
}
|
|
30
|
+
App: hoistNonReactStatics(getStateApp, App)
|
|
27
31
|
});
|
|
28
32
|
},
|
|
29
33
|
|
|
@@ -14,6 +14,8 @@ var _store = require("@modern-js-reduck/store");
|
|
|
14
14
|
|
|
15
15
|
var _react2 = require("@modern-js-reduck/react");
|
|
16
16
|
|
|
17
|
+
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
18
|
+
|
|
17
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
20
|
|
|
19
21
|
var _plugins = require("../plugins");
|
|
@@ -30,6 +32,8 @@ Object.keys(_plugins).forEach(function (key) {
|
|
|
30
32
|
});
|
|
31
33
|
});
|
|
32
34
|
|
|
35
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
|
+
|
|
33
37
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
38
|
|
|
35
39
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -40,15 +44,18 @@ const state = config => (0, _runtimeCore.createPlugin)(() => ({
|
|
|
40
44
|
hoc({
|
|
41
45
|
App
|
|
42
46
|
}, next) {
|
|
47
|
+
const getStateApp = props => {
|
|
48
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
49
|
+
const context = (0, _react.useContext)(_runtimeCore.RuntimeReactContext);
|
|
50
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Provider, {
|
|
51
|
+
store: context.store,
|
|
52
|
+
config: config,
|
|
53
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
43
57
|
return next({
|
|
44
|
-
App:
|
|
45
|
-
const context = (0, _react.useContext)(_runtimeCore.RuntimeReactContext);
|
|
46
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.Provider, {
|
|
47
|
-
store: context.store,
|
|
48
|
-
config: config,
|
|
49
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(App, _objectSpread({}, props))
|
|
50
|
-
});
|
|
51
|
-
}
|
|
58
|
+
App: (0, _hoistNonReactStatics.default)(getStateApp, App)
|
|
52
59
|
});
|
|
53
60
|
},
|
|
54
61
|
|
|
@@ -9,22 +9,27 @@ import { useContext } from 'react';
|
|
|
9
9
|
import { createPlugin, RuntimeReactContext } from '@modern-js/runtime-core';
|
|
10
10
|
import { createStore } from '@modern-js-reduck/store';
|
|
11
11
|
import { Provider } from '@modern-js-reduck/react';
|
|
12
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
|
|
14
15
|
var state = function state(config) {
|
|
15
16
|
return createPlugin(function () {
|
|
16
17
|
return {
|
|
17
18
|
hoc: function hoc(_ref, next) {
|
|
18
|
-
var
|
|
19
|
+
var App = _ref.App;
|
|
20
|
+
|
|
21
|
+
var getStateApp = function getStateApp(props) {
|
|
22
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
23
|
+
var context = useContext(RuntimeReactContext);
|
|
24
|
+
return /*#__PURE__*/_jsx(Provider, {
|
|
25
|
+
store: context.store,
|
|
26
|
+
config: config,
|
|
27
|
+
children: /*#__PURE__*/_jsx(App, _objectSpread({}, props))
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
19
31
|
return next({
|
|
20
|
-
App:
|
|
21
|
-
var context = useContext(RuntimeReactContext);
|
|
22
|
-
return /*#__PURE__*/_jsx(Provider, {
|
|
23
|
-
store: context.store,
|
|
24
|
-
config: config,
|
|
25
|
-
children: /*#__PURE__*/_jsx(_App, _objectSpread({}, props))
|
|
26
|
-
});
|
|
27
|
-
}
|
|
32
|
+
App: hoistNonReactStatics(getStateApp, App)
|
|
28
33
|
});
|
|
29
34
|
},
|
|
30
35
|
init: function init(_ref2, next) {
|
|
@@ -30,7 +30,7 @@ declare const state: (config: PluginProps) => import("@modern-js/plugin").Plugin
|
|
|
30
30
|
App: import("react").ComponentType<any>;
|
|
31
31
|
context?: import("@modern-js/runtime-core").RuntimeContext | undefined;
|
|
32
32
|
}, string>;
|
|
33
|
-
init: import("@modern-js/runtime-core").
|
|
33
|
+
init: import("@modern-js/runtime-core").AsyncPipeline<{
|
|
34
34
|
context: import("@modern-js/runtime-core").RuntimeContext;
|
|
35
35
|
}, unknown>;
|
|
36
36
|
pickContext: import("@modern-js/runtime-core").Pipeline<{
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.
|
|
14
|
+
"version": "1.1.4-rc.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/runtime/index.js",
|
|
@@ -53,26 +53,28 @@
|
|
|
53
53
|
"@modern-js-reduck/react": "^1.0.0",
|
|
54
54
|
"@modern-js-reduck/store": "^1.0.0",
|
|
55
55
|
"@types/redux-logger": "^3.0.9",
|
|
56
|
-
"redux-logger": "^3.0.6"
|
|
56
|
+
"redux-logger": "^3.0.6",
|
|
57
|
+
"hoist-non-react-statics": "^3.3.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@modern-js/core": "^1.2.0",
|
|
60
|
+
"@modern-js/core": "^1.2.1-rc.0",
|
|
60
61
|
"@modern-js/plugin": "^1.1.2",
|
|
61
|
-
"@modern-js/runtime-core": "^1.1.
|
|
62
|
-
"@modern-js/utils": "^1.1.
|
|
62
|
+
"@modern-js/runtime-core": "^1.1.3-rc.0",
|
|
63
|
+
"@modern-js/utils": "^1.1.6-rc.0",
|
|
64
|
+
"@types/hoist-non-react-statics": "^3.3.1",
|
|
63
65
|
"@types/jest": "^26",
|
|
64
66
|
"@types/node": "^14",
|
|
65
67
|
"@types/react": "^17",
|
|
66
68
|
"@types/react-dom": "^17",
|
|
67
69
|
"react": "^17.0.2",
|
|
68
70
|
"typescript": "^4",
|
|
69
|
-
"@modern-js/plugin-testing": "^1.
|
|
70
|
-
"@modern-js/module-tools": "^1.1.
|
|
71
|
+
"@modern-js/plugin-testing": "^1.2.2",
|
|
72
|
+
"@modern-js/module-tools": "^1.1.4"
|
|
71
73
|
},
|
|
72
74
|
"sideEffects": false,
|
|
73
75
|
"peerDependencies": {
|
|
74
|
-
"@modern-js/core": "^1.2.0",
|
|
75
|
-
"@modern-js/runtime-core": "^1.1.
|
|
76
|
+
"@modern-js/core": "^1.2.1-rc.0",
|
|
77
|
+
"@modern-js/runtime-core": "^1.1.3-rc.0",
|
|
76
78
|
"react": "^17.0.2"
|
|
77
79
|
},
|
|
78
80
|
"modernConfig": {},
|
package/src/runtime/plugin.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useContext } from 'react';
|
|
|
3
3
|
import { createPlugin, RuntimeReactContext } from '@modern-js/runtime-core';
|
|
4
4
|
import { createStore, Store } from '@modern-js-reduck/store';
|
|
5
5
|
import { Provider } from '@modern-js-reduck/react';
|
|
6
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
6
7
|
|
|
7
8
|
declare module '@modern-js/runtime-core' {
|
|
8
9
|
interface RuntimeContext {
|
|
@@ -24,16 +25,18 @@ const state = (config: PluginProps) =>
|
|
|
24
25
|
createPlugin(
|
|
25
26
|
() => ({
|
|
26
27
|
hoc({ App }, next) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const getStateApp = (props: any) => {
|
|
29
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
30
|
+
const context = useContext(RuntimeReactContext);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
return (
|
|
33
|
+
<Provider store={context.store} config={config}>
|
|
34
|
+
<App {...props} />
|
|
35
|
+
</Provider>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
return next({
|
|
39
|
+
App: hoistNonReactStatics(getStateApp, App),
|
|
37
40
|
});
|
|
38
41
|
},
|
|
39
42
|
init({ context }, next) {
|