react-cosmos 6.0.0-alpha.9 → 6.0.0-beta.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 +1 -3
- package/bin/cosmos-native.js +1 -3
- package/bin/cosmos.js +1 -7
- package/client.d.ts +1 -0
- package/client.js +1 -0
- package/config.schema.json +53 -15
- package/dist/cjsMocks/requireModule.js +7 -0
- package/dist/cjsMocks/resolve.js +7 -0
- package/dist/cjsMocks/staticPath.js +4 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/corePlugins/exposeImports.d.ts +2 -0
- package/dist/corePlugins/exposeImports.js +53 -0
- package/dist/corePlugins/httpProxy.d.ts +2 -0
- package/dist/corePlugins/httpProxy.js +21 -0
- package/dist/corePlugins/index.d.ts +2 -0
- package/dist/corePlugins/index.js +12 -0
- package/dist/corePlugins/openFile.d.ts +2 -0
- package/dist/corePlugins/openFile.js +59 -0
- package/dist/corePlugins/pluginEndpoint.d.ts +2 -0
- package/dist/corePlugins/pluginEndpoint.js +22 -0
- package/dist/corePlugins/portRetry.d.ts +2 -0
- package/dist/corePlugins/portRetry.js +14 -0
- package/dist/{server/cosmosConfig → cosmosConfig}/createCosmosConfig.js +37 -11
- package/dist/{server/cosmosConfig → cosmosConfig}/shared.js +2 -2
- package/dist/{server/cosmosConfig → cosmosConfig}/types.d.ts +12 -2
- package/dist/{server/cosmosPlugin → cosmosPlugin}/findCosmosPluginConfigs.js +2 -2
- package/dist/{server/cosmosPlugin → cosmosPlugin}/readCosmosPluginConfig.js +4 -7
- package/dist/{server/cosmosPlugin → cosmosPlugin}/types.d.ts +15 -3
- package/dist/devServer/expressApp.d.ts +5 -0
- package/dist/{server/devServer → devServer}/expressApp.js +2 -2
- package/dist/{server/devServer → devServer}/messageHandler.d.ts +1 -1
- package/dist/{server/devServer → devServer}/messageHandler.js +2 -2
- package/dist/devServer/startDevServer.d.ts +2 -0
- package/dist/{server/devServer → devServer}/startDevServer.js +23 -29
- package/dist/{server/export → export}/generateExport.js +21 -18
- package/dist/{server/getFixtures → getFixtures}/getFixtures.d.ts +6 -2
- package/dist/getFixtures/getFixtures.js +53 -0
- package/dist/getFixtures/importUserModules.d.ts +8 -0
- package/dist/getFixtures/importUserModules.js +28 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -1
- package/dist/jest.d.ts +4 -7
- package/dist/jest.js +4 -7
- package/dist/shared/applyServerConfigPlugins.d.ts +11 -0
- package/dist/shared/applyServerConfigPlugins.js +14 -0
- package/dist/shared/findNextAvailablePort.d.ts +1 -0
- package/dist/shared/findNextAvailablePort.js +29 -0
- package/dist/shared/getServerPlugins.d.ts +2 -0
- package/dist/shared/getServerPlugins.js +6 -0
- package/dist/shared/importServerPlugins.d.ts +3 -0
- package/dist/shared/importServerPlugins.js +16 -0
- package/dist/shared/playgroundHtml.d.ts +5 -0
- package/dist/{server/shared → shared}/playgroundHtml.js +25 -33
- package/dist/shared/staticPath.d.ts +1 -0
- package/dist/{server/shared → shared}/staticServer.js +3 -1
- package/dist/{server/testHelpers → testHelpers}/mockConsole.js +8 -4
- package/dist/{server/testHelpers → testHelpers}/mockFs.d.ts +2 -2
- package/dist/{server/testHelpers → testHelpers}/mockFs.js +26 -8
- package/dist/{server/testHelpers → testHelpers}/mockYargs.js +1 -0
- package/dist/{server/userDeps → userModules}/findUserModulePaths.js +2 -2
- package/dist/userModules/generateUserImports.d.ts +10 -0
- package/dist/{server/userDeps/generateUserDepsModule.js → userModules/generateUserImports.js} +8 -3
- package/dist/userModules/shared.d.ts +15 -0
- package/dist/{server/userDeps → userModules}/shared.js +16 -0
- package/dist/userModules/userImportsLazyTemplate.d.ts +2 -0
- package/dist/userModules/userImportsLazyTemplate.js +54 -0
- package/dist/userModules/userImportsTemplate.d.ts +2 -0
- package/dist/userModules/userImportsTemplate.js +56 -0
- package/dist/{server/utils → utils}/cli.d.ts +1 -0
- package/dist/utils/cli.js +4 -0
- package/dist/utils/fs.d.ts +5 -0
- package/dist/{server/utils → utils}/fs.js +10 -6
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/requireModule.d.ts +2 -0
- package/dist/utils/resolve.d.ts +2 -0
- package/package.json +10 -9
- package/dist/server/devServer/corePlugins/httpProxy.d.ts +0 -2
- package/dist/server/devServer/corePlugins/httpProxy.js +0 -18
- package/dist/server/devServer/corePlugins/openFile.d.ts +0 -2
- package/dist/server/devServer/corePlugins/openFile.js +0 -53
- package/dist/server/devServer/corePlugins/pluginEndpoint.d.ts +0 -2
- package/dist/server/devServer/corePlugins/pluginEndpoint.js +0 -17
- package/dist/server/devServer/corePlugins/userDepsFile.d.ts +0 -2
- package/dist/server/devServer/corePlugins/userDepsFile.js +0 -37
- package/dist/server/devServer/expressApp.d.ts +0 -5
- package/dist/server/devServer/startDevServer.d.ts +0 -2
- package/dist/server/getFixtures/getFixtures.js +0 -63
- package/dist/server/shared/playgroundHtml.d.ts +0 -6
- package/dist/server/shared/requirePluginModule.d.ts +0 -2
- package/dist/server/shared/requirePluginModule.js +0 -10
- package/dist/server/shared/resolveRendererUrl.d.ts +0 -1
- package/dist/server/shared/resolveRendererUrl.js +0 -7
- package/dist/server/testHelpers/mockEsmRequire.js +0 -13
- package/dist/server/testHelpers/mockEsmResolve.d.ts +0 -1
- package/dist/server/testHelpers/mockEsmResolve.js +0 -13
- package/dist/server/testHelpers/mockEsmStaticPath.d.ts +0 -1
- package/dist/server/testHelpers/mockEsmStaticPath.js +0 -7
- package/dist/server/userDeps/generateUserDepsModule.d.ts +0 -9
- package/dist/server/userDeps/getUserModules.d.ts +0 -8
- package/dist/server/userDeps/getUserModules.js +0 -26
- package/dist/server/userDeps/shared.d.ts +0 -5
- package/dist/server/userDeps/userDepsTemplate.d.ts +0 -11
- package/dist/server/userDeps/userDepsTemplate.js +0 -49
- package/dist/server/utils/cli.js +0 -4
- package/dist/server/utils/fs.d.ts +0 -4
- package/dist/server.d.ts +0 -20
- package/dist/server.js +0 -20
- package/server.d.ts +0 -1
- package/server.js +0 -1
- /package/dist/{server/utils → cjsMocks}/requireModule.d.ts +0 -0
- /package/dist/{server/utils → cjsMocks}/resolve.d.ts +0 -0
- /package/dist/{server/shared → cjsMocks}/staticPath.d.ts +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/createCosmosConfig.d.ts +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/detectCosmosConfig.d.ts +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/detectCosmosConfig.js +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/getCosmosConfigAtPath.d.ts +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/getCosmosConfigAtPath.js +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/shared.d.ts +0 -0
- /package/dist/{server/cosmosConfig → cosmosConfig}/types.js +0 -0
- /package/dist/{server/cosmosPlugin → cosmosPlugin}/findCosmosPluginConfigs.d.ts +0 -0
- /package/dist/{server/cosmosPlugin → cosmosPlugin}/pluginConfigs.d.ts +0 -0
- /package/dist/{server/cosmosPlugin → cosmosPlugin}/pluginConfigs.js +0 -0
- /package/dist/{server/cosmosPlugin → cosmosPlugin}/readCosmosPluginConfig.d.ts +0 -0
- /package/dist/{server/cosmosPlugin → cosmosPlugin}/types.js +0 -0
- /package/dist/{server/devServer → devServer}/httpServer.d.ts +0 -0
- /package/dist/{server/devServer → devServer}/httpServer.js +0 -0
- /package/dist/{server/export → export}/generateExport.d.ts +0 -0
- /package/dist/{server/shared → shared}/logPluginInfo.d.ts +0 -0
- /package/dist/{server/shared → shared}/logPluginInfo.js +0 -0
- /package/dist/{server/shared → shared}/playgroundUrl.d.ts +0 -0
- /package/dist/{server/shared → shared}/playgroundUrl.js +0 -0
- /package/dist/{server/shared → shared}/staticPath.js +0 -0
- /package/dist/{server/shared → shared}/staticServer.d.ts +0 -0
- /package/dist/{server/static → static}/favicon.ico +0 -0
- /package/dist/{server/static → static}/index.html +0 -0
- /package/dist/{server/testHelpers → testHelpers}/cwd.d.ts +0 -0
- /package/dist/{server/testHelpers → testHelpers}/cwd.js +0 -0
- /package/dist/{server/testHelpers → testHelpers}/mockConsole.d.ts +0 -0
- /package/dist/{server/testHelpers → testHelpers}/mockFetch.d.ts +0 -0
- /package/dist/{server/testHelpers → testHelpers}/mockFetch.js +0 -0
- /package/dist/{server/testHelpers → testHelpers}/mockYargs.d.ts +0 -0
- /package/dist/{server/userDeps → userModules}/findUserModulePaths.d.ts +0 -0
- /package/dist/{server/userDeps → userModules}/fixtureWatcher.d.ts +0 -0
- /package/dist/{server/userDeps → userModules}/fixtureWatcher.js +0 -0
- /package/dist/{server/utils → utils}/isNodeError.d.ts +0 -0
- /package/dist/{server/utils → utils}/isNodeError.js +0 -0
- /package/dist/{server/testHelpers/mockEsmRequire.d.ts → utils/json.js} +0 -0
- /package/dist/{server/utils → utils}/requireModule.js +0 -0
- /package/dist/{server/utils → utils}/requireSilent.d.ts +0 -0
- /package/dist/{server/utils → utils}/requireSilent.js +0 -0
- /package/dist/{server/utils → utils}/resolve.js +0 -0
- /package/dist/{server/utils → utils}/resolveLoose.d.ts +0 -0
- /package/dist/{server/utils → utils}/resolveLoose.js +0 -0
- /package/dist/{server/utils → utils}/resolveSilent.d.ts +0 -0
- /package/dist/{server/utils → utils}/resolveSilent.js +0 -0
- /package/dist/{server/utils → utils}/slash.d.ts +0 -0
- /package/dist/{server/utils → utils}/slash.js +0 -0
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
jest.mock('../utils/requireModule.js', () => {
|
|
2
|
-
function requireModule(moduleId) {
|
|
3
|
-
return require(moduleId);
|
|
4
|
-
}
|
|
5
|
-
function requireFrom(fromDirectory, moduleId) {
|
|
6
|
-
return require(require.resolve(moduleId, { paths: [fromDirectory] }));
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
requireModule,
|
|
10
|
-
requireFrom,
|
|
11
|
-
};
|
|
12
|
-
});
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
jest.mock('../utils/resolve.js', () => {
|
|
2
|
-
function resolve(moduleId) {
|
|
3
|
-
return require.resolve(moduleId);
|
|
4
|
-
}
|
|
5
|
-
function resolveFrom(fromDirectory, moduleId) {
|
|
6
|
-
return require.resolve(moduleId, { paths: [fromDirectory] });
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
resolve,
|
|
10
|
-
resolveFrom,
|
|
11
|
-
};
|
|
12
|
-
});
|
|
13
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CosmosConfig } from '../cosmosConfig/types.js';
|
|
2
|
-
import { Json } from './shared.js';
|
|
3
|
-
type Args = {
|
|
4
|
-
cosmosConfig: CosmosConfig;
|
|
5
|
-
rendererConfig: Json;
|
|
6
|
-
relativeToDir: string | null;
|
|
7
|
-
};
|
|
8
|
-
export declare function generateUserDepsModule({ cosmosConfig, rendererConfig, relativeToDir, }: Args): string;
|
|
9
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactDecorators, ReactFixtureExports } from 'react-cosmos-core';
|
|
2
|
-
import { CosmosConfig } from '../cosmosConfig/types.js';
|
|
3
|
-
type UserModules = {
|
|
4
|
-
fixtures: ReactFixtureExports;
|
|
5
|
-
decorators: ReactDecorators;
|
|
6
|
-
};
|
|
7
|
-
export declare function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }: CosmosConfig): UserModules;
|
|
8
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { slash } from '../utils/slash.js';
|
|
3
|
-
import { findUserModulePaths } from './findUserModulePaths.js';
|
|
4
|
-
export function getUserModules({ rootDir, fixturesDir, fixtureFileSuffix, ignore, }) {
|
|
5
|
-
const { fixturePaths, decoratorPaths } = findUserModulePaths({
|
|
6
|
-
rootDir,
|
|
7
|
-
fixturesDir,
|
|
8
|
-
fixtureFileSuffix,
|
|
9
|
-
ignore,
|
|
10
|
-
});
|
|
11
|
-
return {
|
|
12
|
-
fixtures: getDefaultExports(fixturePaths, rootDir),
|
|
13
|
-
decorators: getDefaultExports(decoratorPaths, rootDir),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function getDefaultExports(paths, rootDir) {
|
|
17
|
-
const exportsByPath = {};
|
|
18
|
-
paths.forEach(p => {
|
|
19
|
-
// Converting to forward slashes on Windows is important because the
|
|
20
|
-
// slashes are used for generating a sorted list of fixtures and
|
|
21
|
-
// decorators.
|
|
22
|
-
const relPath = slash(path.relative(rootDir, p));
|
|
23
|
-
exportsByPath[relPath] = require(p).default;
|
|
24
|
-
});
|
|
25
|
-
return exportsByPath;
|
|
26
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Json } from './shared.js';
|
|
2
|
-
type Args = {
|
|
3
|
-
globalImports: string[];
|
|
4
|
-
fixturePaths: string[];
|
|
5
|
-
decoratorPaths: string[];
|
|
6
|
-
rendererConfig: Json;
|
|
7
|
-
rootDir: string;
|
|
8
|
-
relativeToDir: string | null;
|
|
9
|
-
};
|
|
10
|
-
export declare function userDepsTemplate({ globalImports, fixturePaths, decoratorPaths, rendererConfig, rootDir, relativeToDir, }: Args): string;
|
|
11
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { slash } from '../utils/slash.js';
|
|
3
|
-
export function userDepsTemplate({ globalImports, fixturePaths, decoratorPaths, rendererConfig, rootDir, relativeToDir, }) {
|
|
4
|
-
const fixtures = createImportMap(fixturePaths, rootDir, relativeToDir);
|
|
5
|
-
const fixtureKeys = Object.keys(fixtures);
|
|
6
|
-
const decorators = createImportMap(decoratorPaths, rootDir, relativeToDir);
|
|
7
|
-
const decoratorKeys = Object.keys(decorators);
|
|
8
|
-
return `
|
|
9
|
-
// This file is automatically generated by Cosmos. Add it to .gitignore and
|
|
10
|
-
// only edit if you know what you're doing.
|
|
11
|
-
|
|
12
|
-
// Keeping global imports here is superior to making them bundle entry points
|
|
13
|
-
// because this way they become hot-reloadable.
|
|
14
|
-
${globalImports
|
|
15
|
-
.map(p => `import '${resolveImportPath(p, relativeToDir)}';`)
|
|
16
|
-
.join(`\n`)}
|
|
17
|
-
|
|
18
|
-
${fixtureKeys
|
|
19
|
-
.map((k, i) => `import fixture${i} from '${fixtures[k]}';`)
|
|
20
|
-
.join(`\n`)}
|
|
21
|
-
|
|
22
|
-
${decoratorKeys
|
|
23
|
-
.map((k, i) => `import decorator${i} from '${decorators[k]}';`)
|
|
24
|
-
.join(`\n`)}
|
|
25
|
-
|
|
26
|
-
export const rendererConfig = ${JSON.stringify(rendererConfig, null, 2)};
|
|
27
|
-
|
|
28
|
-
export const fixtures = {
|
|
29
|
-
${fixtureKeys
|
|
30
|
-
.map((k, i) => ` '${k}': { module: { default: fixture${i} } }`)
|
|
31
|
-
.join(`,\n`)}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const decorators = {
|
|
35
|
-
${decoratorKeys.map((k, i) => ` '${k}': decorator${i}`).join(`,\n`)}
|
|
36
|
-
};
|
|
37
|
-
`.trimStart();
|
|
38
|
-
}
|
|
39
|
-
function createImportMap(paths, rootDir, relativeToDir) {
|
|
40
|
-
return paths.reduce((acc, p) => ({
|
|
41
|
-
...acc,
|
|
42
|
-
[slash(path.relative(rootDir, p))]: resolveImportPath(p, relativeToDir),
|
|
43
|
-
}), {});
|
|
44
|
-
}
|
|
45
|
-
function resolveImportPath(filePath, relativeToDir) {
|
|
46
|
-
return slash(relativeToDir
|
|
47
|
-
? `.${path.sep}${path.relative(relativeToDir, filePath)}`
|
|
48
|
-
: filePath);
|
|
49
|
-
}
|
package/dist/server/utils/cli.js
DELETED
package/dist/server.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './server/cosmosConfig/createCosmosConfig.js';
|
|
2
|
-
export * from './server/cosmosConfig/detectCosmosConfig.js';
|
|
3
|
-
export * from './server/cosmosConfig/getCosmosConfigAtPath.js';
|
|
4
|
-
export * from './server/cosmosConfig/types.js';
|
|
5
|
-
export * from './server/cosmosPlugin/findCosmosPluginConfigs.js';
|
|
6
|
-
export * from './server/cosmosPlugin/pluginConfigs.js';
|
|
7
|
-
export * from './server/cosmosPlugin/types.js';
|
|
8
|
-
export * from './server/getFixtures/getFixtures.js';
|
|
9
|
-
export { RENDERER_FILENAME } from './server/shared/playgroundHtml.js';
|
|
10
|
-
export * from './server/shared/playgroundUrl.js';
|
|
11
|
-
export * from './server/shared/staticServer.js';
|
|
12
|
-
export * from './server/testHelpers/cwd.js';
|
|
13
|
-
export * from './server/userDeps/fixtureWatcher.js';
|
|
14
|
-
export * from './server/userDeps/generateUserDepsModule.js';
|
|
15
|
-
export * from './server/utils/cli.js';
|
|
16
|
-
export * from './server/utils/fs.js';
|
|
17
|
-
export * from './server/utils/requireSilent.js';
|
|
18
|
-
export * from './server/utils/resolve.js';
|
|
19
|
-
export * from './server/utils/resolveLoose.js';
|
|
20
|
-
export * from './server/utils/resolveSilent.js';
|
package/dist/server.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * from './server/cosmosConfig/createCosmosConfig.js';
|
|
2
|
-
export * from './server/cosmosConfig/detectCosmosConfig.js';
|
|
3
|
-
export * from './server/cosmosConfig/getCosmosConfigAtPath.js';
|
|
4
|
-
export * from './server/cosmosConfig/types.js';
|
|
5
|
-
export * from './server/cosmosPlugin/findCosmosPluginConfigs.js';
|
|
6
|
-
export * from './server/cosmosPlugin/pluginConfigs.js';
|
|
7
|
-
export * from './server/cosmosPlugin/types.js';
|
|
8
|
-
export * from './server/getFixtures/getFixtures.js';
|
|
9
|
-
export { RENDERER_FILENAME } from './server/shared/playgroundHtml.js';
|
|
10
|
-
export * from './server/shared/playgroundUrl.js';
|
|
11
|
-
export * from './server/shared/staticServer.js';
|
|
12
|
-
export * from './server/testHelpers/cwd.js';
|
|
13
|
-
export * from './server/userDeps/fixtureWatcher.js';
|
|
14
|
-
export * from './server/userDeps/generateUserDepsModule.js';
|
|
15
|
-
export * from './server/utils/cli.js';
|
|
16
|
-
export * from './server/utils/fs.js';
|
|
17
|
-
export * from './server/utils/requireSilent.js';
|
|
18
|
-
export * from './server/utils/resolve.js';
|
|
19
|
-
export * from './server/utils/resolveLoose.js';
|
|
20
|
-
export * from './server/utils/resolveSilent.js';
|
package/server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/server.js';
|
package/server.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './dist/server.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|