creevey 0.9.0-beta.0 → 0.9.0-beta.10
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/CHANGELOG.md +51 -0
- package/README.md +9 -1
- package/addon/README.md +3 -0
- package/addon/package.json +5 -0
- package/docs/config.md +29 -26
- package/jest.config.js +6 -0
- package/lib/cjs/client/addon/Manager.js +122 -270
- package/lib/cjs/client/addon/components/Addon.js +17 -38
- package/lib/cjs/client/addon/components/Icons.js +11 -7
- package/lib/cjs/client/addon/components/Panel.js +17 -13
- package/lib/cjs/client/addon/components/TestSelect.js +11 -9
- package/lib/cjs/client/addon/components/Tools.js +22 -41
- package/lib/cjs/client/addon/decorator.js +1 -1
- package/lib/cjs/client/addon/index.js +31 -0
- package/lib/cjs/client/addon/preset.ie11.js +74 -0
- package/lib/cjs/client/addon/preset.js +4 -68
- package/lib/cjs/client/addon/preset.sb7.js +19 -0
- package/lib/cjs/client/addon/preview.js +14 -0
- package/lib/cjs/client/addon/register.js +46 -70
- package/lib/cjs/client/addon/utils.js +6 -2
- package/lib/cjs/client/addon/withCreevey.js +161 -366
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +22 -18
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
- package/lib/cjs/client/shared/components/ImagesView/index.js +9 -9
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
- package/lib/cjs/client/shared/components/ResultsPage.js +39 -69
- package/lib/cjs/client/shared/creeveyClientApi.js +55 -82
- package/lib/cjs/client/shared/helpers.js +139 -210
- package/lib/cjs/client/shared/viewMode.js +5 -5
- 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/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 +5 -5
- package/lib/cjs/server/config.js +3 -5
- package/lib/cjs/server/docker.js +3 -7
- package/lib/cjs/server/extract.js +1 -5
- 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 +2 -4
- package/lib/cjs/server/loaders/webpack/compile.js +34 -51
- package/lib/cjs/server/loaders/webpack/creevey-loader.js +20 -22
- package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
- package/lib/cjs/server/loaders/webpack/mdx-loader.js +2 -2
- 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 +5 -3
- package/lib/cjs/server/messages.js +8 -10
- package/lib/cjs/server/selenium/browser.js +58 -70
- package/lib/cjs/server/selenium/selenoid.js +5 -7
- package/lib/cjs/server/stories.js +16 -33
- package/lib/cjs/server/storybook/entry.js +7 -22
- package/lib/cjs/server/storybook/helpers.js +21 -28
- package/lib/cjs/server/storybook/providers/browser.js +10 -14
- package/lib/cjs/server/storybook/providers/hybrid.js +17 -14
- package/lib/cjs/server/storybook/providers/nodejs.js +12 -12
- package/lib/cjs/server/{parser.js → testsFiles/parser.js} +1 -14
- package/lib/cjs/server/testsFiles/register.js +44 -0
- package/lib/cjs/server/update.js +1 -5
- package/lib/cjs/server/utils.js +27 -36
- package/lib/cjs/server/worker/reporter.js +8 -20
- package/lib/cjs/server/worker/worker.js +9 -19
- package/lib/cjs/shared/index.js +101 -0
- package/lib/cjs/shared/serializeRegExp.js +42 -0
- package/lib/cjs/types.js +7 -6
- package/lib/esm/client/addon/Manager.js +122 -270
- package/lib/esm/client/addon/components/Addon.js +15 -34
- package/lib/esm/client/addon/components/Icons.js +10 -6
- package/lib/esm/client/addon/components/Panel.js +17 -13
- package/lib/esm/client/addon/components/TestSelect.js +11 -9
- package/lib/esm/client/addon/components/Tools.js +20 -37
- package/lib/esm/client/addon/decorator.js +1 -1
- package/lib/esm/client/addon/index.js +2 -0
- package/lib/esm/client/addon/preset.ie11.js +59 -0
- package/lib/esm/client/addon/preset.js +4 -52
- package/lib/esm/client/addon/preset.sb7.js +8 -0
- package/lib/esm/client/addon/preview.js +5 -0
- package/lib/esm/client/addon/register.js +42 -66
- package/lib/esm/client/addon/utils.js +3 -2
- package/lib/esm/client/addon/withCreevey.js +156 -363
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
- package/lib/esm/client/shared/components/ResultsPage.js +36 -64
- package/lib/esm/client/shared/creeveyClientApi.js +57 -84
- package/lib/esm/client/shared/helpers.js +123 -194
- package/lib/esm/client/shared/viewMode.js +4 -4
- package/lib/esm/creevey.js +3 -5
- package/lib/esm/index.js +2 -4
- package/lib/esm/server/config.js +3 -5
- package/lib/esm/server/docker.js +2 -2
- package/lib/esm/server/extract.js +1 -3
- 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 +3 -5
- package/lib/esm/server/loaders/webpack/compile.js +35 -52
- package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -10
- package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
- package/lib/esm/server/loaders/webpack/mdx-loader.js +2 -2
- 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 +5 -3
- package/lib/esm/server/messages.js +3 -5
- package/lib/esm/server/selenium/browser.js +54 -66
- package/lib/esm/server/selenium/selenoid.js +4 -6
- package/lib/esm/server/stories.js +16 -32
- package/lib/esm/server/storybook/entry.js +5 -22
- package/lib/esm/server/storybook/helpers.js +12 -21
- package/lib/esm/server/storybook/providers/browser.js +6 -9
- package/lib/esm/server/storybook/providers/hybrid.js +10 -13
- package/lib/esm/server/storybook/providers/nodejs.js +10 -11
- package/lib/esm/server/{parser.js → testsFiles/parser.js} +1 -14
- package/lib/esm/server/testsFiles/register.js +31 -0
- package/lib/esm/server/update.js +1 -5
- package/lib/esm/server/utils.js +18 -31
- package/lib/esm/server/worker/reporter.js +8 -20
- package/lib/esm/server/worker/worker.js +9 -19
- package/lib/esm/shared/index.js +78 -0
- package/lib/esm/shared/serializeRegExp.js +24 -0
- package/lib/esm/types.js +1 -0
- package/lib/types/client/addon/Manager.d.ts +2 -2
- package/lib/types/client/addon/components/TestSelect.d.ts +0 -1
- package/lib/types/client/addon/index.d.ts +2 -0
- package/lib/types/client/addon/preset.d.ts +0 -22
- package/lib/types/client/addon/preset.ie11.d.ts +10 -0
- package/lib/types/client/addon/preset.sb7.d.ts +2 -0
- package/lib/types/client/addon/preview.d.ts +4 -0
- package/lib/types/client/addon/utils.d.ts +1 -0
- package/lib/types/client/addon/withCreevey.d.ts +1 -1
- package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +1 -1
- package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +0 -1
- package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +1 -1
- package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +1 -1
- package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +1 -1
- package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +0 -1
- package/lib/types/client/shared/components/PageFooter/Paging.d.ts +0 -1
- package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +1 -1
- package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +0 -1
- package/lib/types/client/shared/components/ResultsPage.d.ts +1 -1
- package/lib/types/client/web/CreeveyApp.d.ts +0 -1
- package/lib/types/client/web/CreeveyLoader.d.ts +1 -2
- package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +1 -1
- package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +0 -1
- package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +4 -4
- package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +0 -1
- package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +1 -1
- package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +1 -1
- package/lib/types/index.d.ts +4 -2
- package/lib/types/server/config.d.ts +1 -1
- package/lib/types/server/loaders/babel/register.d.ts +1 -1
- package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
- package/lib/types/server/logger.d.ts +6 -2
- package/lib/types/server/messages.d.ts +13 -12
- package/lib/types/server/selenium/browser.d.ts +5 -3
- package/lib/types/server/storybook/entry.d.ts +2 -3
- package/lib/types/server/storybook/helpers.d.ts +1 -1
- package/lib/types/server/storybook/providers/browser.d.ts +2 -4
- package/lib/types/server/storybook/providers/hybrid.d.ts +2 -4
- package/lib/types/server/storybook/providers/nodejs.d.ts +3 -3
- package/lib/types/server/{parser.d.ts → testsFiles/parser.d.ts} +1 -1
- package/lib/types/server/testsFiles/register.d.ts +2 -0
- package/lib/types/server/utils.d.ts +5 -1
- package/lib/types/{shared.d.ts → shared/index.d.ts} +1 -10
- package/lib/types/shared/serializeRegExp.d.ts +9 -0
- package/lib/types/types.d.ts +7 -9
- package/package.json +119 -102
- package/preset/ie11.js +5 -0
- package/{preset.js → preset/index.js} +2 -2
- package/preset/sb7.js +5 -0
- package/types/global.d.ts +5 -0
- package/types/mdx.d.ts +3 -2
- package/lib/cjs/client/web/1.js +0 -13
- package/lib/cjs/client/web/2.js +0 -1
- package/lib/cjs/shared.js +0 -107
- package/lib/esm/shared.js +0 -76
- package/storybook-static/stories.json +0 -21
@@ -3,12 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.takeScreenshot = takeScreenshot;
|
7
|
-
exports.updateStorybookGlobals = updateStorybookGlobals;
|
8
|
-
exports.loadStoriesFromBrowser = loadStoriesFromBrowser;
|
9
|
-
exports.getBrowser = getBrowser;
|
10
6
|
exports.closeBrowser = closeBrowser;
|
7
|
+
exports.getBrowser = getBrowser;
|
8
|
+
exports.loadStoriesFromBrowser = loadStoriesFromBrowser;
|
11
9
|
exports.switchStory = switchStory;
|
10
|
+
exports.takeScreenshot = takeScreenshot;
|
11
|
+
exports.updateStorybookGlobals = updateStorybookGlobals;
|
12
12
|
|
13
13
|
var _chalk = _interopRequireDefault(require("chalk"));
|
14
14
|
|
@@ -40,6 +40,7 @@ var _utils = require("../utils");
|
|
40
40
|
|
41
41
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
42
42
|
|
43
|
+
const storybookRootID = (0, _helpers.isStorybookVersionLessThan)(7) ? 'root' : 'storybook-root';
|
43
44
|
const DOCKER_INTERNAL = 'host.docker.internal';
|
44
45
|
let browserLogger = _logger.logger;
|
45
46
|
let browserName = '';
|
@@ -51,9 +52,7 @@ function getSessionData(grid, sessionId = '') {
|
|
51
52
|
gridUrl.pathname = `/host/${sessionId}`;
|
52
53
|
return new Promise((resolve, reject) => (gridUrl.protocol == 'https:' ? _https.default : _http.default).get(gridUrl.toString(), res => {
|
53
54
|
if (res.statusCode !== 200) {
|
54
|
-
|
55
|
-
|
56
|
-
return reject(new Error(`Couldn't get session data for ${sessionId}. Status code: ${(_res$statusCode = res.statusCode) !== null && _res$statusCode !== void 0 ? _res$statusCode : 'Unknown'}`));
|
55
|
+
return reject(new Error(`Couldn't get session data for ${sessionId}. Status code: ${res.statusCode ?? 'Unknown'}`));
|
57
56
|
}
|
58
57
|
|
59
58
|
let data = '';
|
@@ -63,9 +62,7 @@ function getSessionData(grid, sessionId = '') {
|
|
63
62
|
try {
|
64
63
|
resolve(JSON.parse(data));
|
65
64
|
} catch (error) {
|
66
|
-
|
67
|
-
|
68
|
-
reject(new Error(`Couldn't get session data for ${sessionId}. ${error instanceof Error ? (_error$stack = error.stack) !== null && _error$stack !== void 0 ? _error$stack : error.message : error}`));
|
65
|
+
reject(new Error(`Couldn't get session data for ${sessionId}. ${error instanceof Error ? error.stack ?? error.message : error}`));
|
69
66
|
}
|
70
67
|
});
|
71
68
|
}));
|
@@ -120,10 +117,10 @@ function getUrlChecker(browser) {
|
|
120
117
|
// We don't use any page load strategies except `NONE`
|
121
118
|
// because other add significant delay and some of them don't work in earlier chrome versions
|
122
119
|
// Browsers always load page successful even it's failed
|
123
|
-
// So we just check
|
120
|
+
// So we just check `root` element
|
124
121
|
|
125
|
-
browserLogger.debug(`Checking ${_chalk.default.cyan(
|
126
|
-
return source.includes(
|
122
|
+
browserLogger.debug(`Checking ${_chalk.default.cyan(`#${storybookRootID}`)} existence on ${_chalk.default.magenta(url)}`);
|
123
|
+
return source.includes(`id="${storybookRootID}"`);
|
127
124
|
} catch (error) {
|
128
125
|
return false;
|
129
126
|
}
|
@@ -131,17 +128,6 @@ function getUrlChecker(browser) {
|
|
131
128
|
}
|
132
129
|
|
133
130
|
async function waitForStorybook(browser) {
|
134
|
-
// NOTE: Storybook 5.x doesn't have the `last` method
|
135
|
-
if ((0, _helpers.isStorybookVersionLessThan)(6)) {
|
136
|
-
browserLogger.debug('Waiting for `load` event to make sure that storybook is initiated');
|
137
|
-
return browser.executeAsyncScript(function (callback) {
|
138
|
-
if (document.readyState == 'complete') return callback();
|
139
|
-
window.addEventListener('load', function () {
|
140
|
-
callback();
|
141
|
-
});
|
142
|
-
});
|
143
|
-
}
|
144
|
-
|
145
131
|
browserLogger.debug('Waiting for `setStories` event to make sure that storybook is initiated');
|
146
132
|
let wait = true;
|
147
133
|
let isTimeout = false;
|
@@ -151,12 +137,21 @@ async function waitForStorybook(browser) {
|
|
151
137
|
isTimeout = true;
|
152
138
|
}, 60000);
|
153
139
|
|
154
|
-
while (wait) {
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
140
|
+
while (wait !== false) {
|
141
|
+
if ((0, _helpers.isStorybookVersionLessThan)(7)) {
|
142
|
+
wait = await browser.executeAsyncScript(function (SET_STORIES, callback) {
|
143
|
+
if (typeof window.__STORYBOOK_ADDONS_CHANNEL__ == 'undefined') return callback(true);
|
144
|
+
if (window.__STORYBOOK_ADDONS_CHANNEL__.last(SET_STORIES) == undefined) return callback(true);
|
145
|
+
return callback(false);
|
146
|
+
}, Events.SET_STORIES);
|
147
|
+
} else {
|
148
|
+
wait = await browser.executeScript(function (SET_GLOBALS) {
|
149
|
+
if (typeof window.__STORYBOOK_ADDONS_CHANNEL__ == 'undefined') return true;
|
150
|
+
if (window.__STORYBOOK_ADDONS_CHANNEL__.last(SET_GLOBALS) == undefined) return true;
|
151
|
+
return false;
|
152
|
+
}, Events.SET_GLOBALS);
|
153
|
+
}
|
154
|
+
|
160
155
|
if (!wait) clearTimeout(initiateTimeout);
|
161
156
|
}
|
162
157
|
|
@@ -164,11 +159,11 @@ async function waitForStorybook(browser) {
|
|
164
159
|
}
|
165
160
|
|
166
161
|
async function resetMousePosition(browser) {
|
167
|
-
var
|
162
|
+
var _await$browser$getCap, _await$browser$getCap2;
|
168
163
|
|
169
164
|
browserLogger.debug('Resetting mouse position to the top-left corner');
|
170
165
|
const browserName = (await browser.getCapabilities()).getBrowserName();
|
171
|
-
const [browserVersion] = (
|
166
|
+
const [browserVersion] = ((_await$browser$getCap = (await browser.getCapabilities()).getBrowserVersion()) === null || _await$browser$getCap === void 0 ? void 0 : _await$browser$getCap.split('.')) ?? ((_await$browser$getCap2 = (await browser.getCapabilities()).get('version')) === null || _await$browser$getCap2 === void 0 ? void 0 : _await$browser$getCap2.split('.')) ?? []; // NOTE Reset mouse position to support keweb selenium grid browser versions
|
172
167
|
|
173
168
|
if (browserName == 'chrome' && browserVersion == '70') {
|
174
169
|
const {
|
@@ -252,10 +247,10 @@ const getScrollBarWidth = (() => {
|
|
252
247
|
|
253
248
|
|
254
249
|
async function hasScrollBar(browser) {
|
255
|
-
var _await$browser$
|
250
|
+
var _await$browser$getCap3;
|
256
251
|
|
257
252
|
const browserName = (await browser.getCapabilities()).getBrowserName();
|
258
|
-
const [browserVersion] = (
|
253
|
+
const [browserVersion] = ((_await$browser$getCap3 = (await browser.getCapabilities()).getBrowserVersion()) === null || _await$browser$getCap3 === void 0 ? void 0 : _await$browser$getCap3.split('.')) ?? [];
|
259
254
|
return browserName != 'Safari' && // NOTE This need to work with keweb selenium grid
|
260
255
|
!(browserName == 'firefox' && browserVersion == '61');
|
261
256
|
}
|
@@ -306,7 +301,8 @@ async function takeCompositeScreenshot(browser, windowRect, elementRect) {
|
|
306
301
|
const scrollOffset = isFitVertically || isScreenshotWithoutScrollBar ? 0 : scrollBarWidth;
|
307
302
|
const i = (y * compositeImage.width + x) * 4;
|
308
303
|
const j = // NOTE compositeImage(x, y) => image(x, y)
|
309
|
-
(y % viewportHeight * (viewportWidth + scrollOffset) + x % viewportWidth) * 4 + (
|
304
|
+
(y % viewportHeight * (viewportWidth + scrollOffset) + x % viewportWidth) * 4 + ( // NOTE Offset for last row/col image
|
305
|
+
isLastRow ? yOffset * (viewportWidth + scrollOffset) * 4 : 0) + (isLastCol ? xOffset * 4 : 0);
|
310
306
|
const image = images[row * cols + col];
|
311
307
|
compositeImage.data[i + 0] = image.data[j + 0];
|
312
308
|
compositeImage.data[i + 1] = image.data[j + 1];
|
@@ -355,7 +351,7 @@ async function takeScreenshot(browser, captureElement, ignoreElements) {
|
|
355
351
|
const {
|
356
352
|
elementRect,
|
357
353
|
windowRect
|
358
|
-
} = rects
|
354
|
+
} = rects ?? {};
|
359
355
|
if (!elementRect || !windowRect) throw new Error(`Couldn't find element with selector: '${captureElement}'`);
|
360
356
|
const isFitIntoViewport = elementRect.width + elementRect.left <= windowRect.width && elementRect.height + elementRect.top <= windowRect.height;
|
361
357
|
if (isFitIntoViewport) browserLogger.debug(`Capturing ${_chalk.default.cyan(captureElement)}`);else browserLogger.debug(`Capturing composite screenshot image of ${_chalk.default.cyan(captureElement)}`);
|
@@ -381,19 +377,14 @@ async function selectStory(browser, {
|
|
381
377
|
return callback(["Creevey can't switch story. This may happened if forget to add `creevey` addon to your storybook config, or storybook not loaded in browser due syntax error."]);
|
382
378
|
}
|
383
379
|
|
384
|
-
window.__CREEVEY_SELECT_STORY__(id, kind, name, shouldWaitForReady, callback);
|
380
|
+
void window.__CREEVEY_SELECT_STORY__(id, kind, name, shouldWaitForReady, callback);
|
385
381
|
}, id, kind, name, waitForReady);
|
386
|
-
const [errorMessage, isCaptureCalled = false] = result
|
382
|
+
const [errorMessage, isCaptureCalled = false] = result ?? [];
|
387
383
|
if (errorMessage) throw new Error(errorMessage);
|
388
384
|
return isCaptureCalled;
|
389
385
|
}
|
390
386
|
|
391
387
|
async function updateStorybookGlobals(browser, globals) {
|
392
|
-
if ((0, _helpers.isStorybookVersionLessThan)(6)) {
|
393
|
-
browserLogger.warn('Globals are not supported by Storybook versions less than 6');
|
394
|
-
return;
|
395
|
-
}
|
396
|
-
|
397
388
|
browserLogger.debug('Applying storybook globals');
|
398
389
|
await browser.executeScript(function (globals) {
|
399
390
|
window.__CREEVEY_UPDATE_GLOBALS__(globals);
|
@@ -430,13 +421,12 @@ async function resolveCreeveyHost(browser, port) {
|
|
430
421
|
const addresses = getAddresses();
|
431
422
|
creeveyServerHost = await browser.executeAsyncScript(function (hosts, port, callback) {
|
432
423
|
void Promise.all(hosts.map(function (host) {
|
433
|
-
return
|
434
|
-
|
435
|
-
|
436
|
-
fetch('http://' + host + ':' + port + '/ping').then(resolve).catch(reject);
|
437
|
-
}).then(function (response) {
|
424
|
+
return Promise.race([// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
425
|
+
fetch('http://' + host + ':' + port + '/ping').then(function (response) {
|
438
426
|
return response.text();
|
439
|
-
})
|
427
|
+
}), new Promise((_resolve, reject) => {
|
428
|
+
setTimeout(reject, 5000);
|
429
|
+
})]).then(function (pong) {
|
440
430
|
return pong == 'pong' ? host : null;
|
441
431
|
}).catch(function () {
|
442
432
|
return null;
|
@@ -451,21 +441,18 @@ async function resolveCreeveyHost(browser, port) {
|
|
451
441
|
return creeveyServerHost;
|
452
442
|
}
|
453
443
|
|
454
|
-
async function loadStoriesFromBrowser(
|
444
|
+
async function loadStoriesFromBrowser() {
|
455
445
|
if (!browser) throw new Error("Can't get stories from browser if webdriver isn't connected");
|
456
|
-
const
|
457
|
-
const stories = await browser.executeAsyncScript(function (creeveyHost, creeveyPort, callback) {
|
458
|
-
window.__CREEVEY_SERVER_HOST__ = creeveyHost;
|
459
|
-
window.__CREEVEY_SERVER_PORT__ = creeveyPort;
|
446
|
+
const stories = await browser.executeAsyncScript(function (callback) {
|
460
447
|
void window.__CREEVEY_GET_STORIES__().then(callback);
|
461
|
-
}
|
448
|
+
});
|
462
449
|
if (!stories) throw new Error("Can't get stories, it seems creevey or storybook API isn't available");
|
463
450
|
return stories;
|
464
451
|
}
|
465
452
|
|
466
|
-
async function getBrowser(config,
|
453
|
+
async function getBrowser(config, options) {
|
467
454
|
if (browser) return browser;
|
468
|
-
browserName =
|
455
|
+
browserName = options.browser;
|
469
456
|
const browserConfig = config.browsers[browserName];
|
470
457
|
const {
|
471
458
|
gridUrl = config.gridUrl,
|
@@ -495,7 +482,7 @@ async function getBrowser(config, name) {
|
|
495
482
|
const url = new URL(gridUrl);
|
496
483
|
url.username = url.username ? '********' : '';
|
497
484
|
url.password = url.password ? '********' : '';
|
498
|
-
browserLogger.debug(`(${
|
485
|
+
browserLogger.debug(`(${browserName}) Connecting to Selenium ${_chalk.default.magenta(url.toString())}`);
|
499
486
|
browser = await new _seleniumWebdriver.Builder().usingServer(gridUrl).withCapabilities(capabilities).build();
|
500
487
|
const sessionId = (_await$browser$getSes = await browser.getSession()) === null || _await$browser$getSes === void 0 ? void 0 : _await$browser$getSes.getId();
|
501
488
|
let browserHost = '';
|
@@ -509,14 +496,14 @@ async function getBrowser(config, name) {
|
|
509
496
|
/* noop */
|
510
497
|
}
|
511
498
|
|
512
|
-
browserLogger.debug(`(${
|
499
|
+
browserLogger.debug(`(${browserName}) Connected successful with ${[_chalk.default.green(browserHost), _chalk.default.magenta(sessionId)].filter(Boolean).join(':')}`);
|
513
500
|
browserLogger = (0, _loglevel.getLogger)(sessionId);
|
514
501
|
|
515
502
|
_loglevelPluginPrefix.default.apply(browserLogger, {
|
516
503
|
format(level) {
|
517
504
|
const levelColor = _logger.colors[level.toUpperCase()];
|
518
505
|
|
519
|
-
return `[${
|
506
|
+
return `[${browserName}:${_chalk.default.gray(sessionId)}] ${levelColor(level)} =>`;
|
520
507
|
}
|
521
508
|
|
522
509
|
});
|
@@ -530,7 +517,7 @@ async function getBrowser(config, name) {
|
|
530
517
|
});
|
531
518
|
}, () => viewport && browser && resizeViewport(browser, viewport), () => browser && openStorybookPage(browser, realAddress, config.resolveStorybookUrl), () => browser && waitForStorybook(browser)], () => !_utils.isShuttingDown.current);
|
532
519
|
} catch (originalError) {
|
533
|
-
var
|
520
|
+
var _browser4;
|
534
521
|
|
535
522
|
if (_utils.isShuttingDown.current) {
|
536
523
|
var _browser3;
|
@@ -541,7 +528,7 @@ async function getBrowser(config, name) {
|
|
541
528
|
}
|
542
529
|
|
543
530
|
if (originalError instanceof Error && originalError.name == 'ResolveUrlError') throw originalError;
|
544
|
-
const error = new Error(`Can't load storybook root page by URL ${(
|
531
|
+
const error = new Error(`Can't load storybook root page by URL ${(await ((_browser4 = browser) === null || _browser4 === void 0 ? void 0 : _browser4.getCurrentUrl())) ?? realAddress}`);
|
545
532
|
if (originalError instanceof Error) error.stack = originalError.stack;
|
546
533
|
throw error;
|
547
534
|
}
|
@@ -550,9 +537,12 @@ async function getBrowser(config, name) {
|
|
550
537
|
await updateStorybookGlobals(browser, _storybookGlobals);
|
551
538
|
}
|
552
539
|
|
553
|
-
await browser.
|
540
|
+
const creeveyHost = await resolveCreeveyHost(browser, options.port);
|
541
|
+
await browser.executeScript(function (workerId, creeveyHost, creeveyPort) {
|
554
542
|
window.__CREEVEY_WORKER_ID__ = workerId;
|
555
|
-
|
543
|
+
window.__CREEVEY_SERVER_HOST__ = creeveyHost;
|
544
|
+
window.__CREEVEY_SERVER_PORT__ = creeveyPort;
|
545
|
+
}, process.pid, creeveyHost, options.port);
|
556
546
|
return browser;
|
557
547
|
}
|
558
548
|
|
@@ -579,7 +569,7 @@ async function closeBrowser() {
|
|
579
569
|
}
|
580
570
|
|
581
571
|
async function switchStory() {
|
582
|
-
var _this$currentTest, _this$currentTest$ctx
|
572
|
+
var _this$currentTest, _this$currentTest$ctx;
|
583
573
|
|
584
574
|
let testOrSuite = this.currentTest;
|
585
575
|
if (!testOrSuite) throw new Error("Can't switch story, because test context doesn't have 'currentTest' field");
|
@@ -603,10 +593,10 @@ async function switchStory() {
|
|
603
593
|
parameters
|
604
594
|
} = story;
|
605
595
|
const {
|
606
|
-
captureElement =
|
596
|
+
captureElement = `#${storybookRootID}`,
|
607
597
|
waitForReady,
|
608
598
|
ignoreElements
|
609
|
-
} =
|
599
|
+
} = parameters.creevey ?? {};
|
610
600
|
browserLogger.debug(`Switching to story ${_chalk.default.cyan(kind)}/${_chalk.default.cyan(name)} by id ${_chalk.default.magenta(id)}`);
|
611
601
|
if (captureElement) Object.defineProperty(this, 'captureElement', {
|
612
602
|
enumerable: true,
|
@@ -622,8 +612,6 @@ async function switchStory() {
|
|
622
612
|
let storyPlayResolver;
|
623
613
|
let waitForComplete = new Promise(resolve => storyPlayResolver = resolve);
|
624
614
|
const unsubscribe = (0, _messages.subscribeOn)('stories', message => {
|
625
|
-
var _payload$captureEleme, _payload$ignoreElemen;
|
626
|
-
|
627
615
|
if (message.type != 'capture') return;
|
628
616
|
const {
|
629
617
|
payload = {},
|
@@ -631,7 +619,7 @@ async function switchStory() {
|
|
631
619
|
imageName
|
632
620
|
} = {}
|
633
621
|
} = message;
|
634
|
-
void takeScreenshot(this.browser,
|
622
|
+
void takeScreenshot(this.browser, payload.captureElement ?? captureElement, payload.ignoreElements ?? ignoreElements).then(screenshot => {
|
635
623
|
this.screenshots.push({
|
636
624
|
imageName,
|
637
625
|
screenshot
|
@@ -3,8 +3,8 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.startSelenoidStandalone = startSelenoidStandalone;
|
7
6
|
exports.startSelenoidContainer = startSelenoidContainer;
|
7
|
+
exports.startSelenoidStandalone = startSelenoidStandalone;
|
8
8
|
|
9
9
|
var _path = _interopRequireDefault(require("path"));
|
10
10
|
|
@@ -20,7 +20,7 @@ var _core = require("@octokit/core");
|
|
20
20
|
|
21
21
|
var _messages = require("../messages");
|
22
22
|
|
23
|
-
var _cluster = require("cluster");
|
23
|
+
var _cluster = _interopRequireDefault(require("cluster"));
|
24
24
|
|
25
25
|
var _shelljs = require("shelljs");
|
26
26
|
|
@@ -62,8 +62,6 @@ async function createSelenoidConfig(browsers, {
|
|
62
62
|
}
|
63
63
|
|
64
64
|
async function downloadSelenoidBinary(destination) {
|
65
|
-
var _assets$find;
|
66
|
-
|
67
65
|
const platformNameMapping = {
|
68
66
|
darwin: 'selenoid_darwin_amd64',
|
69
67
|
linux: 'selenoid_linux_amd64',
|
@@ -80,9 +78,9 @@ async function downloadSelenoidBinary(destination) {
|
|
80
78
|
const {
|
81
79
|
browser_download_url: downloadUrl,
|
82
80
|
size: binarySize
|
83
|
-
} =
|
81
|
+
} = assets.find(({
|
84
82
|
name
|
85
|
-
}) => platformNameMapping[process.platform] == name)
|
83
|
+
}) => platformNameMapping[process.platform] == name) ?? {};
|
86
84
|
if ((0, _fs.existsSync)(destination) && (0, _fs.lstatSync)(destination).size == binarySize) return;
|
87
85
|
|
88
86
|
if (!downloadUrl) {
|
@@ -94,7 +92,7 @@ async function downloadSelenoidBinary(destination) {
|
|
94
92
|
|
95
93
|
async function startSelenoidStandalone(config, debug) {
|
96
94
|
config.gridUrl = 'http://localhost:4444/wd/hub';
|
97
|
-
if (_cluster.isWorker) return;
|
95
|
+
if (_cluster.default.isWorker) return;
|
98
96
|
const browsers = Object.values(config.browsers).filter(browser => !browser.gridUrl);
|
99
97
|
const selenoidConfigDir = await createSelenoidConfig(browsers, {
|
100
98
|
useDocker: false
|
@@ -19,20 +19,16 @@ var _types = require("../types");
|
|
19
19
|
|
20
20
|
var _utils = require("./utils");
|
21
21
|
|
22
|
-
var _helpers = require("./storybook/helpers");
|
23
|
-
|
24
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
23
|
|
26
24
|
function storyTestFabric(delay, testFn) {
|
27
25
|
return async function storyTest() {
|
28
|
-
var _testFn$call;
|
29
|
-
|
30
26
|
delay ? await new Promise(resolve => setTimeout(resolve, delay)) : void 0;
|
31
|
-
await (
|
27
|
+
await (testFn ? testFn.call(this) : this.screenshots.length > 0 ? this.expect(this.screenshots.reduce((screenshots, {
|
32
28
|
imageName,
|
33
29
|
screenshot
|
34
30
|
}, index) => ({ ...screenshots,
|
35
|
-
[imageName
|
31
|
+
[imageName ?? `screenshot_${index}`]: screenshot
|
36
32
|
}), {})).to.matchImages() : this.expect(await this.takeScreenshot()).to.matchImage());
|
37
33
|
};
|
38
34
|
}
|
@@ -62,15 +58,13 @@ function createCreeveyTest(browser, storyMeta, skipOptions, testName) {
|
|
62
58
|
function convertStories(browserName, stories) {
|
63
59
|
const tests = {};
|
64
60
|
(Array.isArray(stories) ? stories : Object.values(stories)).forEach(storyMeta => {
|
65
|
-
var _storyMeta$parameters;
|
66
|
-
|
67
61
|
// TODO Skip docsOnly stories for now
|
68
62
|
if (storyMeta.parameters.docsOnly) return;
|
69
63
|
const {
|
70
64
|
delay: delayParam,
|
71
65
|
tests: storyTests,
|
72
66
|
skip
|
73
|
-
} =
|
67
|
+
} = storyMeta.parameters.creevey ?? {};
|
74
68
|
const delay = typeof delayParam == 'number' ? delayParam : delayParam !== null && delayParam !== void 0 && delayParam.for.includes(browserName) ? delayParam.ms : 0; // typeof tests === "undefined" => rootSuite -> kindSuite -> storyTest -> [browsers.png]
|
75
69
|
// typeof tests === "function" => rootSuite -> kindSuite -> storyTest -> browser -> [images.png]
|
76
70
|
// typeof tests === "object" => rootSuite -> kindSuite -> storySuite -> test -> [browsers.png]
|
@@ -105,11 +99,11 @@ async function loadTestsFromStories(browsers, provider, update) {
|
|
105
99
|
const tests = {};
|
106
100
|
browsers.forEach(browser => {
|
107
101
|
Array.from(storiesByFiles.entries()).forEach(([filename, stories]) => {
|
108
|
-
var _testIdsByFiles$get
|
102
|
+
var _testIdsByFiles$get;
|
109
103
|
|
110
104
|
Object.assign(tests, convertStories(browser, stories));
|
111
105
|
const changed = Object.keys(tests);
|
112
|
-
const removed = (
|
106
|
+
const removed = ((_testIdsByFiles$get = testIdsByFiles.get(filename)) === null || _testIdsByFiles$get === void 0 ? void 0 : _testIdsByFiles$get.filter(testId => !tests[testId])) ?? [];
|
113
107
|
if (changed.length == 0) testIdsByFiles.delete(filename);else testIdsByFiles.set(filename, changed);
|
114
108
|
Object.assign(testsDiff, tests);
|
115
109
|
removed.forEach(testId => testsDiff[testId] = undefined);
|
@@ -125,36 +119,25 @@ async function loadTestsFromStories(browsers, provider, update) {
|
|
125
119
|
fileName
|
126
120
|
}
|
127
121
|
}
|
128
|
-
}) =>
|
129
|
-
|
130
|
-
|
131
|
-
return (// TODO Don't use filename as a key, due possible collisions if two require.context with same structure of modules are defined
|
132
|
-
testIdsByFiles.set(fileName, [...((_testIdsByFiles$get2 = testIdsByFiles.get(fileName)) !== null && _testIdsByFiles$get2 !== void 0 ? _testIdsByFiles$get2 : []), id])
|
133
|
-
);
|
134
|
-
});
|
122
|
+
}) => // TODO Don't use filename as a key, due possible collisions if two require.context with same structure of modules are defined
|
123
|
+
testIdsByFiles.set(fileName, [...(testIdsByFiles.get(fileName) ?? []), id]));
|
135
124
|
return tests;
|
136
125
|
}
|
137
126
|
|
138
127
|
function saveStoriesJson(storiesData, extract) {
|
139
|
-
|
140
|
-
|
141
|
-
const outputDir = typeof extract == 'boolean' ? 'storybook-static' : extract;
|
142
|
-
|
143
|
-
if (!(0, _helpers.isStorybookVersionLessThan)(6)) {
|
144
|
-
// NOTE Copy-pasted from Storybook's `getStoriesJsonData` method
|
145
|
-
const allowed = ['fileName', 'docsOnly', 'framework', '__id', '__isArgsStory'];
|
146
|
-
storiesData.globalParameters = (0, _lodash.pick)(storiesData.globalParameters, allowed); // @ts-expect-error ignore error
|
128
|
+
const outputDir = typeof extract == 'boolean' ? 'storybook-static' : extract; // NOTE Copy-pasted from Storybook's `getStoriesJsonData` method
|
147
129
|
|
148
|
-
|
130
|
+
const allowed = ['fileName', 'docsOnly', 'framework', '__id', '__isArgsStory'];
|
131
|
+
storiesData.globalParameters = (0, _lodash.pick)(storiesData.globalParameters, allowed); // @ts-expect-error ignore error
|
149
132
|
|
150
|
-
|
151
|
-
parameters: (0, _lodash.pick)(v.parameters, allowed)
|
152
|
-
}));
|
153
|
-
} // TODO Fix args stories
|
133
|
+
storiesData.kindParameters = (0, _lodash.mapValues)(storiesData.kindParameters, v => (0, _lodash.pick)(v, allowed)); // @ts-expect-error ignore error
|
154
134
|
|
135
|
+
storiesData.stories = (0, _lodash.mapValues)(storiesData.stories, v => ({ ...(0, _lodash.pick)(v, ['id', 'name', 'kind', 'story']),
|
136
|
+
parameters: (0, _lodash.pick)(v.parameters, allowed)
|
137
|
+
})); // TODO Fix args stories
|
155
138
|
|
156
|
-
(0, _utils.removeProps)(storiesData
|
157
|
-
Object.values((
|
139
|
+
(0, _utils.removeProps)(storiesData ?? {}, ['stories', () => true, 'parameters', '__isArgsStory']);
|
140
|
+
Object.values((storiesData === null || storiesData === void 0 ? void 0 : storiesData.stories) ?? {}).forEach(story => (0, _types.isObject)(story) && 'parameters' in story && (0, _types.isObject)(story.parameters) && delete story.parameters.__isArgsStory);
|
158
141
|
(0, _fs.mkdirSync)(outputDir, {
|
159
142
|
recursive: true
|
160
143
|
});
|
@@ -3,23 +3,21 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clientApi = exports.clearDecorators = exports.channel = exports.addParameters = exports.addDecorator = void 0;
|
7
7
|
|
8
8
|
var _addons = require("@storybook/addons");
|
9
9
|
|
10
10
|
var _helpers = require("./helpers");
|
11
11
|
|
12
|
-
var _api$channel, _api$context;
|
13
|
-
|
14
12
|
const framework = (0, _helpers.getStorybookFramework)(); // eslint-disable-next-line @typescript-eslint/no-var-requires
|
15
13
|
|
16
|
-
const core = require((0, _helpers.resolveFromStorybook)('@storybook/core'));
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
18
|
-
|
14
|
+
const core = require((0, _helpers.resolveFromStorybook)('@storybook/core-client'));
|
19
15
|
|
20
|
-
const start =
|
16
|
+
const start = core.start;
|
21
17
|
const api = start(() => void 0);
|
22
|
-
|
18
|
+
|
19
|
+
const channel = _addons.addons.getChannel();
|
20
|
+
|
23
21
|
exports.channel = channel;
|
24
22
|
const clientApi = api.clientApi;
|
25
23
|
exports.clientApi = clientApi;
|
@@ -35,21 +33,8 @@ const storiesOf = (kind, m) => {
|
|
35
33
|
exports.storiesOf = storiesOf;
|
36
34
|
|
37
35
|
const configure = (...args) => {
|
38
|
-
|
39
|
-
//NOTE: Storybook <= 5.1 pass args as is
|
40
|
-
//@ts-expect-error: ignore it
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
42
|
-
return api.configApi.configure(...args);
|
43
|
-
}
|
44
|
-
|
45
|
-
if ((0, _helpers.isStorybookVersionLessThan)(6)) {
|
46
|
-
//NOTE: Storybook <= 5.3 pass `framework` as last argument
|
47
|
-
//@ts-expect-error: ignore it
|
48
|
-
return api.configure(...args, framework);
|
49
|
-
} //NOTE Storybook 6.x pass `framework` as first argument
|
36
|
+
//NOTE Storybook 6.x pass `framework` as first argument
|
50
37
|
//@ts-expect-error: ignore it
|
51
|
-
|
52
|
-
|
53
38
|
return api.configure(framework, ...args);
|
54
39
|
};
|
55
40
|
|
@@ -3,16 +3,18 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.getStorybookFramework = getStorybookFramework;
|
7
|
+
exports.getStorybookVersion = getStorybookVersion;
|
6
8
|
exports.hasDocsAddon = hasDocsAddon;
|
7
9
|
exports.hasSvelteCSFAddon = hasSvelteCSFAddon;
|
8
|
-
exports.
|
9
|
-
exports.isStorybookVersionLessThan = isStorybookVersionLessThan;
|
10
|
-
exports.isStorybookVersionGreaterThan = isStorybookVersionGreaterThan;
|
11
|
-
exports.isStorybookVersion = isStorybookVersion;
|
12
|
-
exports.getStorybookFramework = getStorybookFramework;
|
10
|
+
exports.importStorybookClientLogger = void 0;
|
13
11
|
exports.importStorybookConfig = importStorybookConfig;
|
12
|
+
exports.importStorybookCoreEvents = exports.importStorybookCoreCommon = void 0;
|
14
13
|
exports.isCSFv3Enabled = isCSFv3Enabled;
|
15
|
-
exports.
|
14
|
+
exports.isStorybookVersion = isStorybookVersion;
|
15
|
+
exports.isStorybookVersionGreaterThan = isStorybookVersionGreaterThan;
|
16
|
+
exports.isStorybookVersionLessThan = isStorybookVersionLessThan;
|
17
|
+
exports.storybookDirRef = exports.storybookConfigRef = exports.resolveFromStorybookCoreServer = exports.resolveFromStorybookCoreClient = exports.resolveFromStorybookBuilderWebpack4 = exports.resolveFromStorybookAddonDocs = exports.resolveFromStorybook = void 0;
|
16
18
|
|
17
19
|
var _path = _interopRequireDefault(require("path"));
|
18
20
|
|
@@ -42,9 +44,9 @@ const resolveFromStorybookBuilderWebpack4 = modulePath => (0, _resolveFrom.defau
|
|
42
44
|
|
43
45
|
exports.resolveFromStorybookBuilderWebpack4 = resolveFromStorybookBuilderWebpack4;
|
44
46
|
|
45
|
-
const
|
47
|
+
const resolveFromStorybookCoreClient = modulePath => (0, _resolveFrom.default)(resolveFromStorybook('@storybook/core-client'), modulePath);
|
46
48
|
|
47
|
-
exports.
|
49
|
+
exports.resolveFromStorybookCoreClient = resolveFromStorybookCoreClient;
|
48
50
|
|
49
51
|
const resolveFromStorybookCoreServer = modulePath => (0, _resolveFrom.default)(resolveFromStorybook('@storybook/core-server'), modulePath);
|
50
52
|
|
@@ -86,36 +88,28 @@ function getStorybookVersion() {
|
|
86
88
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
87
89
|
const {
|
88
90
|
version
|
89
|
-
} = require(resolveFromStorybook('@storybook/core/package.json'));
|
91
|
+
} = require(resolveFromStorybook('@storybook/core-server/package.json'));
|
90
92
|
|
91
93
|
return version;
|
92
94
|
}
|
93
95
|
|
94
96
|
function isStorybookVersionLessThan(major, minor) {
|
95
|
-
|
96
|
-
|
97
|
-
const [sbMajor, sbMinor] = ((_process$env$__CREEVE = process.env.__CREEVEY_STORYBOOK_VERSION__) !== null && _process$env$__CREEVE !== void 0 ? _process$env$__CREEVE : getStorybookVersion()).split('.');
|
97
|
+
const [sbMajor, sbMinor] = (process.env.__CREEVEY_STORYBOOK_VERSION__ ?? getStorybookVersion()).split('.');
|
98
98
|
return Number(sbMajor) < major || minor != undefined && Number(sbMajor) == major && Number(sbMinor) < minor;
|
99
99
|
}
|
100
100
|
|
101
101
|
function isStorybookVersionGreaterThan(major, minor) {
|
102
|
-
|
103
|
-
|
104
|
-
const [sbMajor, sbMinor] = ((_process$env$__CREEVE2 = process.env.__CREEVEY_STORYBOOK_VERSION__) !== null && _process$env$__CREEVE2 !== void 0 ? _process$env$__CREEVE2 : getStorybookVersion()).split('.');
|
102
|
+
const [sbMajor, sbMinor] = (process.env.__CREEVEY_STORYBOOK_VERSION__ ?? getStorybookVersion()).split('.');
|
105
103
|
return Number(sbMajor) > major || minor != undefined && Number(sbMajor) == major && Number(sbMinor) > minor;
|
106
104
|
}
|
107
105
|
|
108
106
|
function isStorybookVersion(major, minor) {
|
109
|
-
|
110
|
-
|
111
|
-
const [sbMajor, sbMinor] = ((_process$env$__CREEVE3 = process.env.__CREEVEY_STORYBOOK_VERSION__) !== null && _process$env$__CREEVE3 !== void 0 ? _process$env$__CREEVE3 : getStorybookVersion()).split('.');
|
107
|
+
const [sbMajor, sbMinor] = (process.env.__CREEVEY_STORYBOOK_VERSION__ ?? getStorybookVersion()).split('.');
|
112
108
|
return Number(sbMajor) == major || minor != undefined && Number(sbMajor) == major && Number(sbMinor) == minor;
|
113
109
|
}
|
114
110
|
|
115
111
|
function getStorybookFramework() {
|
116
|
-
|
117
|
-
|
118
|
-
const framework = (_process$env$__CREEVE4 = process.env.__CREEVEY_STORYBOOK_FRAMEWORK__) !== null && _process$env$__CREEVE4 !== void 0 ? _process$env$__CREEVE4 : supportedFrameworks.find(framework => {
|
112
|
+
const framework = process.env.__CREEVEY_STORYBOOK_FRAMEWORK__ ?? supportedFrameworks.find(framework => {
|
119
113
|
try {
|
120
114
|
return require.resolve(resolveFromStorybook(`@storybook/${framework}`));
|
121
115
|
} catch (_) {
|
@@ -139,8 +133,8 @@ async function importStorybookConfig() {
|
|
139
133
|
try {
|
140
134
|
return storybookConfigRef.current = (await Promise.resolve(`${require.resolve(configPath)}`).then(s => _interopRequireWildcard(require(s)))).default;
|
141
135
|
} catch (_) {
|
142
|
-
const storybookUtilsPath =
|
143
|
-
const serverRequireModule =
|
136
|
+
const storybookUtilsPath = '@storybook/core-common/dist/cjs/utils';
|
137
|
+
const serverRequireModule = 'interpret-require'; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
144
138
|
|
145
139
|
const {
|
146
140
|
getInterpretedFile
|
@@ -149,17 +143,16 @@ async function importStorybookConfig() {
|
|
149
143
|
const {
|
150
144
|
default: serverRequireFallback,
|
151
145
|
serverRequire = serverRequireFallback
|
152
|
-
} = await Promise.resolve(`${resolveFromStorybook(`${storybookUtilsPath}/${serverRequireModule}`)}`).then(s => _interopRequireWildcard(require(s))); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
146
|
+
} = await Promise.resolve(`${resolveFromStorybook(`${storybookUtilsPath}/${serverRequireModule}`)}`).then(s => _interopRequireWildcard(require(s))); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
153
147
|
|
154
|
-
const mainConfigFile =
|
155
|
-
getInterpretedFile(configPath); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
148
|
+
const mainConfigFile = getInterpretedFile(configPath); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
156
149
|
|
157
150
|
return storybookConfigRef.current = serverRequire(mainConfigFile);
|
158
151
|
}
|
159
152
|
}
|
160
153
|
|
161
154
|
async function isCSFv3Enabled() {
|
162
|
-
var _await$importStoryboo, _await$importStoryboo2
|
155
|
+
var _await$importStoryboo, _await$importStoryboo2;
|
163
156
|
|
164
|
-
return (_await$importStoryboo =
|
157
|
+
return ((_await$importStoryboo = await importStorybookConfig()) === null || _await$importStoryboo === void 0 ? void 0 : (_await$importStoryboo2 = _await$importStoryboo.features) === null || _await$importStoryboo2 === void 0 ? void 0 : _await$importStoryboo2.previewCsfV3) ?? false;
|
165
158
|
}
|