react-cosmos 4.8.0-alpha.1 → 4.8.1
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/dist/client/next/index.js +3 -0
- package/dist/client/next/mount.js +6 -5
- package/dist/client/next/shared.js +8 -0
- package/dist/server/web/plugins/openFile.js +29 -0
- package/dist/server/web/start.js +15 -5
- package/dist/server/web/webpack/default-webpack-config.js +6 -1
- package/package.json +7 -5
|
@@ -6,12 +6,15 @@ var _errorOverlay = require("./errorOverlay");
|
|
|
6
6
|
|
|
7
7
|
var _globalErrorHandler = require("./globalErrorHandler");
|
|
8
8
|
|
|
9
|
+
var _shared = require("./shared");
|
|
10
|
+
|
|
9
11
|
var rendererId = (0, _rendererId.getRendererId)();
|
|
10
12
|
|
|
11
13
|
function mount() {
|
|
12
14
|
// Use dynamic import to load updated modules upon hot reloading
|
|
13
15
|
require('./mount').mount({
|
|
14
16
|
rendererId: rendererId,
|
|
17
|
+
rendererConfig: _shared.rendererConfig,
|
|
15
18
|
onFixtureChange: _errorOverlay.dismissErrorOverlay
|
|
16
19
|
});
|
|
17
20
|
}
|
|
@@ -19,8 +19,11 @@ var _userModules = require("./userModules");
|
|
|
19
19
|
|
|
20
20
|
var _ErrorCatch = require("./ErrorCatch");
|
|
21
21
|
|
|
22
|
-
function mount(
|
|
23
|
-
|
|
22
|
+
function mount(_ref) {
|
|
23
|
+
var rendererId = _ref.rendererId,
|
|
24
|
+
rendererConfig = _ref.rendererConfig,
|
|
25
|
+
onFixtureChange = _ref.onFixtureChange;
|
|
26
|
+
(0, _reactDom.render)(wrapSuitableAdaptor(createFixtureConnectRenderCb(rendererId, onFixtureChange)), (0, _dom.getDomContainer)(rendererConfig.containerQuerySelector));
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
function wrapSuitableAdaptor(element) {
|
|
@@ -33,9 +36,7 @@ function wrapSuitableAdaptor(element) {
|
|
|
33
36
|
}, element);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
function createFixtureConnectRenderCb(
|
|
37
|
-
var rendererId = _ref.rendererId,
|
|
38
|
-
onFixtureChange = _ref.onFixtureChange;
|
|
39
|
+
function createFixtureConnectRenderCb(rendererId, onFixtureChange) {
|
|
39
40
|
return function (_ref2) {
|
|
40
41
|
var subscribe = _ref2.subscribe,
|
|
41
42
|
unsubscribe = _ref2.unsubscribe,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = openFile;
|
|
9
|
+
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
|
|
12
|
+
var _opn = _interopRequireDefault(require("opn"));
|
|
13
|
+
|
|
14
|
+
function openFile(_ref) {
|
|
15
|
+
var app = _ref.app,
|
|
16
|
+
cosmosConfig = _ref.cosmosConfig;
|
|
17
|
+
app.get('/_open', function (req, res) {
|
|
18
|
+
var relPath = req.query.filePath;
|
|
19
|
+
|
|
20
|
+
if (typeof relPath !== 'string') {
|
|
21
|
+
throw new Error("Invalid path: ".concat(String(relPath)));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var absPath = _path.default.join(cosmosConfig.rootPath, relPath);
|
|
25
|
+
|
|
26
|
+
(0, _opn.default)(absPath);
|
|
27
|
+
res.send();
|
|
28
|
+
});
|
|
29
|
+
}
|
package/dist/server/web/start.js
CHANGED
|
@@ -23,6 +23,8 @@ var _socket = require("../shared/socket");
|
|
|
23
23
|
|
|
24
24
|
var _attachWebpack2 = require("./webpack/attach-webpack");
|
|
25
25
|
|
|
26
|
+
var _openFile = _interopRequireDefault(require("./plugins/openFile"));
|
|
27
|
+
|
|
26
28
|
var _playgroundOpts = require("./playground-opts");
|
|
27
29
|
|
|
28
30
|
function startServer() {
|
|
@@ -81,6 +83,14 @@ function _startServer() {
|
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
(0, _server.attachStackFrameEditorLauncher)(app);
|
|
86
|
+
|
|
87
|
+
if (next) {
|
|
88
|
+
(0, _openFile.default)({
|
|
89
|
+
app: app,
|
|
90
|
+
cosmosConfig: cosmosConfig
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
84
94
|
_attachWebpack = (0, _attachWebpack2.attachWebpack)({
|
|
85
95
|
cosmosConfig: cosmosConfig,
|
|
86
96
|
app: app,
|
|
@@ -88,14 +98,14 @@ function _startServer() {
|
|
|
88
98
|
userWebpackConfig: userWebpackConfig
|
|
89
99
|
}), onWebpackDone = _attachWebpack.onWebpackDone, stopWebpack = _attachWebpack.stopWebpack;
|
|
90
100
|
closeSockets = next ? (0, _socket.attachSockets)(server) : function () {};
|
|
91
|
-
_context2.next =
|
|
101
|
+
_context2.next = 20;
|
|
92
102
|
return startServer();
|
|
93
103
|
|
|
94
|
-
case
|
|
95
|
-
_context2.next =
|
|
104
|
+
case 20:
|
|
105
|
+
_context2.next = 22;
|
|
96
106
|
return onWebpackDone;
|
|
97
107
|
|
|
98
|
-
case
|
|
108
|
+
case 22:
|
|
99
109
|
return _context2.abrupt("return",
|
|
100
110
|
/*#__PURE__*/
|
|
101
111
|
(0, _asyncToGenerator2.default)(
|
|
@@ -121,7 +131,7 @@ function _startServer() {
|
|
|
121
131
|
}, _callee, this);
|
|
122
132
|
})));
|
|
123
133
|
|
|
124
|
-
case
|
|
134
|
+
case 23:
|
|
125
135
|
case "end":
|
|
126
136
|
return _context2.stop();
|
|
127
137
|
}
|
|
@@ -31,7 +31,12 @@ function getDefaultWebpackConfig(rootPath) {
|
|
|
31
31
|
rules.push({
|
|
32
32
|
test: /\.jsx?$/,
|
|
33
33
|
loader: babelLoaderPath,
|
|
34
|
-
exclude: /node_modules
|
|
34
|
+
exclude: [/node_modules/, // The following rules only apply in the monorepo. In a user codebase
|
|
35
|
+
// all react cosmos packages will match the node_modules pattern above
|
|
36
|
+
// TODO: Source files are still compiled by Babel when compiling
|
|
37
|
+
// renderer build inside Jest tests. In the future we should extract
|
|
38
|
+
// those high-level tests and always run them against built packages.
|
|
39
|
+
/packages(\/|\\)react-cosmos([a-z0-9-]*)(\/|\\)dist/, /packages(\/|\\)react-cosmos([a-z0-9-]*)(\/|\\)[a-z0-9-]+.js$/]
|
|
35
40
|
}); // This only applies to users who install `react-cosmos-flow`, which
|
|
36
41
|
// requires them to have Flow compilation included in their Babel config
|
|
37
42
|
// Deprecated by: https://github.com/react-cosmos/react-cosmos/pull/785
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.1",
|
|
4
4
|
"description": "CLI for running React Cosmos inside webpack-powered apps",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/master/packages/react-cosmos",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,19 +15,21 @@
|
|
|
15
15
|
"import-from": "^2.1.0",
|
|
16
16
|
"lodash": "^4.17.11",
|
|
17
17
|
"object.values": "^1.1.0",
|
|
18
|
+
"opn": "^5.5.0",
|
|
18
19
|
"react-cosmos-config": "^4.8.0-alpha.0",
|
|
19
|
-
"react-cosmos-fixture": "^4.8.
|
|
20
|
+
"react-cosmos-fixture": "^4.8.1",
|
|
20
21
|
"react-cosmos-loader": "^4.8.0-alpha.0",
|
|
21
22
|
"react-cosmos-playground": "^4.8.0-alpha.0",
|
|
22
|
-
"react-cosmos-playground2": "^4.8.
|
|
23
|
+
"react-cosmos-playground2": "^4.8.1",
|
|
23
24
|
"react-cosmos-shared": "^4.8.0-alpha.0",
|
|
24
|
-
"react-cosmos-shared2": "^4.8.
|
|
25
|
+
"react-cosmos-shared2": "^4.8.1",
|
|
25
26
|
"react-cosmos-voyager": "^4.8.0-alpha.0",
|
|
26
27
|
"react-cosmos-voyager2": "^4.8.0-alpha.0",
|
|
27
28
|
"react-dev-utils": "^6.1.1",
|
|
28
29
|
"react-error-overlay": "^5.1.2",
|
|
29
30
|
"resolve-from": "^4.0.0",
|
|
30
31
|
"socket.io": "^2.2.0",
|
|
32
|
+
"util.promisify": "^1.0.0",
|
|
31
33
|
"webpack-dev-middleware": "^2.0.6",
|
|
32
34
|
"webpack-hot-middleware": "^2.24.3",
|
|
33
35
|
"yargs": "^12.0.5"
|
|
@@ -41,5 +43,5 @@
|
|
|
41
43
|
"cosmos-native": "./bin/cosmos-native.js",
|
|
42
44
|
"print-fixture-files": "./bin/print-fixture-files.js"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "f2adf6ba82d00aa35d7f55d5f12f183b5ffeaae9"
|
|
45
47
|
}
|