react-cosmos 5.7.2 → 6.0.0-alpha.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/bin/cosmos-export.js +4 -3
- package/bin/cosmos-native.js +4 -3
- package/bin/cosmos.js +5 -4
- package/config.schema.json +14 -4
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -70
- package/dist/jest.d.ts +7 -0
- package/dist/jest.js +7 -0
- package/dist/{config → server/cosmosConfig}/createCosmosConfig.d.ts +1 -1
- package/dist/server/cosmosConfig/createCosmosConfig.js +84 -0
- package/dist/server/cosmosConfig/detectCosmosConfig.d.ts +2 -0
- package/dist/server/cosmosConfig/detectCosmosConfig.js +38 -0
- package/dist/{config → server/cosmosConfig}/getCosmosConfigAtPath.d.ts +1 -1
- package/dist/server/cosmosConfig/getCosmosConfigAtPath.js +12 -0
- package/dist/server/cosmosConfig/shared.d.ts +2 -0
- package/dist/server/cosmosConfig/shared.js +7 -0
- package/dist/{config/shared.d.ts → server/cosmosConfig/types.d.ts} +5 -5
- package/dist/server/cosmosPlugin/findCosmosPluginConfigs.d.ts +8 -0
- package/dist/server/cosmosPlugin/findCosmosPluginConfigs.js +14 -0
- package/dist/server/cosmosPlugin/pluginConfigs.d.ts +8 -0
- package/dist/server/cosmosPlugin/pluginConfigs.js +16 -0
- package/dist/server/cosmosPlugin/readCosmosPluginConfig.d.ts +8 -0
- package/dist/server/cosmosPlugin/readCosmosPluginConfig.js +31 -0
- package/dist/server/cosmosPlugin/types.d.ts +21 -0
- package/dist/server/devServer/corePlugins/httpProxy.d.ts +2 -0
- package/dist/server/devServer/corePlugins/httpProxy.js +18 -0
- package/dist/server/devServer/corePlugins/openFile.d.ts +2 -0
- package/dist/server/devServer/corePlugins/openFile.js +53 -0
- package/dist/server/devServer/corePlugins/pluginEndpoint.d.ts +2 -0
- package/dist/server/devServer/corePlugins/pluginEndpoint.js +17 -0
- package/dist/server/devServer/corePlugins/userDepsFile.d.ts +2 -0
- package/dist/server/devServer/corePlugins/userDepsFile.js +37 -0
- package/dist/server/devServer/expressApp.d.ts +5 -0
- package/dist/server/devServer/expressApp.js +21 -0
- package/dist/server/devServer/httpServer.d.ts +12 -0
- package/dist/server/devServer/httpServer.js +42 -0
- package/dist/{devServer → server/devServer}/messageHandler.d.ts +2 -2
- package/dist/server/devServer/messageHandler.js +29 -0
- package/dist/server/devServer/startDevServer.d.ts +2 -0
- package/dist/server/devServer/startDevServer.js +91 -0
- package/dist/server/export/generateExport.d.ts +1 -0
- package/dist/server/export/generateExport.js +97 -0
- package/dist/server/getFixtures/getFixtures.d.ts +14 -0
- package/dist/server/getFixtures/getFixtures.js +63 -0
- package/dist/server/shared/logPluginInfo.d.ts +2 -0
- package/dist/server/shared/logPluginInfo.js +8 -0
- package/dist/server/shared/playgroundHtml.d.ts +6 -0
- package/dist/server/shared/playgroundHtml.js +85 -0
- package/dist/server/shared/playgroundUrl.d.ts +2 -0
- package/dist/server/shared/playgroundUrl.js +6 -0
- package/dist/server/shared/requirePluginModule.d.ts +2 -0
- package/dist/server/shared/requirePluginModule.js +10 -0
- package/dist/server/shared/resolveUrlPath.d.ts +1 -0
- package/dist/server/shared/resolveUrlPath.js +12 -0
- package/dist/server/shared/staticPath.d.ts +1 -0
- package/dist/server/shared/staticPath.js +4 -0
- package/dist/{shared/static.d.ts → server/shared/staticServer.d.ts} +0 -1
- package/dist/server/shared/staticServer.js +12 -0
- package/dist/{shared → server}/static/index.html +1 -1
- package/dist/server/testHelpers/cwd.d.ts +1 -0
- package/dist/server/testHelpers/cwd.js +4 -0
- package/dist/server/testHelpers/mockConsole.d.ts +5 -0
- package/dist/server/testHelpers/mockConsole.js +11 -0
- package/dist/server/testHelpers/mockEsmRequire.js +13 -0
- package/dist/server/testHelpers/mockEsmResolve.d.ts +1 -0
- package/dist/server/testHelpers/mockEsmResolve.js +13 -0
- package/dist/server/testHelpers/mockEsmStaticPath.d.ts +1 -0
- package/dist/server/testHelpers/mockEsmStaticPath.js +7 -0
- package/dist/server/testHelpers/mockFetch.d.ts +2 -0
- package/dist/server/testHelpers/mockFetch.js +7 -0
- package/dist/server/testHelpers/mockFs.d.ts +5 -0
- package/dist/server/testHelpers/mockFs.js +64 -0
- package/dist/server/testHelpers/mockYargs.d.ts +2 -0
- package/dist/server/testHelpers/mockYargs.js +21 -0
- package/dist/{userDeps → server/userDeps}/findUserModulePaths.d.ts +2 -2
- package/dist/server/userDeps/findUserModulePaths.js +20 -0
- package/dist/server/userDeps/fixtureWatcher.d.ts +3 -0
- package/dist/server/userDeps/fixtureWatcher.js +20 -0
- package/dist/{userDeps → server/userDeps}/generateUserDepsModule.d.ts +3 -3
- package/dist/server/userDeps/generateUserDepsModule.js +18 -0
- package/dist/{userDeps → server/userDeps}/getUserModules.d.ts +3 -3
- package/dist/server/userDeps/getUserModules.js +25 -0
- package/dist/{userDeps → server/userDeps}/shared.d.ts +1 -1
- package/dist/server/userDeps/shared.js +20 -0
- package/dist/{userDeps → server/userDeps}/userDepsTemplate.d.ts +2 -2
- package/dist/server/userDeps/userDepsTemplate.js +49 -0
- package/dist/server/utils/cli.js +4 -0
- package/dist/server/utils/fs.d.ts +4 -0
- package/dist/server/utils/fs.js +24 -0
- package/dist/server/utils/isNodeError.d.ts +2 -0
- package/dist/server/utils/isNodeError.js +3 -0
- package/dist/server/utils/requireModule.d.ts +2 -0
- package/dist/server/utils/requireModule.js +13 -0
- package/dist/server/utils/requireSilent.d.ts +1 -0
- package/dist/server/utils/requireSilent.js +11 -0
- package/dist/server/utils/resolve.d.ts +2 -0
- package/dist/server/utils/resolve.js +14 -0
- package/dist/server/utils/resolveLoose.d.ts +1 -0
- package/dist/server/utils/resolveLoose.js +12 -0
- package/dist/server/utils/resolveSilent.d.ts +2 -0
- package/dist/server/utils/resolveSilent.js +22 -0
- package/dist/server/utils/slash.d.ts +1 -0
- package/dist/server/utils/slash.js +5 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.js +20 -0
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/jest.d.ts +1 -0
- package/jest.js +1 -0
- package/package.json +17 -28
- package/server.d.ts +1 -0
- package/server.js +1 -0
- package/dist/config/createCosmosConfig.js +0 -133
- package/dist/config/detectCosmosConfig.d.ts +0 -2
- package/dist/config/detectCosmosConfig.js +0 -57
- package/dist/config/getCosmosConfigAtPath.js +0 -28
- package/dist/config/resolveModule.d.ts +0 -1
- package/dist/config/resolveModule.js +0 -20
- package/dist/config/shared.js +0 -17
- package/dist/devServer/app.d.ts +0 -5
- package/dist/devServer/app.js +0 -51
- package/dist/devServer/httpServer.d.ts +0 -11
- package/dist/devServer/httpServer.js +0 -183
- package/dist/devServer/messageHandler.js +0 -42
- package/dist/devServer/startDevServer.d.ts +0 -18
- package/dist/devServer/startDevServer.js +0 -209
- package/dist/dom/DomFixtureLoader.d.ts +0 -9
- package/dist/dom/DomFixtureLoader.js +0 -38
- package/dist/dom/ErrorCatch.d.ts +0 -15
- package/dist/dom/ErrorCatch.js +0 -117
- package/dist/dom/container.d.ts +0 -1
- package/dist/dom/container.js +0 -32
- package/dist/dom/globalErrorHandler.js +0 -14
- package/dist/dom/index.d.ts +0 -13
- package/dist/dom/index.js +0 -47
- package/dist/dom/renderMessage.d.ts +0 -4
- package/dist/dom/renderMessage.js +0 -30
- package/dist/dom/rendererConnect.d.ts +0 -1
- package/dist/dom/rendererConnect.js +0 -18
- package/dist/dom/rendererId.d.ts +0 -1
- package/dist/dom/rendererId.js +0 -26
- package/dist/dom/selectedFixtureId.d.ts +0 -2
- package/dist/dom/selectedFixtureId.js +0 -41
- package/dist/dom/shared.d.ts +0 -1
- package/dist/dom/shared.js +0 -14
- package/dist/export/generateExport.d.ts +0 -6
- package/dist/export/generateExport.js +0 -137
- package/dist/fixture.d.ts +0 -1
- package/dist/fixture.js +0 -31
- package/dist/generateWebExport.d.ts +0 -1
- package/dist/generateWebExport.js +0 -37
- package/dist/getFixtureUrls.d.ts +0 -8
- package/dist/getFixtureUrls.js +0 -97
- package/dist/getFixtures.d.ts +0 -13
- package/dist/getFixtures.js +0 -89
- package/dist/getFixtures2.d.ts +0 -14
- package/dist/getFixtures2.js +0 -117
- package/dist/native/NativeFixtureLoader.d.ts +0 -12
- package/dist/native/NativeFixtureLoader.js +0 -67
- package/dist/native/index.d.ts +0 -1
- package/dist/native/index.js +0 -25
- package/dist/plugins/httpProxy.d.ts +0 -2
- package/dist/plugins/httpProxy.js +0 -31
- package/dist/plugins/openFile.d.ts +0 -2
- package/dist/plugins/openFile.js +0 -87
- package/dist/plugins/userDepsFile.d.ts +0 -2
- package/dist/plugins/userDepsFile.js +0 -166
- package/dist/plugins/webpack/client/errorOverlay/index.d.ts +0 -1
- package/dist/plugins/webpack/client/errorOverlay/index.js +0 -16
- package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.d.ts +0 -2
- package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +0 -63
- package/dist/plugins/webpack/client/hmrErrorHandler.js +0 -16
- package/dist/plugins/webpack/client/index.d.ts +0 -6
- package/dist/plugins/webpack/client/index.js +0 -43
- package/dist/plugins/webpack/client/reactDevtoolsHook.d.ts +0 -0
- package/dist/plugins/webpack/client/reactDevtoolsHook.js +0 -19
- package/dist/plugins/webpack/client/userDeps.d.ts +0 -5
- package/dist/plugins/webpack/client/userDeps.js +0 -15
- package/dist/plugins/webpack/cosmosConfig/dom.d.ts +0 -6
- package/dist/plugins/webpack/cosmosConfig/dom.js +0 -19
- package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +0 -10
- package/dist/plugins/webpack/cosmosConfig/webpack.js +0 -95
- package/dist/plugins/webpack/devServer.d.ts +0 -2
- package/dist/plugins/webpack/devServer.js +0 -168
- package/dist/plugins/webpack/export.d.ts +0 -2
- package/dist/plugins/webpack/export.js +0 -139
- package/dist/plugins/webpack/index.d.ts +0 -2
- package/dist/plugins/webpack/index.js +0 -21
- package/dist/plugins/webpack/shared.d.ts +0 -2
- package/dist/plugins/webpack/shared.js +0 -22
- package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.d.ts +0 -2
- package/dist/plugins/webpack/webpackConfig/getDefaultWebpackConfig.js +0 -152
- package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getDevWebpackConfig.js +0 -146
- package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getExportWebpackConfig.js +0 -111
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.d.ts +0 -3
- package/dist/plugins/webpack/webpackConfig/getUserWebpackConfig.js +0 -136
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.d.ts +0 -2
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigModule.js +0 -45
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.d.ts +0 -4
- package/dist/plugins/webpack/webpackConfig/getWebpackConfigResolve.js +0 -107
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.d.ts +0 -1
- package/dist/plugins/webpack/webpackConfig/getWebpackNodeEnv.js +0 -12
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.d.ts +0 -16
- package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +0 -80
- package/dist/plugins/webpack/webpackConfig/plugins.d.ts +0 -5
- package/dist/plugins/webpack/webpackConfig/plugins.js +0 -37
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.d.ts +0 -1
- package/dist/plugins/webpack/webpackConfig/resolveWebpackClientPath.js +0 -10
- package/dist/plugins/webpack/webpackConfig/userDepsLoader.js +0 -36
- package/dist/shared/cli.js +0 -14
- package/dist/shared/fs.d.ts +0 -4
- package/dist/shared/fs.js +0 -37
- package/dist/shared/playgroundHtml.d.ts +0 -6
- package/dist/shared/playgroundHtml.js +0 -116
- package/dist/shared/pluginConfigs.d.ts +0 -2
- package/dist/shared/pluginConfigs.js +0 -15
- package/dist/shared/rendererConfig.d.ts +0 -6
- package/dist/shared/rendererConfig.js +0 -5
- package/dist/shared/static.js +0 -30
- package/dist/shared/types.d.ts +0 -1
- package/dist/shared/types.js +0 -5
- package/dist/shared/utils.d.ts +0 -5
- package/dist/shared/utils.js +0 -22
- package/dist/startNativeServer.d.ts +0 -1
- package/dist/startNativeServer.js +0 -39
- package/dist/startWebServer.d.ts +0 -1
- package/dist/startWebServer.js +0 -43
- package/dist/userDeps/findUserModulePaths.js +0 -45
- package/dist/userDeps/generateUserDepsModule.js +0 -37
- package/dist/userDeps/getUserModules.js +0 -45
- package/dist/userDeps/shared.js +0 -32
- package/dist/userDeps/userDepsTemplate.js +0 -52
- package/dom.d.ts +0 -1
- package/dom.js +0 -2
- package/fixture.d.ts +0 -1
- package/fixture.js +0 -2
- package/native.d.ts +0 -1
- package/native.js +0 -2
- package/yarn-error.log +0 -13450
- /package/dist/{dom/globalErrorHandler.d.ts → server/cosmosConfig/types.js} +0 -0
- /package/dist/{plugins/webpack/client/hmrErrorHandler.d.ts → server/cosmosPlugin/types.js} +0 -0
- /package/dist/{shared → server}/static/favicon.ico +0 -0
- /package/dist/{plugins/webpack/webpackConfig/userDepsLoader.d.ts → server/testHelpers/mockEsmRequire.d.ts} +0 -0
- /package/dist/{shared → server/utils}/cli.d.ts +0 -0
package/package.json
CHANGED
|
@@ -1,42 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "6.0.0-alpha.0",
|
|
4
|
+
"description": "Sandbox for developing and testing UI components in isolation",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"main": "index.js",
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"@skidding/launch-editor": "^2.2.3",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"react-cosmos-playground2": "^5.7.2",
|
|
24
|
-
"react-cosmos-plugin": "^5.6.0",
|
|
25
|
-
"react-cosmos-shared2": "^5.7.1",
|
|
26
|
-
"react-error-overlay": "6.0.9",
|
|
27
|
-
"regenerator-runtime": "^0.13.9",
|
|
28
|
-
"resolve-from": "^5.0.0",
|
|
29
|
-
"slash": "^3.0.0",
|
|
30
|
-
"socket.io": "2.2.0",
|
|
31
|
-
"url-parse": "^1.5.4",
|
|
32
|
-
"util.promisify": "^1.1.1",
|
|
33
|
-
"webpack-dev-middleware": "^4.3.0",
|
|
34
|
-
"yargs": "^16.2.0"
|
|
11
|
+
"chokidar": "^3.5.3",
|
|
12
|
+
"express": "^4.18.2",
|
|
13
|
+
"glob": "^8.1.0",
|
|
14
|
+
"http-proxy-middleware": "^2.0.6",
|
|
15
|
+
"lodash-es": "^4.17.21",
|
|
16
|
+
"micromatch": "^4.0.5",
|
|
17
|
+
"open": "^8.4.2",
|
|
18
|
+
"pem": "^1.14.6",
|
|
19
|
+
"pkg-up": "^4.0.0",
|
|
20
|
+
"react-cosmos-core": "^6.0.0-alpha.0",
|
|
21
|
+
"react-cosmos-ui": "^6.0.0-alpha.0",
|
|
22
|
+
"ws": "^8.12.1",
|
|
23
|
+
"yargs": "^17.7.0"
|
|
35
24
|
},
|
|
36
25
|
"bin": {
|
|
37
26
|
"cosmos": "./bin/cosmos.js",
|
|
38
27
|
"cosmos-export": "./bin/cosmos-export.js",
|
|
39
28
|
"cosmos-native": "./bin/cosmos-native.js"
|
|
40
29
|
},
|
|
41
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "b021231584639f3028fe08deacd418f0ec4cc002"
|
|
42
31
|
}
|
package/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/server.js';
|
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/server.js';
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createCosmosConfig = createCosmosConfig;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _cli = require("../shared/cli");
|
|
11
|
-
|
|
12
|
-
var _resolveModule = require("./resolveModule");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
|
-
function createCosmosConfig(rootDir) {
|
|
23
|
-
var _cosmosConfigInput$di, _cosmosConfigInput$ex;
|
|
24
|
-
|
|
25
|
-
var cosmosConfigInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
26
|
-
return _objectSpread(_objectSpread({}, cosmosConfigInput), {}, {
|
|
27
|
-
rootDir: rootDir,
|
|
28
|
-
exportPath: getExportPath(cosmosConfigInput, rootDir),
|
|
29
|
-
disablePlugins: (_cosmosConfigInput$di = cosmosConfigInput.disablePlugins) !== null && _cosmosConfigInput$di !== void 0 ? _cosmosConfigInput$di : true,
|
|
30
|
-
fixtureFileSuffix: getFixtureFileSuffix(cosmosConfigInput),
|
|
31
|
-
fixturesDir: getFixturesDir(cosmosConfigInput),
|
|
32
|
-
globalImports: getGlobalImports(cosmosConfigInput, rootDir),
|
|
33
|
-
hostname: getHostname(cosmosConfigInput),
|
|
34
|
-
https: getHttps(cosmosConfigInput),
|
|
35
|
-
httpsOptions: getHttpsOptions(cosmosConfigInput, rootDir),
|
|
36
|
-
port: getPort(cosmosConfigInput),
|
|
37
|
-
publicUrl: getPublicUrl(cosmosConfigInput),
|
|
38
|
-
staticPath: getStaticPath(cosmosConfigInput, rootDir),
|
|
39
|
-
userDepsFilePath: getUserDepsFilePath(cosmosConfigInput, rootDir),
|
|
40
|
-
watchDirs: getWatchDirs(cosmosConfigInput, rootDir),
|
|
41
|
-
experimentalRendererUrl: (_cosmosConfigInput$ex = cosmosConfigInput.experimentalRendererUrl) !== null && _cosmosConfigInput$ex !== void 0 ? _cosmosConfigInput$ex : null,
|
|
42
|
-
ui: cosmosConfigInput.ui || {}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getExportPath(cosmosConfigInput, rootDir) {
|
|
47
|
-
var _cosmosConfigInput$ex2 = cosmosConfigInput.exportPath,
|
|
48
|
-
exportPath = _cosmosConfigInput$ex2 === void 0 ? 'cosmos-export' : _cosmosConfigInput$ex2;
|
|
49
|
-
return _path.default.resolve(rootDir, exportPath);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function getStaticPath(cosmosConfigInput, rootDir) {
|
|
53
|
-
var _cosmosConfigInput$st = cosmosConfigInput.staticPath,
|
|
54
|
-
staticPath = _cosmosConfigInput$st === void 0 ? null : _cosmosConfigInput$st;
|
|
55
|
-
return staticPath && _path.default.resolve(rootDir, staticPath);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function getHttps(cosmosConfigInput) {
|
|
59
|
-
var _cosmosConfigInput$ht = cosmosConfigInput.https,
|
|
60
|
-
https = _cosmosConfigInput$ht === void 0 ? false : _cosmosConfigInput$ht;
|
|
61
|
-
return https;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getHttpsOptions(cosmosConfigInput, rootDir) {
|
|
65
|
-
var _cosmosConfigInput$ht2, _cosmosConfigInput$ht3;
|
|
66
|
-
|
|
67
|
-
if ((_cosmosConfigInput$ht2 = cosmosConfigInput.httpsOptions) !== null && _cosmosConfigInput$ht2 !== void 0 && _cosmosConfigInput$ht2.keyPath && (_cosmosConfigInput$ht3 = cosmosConfigInput.httpsOptions) !== null && _cosmosConfigInput$ht3 !== void 0 && _cosmosConfigInput$ht3.certPath) {
|
|
68
|
-
return {
|
|
69
|
-
keyPath: _path.default.resolve(rootDir, cosmosConfigInput.httpsOptions.keyPath),
|
|
70
|
-
certPath: _path.default.resolve(rootDir, cosmosConfigInput.httpsOptions.certPath)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getPublicUrl(_ref) {
|
|
78
|
-
var _ref$publicUrl = _ref.publicUrl,
|
|
79
|
-
publicUrl = _ref$publicUrl === void 0 ? '/' : _ref$publicUrl;
|
|
80
|
-
return publicUrl;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getFixturesDir(_ref2) {
|
|
84
|
-
var _ref2$fixturesDir = _ref2.fixturesDir,
|
|
85
|
-
fixturesDir = _ref2$fixturesDir === void 0 ? '__fixtures__' : _ref2$fixturesDir;
|
|
86
|
-
return fixturesDir;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function getFixtureFileSuffix(_ref3) {
|
|
90
|
-
var _ref3$fixtureFileSuff = _ref3.fixtureFileSuffix,
|
|
91
|
-
fixtureFileSuffix = _ref3$fixtureFileSuff === void 0 ? 'fixture' : _ref3$fixtureFileSuff;
|
|
92
|
-
return fixtureFileSuffix;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getWatchDirs(cosmosConfigInput, rootDir) {
|
|
96
|
-
var _cosmosConfigInput$wa = cosmosConfigInput.watchDirs,
|
|
97
|
-
watchDirs = _cosmosConfigInput$wa === void 0 ? ['.'] : _cosmosConfigInput$wa;
|
|
98
|
-
return watchDirs.map(function (watchDir) {
|
|
99
|
-
return _path.default.resolve(rootDir, watchDir);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getUserDepsFilePath(cosmosConfigInput, rootDir) {
|
|
104
|
-
var _cosmosConfigInput$us = cosmosConfigInput.userDepsFilePath,
|
|
105
|
-
userDepsFilePath = _cosmosConfigInput$us === void 0 ? 'cosmos.userdeps.js' : _cosmosConfigInput$us;
|
|
106
|
-
return _path.default.resolve(rootDir, userDepsFilePath);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getHostname(_ref4) {
|
|
110
|
-
var _ref4$hostname = _ref4.hostname,
|
|
111
|
-
hostname = _ref4$hostname === void 0 ? null : _ref4$hostname;
|
|
112
|
-
return hostname;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function getPort(cosmosConfigInput) {
|
|
116
|
-
var cliArgs = (0, _cli.getCliArgs)();
|
|
117
|
-
|
|
118
|
-
if (typeof cliArgs.port === 'number') {
|
|
119
|
-
return cliArgs.port;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var _cosmosConfigInput$po = cosmosConfigInput.port,
|
|
123
|
-
port = _cosmosConfigInput$po === void 0 ? 5000 : _cosmosConfigInput$po;
|
|
124
|
-
return port;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function getGlobalImports(cosmosConfigInput, rootDir) {
|
|
128
|
-
var _cosmosConfigInput$gl = cosmosConfigInput.globalImports,
|
|
129
|
-
globalImports = _cosmosConfigInput$gl === void 0 ? [] : _cosmosConfigInput$gl;
|
|
130
|
-
return globalImports.map(function (globalImport) {
|
|
131
|
-
return (0, _resolveModule.resolveModule)(rootDir, globalImport);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.detectCosmosConfig = detectCosmosConfig;
|
|
7
|
-
exports.detectCosmosConfigPath = detectCosmosConfigPath;
|
|
8
|
-
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
|
|
11
|
-
var _cli = require("../shared/cli");
|
|
12
|
-
|
|
13
|
-
var _fs = require("../shared/fs");
|
|
14
|
-
|
|
15
|
-
var _createCosmosConfig = require("./createCosmosConfig");
|
|
16
|
-
|
|
17
|
-
var _getCosmosConfigAtPath = require("./getCosmosConfigAtPath");
|
|
18
|
-
|
|
19
|
-
var _shared = require("./shared");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
function detectCosmosConfig() {
|
|
24
|
-
var cosmosConfigPath = detectCosmosConfigPath();
|
|
25
|
-
return cosmosConfigPath ? (0, _getCosmosConfigAtPath.getCosmosConfigAtPath)(cosmosConfigPath) : (0, _createCosmosConfig.createCosmosConfig)(detectRootDir());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function detectCosmosConfigPath() {
|
|
29
|
-
var rootDir = detectRootDir();
|
|
30
|
-
var cliArgs = (0, _cli.getCliArgs)(); // CLI support for --config path/to/cosmos.config.json
|
|
31
|
-
|
|
32
|
-
if (typeof cliArgs.config === 'string') {
|
|
33
|
-
if (_path.default.extname(cliArgs.config) !== '.json') throw new Error("[Cosmos] Invalid config file type: ".concat(cliArgs.config, " (must be .json)"));
|
|
34
|
-
|
|
35
|
-
var absPath = _path.default.resolve(rootDir, cliArgs.config);
|
|
36
|
-
|
|
37
|
-
if (!(0, _fs.fileExists)(absPath)) throw new Error("[Cosmos] Config not found at path: ".concat(cliArgs.config));
|
|
38
|
-
return absPath;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var defaultConfigPath = _path.default.join(rootDir, 'cosmos.config.json');
|
|
42
|
-
|
|
43
|
-
return (0, _fs.moduleExists)(defaultConfigPath) ? defaultConfigPath : null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function detectRootDir() {
|
|
47
|
-
var cliArgs = (0, _cli.getCliArgs)(); // CLI support for --root-dir path/to/project
|
|
48
|
-
|
|
49
|
-
if (typeof cliArgs.rootDir === 'string') {
|
|
50
|
-
var absPath = _path.default.resolve((0, _shared.getCurrentDir)(), cliArgs.rootDir);
|
|
51
|
-
|
|
52
|
-
if (!(0, _fs.dirExists)(absPath)) throw new Error("[Cosmos] Dir not found at path: ".concat(cliArgs.rootDir));
|
|
53
|
-
return absPath;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return (0, _shared.getCurrentDir)();
|
|
57
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCosmosConfigAtPath = getCosmosConfigAtPath;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _createCosmosConfig = require("./createCosmosConfig");
|
|
11
|
-
|
|
12
|
-
var _shared = require("./shared");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function getCosmosConfigAtPath(cosmosConfigPath) {
|
|
17
|
-
var cosmosConfigInput = (0, _shared.requireConfigFile)(cosmosConfigPath);
|
|
18
|
-
var rootDir = deriveRootDir(cosmosConfigPath, cosmosConfigInput);
|
|
19
|
-
return (0, _createCosmosConfig.createCosmosConfig)(rootDir, cosmosConfigInput);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function deriveRootDir(cosmosConfigPath, _ref) {
|
|
23
|
-
var rootDir = _ref.rootDir;
|
|
24
|
-
|
|
25
|
-
var configDir = _path.default.dirname(cosmosConfigPath);
|
|
26
|
-
|
|
27
|
-
return rootDir ? _path.default.resolve(configDir, rootDir) : configDir;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveModule(rootDir: string, moduleId: string): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.resolveModule = resolveModule;
|
|
7
|
-
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function resolveModule(rootDir, moduleId) {
|
|
15
|
-
// Use to deal with file paths and module names interchangeably.
|
|
16
|
-
return _path.default.isAbsolute(moduleId) ? moduleId : _resolveFrom.default.silent(rootDir, moduleId) || // Final attempt: Resolve relative paths that don't either
|
|
17
|
-
// 1. Don't start with ./
|
|
18
|
-
// 2. Don't point to an existing file
|
|
19
|
-
_path.default.join(rootDir, moduleId);
|
|
20
|
-
}
|
package/dist/config/shared.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCurrentDir = getCurrentDir;
|
|
7
|
-
exports.requireConfigFile = requireConfigFile;
|
|
8
|
-
|
|
9
|
-
var _fs = require("../shared/fs");
|
|
10
|
-
|
|
11
|
-
function getCurrentDir() {
|
|
12
|
-
return process.cwd();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function requireConfigFile(cosmosConfigPath) {
|
|
16
|
-
return (0, _fs.requireModule)(cosmosConfigPath);
|
|
17
|
-
}
|
package/dist/devServer/app.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { CosmosPluginConfig } from 'react-cosmos-plugin';
|
|
3
|
-
import { CosmosConfig } from '../config/shared';
|
|
4
|
-
import { PlatformType } from '../shared/types';
|
|
5
|
-
export declare function createApp(platformType: PlatformType, cosmosConfig: CosmosConfig, pluginConfigs: CosmosPluginConfig[]): express.Express;
|
package/dist/devServer/app.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createApp = createApp;
|
|
7
|
-
|
|
8
|
-
var _express = _interopRequireDefault(require("express"));
|
|
9
|
-
|
|
10
|
-
var _resolveFrom = _interopRequireDefault(require("resolve-from"));
|
|
11
|
-
|
|
12
|
-
var _playgroundHtml = require("../shared/playgroundHtml");
|
|
13
|
-
|
|
14
|
-
var _static = require("../shared/static");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function createApp(platformType, cosmosConfig, pluginConfigs) {
|
|
19
|
-
var app = (0, _express.default)();
|
|
20
|
-
var playgroundHtml = (0, _playgroundHtml.getDevPlaygroundHtml)(platformType, cosmosConfig, pluginConfigs);
|
|
21
|
-
app.get('/', function (req, res) {
|
|
22
|
-
res.send(playgroundHtml);
|
|
23
|
-
});
|
|
24
|
-
app.get('/_plugin/:scriptPath', function (req, res) {
|
|
25
|
-
var scriptPath = req.params.scriptPath;
|
|
26
|
-
|
|
27
|
-
if (!scriptPath) {
|
|
28
|
-
res.sendStatus(404);
|
|
29
|
-
return;
|
|
30
|
-
} // TODO: Restrict which scripts can be opened based on plugin configs
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var cleanPath = "./".concat(decodeURIComponent(scriptPath));
|
|
34
|
-
|
|
35
|
-
var absolutePath = _resolveFrom.default.silent(cosmosConfig.rootDir, cleanPath);
|
|
36
|
-
|
|
37
|
-
if (!absolutePath) {
|
|
38
|
-
res.sendStatus(404);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
res.sendFile(absolutePath);
|
|
43
|
-
});
|
|
44
|
-
app.get('/_playground.js', function (req, res) {
|
|
45
|
-
res.sendFile(require.resolve('react-cosmos-playground2/dist'));
|
|
46
|
-
});
|
|
47
|
-
app.get('/_cosmos.ico', function (req, res) {
|
|
48
|
-
res.sendFile((0, _static.getStaticPath)('favicon.ico'));
|
|
49
|
-
});
|
|
50
|
-
return app;
|
|
51
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import http from 'http';
|
|
3
|
-
import https from 'https';
|
|
4
|
-
import { CosmosConfig } from '../config/shared';
|
|
5
|
-
declare type RequestListener = (request: http.IncomingMessage, response: http.ServerResponse) => void;
|
|
6
|
-
export declare function createHttpServer(cosmosConfig: CosmosConfig, requestListener: RequestListener): Promise<{
|
|
7
|
-
server: http.Server | https.Server;
|
|
8
|
-
start: () => Promise<void>;
|
|
9
|
-
stop: () => Promise<void>;
|
|
10
|
-
}>;
|
|
11
|
-
export {};
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createHttpServer = createHttpServer;
|
|
7
|
-
|
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
|
-
var _http = _interopRequireDefault(require("http"));
|
|
11
|
-
|
|
12
|
-
var _https = _interopRequireDefault(require("https"));
|
|
13
|
-
|
|
14
|
-
var _pem = _interopRequireDefault(require("pem"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
19
|
-
|
|
20
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
21
|
-
|
|
22
|
-
function createHttpServer(_x, _x2) {
|
|
23
|
-
return _createHttpServer.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function _createHttpServer() {
|
|
27
|
-
_createHttpServer = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(cosmosConfig, requestListener) {
|
|
28
|
-
var port, hostname, httpsEnabled, server, start, _start, stop, _stop;
|
|
29
|
-
|
|
30
|
-
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
31
|
-
while (1) {
|
|
32
|
-
switch (_context3.prev = _context3.next) {
|
|
33
|
-
case 0:
|
|
34
|
-
_stop = function _stop3() {
|
|
35
|
-
_stop = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
36
|
-
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
37
|
-
while (1) {
|
|
38
|
-
switch (_context2.prev = _context2.next) {
|
|
39
|
-
case 0:
|
|
40
|
-
_context2.next = 2;
|
|
41
|
-
return new Promise(function (resolve) {
|
|
42
|
-
return server.close(resolve);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
case 2:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context2.stop();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}, _callee2);
|
|
51
|
-
}));
|
|
52
|
-
return _stop.apply(this, arguments);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
stop = function _stop2() {
|
|
56
|
-
return _stop.apply(this, arguments);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
_start = function _start3() {
|
|
60
|
-
_start = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
61
|
-
var hostnameDisplay, protocol;
|
|
62
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
|
-
while (1) {
|
|
64
|
-
switch (_context.prev = _context.next) {
|
|
65
|
-
case 0:
|
|
66
|
-
_context.next = 2;
|
|
67
|
-
return new Promise(function (resolve) {
|
|
68
|
-
if (hostname === null) {
|
|
69
|
-
server.listen(port, resolve);
|
|
70
|
-
} else {
|
|
71
|
-
server.listen(port, hostname, resolve);
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
case 2:
|
|
76
|
-
hostnameDisplay = hostname || 'localhost';
|
|
77
|
-
protocol = httpsEnabled ? 'https' : 'http';
|
|
78
|
-
console.log("[Cosmos] See you at ".concat(protocol, "://").concat(hostnameDisplay, ":").concat(port));
|
|
79
|
-
|
|
80
|
-
case 5:
|
|
81
|
-
case "end":
|
|
82
|
-
return _context.stop();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}, _callee);
|
|
86
|
-
}));
|
|
87
|
-
return _start.apply(this, arguments);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
start = function _start2() {
|
|
91
|
-
return _start.apply(this, arguments);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
port = cosmosConfig.port, hostname = cosmosConfig.hostname, httpsEnabled = cosmosConfig.https;
|
|
95
|
-
|
|
96
|
-
if (!httpsEnabled) {
|
|
97
|
-
_context3.next = 14;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
_context3.t1 = _https.default;
|
|
102
|
-
_context3.next = 9;
|
|
103
|
-
return getHttpsOpts(cosmosConfig);
|
|
104
|
-
|
|
105
|
-
case 9:
|
|
106
|
-
_context3.t2 = _context3.sent;
|
|
107
|
-
_context3.t3 = requestListener;
|
|
108
|
-
_context3.t0 = _context3.t1.createServer.call(_context3.t1, _context3.t2, _context3.t3);
|
|
109
|
-
_context3.next = 15;
|
|
110
|
-
break;
|
|
111
|
-
|
|
112
|
-
case 14:
|
|
113
|
-
_context3.t0 = _http.default.createServer(requestListener);
|
|
114
|
-
|
|
115
|
-
case 15:
|
|
116
|
-
server = _context3.t0;
|
|
117
|
-
return _context3.abrupt("return", {
|
|
118
|
-
server: server,
|
|
119
|
-
start: start,
|
|
120
|
-
stop: stop
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
case 17:
|
|
124
|
-
case "end":
|
|
125
|
-
return _context3.stop();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}, _callee3);
|
|
129
|
-
}));
|
|
130
|
-
return _createHttpServer.apply(this, arguments);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function getHttpsOpts(_x3) {
|
|
134
|
-
return _getHttpsOpts.apply(this, arguments);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function _getHttpsOpts() {
|
|
138
|
-
_getHttpsOpts = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(cosmosConfig) {
|
|
139
|
-
var httpsOptions;
|
|
140
|
-
return regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
141
|
-
while (1) {
|
|
142
|
-
switch (_context4.prev = _context4.next) {
|
|
143
|
-
case 0:
|
|
144
|
-
httpsOptions = cosmosConfig.httpsOptions;
|
|
145
|
-
|
|
146
|
-
if (!httpsOptions) {
|
|
147
|
-
_context4.next = 3;
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return _context4.abrupt("return", {
|
|
152
|
-
key: _fs.default.readFileSync(httpsOptions.keyPath, 'utf8'),
|
|
153
|
-
cert: _fs.default.readFileSync(httpsOptions.certPath, 'utf8')
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
case 3:
|
|
157
|
-
console.log('[Cosmos] Generating HTTPS certificate');
|
|
158
|
-
_context4.next = 6;
|
|
159
|
-
return new Promise(function (resolve, reject) {
|
|
160
|
-
_pem.default.createCertificate({
|
|
161
|
-
days: 1000,
|
|
162
|
-
selfSigned: true
|
|
163
|
-
}, function (err, keys) {
|
|
164
|
-
if (err) return reject(err);
|
|
165
|
-
return resolve({
|
|
166
|
-
key: keys.serviceKey,
|
|
167
|
-
cert: keys.certificate
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
case 6:
|
|
173
|
-
return _context4.abrupt("return", _context4.sent);
|
|
174
|
-
|
|
175
|
-
case 7:
|
|
176
|
-
case "end":
|
|
177
|
-
return _context4.stop();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}, _callee4);
|
|
181
|
-
}));
|
|
182
|
-
return _getHttpsOpts.apply(this, arguments);
|
|
183
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createMessageHandler = createMessageHandler;
|
|
7
|
-
|
|
8
|
-
var _socket = _interopRequireDefault(require("socket.io"));
|
|
9
|
-
|
|
10
|
-
var _build = require("react-cosmos-shared2/build");
|
|
11
|
-
|
|
12
|
-
var _renderer = require("react-cosmos-shared2/renderer");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function createMessageHandler(httpServer) {
|
|
17
|
-
var io = (0, _socket.default)(httpServer);
|
|
18
|
-
io.on('connection', function (socket) {
|
|
19
|
-
// Forward commands between connected clients. Parties involved can be the
|
|
20
|
-
// - The Cosmos UI, which acts as a remote control
|
|
21
|
-
// - The web iframe or the React Native component renderers
|
|
22
|
-
socket.on(_renderer.RENDERER_MESSAGE_EVENT_NAME, function (msg) {
|
|
23
|
-
socket.broadcast.emit(_renderer.RENDERER_MESSAGE_EVENT_NAME, msg);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
function sendMessage(msg) {
|
|
28
|
-
io.emit(_build.SERVER_MESSAGE_EVENT_NAME, msg);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function cleanUp() {
|
|
32
|
-
var sockets = io.sockets.sockets;
|
|
33
|
-
Object.keys(sockets).forEach(function (id) {
|
|
34
|
-
sockets[id].disconnect(true);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
sendMessage: sendMessage,
|
|
40
|
-
cleanUp: cleanUp
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import express from 'express';
|
|
3
|
-
import http from 'http';
|
|
4
|
-
import { Message } from 'react-cosmos-shared2/util';
|
|
5
|
-
import { CosmosConfig } from '../config/shared';
|
|
6
|
-
import { PlatformType } from '../shared/types';
|
|
7
|
-
declare type PluginCleanupCallback = () => unknown;
|
|
8
|
-
declare type PluginReturn = void | null | PluginCleanupCallback;
|
|
9
|
-
export declare type DevServerPluginArgs = {
|
|
10
|
-
cosmosConfig: CosmosConfig;
|
|
11
|
-
platformType: PlatformType;
|
|
12
|
-
httpServer: http.Server;
|
|
13
|
-
expressApp: express.Express;
|
|
14
|
-
sendMessage(msg: Message): unknown;
|
|
15
|
-
};
|
|
16
|
-
export declare type DevServerPlugin = (args: DevServerPluginArgs) => PluginReturn | Promise<PluginReturn>;
|
|
17
|
-
export declare function startDevServer(platformType: PlatformType, plugins?: DevServerPlugin[]): Promise<() => Promise<void>>;
|
|
18
|
-
export {};
|