react-cosmos 5.6.4

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.
Files changed (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/bin/cosmos-export.js +14 -0
  4. package/bin/cosmos-native.js +14 -0
  5. package/bin/cosmos.js +18 -0
  6. package/config.schema.json +186 -0
  7. package/dist/config/createCosmosConfig.d.ts +2 -0
  8. package/dist/config/createCosmosConfig.js +133 -0
  9. package/dist/config/detectCosmosConfig.d.ts +2 -0
  10. package/dist/config/detectCosmosConfig.js +57 -0
  11. package/dist/config/getCosmosConfigAtPath.d.ts +1 -0
  12. package/dist/config/getCosmosConfigAtPath.js +28 -0
  13. package/dist/config/index.d.ts +5 -0
  14. package/dist/config/index.js +51 -0
  15. package/dist/config/resolve.d.ts +1 -0
  16. package/dist/config/resolve.js +20 -0
  17. package/dist/config/shared.d.ts +29 -0
  18. package/dist/config/shared.js +17 -0
  19. package/dist/dom/DomFixtureLoader.d.ts +8 -0
  20. package/dist/dom/DomFixtureLoader.js +38 -0
  21. package/dist/dom/ErrorCatch.d.ts +15 -0
  22. package/dist/dom/ErrorCatch.js +117 -0
  23. package/dist/dom/container.d.ts +1 -0
  24. package/dist/dom/container.js +32 -0
  25. package/dist/dom/globalErrorHandler.d.ts +1 -0
  26. package/dist/dom/globalErrorHandler.js +14 -0
  27. package/dist/dom/index.d.ts +13 -0
  28. package/dist/dom/index.js +47 -0
  29. package/dist/dom/renderMessage.d.ts +3 -0
  30. package/dist/dom/renderMessage.js +30 -0
  31. package/dist/dom/rendererConnect.d.ts +1 -0
  32. package/dist/dom/rendererConnect.js +18 -0
  33. package/dist/dom/rendererId.d.ts +1 -0
  34. package/dist/dom/rendererId.js +26 -0
  35. package/dist/dom/selectedFixtureId.d.ts +2 -0
  36. package/dist/dom/selectedFixtureId.js +41 -0
  37. package/dist/dom/shared.d.ts +1 -0
  38. package/dist/dom/shared.js +14 -0
  39. package/dist/fixture.d.ts +1 -0
  40. package/dist/fixture.js +31 -0
  41. package/dist/getFixtureUrls.d.ts +8 -0
  42. package/dist/getFixtureUrls.js +98 -0
  43. package/dist/getFixtures.d.ts +13 -0
  44. package/dist/getFixtures.js +90 -0
  45. package/dist/getFixtures2.d.ts +14 -0
  46. package/dist/getFixtures2.js +117 -0
  47. package/dist/index.d.ts +4 -0
  48. package/dist/index.js +67 -0
  49. package/dist/native.d.ts +9 -0
  50. package/dist/native.js +69 -0
  51. package/dist/nativeServer.d.ts +1 -0
  52. package/dist/nativeServer.js +39 -0
  53. package/dist/plugins/httpProxy.d.ts +2 -0
  54. package/dist/plugins/httpProxy.js +31 -0
  55. package/dist/plugins/openFile.d.ts +2 -0
  56. package/dist/plugins/openFile.js +87 -0
  57. package/dist/plugins/userDepsFile.d.ts +2 -0
  58. package/dist/plugins/userDepsFile.js +164 -0
  59. package/dist/plugins/webpack/client/errorOverlay/index.d.ts +1 -0
  60. package/dist/plugins/webpack/client/errorOverlay/index.js +16 -0
  61. package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.d.ts +2 -0
  62. package/dist/plugins/webpack/client/errorOverlay/reactErrorOverlay.js +63 -0
  63. package/dist/plugins/webpack/client/hmrErrorHandler.d.ts +1 -0
  64. package/dist/plugins/webpack/client/hmrErrorHandler.js +16 -0
  65. package/dist/plugins/webpack/client/index.d.ts +6 -0
  66. package/dist/plugins/webpack/client/index.js +43 -0
  67. package/dist/plugins/webpack/client/reactDevtoolsHook.d.ts +0 -0
  68. package/dist/plugins/webpack/client/reactDevtoolsHook.js +19 -0
  69. package/dist/plugins/webpack/client/userDeps.d.ts +5 -0
  70. package/dist/plugins/webpack/client/userDeps.js +15 -0
  71. package/dist/plugins/webpack/cosmosConfig/dom.d.ts +6 -0
  72. package/dist/plugins/webpack/cosmosConfig/dom.js +19 -0
  73. package/dist/plugins/webpack/cosmosConfig/webpack.d.ts +9 -0
  74. package/dist/plugins/webpack/cosmosConfig/webpack.js +88 -0
  75. package/dist/plugins/webpack/devServer.d.ts +2 -0
  76. package/dist/plugins/webpack/devServer.js +168 -0
  77. package/dist/plugins/webpack/export.d.ts +2 -0
  78. package/dist/plugins/webpack/export.js +135 -0
  79. package/dist/plugins/webpack/index.d.ts +2 -0
  80. package/dist/plugins/webpack/index.js +21 -0
  81. package/dist/plugins/webpack/shared.d.ts +2 -0
  82. package/dist/plugins/webpack/shared.js +22 -0
  83. package/dist/plugins/webpack/webpackConfig/default.d.ts +2 -0
  84. package/dist/plugins/webpack/webpackConfig/default.js +152 -0
  85. package/dist/plugins/webpack/webpackConfig/devServer.d.ts +3 -0
  86. package/dist/plugins/webpack/webpackConfig/devServer.js +144 -0
  87. package/dist/plugins/webpack/webpackConfig/export.d.ts +3 -0
  88. package/dist/plugins/webpack/webpackConfig/export.js +110 -0
  89. package/dist/plugins/webpack/webpackConfig/htmlPlugin.d.ts +16 -0
  90. package/dist/plugins/webpack/webpackConfig/htmlPlugin.js +80 -0
  91. package/dist/plugins/webpack/webpackConfig/index.d.ts +2 -0
  92. package/dist/plugins/webpack/webpackConfig/index.js +21 -0
  93. package/dist/plugins/webpack/webpackConfig/module.d.ts +3 -0
  94. package/dist/plugins/webpack/webpackConfig/module.js +18 -0
  95. package/dist/plugins/webpack/webpackConfig/shared.d.ts +11 -0
  96. package/dist/plugins/webpack/webpackConfig/shared.js +254 -0
  97. package/dist/plugins/webpack/webpackConfig/userDepsLoader.d.ts +1 -0
  98. package/dist/plugins/webpack/webpackConfig/userDepsLoader.js +36 -0
  99. package/dist/shared/cli.d.ts +5 -0
  100. package/dist/shared/cli.js +14 -0
  101. package/dist/shared/devServer/app.d.ts +5 -0
  102. package/dist/shared/devServer/app.js +51 -0
  103. package/dist/shared/devServer/httpServer.d.ts +11 -0
  104. package/dist/shared/devServer/httpServer.js +183 -0
  105. package/dist/shared/devServer/index.d.ts +18 -0
  106. package/dist/shared/devServer/index.js +209 -0
  107. package/dist/shared/devServer/messageHandler.d.ts +7 -0
  108. package/dist/shared/devServer/messageHandler.js +42 -0
  109. package/dist/shared/export.d.ts +6 -0
  110. package/dist/shared/export.js +137 -0
  111. package/dist/shared/fs.d.ts +4 -0
  112. package/dist/shared/fs.js +37 -0
  113. package/dist/shared/playgroundHtml.d.ts +6 -0
  114. package/dist/shared/playgroundHtml.js +116 -0
  115. package/dist/shared/pluginConfigs.d.ts +2 -0
  116. package/dist/shared/pluginConfigs.js +15 -0
  117. package/dist/shared/rendererConfig.d.ts +6 -0
  118. package/dist/shared/rendererConfig.js +5 -0
  119. package/dist/shared/shared.d.ts +6 -0
  120. package/dist/shared/shared.js +22 -0
  121. package/dist/shared/static/favicon.ico +0 -0
  122. package/dist/shared/static/index.html +19 -0
  123. package/dist/shared/static.d.ts +3 -0
  124. package/dist/shared/static.js +30 -0
  125. package/dist/shared/userDeps/findUserModulePaths.d.ts +11 -0
  126. package/dist/shared/userDeps/findUserModulePaths.js +45 -0
  127. package/dist/shared/userDeps/generateUserDepsModule.d.ts +9 -0
  128. package/dist/shared/userDeps/generateUserDepsModule.js +37 -0
  129. package/dist/shared/userDeps/getUserModules.d.ts +8 -0
  130. package/dist/shared/userDeps/getUserModules.js +45 -0
  131. package/dist/shared/userDeps/index.d.ts +4 -0
  132. package/dist/shared/userDeps/index.js +49 -0
  133. package/dist/shared/userDeps/shared.d.ts +6 -0
  134. package/dist/shared/userDeps/shared.js +32 -0
  135. package/dist/shared/userDeps/userDepsTemplate.d.ts +11 -0
  136. package/dist/shared/userDeps/userDepsTemplate.js +52 -0
  137. package/dist/webExport.d.ts +1 -0
  138. package/dist/webExport.js +37 -0
  139. package/dist/webServer.d.ts +1 -0
  140. package/dist/webServer.js +43 -0
  141. package/dom.d.ts +1 -0
  142. package/dom.js +2 -0
  143. package/fixture.d.ts +1 -0
  144. package/fixture.js +2 -0
  145. package/index.d.ts +1 -0
  146. package/index.js +2 -0
  147. package/native.d.ts +1 -0
  148. package/native.js +2 -0
  149. package/package.json +42 -0
  150. package/yarn-error.log +13450 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-present Ovidiu Cherecheș
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ <p align="center">
2
+ <a href="https://reactcosmos.org"><img alt="Cosmos" width="150" height="150" src="https://raw.githubusercontent.com/react-cosmos/react-cosmos/main/cosmos.png"></a>
3
+ </p>
4
+
5
+ # React Cosmos
6
+
7
+ Sandbox for developing and testing UI components in isolation.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Set the env before any code reads it
4
+ process.env.NODE_ENV = process.env.NODE_ENV || 'production';
5
+
6
+ require('regenerator-runtime/runtime');
7
+ const { generateWebExport } = require('../dist/webExport');
8
+
9
+ generateWebExport().catch(err => {
10
+ console.log('[Cosmos] Export failed...');
11
+ console.log(`\n (╯°□°)╯︵ ┻━┻\n`);
12
+ console.log(err);
13
+ process.exit(1);
14
+ });
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Set the env before any code reads it
4
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
5
+
6
+ require('regenerator-runtime/runtime');
7
+ const { startNativeServer } = require('../dist/nativeServer');
8
+
9
+ startNativeServer().catch(err => {
10
+ console.log('[Cosmos] Server crashed...');
11
+ console.log(`\n (╯°□°)╯︵ ┻━┻\n`);
12
+ console.log(err);
13
+ process.exit(1);
14
+ });
package/bin/cosmos.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Set the env before any code reads it
4
+ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
5
+
6
+ // Auto disable Fast Refresh in CRA 4 until integration is implemented
7
+ // https://github.com/react-cosmos/react-cosmos/issues/1272
8
+ process.env.FAST_REFRESH = process.env.FAST_REFRESH || false;
9
+
10
+ require('regenerator-runtime/runtime');
11
+ const { startWebServer } = require('../dist/webServer');
12
+
13
+ startWebServer().catch(err => {
14
+ console.log('[Cosmos] Server crashed...');
15
+ console.log(`\n (╯°□°)╯︵ ┻━┻\n`);
16
+ console.log(err);
17
+ process.exit(1);
18
+ });
@@ -0,0 +1,186 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-04/schema",
3
+ "title": "JSON schema for React Cosmos configs",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "$schema": {
8
+ "type": "string"
9
+ },
10
+ "rootDir": {
11
+ "description": "The root directory that all others paths in this config are relative to. Usually the root of your repo. If omitted, rootDir is equal to the directory containing your Cosmos config. When you don't use a Cosmos config, rootDir defaults to the current working directory.",
12
+ "type": "string",
13
+ "minLength": 1
14
+ },
15
+ "exportPath": {
16
+ "description": "Where to generate static exports on disk. [default: \"cosmos-export\"]",
17
+ "type": "string",
18
+ "minLength": 1
19
+ },
20
+ "disablePlugins": {
21
+ "description": "Disable plugins",
22
+ "type": "boolean"
23
+ },
24
+ "staticPath": {
25
+ "description": "Dir path to serve static assets from.",
26
+ "type": "string",
27
+ "minLength": 1
28
+ },
29
+ "publicUrl": {
30
+ "description": "Base URL for static assets. [default: \"/\"]",
31
+ "type": "string"
32
+ },
33
+ "fixturesDir": {
34
+ "description": "Name for directories that contain fixtures (eg. __fixtures__/example.jsx). [default: \"__fixtures__\"]",
35
+ "type": "string",
36
+ "minLength": 1
37
+ },
38
+ "fixtureFileSuffix": {
39
+ "description": "Suffix for fixture files (eg. example.fixture.jsx). [default: \"fixture\"]",
40
+ "type": "string",
41
+ "minLength": 1
42
+ },
43
+ "watchDirs": {
44
+ "description": "Directories where the Cosmos server watches for fixture files changes while running. [default: [\".\"]]",
45
+ "type": "array",
46
+ "items": {
47
+ "type": "string",
48
+ "minLength": 1
49
+ },
50
+ "uniqueItems": true
51
+ },
52
+ "userDepsFilePath": {
53
+ "description": "Where to generate a file that contains a map to all fixtures and other Cosmos-related user modules. Only used in setups where Cosmos can't piggyback on the user's build (eg. React Native setups). [default: \"cosmos.userdeps.js\"]",
54
+ "type": "string",
55
+ "minLength": 1
56
+ },
57
+ "hostname": {
58
+ "description": "Dev server hostname. Set to null to accept connections with any hostname. [default: null]",
59
+ "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }]
60
+ },
61
+ "port": {
62
+ "description": "Dev server port. [default: 5000]",
63
+ "type": "number"
64
+ },
65
+ "https": {
66
+ "description": "Server will be served over HTTPS",
67
+ "type": "boolean"
68
+ },
69
+ "httpsOptions": {
70
+ "description": "Additional options for HTTPS server",
71
+ "type": "object",
72
+ "additionalProperties": false,
73
+ "properties": {
74
+ "certPath": {
75
+ "description": "Path of a certificate file",
76
+ "type": "string"
77
+ },
78
+ "keyPath": {
79
+ "description": "Path of a certificate's key file",
80
+ "type": "string"
81
+ }
82
+ }
83
+ },
84
+ "httpProxy": {
85
+ "description": "Proxy some URLs to a different HTTP server (eg. an API backend dev server). Similar to devServer.proxy in webpack config.",
86
+ "type": "object",
87
+ "additionalProperties": true,
88
+ "patternProperties": {
89
+ ".*": {
90
+ "anyOf": [
91
+ { "type": "string" },
92
+ {
93
+ "type": "object",
94
+ "description": "Advanced HTTP proxy config.",
95
+ "additionalProperties": true,
96
+ "required": ["target"],
97
+ "properties": {
98
+ "target": { "type": "string" },
99
+ "secure": { "type": "boolean" },
100
+ "pathRewrite": {
101
+ "type": "object",
102
+ "patternProperties": { ".*": { "type": "string" } }
103
+ },
104
+ "logLevel": {
105
+ "type": "string",
106
+ "enum": ["error", "debug", "info", "warn", "silent"]
107
+ }
108
+ }
109
+ }
110
+ ]
111
+ }
112
+ }
113
+ },
114
+ "globalImports": {
115
+ "description": "Modules to be imported before loading components. Stuff like reset.css, polyfills, etc.",
116
+ "type": "array",
117
+ "items": { "type": "string", "minLength": 1 },
118
+ "uniqueItems": true
119
+ },
120
+ "experimentalRendererUrl": {
121
+ "description": "Custom renderer URL. This setting disables webpack bundling and allows integration with other build tools like Snowpack. [default: null]",
122
+ "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }]
123
+ },
124
+ "dom": {
125
+ "description": "DOM-related options",
126
+ "type": "object",
127
+ "properties": {
128
+ "containerQuerySelector": {
129
+ "description": "Document selector for existing element to use as component parent (eg. #root). A blank container element is created from scratch if no selector is provided. [default: null]",
130
+ "type": ["string", "null"],
131
+ "minLength": 1
132
+ }
133
+ }
134
+ },
135
+ "webpack": {
136
+ "description": "Webpack-related options",
137
+ "type": "object",
138
+ "additionalProperties": false,
139
+ "properties": {
140
+ "configPath": {
141
+ "description": "Path to an existing webpack config, which Cosmos will reuse to build your code. Set to null to disable this behavior. [default \"webpack.config.js\"]",
142
+ "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }]
143
+ },
144
+ "overridePath": {
145
+ "description": "Path to a user module that customizes the webpack config used by Cosmos. Set to null to disable this behavior. [default \"webpack.override.js\"]",
146
+ "anyOf": [{ "type": "string", "minLength": 1 }, { "type": "null" }]
147
+ },
148
+ "includeHashInOutputFilename": {
149
+ "description": "Changes output filename from \"[name].js\" to \"[name].[contenthash].js\". [default: false]",
150
+ "type": "boolean"
151
+ },
152
+ "hotReload": {
153
+ "description": "Enable webpack's Hot Module Replacement. [default: true]",
154
+ "type": "boolean"
155
+ }
156
+ }
157
+ },
158
+ "ui": {
159
+ "description": "UI plugin options",
160
+ "type": "object",
161
+ "additionalProperties": true,
162
+ "properties": {
163
+ "responsivePreview": {
164
+ "type": "object",
165
+ "additionalProperties": false,
166
+ "properties": {
167
+ "devices": {
168
+ "description": "List of device viewports",
169
+ "type": "array",
170
+ "items": {
171
+ "type": "object",
172
+ "additionalProperties": false,
173
+ "required": ["label", "width", "height"],
174
+ "properties": {
175
+ "label": { "type": "string", "minLength": 1 },
176
+ "width": { "type": "number", "minimum": 1 },
177
+ "height": { "type": "number", "minimum": 1 }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
@@ -0,0 +1,2 @@
1
+ import { CosmosConfig, CosmosConfigInput } from './shared';
2
+ export declare function createCosmosConfig(rootDir: string, cosmosConfigInput?: CosmosConfigInput): CosmosConfig;
@@ -0,0 +1,133 @@
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 _resolve = require("./resolve");
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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { 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, _resolve.resolveModule)(rootDir, globalImport);
132
+ });
133
+ }
@@ -0,0 +1,2 @@
1
+ export declare function detectCosmosConfig(): import("./shared").CosmosConfig;
2
+ export declare function detectCosmosConfigPath(): string | null;
@@ -0,0 +1,57 @@
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
+ }
@@ -0,0 +1 @@
1
+ export declare function getCosmosConfigAtPath(cosmosConfigPath: string): import("./shared").CosmosConfig;
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ export { createCosmosConfig } from './createCosmosConfig';
2
+ export { detectCosmosConfig, detectCosmosConfigPath, } from './detectCosmosConfig';
3
+ export { getCosmosConfigAtPath } from './getCosmosConfigAtPath';
4
+ export { resolveModule } from './resolve';
5
+ export { CosmosConfig } from './shared';
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "createCosmosConfig", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _createCosmosConfig.createCosmosConfig;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "detectCosmosConfig", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _detectCosmosConfig.detectCosmosConfig;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "detectCosmosConfigPath", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _detectCosmosConfig.detectCosmosConfigPath;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "getCosmosConfigAtPath", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _getCosmosConfigAtPath.getCosmosConfigAtPath;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "resolveModule", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _resolve.resolveModule;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "CosmosConfig", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _shared.CosmosConfig;
40
+ }
41
+ });
42
+
43
+ var _createCosmosConfig = require("./createCosmosConfig");
44
+
45
+ var _detectCosmosConfig = require("./detectCosmosConfig");
46
+
47
+ var _getCosmosConfigAtPath = require("./getCosmosConfigAtPath");
48
+
49
+ var _resolve = require("./resolve");
50
+
51
+ var _shared = require("./shared");
@@ -0,0 +1 @@
1
+ export declare function resolveModule(rootDir: string, moduleId: string): string;
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,29 @@
1
+ interface HttpsOptions {
2
+ keyPath: string;
3
+ certPath: string;
4
+ }
5
+ export declare type CosmosConfig = {
6
+ exportPath: string;
7
+ disablePlugins: boolean;
8
+ fixtureFileSuffix: string;
9
+ fixturesDir: string;
10
+ globalImports: string[];
11
+ hostname: null | string;
12
+ https: boolean;
13
+ httpsOptions: null | HttpsOptions;
14
+ port: number;
15
+ publicUrl: string;
16
+ rootDir: string;
17
+ staticPath: null | string;
18
+ userDepsFilePath: string;
19
+ watchDirs: string[];
20
+ experimentalRendererUrl: string | null;
21
+ [option: string]: unknown;
22
+ ui: {
23
+ [pluginName: string]: {};
24
+ };
25
+ };
26
+ export declare type CosmosConfigInput = Partial<CosmosConfig>;
27
+ export declare function getCurrentDir(): string;
28
+ export declare function requireConfigFile(cosmosConfigPath: string): CosmosConfigInput;
29
+ export {};
@@ -0,0 +1,17 @@
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
+ }
@@ -0,0 +1,8 @@
1
+ import { ReactDecoratorsByPath, ReactFixtureExportsByPath } from 'react-cosmos-shared2/react';
2
+ declare type Props = {
3
+ fixtures: ReactFixtureExportsByPath;
4
+ decorators: ReactDecoratorsByPath;
5
+ onErrorReset?: () => unknown;
6
+ };
7
+ export declare function DomFixtureLoader({ fixtures, decorators, onErrorReset, }: Props): JSX.Element;
8
+ export {};