creevey 0.9.0-beta.2 → 0.9.0-non-webpack.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/AUTHORS +15 -15
- package/CHANGELOG.md +1275 -1275
- package/LICENSE +21 -21
- package/README.md +7 -0
- package/addon/README.md +3 -0
- package/addon/package.json +4 -0
- package/docs/config.md +212 -212
- package/docs/grid.md +10 -10
- package/docs/tests.md +63 -63
- package/jest.config.js +6 -0
- package/lib/cjs/client/addon/Manager.js +11 -5
- package/lib/cjs/client/addon/components/Addon.js +1 -1
- package/lib/cjs/client/addon/components/Icons.js +2 -2
- package/lib/cjs/client/addon/components/Tools.js +1 -1
- package/lib/cjs/client/addon/index.js +31 -0
- package/lib/cjs/client/addon/preset.js +3 -3
- package/lib/cjs/client/addon/register.js +7 -3
- package/lib/cjs/client/addon/withCreevey.js +57 -30
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +1 -1
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +1 -1
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +1 -1
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +1 -1
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +1 -1
- package/lib/cjs/client/shared/components/ImagesView/index.js +4 -4
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +1 -1
- package/lib/cjs/client/shared/components/ResultsPage.js +2 -2
- package/lib/cjs/client/shared/creeveyClientApi.js +6 -2
- package/lib/cjs/client/shared/helpers.js +22 -22
- package/lib/cjs/client/shared/viewMode.js +1 -1
- package/lib/cjs/client/web/142.js +2 -0
- package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
- package/lib/cjs/client/web/32.js +1 -0
- package/lib/cjs/client/web/551.js +1 -0
- package/lib/cjs/client/web/566.js +2 -0
- package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
- package/lib/cjs/client/web/691.js +2 -0
- package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
- package/lib/cjs/client/web/725.js +1 -0
- package/lib/cjs/client/web/index.html +19 -19
- package/lib/cjs/client/web/main.js +2 -38
- package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
- package/lib/cjs/creevey.js +3 -5
- package/lib/cjs/index.js +4 -4
- package/lib/cjs/server/config.js +1 -1
- package/lib/cjs/server/docker.js +3 -7
- package/lib/cjs/server/index.js +1 -1
- package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
- package/lib/cjs/server/loaders/babel/helpers.js +13 -23
- package/lib/cjs/server/loaders/babel/register.js +1 -3
- package/lib/cjs/server/loaders/webpack/compile.js +31 -24
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +10 -5
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +1 -1
- package/lib/cjs/server/loaders/webpack/start.js +1 -1
- package/lib/cjs/server/logger.js +2 -1
- package/lib/cjs/server/master/index.js +2 -2
- package/lib/cjs/server/master/pool.js +9 -18
- package/lib/cjs/server/master/runner.js +53 -66
- package/lib/cjs/server/master/server.js +2 -2
- package/lib/cjs/server/messages.js +8 -10
- package/lib/cjs/server/selenium/browser.js +23 -31
- package/lib/cjs/server/selenium/selenoid.js +5 -7
- package/lib/cjs/server/stories.js +9 -20
- package/lib/cjs/server/storybook/entry.js +5 -3
- package/lib/cjs/server/storybook/helpers.js +15 -21
- package/lib/cjs/server/storybook/providers/browser.js +5 -9
- package/lib/cjs/server/storybook/providers/nodejs.js +4 -4
- package/lib/cjs/server/update.js +1 -5
- package/lib/cjs/server/utils.js +13 -15
- package/lib/cjs/server/worker/reporter.js +8 -20
- package/lib/cjs/server/worker/worker.js +6 -16
- package/lib/cjs/shared/index.js +89 -0
- package/lib/cjs/shared/serializeRegExp.js +41 -0
- package/lib/cjs/types.js +6 -6
- package/lib/esm/client/addon/Manager.js +11 -5
- package/lib/esm/client/addon/components/Icons.js +1 -1
- package/lib/esm/client/addon/index.js +2 -0
- package/lib/esm/client/addon/preset.js +1 -1
- package/lib/esm/client/addon/register.js +6 -2
- package/lib/esm/client/addon/withCreevey.js +55 -30
- package/lib/esm/client/shared/creeveyClientApi.js +6 -2
- package/lib/esm/client/shared/helpers.js +6 -6
- package/lib/esm/creevey.js +3 -5
- package/lib/esm/index.js +1 -3
- package/lib/esm/server/docker.js +2 -2
- package/lib/esm/server/index.js +1 -1
- package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
- package/lib/esm/server/loaders/babel/helpers.js +12 -22
- package/lib/esm/server/loaders/babel/register.js +1 -3
- package/lib/esm/server/loaders/webpack/compile.js +31 -24
- package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -4
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
- package/lib/esm/server/loaders/webpack/start.js +1 -1
- package/lib/esm/server/master/index.js +2 -2
- package/lib/esm/server/master/pool.js +7 -18
- package/lib/esm/server/master/runner.js +53 -66
- package/lib/esm/server/master/server.js +2 -2
- package/lib/esm/server/messages.js +3 -5
- package/lib/esm/server/selenium/browser.js +20 -28
- package/lib/esm/server/selenium/selenoid.js +4 -6
- package/lib/esm/server/stories.js +9 -20
- package/lib/esm/server/storybook/entry.js +4 -2
- package/lib/esm/server/storybook/helpers.js +7 -15
- package/lib/esm/server/storybook/providers/browser.js +4 -5
- package/lib/esm/server/storybook/providers/nodejs.js +3 -3
- package/lib/esm/server/update.js +1 -5
- package/lib/esm/server/utils.js +5 -9
- package/lib/esm/server/worker/reporter.js +8 -20
- package/lib/esm/server/worker/worker.js +6 -16
- package/lib/esm/shared/index.js +66 -0
- package/lib/esm/shared/serializeRegExp.js +23 -0
- package/lib/types/cli.d.ts +1 -1
- package/lib/types/client/addon/Manager.d.ts +37 -37
- package/lib/types/client/addon/components/Addon.d.ts +8 -8
- package/lib/types/client/addon/components/Icons.d.ts +7 -7
- package/lib/types/client/addon/components/Panel.d.ts +9 -9
- package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
- package/lib/types/client/addon/components/Tools.d.ts +6 -6
- package/lib/types/client/addon/decorator.d.ts +1 -1
- package/lib/types/client/addon/index.d.ts +2 -0
- package/lib/types/client/addon/preset.d.ts +23 -24
- package/lib/types/client/addon/readyForCapture.d.ts +6 -6
- package/lib/types/client/addon/register.d.ts +3 -3
- package/lib/types/client/addon/utils.d.ts +2 -2
- package/lib/types/client/addon/withCreevey.d.ts +24 -24
- package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
- package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
- package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
- package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
- package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
- package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
- package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
- package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
- package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
- package/lib/types/client/shared/helpers.d.ts +46 -46
- package/lib/types/client/shared/viewMode.d.ts +4 -4
- package/lib/types/client/web/CreeveyApp.d.ts +11 -12
- package/lib/types/client/web/CreeveyContext.d.ts +11 -11
- package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
- package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
- package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
- package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
- package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
- package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
- package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
- package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
- package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
- package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
- package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
- package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
- package/lib/types/client/web/index.d.ts +4 -4
- package/lib/types/creevey.d.ts +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/server/config.d.ts +4 -4
- package/lib/types/server/docker.d.ts +7 -7
- package/lib/types/server/extract.d.ts +2 -2
- package/lib/types/server/index.d.ts +2 -2
- package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
- package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
- package/lib/types/server/loaders/babel/register.d.ts +5 -5
- package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
- package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
- package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
- package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
- package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
- package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
- package/lib/types/server/loaders/webpack/start.d.ts +1 -1
- package/lib/types/server/logger.d.ts +10 -6
- package/lib/types/server/master/api.d.ts +7 -7
- package/lib/types/server/master/index.d.ts +3 -3
- package/lib/types/server/master/master.d.ts +7 -7
- package/lib/types/server/master/pool.d.ts +31 -31
- package/lib/types/server/master/runner.d.ts +26 -26
- package/lib/types/server/master/server.d.ts +2 -2
- package/lib/types/server/messages.d.ts +27 -27
- package/lib/types/server/selenium/browser.d.ts +17 -17
- package/lib/types/server/selenium/index.d.ts +2 -2
- package/lib/types/server/selenium/selenoid.d.ts +3 -3
- package/lib/types/server/stories.d.ts +8 -8
- package/lib/types/server/storybook/entry.d.ts +18 -18
- package/lib/types/server/storybook/helpers.d.ts +24 -24
- package/lib/types/server/storybook/providers/browser.d.ts +4 -4
- package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
- package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
- package/lib/types/server/testsFiles/parser.d.ts +12 -12
- package/lib/types/server/testsFiles/register.d.ts +2 -2
- package/lib/types/server/update.d.ts +2 -2
- package/lib/types/server/utils.d.ts +20 -20
- package/lib/types/server/worker/chai-image.d.ts +6 -6
- package/lib/types/server/worker/helpers.d.ts +8 -8
- package/lib/types/server/worker/index.d.ts +1 -1
- package/lib/types/server/worker/reporter.d.ts +8 -8
- package/lib/types/server/worker/worker.d.ts +4 -4
- package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
- package/lib/types/shared/serializeRegExp.d.ts +9 -0
- package/lib/types/types.d.ts +490 -489
- package/package.json +115 -102
- package/preset.js +9 -9
- package/types/babel__register.d.ts +1 -1
- package/types/chai.d.ts +12 -12
- package/types/event-source-polyfill.d.ts +6 -6
- package/types/mdx.d.ts +3 -2
- package/types/mocha.d.ts +20 -20
- package/types/png.d.ts +4 -4
- package/lib/cjs/client/web/1.js +0 -13
- package/lib/cjs/client/web/2.js +0 -1
- package/lib/cjs/shared.js +0 -124
- package/lib/esm/shared.js +0 -93
- package/storybook-static/stories.json +0 -21
@@ -0,0 +1,49 @@
|
|
1
|
+
/*
|
2
|
+
object-assign
|
3
|
+
(c) Sindre Sorhus
|
4
|
+
@license MIT
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*! *****************************************************************************
|
8
|
+
Copyright (c) Microsoft Corporation.
|
9
|
+
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
11
|
+
purpose with or without fee is hereby granted.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
20
|
+
***************************************************************************** */
|
21
|
+
|
22
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
23
|
+
|
24
|
+
/** @license React v0.20.2
|
25
|
+
* scheduler.production.min.js
|
26
|
+
*
|
27
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
28
|
+
*
|
29
|
+
* This source code is licensed under the MIT license found in the
|
30
|
+
* LICENSE file in the root directory of this source tree.
|
31
|
+
*/
|
32
|
+
|
33
|
+
/** @license React v17.0.2
|
34
|
+
* react-dom.production.min.js
|
35
|
+
*
|
36
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
37
|
+
*
|
38
|
+
* This source code is licensed under the MIT license found in the
|
39
|
+
* LICENSE file in the root directory of this source tree.
|
40
|
+
*/
|
41
|
+
|
42
|
+
/** @license React v17.0.2
|
43
|
+
* react.production.min.js
|
44
|
+
*
|
45
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
46
|
+
*
|
47
|
+
* This source code is licensed under the MIT license found in the
|
48
|
+
* LICENSE file in the root directory of this source tree.
|
49
|
+
*/
|
package/lib/cjs/creevey.js
CHANGED
@@ -19,10 +19,8 @@ var _logger = require("./server/logger");
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
20
|
|
21
21
|
function shutdownOnException(reason) {
|
22
|
-
var _reason$stack;
|
23
|
-
|
24
22
|
if (_utils.isShuttingDown.current) return;
|
25
|
-
const error = reason instanceof Error ?
|
23
|
+
const error = reason instanceof Error ? reason.stack ?? reason.message : reason;
|
26
24
|
|
27
25
|
_logger.logger.error(error);
|
28
26
|
|
@@ -33,13 +31,13 @@ function shutdownOnException(reason) {
|
|
33
31
|
error
|
34
32
|
}
|
35
33
|
});
|
36
|
-
if (_cluster.default.
|
34
|
+
if (_cluster.default.isPrimary && !_utils.isShuttingDown.current) void (0, _utils.shutdownWorkers)();
|
37
35
|
}
|
38
36
|
|
39
37
|
process.on('uncaughtException', shutdownOnException);
|
40
38
|
process.on('unhandledRejection', shutdownOnException);
|
41
39
|
if (_cluster.default.isWorker) process.on('SIGINT', _types.noop);
|
42
|
-
if (_cluster.default.
|
40
|
+
if (_cluster.default.isPrimary) process.on('SIGINT', _utils.shutdown);
|
43
41
|
const argv = (0, _minimist.default)(process.argv.slice(2), {
|
44
42
|
string: ['browser', 'config', 'reporter', 'reportDir', 'screenDir'],
|
45
43
|
boolean: ['debug', 'ui', 'saveReport', 'webpack', 'tests'],
|
package/lib/cjs/index.js
CHANGED
@@ -14,16 +14,16 @@ Object.defineProperty(exports, "browserStoriesProvider", {
|
|
14
14
|
return _browser.loadStories;
|
15
15
|
}
|
16
16
|
});
|
17
|
-
Object.defineProperty(exports, "
|
17
|
+
Object.defineProperty(exports, "hybridStoriesProvider", {
|
18
18
|
enumerable: true,
|
19
19
|
get: function () {
|
20
|
-
return
|
20
|
+
return _hybrid.loadStories;
|
21
21
|
}
|
22
22
|
});
|
23
|
-
Object.defineProperty(exports, "
|
23
|
+
Object.defineProperty(exports, "nodejsStoriesProvider", {
|
24
24
|
enumerable: true,
|
25
25
|
get: function () {
|
26
|
-
return
|
26
|
+
return _nodejs.loadStories;
|
27
27
|
}
|
28
28
|
});
|
29
29
|
|
package/lib/cjs/server/config.js
CHANGED
package/lib/cjs/server/docker.js
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = _default;
|
6
7
|
exports.pullImages = pullImages;
|
7
8
|
exports.runImage = runImage;
|
8
|
-
exports.default = _default;
|
9
9
|
|
10
|
-
var _cluster =
|
10
|
+
var _cluster = _interopRequireDefault(require("cluster"));
|
11
11
|
|
12
12
|
var _types = require("../types");
|
13
13
|
|
@@ -25,10 +25,6 @@ var _logger = require("./logger");
|
|
25
25
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27
27
|
|
28
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
29
|
-
|
30
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
31
|
-
|
32
28
|
const docker = new _dockerode.default();
|
33
29
|
|
34
30
|
class DevNull extends _stream.Writable {
|
@@ -117,7 +113,7 @@ async function runImage(image, args, options, debug) {
|
|
117
113
|
}
|
118
114
|
|
119
115
|
async function _default(config, browser, startContainer) {
|
120
|
-
if (_cluster.
|
116
|
+
if (_cluster.default.isPrimary) {
|
121
117
|
const host = await startContainer();
|
122
118
|
let gridUrl = 'http://localhost:4444/wd/hub';
|
123
119
|
gridUrl = _utils.isInsideDocker ? gridUrl.replace(_utils.LOCALHOST_REGEXP, host) : gridUrl;
|
package/lib/cjs/server/index.js
CHANGED
@@ -63,7 +63,7 @@ async function _default(options) {
|
|
63
63
|
return (await Promise.resolve().then(() => _interopRequireWildcard(require('./loaders/webpack/compile')))).default(config, options);
|
64
64
|
}
|
65
65
|
|
66
|
-
case _cluster.default.
|
66
|
+
case _cluster.default.isPrimary:
|
67
67
|
{
|
68
68
|
_logger.logger.info('Starting Master Process');
|
69
69
|
|
@@ -20,9 +20,7 @@ const reexportedStories = new Map();
|
|
20
20
|
function _default() {
|
21
21
|
return {
|
22
22
|
pre() {
|
23
|
-
|
24
|
-
|
25
|
-
const parents = (_this$opts$parents = this.opts.parents()) !== null && _this$opts$parents !== void 0 ? _this$opts$parents : [];
|
23
|
+
const parents = this.opts.parents() ?? [];
|
26
24
|
const story = this.opts.story();
|
27
25
|
this.resourcePath = this.filename;
|
28
26
|
this.fileType = _helpers.FileType.Invalid; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.storyVisitor = exports.
|
6
|
+
exports.storyVisitor = exports.previewVisitor = exports.mdxVisitor = exports.commonVisitor = exports.FileType = void 0;
|
7
7
|
|
8
8
|
var t = _interopRequireWildcard(require("@babel/types"));
|
9
9
|
|
@@ -69,11 +69,9 @@ function getPropertyPath(path, name) {
|
|
69
69
|
|
70
70
|
function getDeclaratorPath(path) {
|
71
71
|
if (path !== null && path !== void 0 && path.isIdentifier()) {
|
72
|
-
var _path$scope$getBindin;
|
73
|
-
|
74
72
|
const {
|
75
73
|
path: bindingPath
|
76
|
-
} =
|
74
|
+
} = path.scope.getBinding(path.node.name) ?? {};
|
77
75
|
if (bindingPath !== null && bindingPath !== void 0 && bindingPath.isVariableDeclarator() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isFunctionDeclaration() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isImportSpecifier()) return bindingPath;
|
78
76
|
}
|
79
77
|
}
|
@@ -112,7 +110,7 @@ function removeAllPropsExcept(path, propNames) {
|
|
112
110
|
}
|
113
111
|
|
114
112
|
function removeAllPropAssignsExcept(propAssigns, propNames) {
|
115
|
-
for (const [assignPath, props] of propAssigns
|
113
|
+
for (const [assignPath, props] of propAssigns ?? []) {
|
116
114
|
const restNames = props.reduce((subPropNames, prop) => {
|
117
115
|
const propName = subPropNames.find(names => {
|
118
116
|
const name = Array.isArray(names) ? names[0] : names;
|
@@ -150,13 +148,11 @@ function getAssignmentPathWithProps(refPath) {
|
|
150
148
|
function getPropertyAssignmentPaths(idPaths) {
|
151
149
|
const assignPaths = new Map();
|
152
150
|
idPaths.forEach(idPath => {
|
153
|
-
var _idPath$scope$getBind
|
151
|
+
var _idPath$scope$getBind;
|
154
152
|
|
155
|
-
const referencePaths = (_idPath$scope$getBind =
|
153
|
+
const referencePaths = ((_idPath$scope$getBind = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind === void 0 ? void 0 : _idPath$scope$getBind.referencePaths) ?? [];
|
156
154
|
referencePaths.forEach(refPath => {
|
157
|
-
|
158
|
-
|
159
|
-
const [assignmentPath, props] = (_getAssignmentPathWit = getAssignmentPathWithProps(refPath)) !== null && _getAssignmentPathWit !== void 0 ? _getAssignmentPathWit : [];
|
155
|
+
const [assignmentPath, props] = getAssignmentPathWithProps(refPath) ?? [];
|
160
156
|
if (assignmentPath && props) assignPaths.set(assignmentPath, props);
|
161
157
|
});
|
162
158
|
});
|
@@ -346,12 +342,12 @@ const previewVisitor = {
|
|
346
342
|
exports.previewVisitor = previewVisitor;
|
347
343
|
const mdxVisitor = {
|
348
344
|
FunctionDeclaration(functionPath) {
|
349
|
-
var _functionPath$get$nod, _rootPath$scope$getBi
|
345
|
+
var _functionPath$get$nod, _rootPath$scope$getBi;
|
350
346
|
|
351
347
|
const functionName = (_functionPath$get$nod = functionPath.get('id').node) === null || _functionPath$get$nod === void 0 ? void 0 : _functionPath$get$nod.name;
|
352
348
|
if (functionName != 'MDXContent') return;
|
353
349
|
const rootPath = findRootPath(functionPath);
|
354
|
-
const refs = (
|
350
|
+
const refs = (rootPath === null || rootPath === void 0 ? void 0 : (_rootPath$scope$getBi = rootPath.scope.getBinding(functionName)) === null || _rootPath$scope$getBi === void 0 ? void 0 : _rootPath$scope$getBi.referencePaths) ?? [];
|
355
351
|
refs.forEach(refPath => {
|
356
352
|
var _findRootPath;
|
357
353
|
|
@@ -377,10 +373,8 @@ const storyVisitor = {
|
|
377
373
|
},
|
378
374
|
|
379
375
|
ExportAllDeclaration(allPath) {
|
380
|
-
var _this$reexportedStori;
|
381
|
-
|
382
376
|
const request = allPath.get('source').node.value;
|
383
|
-
this.reexportedStories.set(this.resourcePath, (
|
377
|
+
this.reexportedStories.set(this.resourcePath, (this.reexportedStories.get(this.resourcePath) ?? new Set()).add(request));
|
384
378
|
this.visitedTopPaths.add(allPath);
|
385
379
|
},
|
386
380
|
|
@@ -414,9 +408,9 @@ const storyVisitor = {
|
|
414
408
|
const storiesIdPath = (_rootPath$get$find = rootPath.get('declarations').find(decl => decl.get('init') == rootCallPath)) === null || _rootPath$get$find === void 0 ? void 0 : _rootPath$get$find.get('id');
|
415
409
|
|
416
410
|
if (storiesIdPath !== null && storiesIdPath !== void 0 && storiesIdPath.isIdentifier()) {
|
417
|
-
var _storiesIdPath$scope
|
411
|
+
var _storiesIdPath$scope$;
|
418
412
|
|
419
|
-
((
|
413
|
+
(((_storiesIdPath$scope$ = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$ === void 0 ? void 0 : _storiesIdPath$scope$.referencePaths) ?? []).forEach(cleanUpStoriesOfCallChain);
|
420
414
|
}
|
421
415
|
}
|
422
416
|
|
@@ -425,11 +419,9 @@ const storyVisitor = {
|
|
425
419
|
|
426
420
|
Identifier(identifierPath) {
|
427
421
|
if (isExports(identifierPath)) {
|
428
|
-
var _getAssignmentPathWit2;
|
429
|
-
|
430
422
|
const rootPath = findRootPath(identifierPath);
|
431
423
|
if (rootPath) this.visitedTopPaths.add(rootPath);
|
432
|
-
const [assignmentPath, props] =
|
424
|
+
const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
|
433
425
|
|
434
426
|
if (assignmentPath && props) {
|
435
427
|
if (props.length == 1 && props[0] != 'default') {
|
@@ -449,11 +441,9 @@ const storyVisitor = {
|
|
449
441
|
}
|
450
442
|
|
451
443
|
if (isModuleExports(identifierPath)) {
|
452
|
-
var _getAssignmentPathWit3;
|
453
|
-
|
454
444
|
const rootPath = findRootPath(identifierPath);
|
455
445
|
if (rootPath) this.visitedTopPaths.add(rootPath);
|
456
|
-
const [assignmentPath, props] =
|
446
|
+
const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
|
457
447
|
|
458
448
|
if (assignmentPath && props) {
|
459
449
|
if (props.length == 1 && props[0] == 'exports') {
|
@@ -59,12 +59,10 @@ function getRequireContext(rootDir) {
|
|
59
59
|
_fs.default.readdirSync(dirPath, {
|
60
60
|
withFileTypes: true
|
61
61
|
}).forEach(dirent => {
|
62
|
-
var _filter$test;
|
63
|
-
|
64
62
|
const filename = dirent.name;
|
65
63
|
const filePath = (0, _path.join)(dirPath, filename);
|
66
64
|
if (dirent.isDirectory() && deep) return traverse(filePath);
|
67
|
-
if (dirent.isFile() && ((
|
65
|
+
if (dirent.isFile() && ((filter === null || filter === void 0 ? void 0 : filter.test(`./${(0, _path.relative)(contextPath, filePath)}`)) ?? true)) return ids.push(filePath);
|
68
66
|
});
|
69
67
|
};
|
70
68
|
|
@@ -33,6 +33,8 @@ let isInitiated = false;
|
|
33
33
|
let dumpStats = _types.noop;
|
34
34
|
|
35
35
|
function handleWebpackBuild(error, stats) {
|
36
|
+
var _stats$toJson$warning;
|
37
|
+
|
36
38
|
dumpStats(stats);
|
37
39
|
|
38
40
|
if (error || !stats || stats.hasErrors()) {
|
@@ -43,17 +45,16 @@ function handleWebpackBuild(error, stats) {
|
|
43
45
|
if (error) return console.error(error.message);
|
44
46
|
|
45
47
|
if (stats && (stats.hasErrors() || stats.hasWarnings())) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
warnings.forEach(e => console.error(e));
|
48
|
+
var _statsJson$errors, _statsJson$warnings;
|
49
|
+
|
50
|
+
const statsJson = stats.toJson();
|
51
|
+
(_statsJson$errors = statsJson.errors) === null || _statsJson$errors === void 0 ? void 0 : _statsJson$errors.forEach(e => console.error(e));
|
52
|
+
(_statsJson$warnings = statsJson.warnings) === null || _statsJson$warnings === void 0 ? void 0 : _statsJson$warnings.forEach(e => console.error(e));
|
52
53
|
return;
|
53
54
|
}
|
54
55
|
}
|
55
56
|
|
56
|
-
stats.toJson().warnings.forEach(e => console.warn(e));
|
57
|
+
stats === null || stats === void 0 ? void 0 : (_stats$toJson$warning = stats.toJson().warnings) === null || _stats$toJson$warning === void 0 ? void 0 : _stats$toJson$warning.forEach(e => console.warn(e));
|
57
58
|
|
58
59
|
if (!isInitiated) {
|
59
60
|
isInitiated = true;
|
@@ -79,39 +80,39 @@ async function applyMdxLoader(config, areAddonsRemoved, loader) {
|
|
79
80
|
const mdRegexps = [/\.md$/, /\.mdx$/];
|
80
81
|
|
81
82
|
if (areAddonsRemoved) {
|
82
|
-
var _config$module2;
|
83
|
+
var _config$module2, _config$module2$rules;
|
83
84
|
|
84
85
|
mdRegexps.forEach(test => {
|
85
|
-
var _config$module;
|
86
|
+
var _config$module, _config$module$rules;
|
86
87
|
|
87
|
-
return (_config$module = config.module) === null || _config$module === void 0 ? void 0 : _config$module.rules.unshift({
|
88
|
+
return (_config$module = config.module) === null || _config$module === void 0 ? void 0 : (_config$module$rules = _config$module.rules) === null || _config$module$rules === void 0 ? void 0 : _config$module$rules.unshift({
|
88
89
|
test,
|
89
90
|
exclude: /(stories|story)\.mdx$/,
|
90
91
|
use: require.resolve('null-loader')
|
91
92
|
});
|
92
93
|
});
|
93
|
-
(_config$module2 = config.module) === null || _config$module2 === void 0 ? void 0 : _config$module2.rules.unshift({
|
94
|
+
(_config$module2 = config.module) === null || _config$module2 === void 0 ? void 0 : (_config$module2$rules = _config$module2.rules) === null || _config$module2$rules === void 0 ? void 0 : _config$module2$rules.unshift({
|
94
95
|
test: /(stories|story)\.mdx$/,
|
95
96
|
use: mdxLoaders
|
96
97
|
});
|
97
98
|
} else {
|
98
|
-
var _config$module3, _config$module4, _config$
|
99
|
+
var _config$module3, _config$module3$rules, _config$module4, _config$module4$rules, _config$module5, _config$module5$rules;
|
99
100
|
|
100
101
|
// NOTE Exclude addons' entry points
|
101
102
|
config.entry = Array.isArray(config.entry) ? config.entry.filter(entry => !/@storybook(\/|\\)addon/.test(entry)) : config.entry;
|
102
|
-
(_config$module3 = config.module) === null || _config$module3 === void 0 ? void 0 : _config$module3.rules.filter(rule => mdRegexps.some(test => {
|
103
|
+
(_config$module3 = config.module) === null || _config$module3 === void 0 ? void 0 : (_config$module3$rules = _config$module3.rules) === null || _config$module3$rules === void 0 ? void 0 : _config$module3$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => mdRegexps.some(test => {
|
103
104
|
var _rule$test;
|
104
105
|
|
105
106
|
return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) == test.toString();
|
106
107
|
})).forEach(rule => rule.use = require.resolve('null-loader'));
|
107
|
-
(_config$module4 = config.module) === null || _config$module4 === void 0 ? void 0 : _config$module4.rules.filter(rule => mdxRegexps.some(test => {
|
108
|
+
(_config$module4 = config.module) === null || _config$module4 === void 0 ? void 0 : (_config$module4$rules = _config$module4.rules) === null || _config$module4$rules === void 0 ? void 0 : _config$module4$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => mdxRegexps.some(test => {
|
108
109
|
var _rule$test2;
|
109
110
|
|
110
111
|
return ((_rule$test2 = rule.test) === null || _rule$test2 === void 0 ? void 0 : _rule$test2.toString()) == test.toString();
|
111
112
|
})).forEach(rule => rule.use = mdxLoaders); // NOTE Exclude source-loader
|
112
113
|
|
113
114
|
config.module = { ...config.module,
|
114
|
-
rules: (_config$module$
|
115
|
+
rules: ((_config$module5 = config.module) === null || _config$module5 === void 0 ? void 0 : (_config$module5$rules = _config$module5.rules) === null || _config$module5$rules === void 0 ? void 0 : _config$module5$rules.flatMap(rule => typeof rule == 'object' && 'test' in rule ? rule : []).filter(rule => !(typeof rule.loader == 'string' && /@storybook(\/|\\)source-loader/.test(rule.loader)))) ?? []
|
115
116
|
};
|
116
117
|
}
|
117
118
|
}
|
@@ -204,7 +205,7 @@ async function compile(config, {
|
|
204
205
|
debug,
|
205
206
|
ui
|
206
207
|
}) {
|
207
|
-
var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5
|
208
|
+
var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5;
|
208
209
|
|
209
210
|
const storybookFramework = (0, _helpers.getStorybookFramework)();
|
210
211
|
|
@@ -230,7 +231,7 @@ async function compile(config, {
|
|
230
231
|
const areAddonsRemoved = await removeAddons();
|
231
232
|
const getWebpackConfig = (0, _helpers.isStorybookVersionLessThan)(6, 2) ? getWebpackConfigForStorybook_pre6_2 : getWebpackConfigForStorybook_6_2;
|
232
233
|
const storybookWebpackConfig = await getWebpackConfig(storybookFramework, config.storybookDir, outputDir);
|
233
|
-
const extensions = (_storybookWebpackConf =
|
234
|
+
const extensions = ((_storybookWebpackConf = storybookWebpackConfig.resolve) === null || _storybookWebpackConf === void 0 ? void 0 : _storybookWebpackConf.extensions) ?? _utils.extensions;
|
234
235
|
delete storybookWebpackConfig.optimization;
|
235
236
|
storybookWebpackConfig.devtool = false;
|
236
237
|
storybookWebpackConfig.performance = false;
|
@@ -245,18 +246,21 @@ async function compile(config, {
|
|
245
246
|
|
246
247
|
if ((0, _helpers.hasDocsAddon)()) await applyMdxLoader(storybookWebpackConfig, areAddonsRemoved, creeveyLoader); // NOTE Add creevey-loader to cut off all unnecessary code except stories meta and tests
|
247
248
|
|
248
|
-
(
|
249
|
+
(_storybookWebpackConf2 = storybookWebpackConfig.module) === null || _storybookWebpackConf2 === void 0 ? void 0 : (_storybookWebpackConf3 = _storybookWebpackConf2.rules) === null || _storybookWebpackConf3 === void 0 ? void 0 : _storybookWebpackConf3.unshift({
|
249
250
|
enforce: 'pre',
|
250
251
|
test: new RegExp(`\\.(${(_extensions$map = extensions.map(x => x.slice(1))) === null || _extensions$map === void 0 ? void 0 : _extensions$map.join('|')})$`),
|
251
252
|
exclude: /node_modules/,
|
252
253
|
use: creeveyLoader
|
253
254
|
});
|
254
|
-
const aliases = (_storybookWebpackConf4 =
|
255
|
+
const aliases = ((_storybookWebpackConf4 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf4 === void 0 ? void 0 : _storybookWebpackConf4.alias) ?? {};
|
255
256
|
const excluded = ['@storybook/addons', '@storybook/api', '@storybook/channel-postmessage', '@storybook/channels', '@storybook/client-api', '@storybook/client-logger', '@storybook/components', '@storybook/core-events', '@storybook/router', '@storybook/semver', '@storybook/theming']; // NOTE Exclude from bundle all modules from node_modules
|
256
257
|
|
257
|
-
storybookWebpackConfig.externals = [...
|
258
|
-
|
259
|
-
|
258
|
+
storybookWebpackConfig.externals = [...(Array.isArray(aliases) ? aliases.map(({
|
259
|
+
name,
|
260
|
+
alias
|
261
|
+
}) => [name, alias]) : Object.entries(aliases)).filter(([alias]) => excluded.includes(alias)).flatMap(([, aliasPath]) => aliasPath == false ? [] : (Array.isArray(aliasPath) ? aliasPath : [aliasPath]).map(x => ({
|
262
|
+
[x]: `commonjs ${x}`
|
263
|
+
}))), // NOTE Replace `@storybook/${framework}` to ../../storybook.ts
|
260
264
|
{
|
261
265
|
[`@storybook/${storybookFramework}`]: `commonjs ${require.resolve('../../storybook/entry')}`
|
262
266
|
}, (0, _webpackNodeExternals.default)({
|
@@ -270,11 +274,14 @@ async function compile(config, {
|
|
270
274
|
})]; // NOTE Exclude some plugins
|
271
275
|
|
272
276
|
const excludedPlugins = ['DocgenPlugin', 'ForkTsCheckerWebpackPlugin'];
|
273
|
-
storybookWebpackConfig.plugins = (
|
277
|
+
storybookWebpackConfig.plugins = (_storybookWebpackConf5 = storybookWebpackConfig.plugins) === null || _storybookWebpackConf5 === void 0 ? void 0 : _storybookWebpackConf5.filter(plugin => !excludedPlugins.includes(plugin.constructor.name));
|
274
278
|
const storybookWebpackCompiler = (0, _webpack.default)(storybookWebpackConfig);
|
275
279
|
|
276
280
|
if (debug) {
|
277
|
-
dumpStats = stats =>
|
281
|
+
dumpStats = stats => {
|
282
|
+
if (!stats) return;
|
283
|
+
(0, _fs.writeFile)(_path.default.join(config.reportDir, 'stats.json'), JSON.stringify(stats.toJson(), null, 2), _types.noop);
|
284
|
+
};
|
278
285
|
}
|
279
286
|
|
280
287
|
if (ui) {
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default =
|
6
|
+
exports.default = loader;
|
7
7
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
9
9
|
|
@@ -112,13 +112,18 @@ let resourcePath = '';
|
|
112
112
|
const entries = new Set();
|
113
113
|
const stories = new Set();
|
114
114
|
const reexportedStories = new Map();
|
115
|
-
|
115
|
+
|
116
|
+
const isTest = () => process.env.__CREEVEY_ENV__ == 'test';
|
117
|
+
|
116
118
|
const defaultOptions = {
|
117
|
-
debug
|
119
|
+
get debug() {
|
120
|
+
return isTest();
|
121
|
+
},
|
122
|
+
|
118
123
|
storybookDir: process.cwd()
|
119
124
|
};
|
120
125
|
|
121
|
-
function
|
126
|
+
function loader(source) {
|
122
127
|
const options = this ? (0, _loaderUtils.getOptions)(this) || defaultOptions : defaultOptions;
|
123
128
|
(0, _schemaUtils.validate)(schema, options, {
|
124
129
|
name: 'Creevey Stories Loader'
|
@@ -146,7 +151,7 @@ function _default(source) {
|
|
146
151
|
}
|
147
152
|
}
|
148
153
|
|
149
|
-
if (isTest && !Number.isNaN(Number(process.env.CREEVEY_LOADER_FILE_TYPE))) {
|
154
|
+
if (isTest() && !Number.isNaN(Number(process.env.CREEVEY_LOADER_FILE_TYPE))) {
|
150
155
|
fileType = Number(process.env.CREEVEY_LOADER_FILE_TYPE);
|
151
156
|
}
|
152
157
|
|
@@ -4,19 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
|
-
|
8
|
-
var _global$__CREEVEY_HMR;
|
9
|
-
|
10
|
-
global.__CREEVEY_HMR_DATA__ = (_global$__CREEVEY_HMR = global.__CREEVEY_HMR_DATA__) !== null && _global$__CREEVEY_HMR !== void 0 ? _global$__CREEVEY_HMR : {};
|
7
|
+
global.__CREEVEY_HMR_DATA__ = global.__CREEVEY_HMR_DATA__ ?? {};
|
11
8
|
Object.entries(__webpack_require__.m).forEach(([key, moduleFn]) => {
|
12
9
|
__webpack_require__.m[key] = new Proxy(moduleFn, {
|
13
10
|
apply(target, thisArg, args) {
|
14
|
-
var _global$__CREEVEY_HMR2;
|
15
|
-
|
16
11
|
const [module] = args;
|
17
12
|
const {
|
18
13
|
data
|
19
|
-
} = global.__CREEVEY_HMR_DATA__[module.i] =
|
14
|
+
} = global.__CREEVEY_HMR_DATA__[module.i] = global.__CREEVEY_HMR_DATA__[module.i] ?? {
|
20
15
|
data: {}
|
21
16
|
};
|
22
17
|
Object.assign(module, {
|
@@ -23,7 +23,7 @@ function startWebpackCompiler() {
|
|
23
23
|
|
24
24
|
webpackCompiler.on('message', message => {
|
25
25
|
if (!(0, _types.isWebpackMessage)(message)) return;
|
26
|
-
Object.values(_cluster.default.workers).filter(worker => worker != webpackCompiler).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(message));
|
26
|
+
Object.values(_cluster.default.workers ?? {}).filter(worker => worker != webpackCompiler).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(message));
|
27
27
|
|
28
28
|
switch (message.type) {
|
29
29
|
case 'success':
|
package/lib/cjs/server/logger.js
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.colors = void 0;
|
6
7
|
Object.defineProperty(exports, "getLogger", {
|
7
8
|
enumerable: true,
|
8
9
|
get: function () {
|
9
10
|
return _loglevel.getLogger;
|
10
11
|
}
|
11
12
|
});
|
12
|
-
exports.logger =
|
13
|
+
exports.logger = void 0;
|
13
14
|
|
14
15
|
var _chalk = _interopRequireDefault(require("chalk"));
|
15
16
|
|
@@ -126,9 +126,9 @@ async function _default(config, options, resolveApi) {
|
|
126
126
|
}
|
127
127
|
|
128
128
|
runner.once('stop', () => {
|
129
|
-
var
|
129
|
+
var _runner6;
|
130
130
|
|
131
|
-
const tests = Object.values((
|
131
|
+
const tests = Object.values(((_runner6 = runner) === null || _runner6 === void 0 ? void 0 : _runner6.status.tests) ?? {});
|
132
132
|
const isSuccess = tests.filter(_types.isDefined).filter(({
|
133
133
|
skip
|
134
134
|
}) => !skip).every(({
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
var _cluster =
|
8
|
+
var _cluster = _interopRequireWildcard(require("cluster"));
|
9
9
|
|
10
10
|
var _events = require("events");
|
11
11
|
|
@@ -15,13 +15,17 @@ var _messages = require("../messages");
|
|
15
15
|
|
16
16
|
var _utils = require("../utils");
|
17
17
|
|
18
|
-
function
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
19
|
|
20
|
-
function
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
21
|
|
22
22
|
const FORK_RETRIES = 5;
|
23
23
|
|
24
24
|
class Pool extends _events.EventEmitter {
|
25
|
+
workers = [];
|
26
|
+
queue = [];
|
27
|
+
forcedStop = false;
|
28
|
+
|
25
29
|
get isRunning() {
|
26
30
|
return this.workers.length !== this.freeWorkers.length;
|
27
31
|
}
|
@@ -29,19 +33,6 @@ class Pool extends _events.EventEmitter {
|
|
29
33
|
constructor(config, browser) {
|
30
34
|
super();
|
31
35
|
this.browser = browser;
|
32
|
-
|
33
|
-
_defineProperty(this, "maxRetries", void 0);
|
34
|
-
|
35
|
-
_defineProperty(this, "config", void 0);
|
36
|
-
|
37
|
-
_defineProperty(this, "workers", []);
|
38
|
-
|
39
|
-
_defineProperty(this, "queue", []);
|
40
|
-
|
41
|
-
_defineProperty(this, "forcedStop", false);
|
42
|
-
|
43
|
-
_defineProperty(this, "failFast", void 0);
|
44
|
-
|
45
36
|
this.failFast = config.failFast;
|
46
37
|
this.maxRetries = config.maxRetries;
|
47
38
|
this.config = config.browsers[browser];
|
@@ -51,7 +42,7 @@ class Pool extends _events.EventEmitter {
|
|
51
42
|
const poolSize = this.config.limit || 1;
|
52
43
|
this.workers = (await Promise.all(Array.from({
|
53
44
|
length: poolSize
|
54
|
-
}).map(() => this.forkWorker()))).filter(workerOrError => workerOrError instanceof _cluster.
|
45
|
+
}).map(() => this.forkWorker()))).filter(workerOrError => workerOrError instanceof _cluster.Worker);
|
55
46
|
if (this.workers.length != poolSize) throw new Error(`Can't instantiate workers for ${this.browser} due many errors`);
|
56
47
|
this.workers.forEach(worker => this.exitHandler(worker));
|
57
48
|
}
|
@@ -151,7 +142,7 @@ class Pool extends _events.EventEmitter {
|
|
151
142
|
worker.once('exit', async () => {
|
152
143
|
if (_utils.isShuttingDown.current) return;
|
153
144
|
const workerOrError = await this.forkWorker();
|
154
|
-
if (!(workerOrError instanceof _cluster.
|
145
|
+
if (!(workerOrError instanceof _cluster.Worker)) throw new Error(`Can't instantiate worker for ${this.browser} due many errors`);
|
155
146
|
this.exitHandler(workerOrError);
|
156
147
|
this.workers[this.workers.indexOf(worker)] = workerOrError;
|
157
148
|
this.process();
|