react-cosmos 6.0.0-alpha.0 → 6.0.0-alpha.6
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/server/cosmosPlugin/pluginConfigs.js +1 -1
- package/dist/server/devServer/startDevServer.js +3 -1
- package/dist/server/getFixtures/getFixtures.js +3 -3
- package/dist/server/shared/playgroundHtml.js +3 -3
- package/dist/server/shared/resolveRendererUrl.d.ts +1 -0
- package/dist/server/shared/resolveRendererUrl.js +7 -0
- package/package.json +5 -5
- package/dist/server/shared/resolveUrlPath.d.ts +0 -1
- package/dist/server/shared/resolveUrlPath.js +0 -12
|
@@ -9,7 +9,7 @@ export async function getPluginConfigs({ cosmosConfig, relativePaths, }) {
|
|
|
9
9
|
return moduleConfigs;
|
|
10
10
|
const localConfigs = await findCosmosPluginConfigs({
|
|
11
11
|
rootDir,
|
|
12
|
-
ignore: [`${exportPath}/**`],
|
|
12
|
+
ignore: ['**/node_modules/**', `${exportPath}/**`],
|
|
13
13
|
relativePaths,
|
|
14
14
|
});
|
|
15
15
|
return [...moduleConfigs, ...localConfigs];
|
|
@@ -31,6 +31,9 @@ export async function startDevServer(platformType) {
|
|
|
31
31
|
const app = await createExpressApp(platformType, cosmosConfig, pluginConfigs);
|
|
32
32
|
const httpServer = await createHttpServer(cosmosConfig, app);
|
|
33
33
|
const msgHandler = createMessageHandler(httpServer.server);
|
|
34
|
+
// Make Playground available as soon as possible and show a loading screen
|
|
35
|
+
// while plugins are initializing
|
|
36
|
+
await httpServer.start();
|
|
34
37
|
const pluginCleanupCallbacks = [];
|
|
35
38
|
async function cleanUp() {
|
|
36
39
|
await Promise.all(pluginCleanupCallbacks.map(cleanup => cleanup()));
|
|
@@ -72,7 +75,6 @@ export async function startDevServer(platformType) {
|
|
|
72
75
|
if (cosmosConfig.staticPath) {
|
|
73
76
|
serveStaticDir(app, cosmosConfig.staticPath, cosmosConfig.publicUrl);
|
|
74
77
|
}
|
|
75
|
-
await httpServer.start();
|
|
76
78
|
return cleanUp;
|
|
77
79
|
}
|
|
78
80
|
function logCosmosConfigInfo() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { createFixtureTree, flattenFixtureTree, getDecoratedFixtureElement, getFixtureListFromExports, getSortedDecoratorsForFixturePath, stringifyPlaygroundUrlQuery, stringifyRendererUrlQuery, } from 'react-cosmos-core';
|
|
3
3
|
import { RENDERER_FILENAME } from '../shared/playgroundHtml.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolveRendererUrl } from '../shared/resolveRendererUrl.js';
|
|
5
5
|
import { getUserModules } from '../userDeps/getUserModules.js';
|
|
6
6
|
export function getFixtures(cosmosConfig) {
|
|
7
7
|
const { fixturesDir, fixtureFileSuffix, rootDir } = cosmosConfig;
|
|
@@ -47,8 +47,8 @@ function getRendererUrl(cosmosConfig, fixtureId) {
|
|
|
47
47
|
if (rendererUrl)
|
|
48
48
|
return `${rendererUrl}?${query}`;
|
|
49
49
|
const host = getPlaygroundHost(cosmosConfig);
|
|
50
|
-
const urlPath =
|
|
51
|
-
return `${
|
|
50
|
+
const urlPath = resolveRendererUrl(publicUrl, RENDERER_FILENAME);
|
|
51
|
+
return new URL(`${urlPath}?${query}`, host).toString();
|
|
52
52
|
}
|
|
53
53
|
function getPlaygroundHost({ hostname, port, https }) {
|
|
54
54
|
return `${https ? 'https' : 'http'}://${hostname || 'localhost'}:${port}`;
|
|
@@ -3,7 +3,7 @@ import { readFile } from 'fs/promises';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { pkgUpSync } from 'pkg-up';
|
|
5
5
|
import { replaceKeys } from 'react-cosmos-core';
|
|
6
|
-
import {
|
|
6
|
+
import { resolveRendererUrl } from './resolveRendererUrl.js';
|
|
7
7
|
import { getStaticPath } from './staticPath.js';
|
|
8
8
|
export const RENDERER_FILENAME = '_renderer.html';
|
|
9
9
|
export async function getDevPlaygroundHtml(platformType, cosmosConfig, pluginConfigs) {
|
|
@@ -39,7 +39,7 @@ async function getDevCoreConfig(platformType, cosmosConfig) {
|
|
|
39
39
|
...(await getSharedCoreConfig(cosmosConfig)),
|
|
40
40
|
devServerOn: true,
|
|
41
41
|
webRendererUrl: cosmosConfig.rendererUrl ||
|
|
42
|
-
|
|
42
|
+
resolveRendererUrl(cosmosConfig.publicUrl, RENDERER_FILENAME),
|
|
43
43
|
};
|
|
44
44
|
default:
|
|
45
45
|
throw new Error(`Invalid platform type: ${platformType}`);
|
|
@@ -49,7 +49,7 @@ async function getExportCoreConfig(cosmosConfig) {
|
|
|
49
49
|
return {
|
|
50
50
|
...(await getSharedCoreConfig(cosmosConfig)),
|
|
51
51
|
devServerOn: false,
|
|
52
|
-
webRendererUrl:
|
|
52
|
+
webRendererUrl: resolveRendererUrl(cosmosConfig.publicUrl, RENDERER_FILENAME),
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
async function getSharedCoreConfig(cosmosConfig) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveRendererUrl(publicUrl: string, filename: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.6",
|
|
4
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",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"open": "^8.4.2",
|
|
18
18
|
"pem": "^1.14.6",
|
|
19
19
|
"pkg-up": "^4.0.0",
|
|
20
|
-
"react-cosmos-core": "^6.0.0-alpha.
|
|
21
|
-
"react-cosmos-ui": "^6.0.0-alpha.
|
|
20
|
+
"react-cosmos-core": "^6.0.0-alpha.6",
|
|
21
|
+
"react-cosmos-ui": "^6.0.0-alpha.6",
|
|
22
22
|
"ws": "^8.12.1",
|
|
23
|
-
"yargs": "^17.7.
|
|
23
|
+
"yargs": "^17.7.1"
|
|
24
24
|
},
|
|
25
25
|
"bin": {
|
|
26
26
|
"cosmos": "./bin/cosmos.js",
|
|
27
27
|
"cosmos-export": "./bin/cosmos-export.js",
|
|
28
28
|
"cosmos-native": "./bin/cosmos-native.js"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "e901d3a46ee43a24b6279395e6718c9521088b60"
|
|
31
31
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveUrlPath(base: string, urlPath: string): string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// resolveUrlPath('/', '_renderer.html') => '/_renderer.html'
|
|
2
|
-
// resolveUrlPath('./', '_renderer.html') => '/_renderer.html'
|
|
3
|
-
// resolveUrlPath('http://localhost:5000', '_renderer.html') => 'http://localhost:5000/_renderer.html'
|
|
4
|
-
export function resolveUrlPath(base, urlPath) {
|
|
5
|
-
// The 'resolve://' protocol is only added when base is a relative URL.
|
|
6
|
-
const resolvedUrl = new URL(urlPath, new URL(base, 'resolve://'));
|
|
7
|
-
if (resolvedUrl.protocol === 'resolve:') {
|
|
8
|
-
const { pathname, search, hash } = resolvedUrl;
|
|
9
|
-
return pathname + search + hash;
|
|
10
|
-
}
|
|
11
|
-
return resolvedUrl.toString();
|
|
12
|
-
}
|