react-cosmos 6.0.0-alpha.13 → 6.0.0-alpha.14
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.
|
@@ -35,6 +35,9 @@ export async function startDevServer(platformType) {
|
|
|
35
35
|
const app = await createExpressApp(platformType, cosmosConfig, pluginConfigs);
|
|
36
36
|
const httpServer = await createHttpServer(cosmosConfig, app);
|
|
37
37
|
const msgHandler = createMessageHandler(httpServer.server);
|
|
38
|
+
if (cosmosConfig.staticPath) {
|
|
39
|
+
serveStaticDir(app, cosmosConfig.staticPath, cosmosConfig.publicUrl);
|
|
40
|
+
}
|
|
38
41
|
// Make Playground available as soon as possible and show a loading screen
|
|
39
42
|
// while plugins are initializing
|
|
40
43
|
await httpServer.start();
|
|
@@ -77,9 +80,6 @@ export async function startDevServer(platformType) {
|
|
|
77
80
|
throw err;
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
if (cosmosConfig.staticPath) {
|
|
81
|
-
serveStaticDir(app, cosmosConfig.staticPath, cosmosConfig.publicUrl);
|
|
82
|
-
}
|
|
83
83
|
return cleanUp;
|
|
84
84
|
}
|
|
85
85
|
function logCosmosConfigInfo() {
|
|
@@ -2,7 +2,9 @@ import fs from 'fs';
|
|
|
2
2
|
import { readFile } from 'fs/promises';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { pkgUpSync } from 'pkg-up';
|
|
5
|
-
import { replaceKeys } from 'react-cosmos-core';
|
|
5
|
+
import { replaceKeys, } from 'react-cosmos-core';
|
|
6
|
+
import { findUserModulePaths } from '../userDeps/findUserModulePaths.js';
|
|
7
|
+
import { userDepsKeyPath } from '../userDeps/userDepsShared.js';
|
|
6
8
|
import { resolveRendererUrl } from './resolveRendererUrl.js';
|
|
7
9
|
import { getStaticPath } from './staticPath.js';
|
|
8
10
|
export const RENDERER_FILENAME = '_renderer.html';
|
|
@@ -12,6 +14,7 @@ export async function getDevPlaygroundHtml(platformType, cosmosConfig, pluginCon
|
|
|
12
14
|
playgroundConfig: {
|
|
13
15
|
...ui,
|
|
14
16
|
core: await getDevCoreConfig(platformType, cosmosConfig),
|
|
17
|
+
rendererCore: { fixtures: getFixtureList(cosmosConfig) },
|
|
15
18
|
},
|
|
16
19
|
pluginConfigs,
|
|
17
20
|
});
|
|
@@ -22,6 +25,7 @@ export async function getExportPlaygroundHtml(cosmosConfig, pluginConfigs) {
|
|
|
22
25
|
playgroundConfig: {
|
|
23
26
|
...ui,
|
|
24
27
|
core: await getExportCoreConfig(cosmosConfig),
|
|
28
|
+
rendererCore: { fixtures: getFixtureList(cosmosConfig) },
|
|
25
29
|
},
|
|
26
30
|
pluginConfigs,
|
|
27
31
|
});
|
|
@@ -83,3 +87,10 @@ function getPlaygroundHtml(playgroundArgs) {
|
|
|
83
87
|
function getPlaygroundHtmlTemplate() {
|
|
84
88
|
return fs.readFileSync(getStaticPath('index.html'), 'utf8');
|
|
85
89
|
}
|
|
90
|
+
function getFixtureList(cosmosConfig) {
|
|
91
|
+
const { fixturePaths } = findUserModulePaths(cosmosConfig);
|
|
92
|
+
return fixturePaths.reduce((acc, fixturePath) => ({
|
|
93
|
+
...acc,
|
|
94
|
+
[userDepsKeyPath(fixturePath, cosmosConfig.rootDir)]: { type: 'single' },
|
|
95
|
+
}), {});
|
|
96
|
+
}
|
|
@@ -8,4 +8,5 @@ export type UserDepsTemplateArgs = {
|
|
|
8
8
|
relativeToDir: string | null;
|
|
9
9
|
};
|
|
10
10
|
export declare function userDepsImportMap(paths: string[], rootDir: string, relativeToDir: string | null): Record<string, string>;
|
|
11
|
+
export declare function userDepsKeyPath(filePath: string, rootDir: string): string;
|
|
11
12
|
export declare function userDepsImportPath(filePath: string, relativeToDir: string | null): string;
|
|
@@ -3,9 +3,12 @@ import { slash } from '../utils/slash.js';
|
|
|
3
3
|
export function userDepsImportMap(paths, rootDir, relativeToDir) {
|
|
4
4
|
return paths.reduce((acc, p) => ({
|
|
5
5
|
...acc,
|
|
6
|
-
[
|
|
6
|
+
[userDepsKeyPath(p, rootDir)]: userDepsImportPath(p, relativeToDir),
|
|
7
7
|
}), {});
|
|
8
8
|
}
|
|
9
|
+
export function userDepsKeyPath(filePath, rootDir) {
|
|
10
|
+
return slash(path.relative(rootDir, filePath));
|
|
11
|
+
}
|
|
9
12
|
export function userDepsImportPath(filePath, relativeToDir) {
|
|
10
13
|
return slash(relativeToDir
|
|
11
14
|
? `.${path.sep}${path.relative(relativeToDir, filePath)}`
|
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.14",
|
|
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,8 +17,8 @@
|
|
|
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.14",
|
|
21
|
+
"react-cosmos-ui": "6.0.0-alpha.14",
|
|
22
22
|
"ws": "^8.12.1",
|
|
23
23
|
"yargs": "^17.7.1"
|
|
24
24
|
},
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"cosmos-export": "./bin/cosmos-export.js",
|
|
28
28
|
"cosmos-native": "./bin/cosmos-native.js"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "ed13194534675df091da3ceaef4202572ddeed12"
|
|
31
31
|
}
|