creevey 0.9.0-beta.2 → 0.9.0-non-webpack.1

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 (236) hide show
  1. package/AUTHORS +15 -15
  2. package/CHANGELOG.md +1275 -1275
  3. package/LICENSE +21 -21
  4. package/README.md +7 -0
  5. package/addon/README.md +3 -0
  6. package/addon/package.json +4 -0
  7. package/docs/config.md +212 -212
  8. package/docs/grid.md +10 -10
  9. package/docs/tests.md +63 -63
  10. package/jest.config.js +6 -0
  11. package/lib/cjs/client/addon/Manager.js +123 -271
  12. package/lib/cjs/client/addon/components/Addon.js +17 -38
  13. package/lib/cjs/client/addon/components/Icons.js +12 -8
  14. package/lib/cjs/client/addon/components/Panel.js +17 -13
  15. package/lib/cjs/client/addon/components/TestSelect.js +11 -9
  16. package/lib/cjs/client/addon/components/Tools.js +21 -40
  17. package/lib/cjs/client/addon/decorator.js +1 -1
  18. package/lib/cjs/client/addon/index.js +31 -0
  19. package/lib/cjs/client/addon/preset.js +13 -32
  20. package/lib/cjs/client/addon/register.js +46 -70
  21. package/lib/cjs/client/addon/utils.js +1 -1
  22. package/lib/cjs/client/addon/withCreevey.js +164 -344
  23. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
  24. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +22 -18
  25. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
  26. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
  27. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
  28. package/lib/cjs/client/shared/components/ImagesView/index.js +9 -9
  29. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
  30. package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
  31. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
  32. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
  33. package/lib/cjs/client/shared/components/ResultsPage.js +39 -69
  34. package/lib/cjs/client/shared/creeveyClientApi.js +55 -82
  35. package/lib/cjs/client/shared/helpers.js +143 -214
  36. package/lib/cjs/client/shared/viewMode.js +5 -5
  37. package/lib/cjs/client/web/142.js +2 -0
  38. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  39. package/lib/cjs/client/web/32.js +1 -0
  40. package/lib/cjs/client/web/551.js +1 -0
  41. package/lib/cjs/client/web/566.js +2 -0
  42. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  43. package/lib/cjs/client/web/691.js +2 -0
  44. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  45. package/lib/cjs/client/web/725.js +1 -0
  46. package/lib/cjs/client/web/index.html +19 -19
  47. package/lib/cjs/client/web/main.js +2 -38
  48. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  49. package/lib/cjs/creevey.js +3 -5
  50. package/lib/cjs/index.js +4 -4
  51. package/lib/cjs/server/config.js +1 -1
  52. package/lib/cjs/server/docker.js +3 -7
  53. package/lib/cjs/server/index.js +1 -1
  54. package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
  55. package/lib/cjs/server/loaders/babel/helpers.js +13 -23
  56. package/lib/cjs/server/loaders/babel/register.js +1 -3
  57. package/lib/cjs/server/loaders/webpack/compile.js +31 -24
  58. package/lib/cjs/server/loaders/webpack/creevey-loader.js +10 -5
  59. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
  60. package/lib/cjs/server/loaders/webpack/mdx-loader.js +1 -1
  61. package/lib/cjs/server/loaders/webpack/start.js +1 -1
  62. package/lib/cjs/server/logger.js +2 -1
  63. package/lib/cjs/server/master/index.js +2 -2
  64. package/lib/cjs/server/master/pool.js +9 -18
  65. package/lib/cjs/server/master/runner.js +53 -66
  66. package/lib/cjs/server/master/server.js +2 -2
  67. package/lib/cjs/server/messages.js +8 -10
  68. package/lib/cjs/server/selenium/browser.js +23 -31
  69. package/lib/cjs/server/selenium/selenoid.js +5 -7
  70. package/lib/cjs/server/stories.js +9 -20
  71. package/lib/cjs/server/storybook/entry.js +5 -3
  72. package/lib/cjs/server/storybook/helpers.js +15 -21
  73. package/lib/cjs/server/storybook/providers/browser.js +5 -9
  74. package/lib/cjs/server/storybook/providers/nodejs.js +4 -4
  75. package/lib/cjs/server/update.js +1 -5
  76. package/lib/cjs/server/utils.js +13 -15
  77. package/lib/cjs/server/worker/reporter.js +8 -20
  78. package/lib/cjs/server/worker/worker.js +6 -16
  79. package/lib/cjs/shared/index.js +101 -0
  80. package/lib/cjs/shared/serializeRegExp.js +42 -0
  81. package/lib/cjs/types.js +6 -6
  82. package/lib/esm/client/addon/Manager.js +123 -271
  83. package/lib/esm/client/addon/components/Addon.js +15 -34
  84. package/lib/esm/client/addon/components/Icons.js +11 -7
  85. package/lib/esm/client/addon/components/Panel.js +17 -13
  86. package/lib/esm/client/addon/components/TestSelect.js +11 -9
  87. package/lib/esm/client/addon/components/Tools.js +19 -36
  88. package/lib/esm/client/addon/decorator.js +1 -1
  89. package/lib/esm/client/addon/index.js +2 -0
  90. package/lib/esm/client/addon/preset.js +10 -25
  91. package/lib/esm/client/addon/register.js +42 -66
  92. package/lib/esm/client/addon/utils.js +1 -1
  93. package/lib/esm/client/addon/withCreevey.js +157 -341
  94. package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
  95. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
  96. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
  97. package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
  98. package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
  99. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
  100. package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
  101. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
  102. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
  103. package/lib/esm/client/shared/components/ResultsPage.js +36 -64
  104. package/lib/esm/client/shared/creeveyClientApi.js +57 -84
  105. package/lib/esm/client/shared/helpers.js +127 -198
  106. package/lib/esm/client/shared/viewMode.js +4 -4
  107. package/lib/esm/creevey.js +3 -5
  108. package/lib/esm/index.js +1 -3
  109. package/lib/esm/server/docker.js +2 -2
  110. package/lib/esm/server/index.js +1 -1
  111. package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
  112. package/lib/esm/server/loaders/babel/helpers.js +12 -22
  113. package/lib/esm/server/loaders/babel/register.js +1 -3
  114. package/lib/esm/server/loaders/webpack/compile.js +31 -24
  115. package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -4
  116. package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
  117. package/lib/esm/server/loaders/webpack/start.js +1 -1
  118. package/lib/esm/server/master/index.js +2 -2
  119. package/lib/esm/server/master/pool.js +7 -18
  120. package/lib/esm/server/master/runner.js +53 -66
  121. package/lib/esm/server/master/server.js +2 -2
  122. package/lib/esm/server/messages.js +3 -5
  123. package/lib/esm/server/selenium/browser.js +20 -28
  124. package/lib/esm/server/selenium/selenoid.js +4 -6
  125. package/lib/esm/server/stories.js +9 -20
  126. package/lib/esm/server/storybook/entry.js +4 -2
  127. package/lib/esm/server/storybook/helpers.js +7 -15
  128. package/lib/esm/server/storybook/providers/browser.js +4 -5
  129. package/lib/esm/server/storybook/providers/nodejs.js +3 -3
  130. package/lib/esm/server/update.js +1 -5
  131. package/lib/esm/server/utils.js +5 -9
  132. package/lib/esm/server/worker/reporter.js +8 -20
  133. package/lib/esm/server/worker/worker.js +6 -16
  134. package/lib/esm/shared/index.js +78 -0
  135. package/lib/esm/shared/serializeRegExp.js +24 -0
  136. package/lib/types/cli.d.ts +1 -1
  137. package/lib/types/client/addon/Manager.d.ts +37 -37
  138. package/lib/types/client/addon/components/Addon.d.ts +8 -8
  139. package/lib/types/client/addon/components/Icons.d.ts +7 -7
  140. package/lib/types/client/addon/components/Panel.d.ts +9 -9
  141. package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
  142. package/lib/types/client/addon/components/Tools.d.ts +6 -6
  143. package/lib/types/client/addon/decorator.d.ts +1 -1
  144. package/lib/types/client/addon/index.d.ts +2 -0
  145. package/lib/types/client/addon/preset.d.ts +23 -24
  146. package/lib/types/client/addon/readyForCapture.d.ts +6 -6
  147. package/lib/types/client/addon/register.d.ts +3 -3
  148. package/lib/types/client/addon/utils.d.ts +2 -2
  149. package/lib/types/client/addon/withCreevey.d.ts +24 -24
  150. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
  151. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
  152. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
  153. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
  154. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
  155. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
  156. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
  157. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
  158. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
  159. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
  160. package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
  161. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
  162. package/lib/types/client/shared/helpers.d.ts +46 -46
  163. package/lib/types/client/shared/viewMode.d.ts +4 -4
  164. package/lib/types/client/web/CreeveyApp.d.ts +11 -12
  165. package/lib/types/client/web/CreeveyContext.d.ts +11 -11
  166. package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
  167. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
  168. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
  169. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
  170. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
  171. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
  172. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
  173. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
  174. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
  175. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
  176. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
  177. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
  178. package/lib/types/client/web/index.d.ts +4 -4
  179. package/lib/types/creevey.d.ts +1 -1
  180. package/lib/types/index.d.ts +0 -1
  181. package/lib/types/server/config.d.ts +4 -4
  182. package/lib/types/server/docker.d.ts +7 -7
  183. package/lib/types/server/extract.d.ts +2 -2
  184. package/lib/types/server/index.d.ts +2 -2
  185. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
  186. package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
  187. package/lib/types/server/loaders/babel/register.d.ts +5 -5
  188. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
  189. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
  190. package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
  191. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  192. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
  193. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
  194. package/lib/types/server/loaders/webpack/start.d.ts +1 -1
  195. package/lib/types/server/logger.d.ts +10 -6
  196. package/lib/types/server/master/api.d.ts +7 -7
  197. package/lib/types/server/master/index.d.ts +3 -3
  198. package/lib/types/server/master/master.d.ts +7 -7
  199. package/lib/types/server/master/pool.d.ts +31 -31
  200. package/lib/types/server/master/runner.d.ts +26 -26
  201. package/lib/types/server/master/server.d.ts +2 -2
  202. package/lib/types/server/messages.d.ts +27 -27
  203. package/lib/types/server/selenium/browser.d.ts +17 -17
  204. package/lib/types/server/selenium/index.d.ts +2 -2
  205. package/lib/types/server/selenium/selenoid.d.ts +3 -3
  206. package/lib/types/server/stories.d.ts +8 -8
  207. package/lib/types/server/storybook/entry.d.ts +18 -18
  208. package/lib/types/server/storybook/helpers.d.ts +24 -24
  209. package/lib/types/server/storybook/providers/browser.d.ts +4 -4
  210. package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
  211. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
  212. package/lib/types/server/testsFiles/parser.d.ts +12 -12
  213. package/lib/types/server/testsFiles/register.d.ts +2 -2
  214. package/lib/types/server/update.d.ts +2 -2
  215. package/lib/types/server/utils.d.ts +20 -20
  216. package/lib/types/server/worker/chai-image.d.ts +6 -6
  217. package/lib/types/server/worker/helpers.d.ts +8 -8
  218. package/lib/types/server/worker/index.d.ts +1 -1
  219. package/lib/types/server/worker/reporter.d.ts +8 -8
  220. package/lib/types/server/worker/worker.d.ts +4 -4
  221. package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
  222. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  223. package/lib/types/types.d.ts +490 -489
  224. package/package.json +115 -102
  225. package/preset.js +9 -9
  226. package/types/babel__register.d.ts +1 -1
  227. package/types/chai.d.ts +12 -12
  228. package/types/event-source-polyfill.d.ts +6 -6
  229. package/types/mdx.d.ts +3 -2
  230. package/types/mocha.d.ts +20 -20
  231. package/types/png.d.ts +4 -4
  232. package/lib/cjs/client/web/1.js +0 -13
  233. package/lib/cjs/client/web/2.js +0 -1
  234. package/lib/cjs/shared.js +0 -124
  235. package/lib/esm/shared.js +0 -93
  236. package/storybook-static/stories.json +0 -21
@@ -57,11 +57,9 @@ function getPropertyPath(path, name) {
57
57
 
58
58
  function getDeclaratorPath(path) {
59
59
  if (path !== null && path !== void 0 && path.isIdentifier()) {
60
- var _path$scope$getBindin;
61
-
62
60
  const {
63
61
  path: bindingPath
64
- } = (_path$scope$getBindin = path.scope.getBinding(path.node.name)) !== null && _path$scope$getBindin !== void 0 ? _path$scope$getBindin : {};
62
+ } = path.scope.getBinding(path.node.name) ?? {};
65
63
  if (bindingPath !== null && bindingPath !== void 0 && bindingPath.isVariableDeclarator() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isFunctionDeclaration() || bindingPath !== null && bindingPath !== void 0 && bindingPath.isImportSpecifier()) return bindingPath;
66
64
  }
67
65
  }
@@ -100,7 +98,7 @@ function removeAllPropsExcept(path, propNames) {
100
98
  }
101
99
 
102
100
  function removeAllPropAssignsExcept(propAssigns, propNames) {
103
- for (const [assignPath, props] of propAssigns !== null && propAssigns !== void 0 ? propAssigns : []) {
101
+ for (const [assignPath, props] of propAssigns ?? []) {
104
102
  const restNames = props.reduce((subPropNames, prop) => {
105
103
  const propName = subPropNames.find(names => {
106
104
  const name = Array.isArray(names) ? names[0] : names;
@@ -138,13 +136,11 @@ function getAssignmentPathWithProps(refPath) {
138
136
  function getPropertyAssignmentPaths(idPaths) {
139
137
  const assignPaths = new Map();
140
138
  idPaths.forEach(idPath => {
141
- var _idPath$scope$getBind, _idPath$scope$getBind2;
139
+ var _idPath$scope$getBind;
142
140
 
143
- const referencePaths = (_idPath$scope$getBind = (_idPath$scope$getBind2 = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind2 === void 0 ? void 0 : _idPath$scope$getBind2.referencePaths) !== null && _idPath$scope$getBind !== void 0 ? _idPath$scope$getBind : [];
141
+ const referencePaths = ((_idPath$scope$getBind = idPath.scope.getBinding(idPath.node.name)) === null || _idPath$scope$getBind === void 0 ? void 0 : _idPath$scope$getBind.referencePaths) ?? [];
144
142
  referencePaths.forEach(refPath => {
145
- var _getAssignmentPathWit;
146
-
147
- const [assignmentPath, props] = (_getAssignmentPathWit = getAssignmentPathWithProps(refPath)) !== null && _getAssignmentPathWit !== void 0 ? _getAssignmentPathWit : [];
143
+ const [assignmentPath, props] = getAssignmentPathWithProps(refPath) ?? [];
148
144
  if (assignmentPath && props) assignPaths.set(assignmentPath, props);
149
145
  });
150
146
  });
@@ -331,12 +327,12 @@ export const previewVisitor = {
331
327
  };
332
328
  export const mdxVisitor = {
333
329
  FunctionDeclaration(functionPath) {
334
- var _functionPath$get$nod, _rootPath$scope$getBi, _rootPath$scope$getBi2;
330
+ var _functionPath$get$nod, _rootPath$scope$getBi;
335
331
 
336
332
  const functionName = (_functionPath$get$nod = functionPath.get('id').node) === null || _functionPath$get$nod === void 0 ? void 0 : _functionPath$get$nod.name;
337
333
  if (functionName != 'MDXContent') return;
338
334
  const rootPath = findRootPath(functionPath);
339
- const refs = (_rootPath$scope$getBi = rootPath === null || rootPath === void 0 ? void 0 : (_rootPath$scope$getBi2 = rootPath.scope.getBinding(functionName)) === null || _rootPath$scope$getBi2 === void 0 ? void 0 : _rootPath$scope$getBi2.referencePaths) !== null && _rootPath$scope$getBi !== void 0 ? _rootPath$scope$getBi : [];
335
+ 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) ?? [];
340
336
  refs.forEach(refPath => {
341
337
  var _findRootPath;
342
338
 
@@ -361,10 +357,8 @@ export const storyVisitor = {
361
357
  },
362
358
 
363
359
  ExportAllDeclaration(allPath) {
364
- var _this$reexportedStori;
365
-
366
360
  const request = allPath.get('source').node.value;
367
- this.reexportedStories.set(this.resourcePath, ((_this$reexportedStori = this.reexportedStories.get(this.resourcePath)) !== null && _this$reexportedStori !== void 0 ? _this$reexportedStori : new Set()).add(request));
361
+ this.reexportedStories.set(this.resourcePath, (this.reexportedStories.get(this.resourcePath) ?? new Set()).add(request));
368
362
  this.visitedTopPaths.add(allPath);
369
363
  },
370
364
 
@@ -398,9 +392,9 @@ export const storyVisitor = {
398
392
  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');
399
393
 
400
394
  if (storiesIdPath !== null && storiesIdPath !== void 0 && storiesIdPath.isIdentifier()) {
401
- var _storiesIdPath$scope$, _storiesIdPath$scope$2;
395
+ var _storiesIdPath$scope$;
402
396
 
403
- ((_storiesIdPath$scope$ = (_storiesIdPath$scope$2 = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$2 === void 0 ? void 0 : _storiesIdPath$scope$2.referencePaths) !== null && _storiesIdPath$scope$ !== void 0 ? _storiesIdPath$scope$ : []).forEach(cleanUpStoriesOfCallChain);
397
+ (((_storiesIdPath$scope$ = storiesIdPath.scope.getBinding(storiesIdPath.node.name)) === null || _storiesIdPath$scope$ === void 0 ? void 0 : _storiesIdPath$scope$.referencePaths) ?? []).forEach(cleanUpStoriesOfCallChain);
404
398
  }
405
399
  }
406
400
 
@@ -409,11 +403,9 @@ export const storyVisitor = {
409
403
 
410
404
  Identifier(identifierPath) {
411
405
  if (isExports(identifierPath)) {
412
- var _getAssignmentPathWit2;
413
-
414
406
  const rootPath = findRootPath(identifierPath);
415
407
  if (rootPath) this.visitedTopPaths.add(rootPath);
416
- const [assignmentPath, props] = (_getAssignmentPathWit2 = getAssignmentPathWithProps(identifierPath)) !== null && _getAssignmentPathWit2 !== void 0 ? _getAssignmentPathWit2 : [];
408
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
417
409
 
418
410
  if (assignmentPath && props) {
419
411
  if (props.length == 1 && props[0] != 'default') {
@@ -433,11 +425,9 @@ export const storyVisitor = {
433
425
  }
434
426
 
435
427
  if (isModuleExports(identifierPath)) {
436
- var _getAssignmentPathWit3;
437
-
438
428
  const rootPath = findRootPath(identifierPath);
439
429
  if (rootPath) this.visitedTopPaths.add(rootPath);
440
- const [assignmentPath, props] = (_getAssignmentPathWit3 = getAssignmentPathWithProps(identifierPath)) !== null && _getAssignmentPathWit3 !== void 0 ? _getAssignmentPathWit3 : [];
430
+ const [assignmentPath, props] = getAssignmentPathWithProps(identifierPath) ?? [];
441
431
 
442
432
  if (assignmentPath && props) {
443
433
  if (props.length == 1 && props[0] == 'exports') {
@@ -38,12 +38,10 @@ function getRequireContext(rootDir) {
38
38
  fs.readdirSync(dirPath, {
39
39
  withFileTypes: true
40
40
  }).forEach(dirent => {
41
- var _filter$test;
42
-
43
41
  const filename = dirent.name;
44
42
  const filePath = join(dirPath, filename);
45
43
  if (dirent.isDirectory() && deep) return traverse(filePath);
46
- if (dirent.isFile() && ((_filter$test = filter === null || filter === void 0 ? void 0 : filter.test(`./${relative(contextPath, filePath)}`)) !== null && _filter$test !== void 0 ? _filter$test : true)) return ids.push(filePath);
44
+ if (dirent.isFile() && ((filter === null || filter === void 0 ? void 0 : filter.test(`./${relative(contextPath, filePath)}`)) ?? true)) return ids.push(filePath);
47
45
  });
48
46
  };
49
47
 
@@ -11,6 +11,8 @@ let isInitiated = false;
11
11
  let dumpStats = noop;
12
12
 
13
13
  function handleWebpackBuild(error, stats) {
14
+ var _stats$toJson$warning;
15
+
14
16
  dumpStats(stats);
15
17
 
16
18
  if (error || !stats || stats.hasErrors()) {
@@ -21,17 +23,16 @@ function handleWebpackBuild(error, stats) {
21
23
  if (error) return console.error(error.message);
22
24
 
23
25
  if (stats && (stats.hasErrors() || stats.hasWarnings())) {
24
- const {
25
- warnings,
26
- errors
27
- } = stats.toJson();
28
- errors.forEach(e => console.error(e));
29
- warnings.forEach(e => console.error(e));
26
+ var _statsJson$errors, _statsJson$warnings;
27
+
28
+ const statsJson = stats.toJson();
29
+ (_statsJson$errors = statsJson.errors) === null || _statsJson$errors === void 0 ? void 0 : _statsJson$errors.forEach(e => console.error(e));
30
+ (_statsJson$warnings = statsJson.warnings) === null || _statsJson$warnings === void 0 ? void 0 : _statsJson$warnings.forEach(e => console.error(e));
30
31
  return;
31
32
  }
32
33
  }
33
34
 
34
- stats.toJson().warnings.forEach(e => console.warn(e));
35
+ 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));
35
36
 
36
37
  if (!isInitiated) {
37
38
  isInitiated = true;
@@ -57,39 +58,39 @@ async function applyMdxLoader(config, areAddonsRemoved, loader) {
57
58
  const mdRegexps = [/\.md$/, /\.mdx$/];
58
59
 
59
60
  if (areAddonsRemoved) {
60
- var _config$module2;
61
+ var _config$module2, _config$module2$rules;
61
62
 
62
63
  mdRegexps.forEach(test => {
63
- var _config$module;
64
+ var _config$module, _config$module$rules;
64
65
 
65
- return (_config$module = config.module) === null || _config$module === void 0 ? void 0 : _config$module.rules.unshift({
66
+ 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({
66
67
  test,
67
68
  exclude: /(stories|story)\.mdx$/,
68
69
  use: require.resolve('null-loader')
69
70
  });
70
71
  });
71
- (_config$module2 = config.module) === null || _config$module2 === void 0 ? void 0 : _config$module2.rules.unshift({
72
+ (_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({
72
73
  test: /(stories|story)\.mdx$/,
73
74
  use: mdxLoaders
74
75
  });
75
76
  } else {
76
- var _config$module3, _config$module4, _config$module$rules$, _config$module5;
77
+ var _config$module3, _config$module3$rules, _config$module4, _config$module4$rules, _config$module5, _config$module5$rules;
77
78
 
78
79
  // NOTE Exclude addons' entry points
79
80
  config.entry = Array.isArray(config.entry) ? config.entry.filter(entry => !/@storybook(\/|\\)addon/.test(entry)) : config.entry;
80
- (_config$module3 = config.module) === null || _config$module3 === void 0 ? void 0 : _config$module3.rules.filter(rule => mdRegexps.some(test => {
81
+ (_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 => {
81
82
  var _rule$test;
82
83
 
83
84
  return ((_rule$test = rule.test) === null || _rule$test === void 0 ? void 0 : _rule$test.toString()) == test.toString();
84
85
  })).forEach(rule => rule.use = require.resolve('null-loader'));
85
- (_config$module4 = config.module) === null || _config$module4 === void 0 ? void 0 : _config$module4.rules.filter(rule => mdxRegexps.some(test => {
86
+ (_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 => {
86
87
  var _rule$test2;
87
88
 
88
89
  return ((_rule$test2 = rule.test) === null || _rule$test2 === void 0 ? void 0 : _rule$test2.toString()) == test.toString();
89
90
  })).forEach(rule => rule.use = mdxLoaders); // NOTE Exclude source-loader
90
91
 
91
92
  config.module = { ...config.module,
92
- rules: (_config$module$rules$ = (_config$module5 = config.module) === null || _config$module5 === void 0 ? void 0 : _config$module5.rules.filter(rule => !(typeof rule.loader == 'string' && /@storybook(\/|\\)source-loader/.test(rule.loader)))) !== null && _config$module$rules$ !== void 0 ? _config$module$rules$ : []
93
+ 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)))) ?? []
93
94
  };
94
95
  }
95
96
  }
@@ -182,7 +183,7 @@ export default async function compile(config, {
182
183
  debug,
183
184
  ui
184
185
  }) {
185
- var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5, _storybookWebpackConf6;
186
+ var _storybookWebpackConf, _storybookWebpackConf2, _storybookWebpackConf3, _extensions$map, _storybookWebpackConf4, _storybookWebpackConf5;
186
187
 
187
188
  const storybookFramework = getStorybookFramework();
188
189
  const outputDir = path.join(getCreeveyCache(), 'storybook');
@@ -207,7 +208,7 @@ export default async function compile(config, {
207
208
  const areAddonsRemoved = await removeAddons();
208
209
  const getWebpackConfig = isStorybookVersionLessThan(6, 2) ? getWebpackConfigForStorybook_pre6_2 : getWebpackConfigForStorybook_6_2;
209
210
  const storybookWebpackConfig = await getWebpackConfig(storybookFramework, config.storybookDir, outputDir);
210
- const extensions = (_storybookWebpackConf = (_storybookWebpackConf2 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf2 === void 0 ? void 0 : _storybookWebpackConf2.extensions) !== null && _storybookWebpackConf !== void 0 ? _storybookWebpackConf : fallbackExtensions;
211
+ const extensions = ((_storybookWebpackConf = storybookWebpackConfig.resolve) === null || _storybookWebpackConf === void 0 ? void 0 : _storybookWebpackConf.extensions) ?? fallbackExtensions;
211
212
  delete storybookWebpackConfig.optimization;
212
213
  storybookWebpackConfig.devtool = false;
213
214
  storybookWebpackConfig.performance = false;
@@ -222,18 +223,21 @@ export default async function compile(config, {
222
223
 
223
224
  if (hasDocsAddon()) await applyMdxLoader(storybookWebpackConfig, areAddonsRemoved, creeveyLoader); // NOTE Add creevey-loader to cut off all unnecessary code except stories meta and tests
224
225
 
225
- (_storybookWebpackConf3 = storybookWebpackConfig.module) === null || _storybookWebpackConf3 === void 0 ? void 0 : _storybookWebpackConf3.rules.unshift({
226
+ (_storybookWebpackConf2 = storybookWebpackConfig.module) === null || _storybookWebpackConf2 === void 0 ? void 0 : (_storybookWebpackConf3 = _storybookWebpackConf2.rules) === null || _storybookWebpackConf3 === void 0 ? void 0 : _storybookWebpackConf3.unshift({
226
227
  enforce: 'pre',
227
228
  test: new RegExp(`\\.(${(_extensions$map = extensions.map(x => x.slice(1))) === null || _extensions$map === void 0 ? void 0 : _extensions$map.join('|')})$`),
228
229
  exclude: /node_modules/,
229
230
  use: creeveyLoader
230
231
  });
231
- const aliases = (_storybookWebpackConf4 = (_storybookWebpackConf5 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf5 === void 0 ? void 0 : _storybookWebpackConf5.alias) !== null && _storybookWebpackConf4 !== void 0 ? _storybookWebpackConf4 : {};
232
+ const aliases = ((_storybookWebpackConf4 = storybookWebpackConfig.resolve) === null || _storybookWebpackConf4 === void 0 ? void 0 : _storybookWebpackConf4.alias) ?? {};
232
233
  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
233
234
 
234
- storybookWebpackConfig.externals = [...Object.entries(aliases).filter(([alias]) => excluded.includes(alias)).map(([, aliasPath]) => ({
235
- [aliasPath]: `commonjs ${aliasPath}`
236
- })), // NOTE Replace `@storybook/${framework}` to ../../storybook.ts
235
+ storybookWebpackConfig.externals = [...(Array.isArray(aliases) ? aliases.map(({
236
+ name,
237
+ alias
238
+ }) => [name, alias]) : Object.entries(aliases)).filter(([alias]) => excluded.includes(alias)).flatMap(([, aliasPath]) => aliasPath == false ? [] : (Array.isArray(aliasPath) ? aliasPath : [aliasPath]).map(x => ({
239
+ [x]: `commonjs ${x}`
240
+ }))), // NOTE Replace `@storybook/${framework}` to ../../storybook.ts
237
241
  {
238
242
  [`@storybook/${storybookFramework}`]: `commonjs ${require.resolve('../../storybook/entry')}`
239
243
  }, nodeExternals({
@@ -247,11 +251,14 @@ export default async function compile(config, {
247
251
  })]; // NOTE Exclude some plugins
248
252
 
249
253
  const excludedPlugins = ['DocgenPlugin', 'ForkTsCheckerWebpackPlugin'];
250
- storybookWebpackConfig.plugins = (_storybookWebpackConf6 = storybookWebpackConfig.plugins) === null || _storybookWebpackConf6 === void 0 ? void 0 : _storybookWebpackConf6.filter(plugin => !excludedPlugins.includes(plugin.constructor.name));
254
+ storybookWebpackConfig.plugins = (_storybookWebpackConf5 = storybookWebpackConfig.plugins) === null || _storybookWebpackConf5 === void 0 ? void 0 : _storybookWebpackConf5.filter(plugin => !excludedPlugins.includes(plugin.constructor.name));
251
255
  const storybookWebpackCompiler = webpack(storybookWebpackConfig);
252
256
 
253
257
  if (debug) {
254
- dumpStats = stats => writeFile(path.join(config.reportDir, 'stats.json'), JSON.stringify(stats.toJson(), null, 2), noop);
258
+ dumpStats = stats => {
259
+ if (!stats) return;
260
+ writeFile(path.join(config.reportDir, 'stats.json'), JSON.stringify(stats.toJson(), null, 2), noop);
261
+ };
255
262
  }
256
263
 
257
264
  if (ui) {
@@ -93,12 +93,17 @@ let resourcePath = '';
93
93
  const entries = new Set();
94
94
  const stories = new Set();
95
95
  const reexportedStories = new Map();
96
- const isTest = process.env.__CREEVEY_ENV__ == 'test';
96
+
97
+ const isTest = () => process.env.__CREEVEY_ENV__ == 'test';
98
+
97
99
  const defaultOptions = {
98
- debug: isTest,
100
+ get debug() {
101
+ return isTest();
102
+ },
103
+
99
104
  storybookDir: process.cwd()
100
105
  };
101
- export default function (source) {
106
+ export default function loader(source) {
102
107
  const options = this ? getOptions(this) || defaultOptions : defaultOptions;
103
108
  validate(schema, options, {
104
109
  name: 'Creevey Stories Loader'
@@ -125,7 +130,7 @@ export default function (source) {
125
130
  }
126
131
  }
127
132
 
128
- if (isTest && !Number.isNaN(Number(process.env.CREEVEY_LOADER_FILE_TYPE))) {
133
+ if (isTest() && !Number.isNaN(Number(process.env.CREEVEY_LOADER_FILE_TYPE))) {
129
134
  fileType = Number(process.env.CREEVEY_LOADER_FILE_TYPE);
130
135
  }
131
136
 
@@ -1,15 +1,11 @@
1
- var _global$__CREEVEY_HMR;
2
-
3
- global.__CREEVEY_HMR_DATA__ = (_global$__CREEVEY_HMR = global.__CREEVEY_HMR_DATA__) !== null && _global$__CREEVEY_HMR !== void 0 ? _global$__CREEVEY_HMR : {};
1
+ global.__CREEVEY_HMR_DATA__ = global.__CREEVEY_HMR_DATA__ ?? {};
4
2
  Object.entries(__webpack_require__.m).forEach(([key, moduleFn]) => {
5
3
  __webpack_require__.m[key] = new Proxy(moduleFn, {
6
4
  apply(target, thisArg, args) {
7
- var _global$__CREEVEY_HMR2;
8
-
9
5
  const [module] = args;
10
6
  const {
11
7
  data
12
- } = global.__CREEVEY_HMR_DATA__[module.i] = (_global$__CREEVEY_HMR2 = global.__CREEVEY_HMR_DATA__[module.i]) !== null && _global$__CREEVEY_HMR2 !== void 0 ? _global$__CREEVEY_HMR2 : {
8
+ } = global.__CREEVEY_HMR_DATA__[module.i] = global.__CREEVEY_HMR_DATA__[module.i] ?? {
13
9
  data: {}
14
10
  };
15
11
  Object.assign(module, {
@@ -9,7 +9,7 @@ export function startWebpackCompiler() {
9
9
  const webpackCompiler = cluster.fork();
10
10
  webpackCompiler.on('message', message => {
11
11
  if (!isWebpackMessage(message)) return;
12
- Object.values(cluster.workers).filter(worker => worker != webpackCompiler).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(message));
12
+ Object.values(cluster.workers ?? {}).filter(worker => worker != webpackCompiler).forEach(worker => worker === null || worker === void 0 ? void 0 : worker.send(message));
13
13
 
14
14
  switch (message.type) {
15
15
  case 'success':
@@ -105,9 +105,9 @@ export default async function (config, options, resolveApi) {
105
105
  }
106
106
 
107
107
  runner.once('stop', () => {
108
- var _runner$status$tests, _runner6;
108
+ var _runner6;
109
109
 
110
- const tests = Object.values((_runner$status$tests = (_runner6 = runner) === null || _runner6 === void 0 ? void 0 : _runner6.status.tests) !== null && _runner$status$tests !== void 0 ? _runner$status$tests : {});
110
+ const tests = Object.values(((_runner6 = runner) === null || _runner6 === void 0 ? void 0 : _runner6.status.tests) ?? {});
111
111
  const isSuccess = tests.filter(isDefined).filter(({
112
112
  skip
113
113
  }) => !skip).every(({
@@ -1,12 +1,14 @@
1
- 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; }
2
-
3
- import cluster from 'cluster';
1
+ import cluster, { Worker as ClusterWorker } from 'cluster';
4
2
  import { EventEmitter } from 'events';
5
3
  import { isWorkerMessage } from '../../types';
6
4
  import { sendTestMessage, sendShutdownMessage, subscribeOnWorker } from '../messages';
7
5
  import { isShuttingDown } from '../utils';
8
6
  const FORK_RETRIES = 5;
9
7
  export default class Pool extends EventEmitter {
8
+ workers = [];
9
+ queue = [];
10
+ forcedStop = false;
11
+
10
12
  get isRunning() {
11
13
  return this.workers.length !== this.freeWorkers.length;
12
14
  }
@@ -14,19 +16,6 @@ export default class Pool extends EventEmitter {
14
16
  constructor(config, browser) {
15
17
  super();
16
18
  this.browser = browser;
17
-
18
- _defineProperty(this, "maxRetries", void 0);
19
-
20
- _defineProperty(this, "config", void 0);
21
-
22
- _defineProperty(this, "workers", []);
23
-
24
- _defineProperty(this, "queue", []);
25
-
26
- _defineProperty(this, "forcedStop", false);
27
-
28
- _defineProperty(this, "failFast", void 0);
29
-
30
19
  this.failFast = config.failFast;
31
20
  this.maxRetries = config.maxRetries;
32
21
  this.config = config.browsers[browser];
@@ -36,7 +25,7 @@ export default class Pool extends EventEmitter {
36
25
  const poolSize = this.config.limit || 1;
37
26
  this.workers = (await Promise.all(Array.from({
38
27
  length: poolSize
39
- }).map(() => this.forkWorker()))).filter(workerOrError => workerOrError instanceof cluster.Worker);
28
+ }).map(() => this.forkWorker()))).filter(workerOrError => workerOrError instanceof ClusterWorker);
40
29
  if (this.workers.length != poolSize) throw new Error(`Can't instantiate workers for ${this.browser} due many errors`);
41
30
  this.workers.forEach(worker => this.exitHandler(worker));
42
31
  }
@@ -134,7 +123,7 @@ export default class Pool extends EventEmitter {
134
123
  worker.once('exit', async () => {
135
124
  if (isShuttingDown.current) return;
136
125
  const workerOrError = await this.forkWorker();
137
- if (!(workerOrError instanceof cluster.Worker)) throw new Error(`Can't instantiate worker for ${this.browser} due many errors`);
126
+ if (!(workerOrError instanceof ClusterWorker)) throw new Error(`Can't instantiate worker for ${this.browser} due many errors`);
138
127
  this.exitHandler(workerOrError);
139
128
  this.workers[this.workers.indexOf(worker)] = workerOrError;
140
129
  this.process();
@@ -1,5 +1,3 @@
1
- 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; }
2
-
3
1
  import path from 'path';
4
2
  import { copyFile, mkdir } from 'fs';
5
3
  import { promisify } from 'util';
@@ -9,63 +7,40 @@ import Pool from './pool';
9
7
  const copyFileAsync = promisify(copyFile);
10
8
  const mkdirAsync = promisify(mkdir);
11
9
  export default class Runner extends EventEmitter {
10
+ pools = {};
11
+ tests = {};
12
+
12
13
  get isRunning() {
13
14
  return Object.values(this.pools).some(pool => pool.isRunning);
14
15
  }
15
16
 
16
17
  constructor(config) {
17
18
  super();
19
+ this.failFast = config.failFast;
20
+ this.screenDir = config.screenDir;
21
+ this.reportDir = config.reportDir;
22
+ this.browsers = Object.keys(config.browsers);
23
+ this.browsers.map(browser => this.pools[browser] = new Pool(config, browser)).map(pool => pool.on('test', this.handlePoolMessage));
24
+ }
18
25
 
19
- _defineProperty(this, "failFast", void 0);
20
-
21
- _defineProperty(this, "screenDir", void 0);
22
-
23
- _defineProperty(this, "reportDir", void 0);
24
-
25
- _defineProperty(this, "browsers", void 0);
26
-
27
- _defineProperty(this, "pools", {});
28
-
29
- _defineProperty(this, "tests", {});
30
-
31
- _defineProperty(this, "handlePoolMessage", message => {
32
- const {
33
- id,
34
- status,
35
- result
36
- } = message;
37
- const test = this.tests[id];
38
- if (!test) return;
39
- const {
40
- browser,
41
- testName,
42
- storyPath,
43
- storyId
44
- } = test; // TODO Handle 'retrying' status
45
-
46
- test.status = status == 'retrying' ? 'failed' : status;
47
-
48
- if (!result) {
49
- this.sendUpdate({
50
- tests: {
51
- [id]: {
52
- id,
53
- browser,
54
- testName,
55
- storyPath,
56
- status: test.status,
57
- storyId
58
- }
59
- }
60
- });
61
- return;
62
- }
26
+ handlePoolMessage = message => {
27
+ const {
28
+ id,
29
+ status,
30
+ result
31
+ } = message;
32
+ const test = this.tests[id];
33
+ if (!test) return;
34
+ const {
35
+ browser,
36
+ testName,
37
+ storyPath,
38
+ storyId
39
+ } = test; // TODO Handle 'retrying' status
63
40
 
64
- if (!test.results) {
65
- test.results = [];
66
- }
41
+ test.status = status == 'retrying' ? 'failed' : status;
67
42
 
68
- test.results.push(result);
43
+ if (!result) {
69
44
  this.sendUpdate({
70
45
  tests: {
71
46
  [id]: {
@@ -74,29 +49,41 @@ export default class Runner extends EventEmitter {
74
49
  testName,
75
50
  storyPath,
76
51
  status: test.status,
77
- results: [result],
78
52
  storyId
79
53
  }
80
54
  }
81
55
  });
82
- if (this.failFast && status == 'failed') this.stop();
83
- });
56
+ return;
57
+ }
84
58
 
85
- _defineProperty(this, "handlePoolStop", () => {
86
- if (!this.isRunning) {
87
- this.sendUpdate({
88
- isRunning: false
89
- });
90
- this.emit('stop');
59
+ if (!test.results) {
60
+ test.results = [];
61
+ }
62
+
63
+ test.results.push(result);
64
+ this.sendUpdate({
65
+ tests: {
66
+ [id]: {
67
+ id,
68
+ browser,
69
+ testName,
70
+ storyPath,
71
+ status: test.status,
72
+ results: [result],
73
+ storyId
74
+ }
91
75
  }
92
76
  });
93
-
94
- this.failFast = config.failFast;
95
- this.screenDir = config.screenDir;
96
- this.reportDir = config.reportDir;
97
- this.browsers = Object.keys(config.browsers);
98
- this.browsers.map(browser => this.pools[browser] = new Pool(config, browser)).map(pool => pool.on('test', this.handlePoolMessage));
99
- }
77
+ if (this.failFast && status == 'failed') this.stop();
78
+ };
79
+ handlePoolStop = () => {
80
+ if (!this.isRunning) {
81
+ this.sendUpdate({
82
+ isRunning: false
83
+ });
84
+ this.emit('stop');
85
+ }
86
+ };
100
87
 
101
88
  async init() {
102
89
  await Promise.all(Object.values(this.pools).map(pool => pool.init()));
@@ -51,7 +51,7 @@ export default function server(reportDir, port, ui) {
51
51
  type: 'update',
52
52
  payload: deserializedStories
53
53
  });
54
- Object.values(cluster.workers).filter(isDefined).filter(worker => worker.isConnected()).forEach(worker => sendStoriesMessage(worker, {
54
+ Object.values(cluster.workers ?? {}).filter(isDefined).filter(worker => worker.isConnected()).forEach(worker => sendStoriesMessage(worker, {
55
55
  type: 'update',
56
56
  payload: deserializedStories
57
57
  }));
@@ -66,7 +66,7 @@ export default function server(reportDir, port, ui) {
66
66
  workerId,
67
67
  options
68
68
  } = ctx.request.body;
69
- const worker = Object.values(cluster.workers).filter(isDefined).find(worker => worker.process.pid == workerId); // NOTE: Hypothetical case when someone send to us capture req and we don't have a worker with browser session for it
69
+ const worker = Object.values(cluster.workers ?? {}).filter(isDefined).find(worker => worker.process.pid == workerId); // NOTE: Hypothetical case when someone send to us capture req and we don't have a worker with browser session for it
70
70
 
71
71
  if (!worker) return;
72
72
  await new Promise(resolve => {
@@ -1,10 +1,10 @@
1
1
  import cluster from 'cluster';
2
2
 
3
3
  function emitMessage(message) {
4
- var _process$send, _process$send2, _process;
4
+ var _process$send, _process;
5
5
 
6
6
  if (cluster.isWorker && !process.connected) return false;
7
- return (_process$send = (_process$send2 = (_process = process).send) === null || _process$send2 === void 0 ? void 0 : _process$send2.call(_process, message)) !== null && _process$send !== void 0 ? _process$send : // @ts-expect-error: wrong typings `process.emit` return boolean
7
+ return ((_process$send = (_process = process).send) === null || _process$send === void 0 ? void 0 : _process$send.call(_process, message)) ?? // @ts-expect-error: wrong typings `process.emit` return boolean
8
8
  process.emit('message', message);
9
9
  }
10
10
 
@@ -158,9 +158,7 @@ export function subscribeOn(scope, handler) {
158
158
  }
159
159
  const workers = new Map();
160
160
  export function subscribeOnWorker(worker, scope, handler) {
161
- var _workers$get;
162
-
163
- const workerHandlers = (_workers$get = workers.get(worker)) !== null && _workers$get !== void 0 ? _workers$get : createHandlers();
161
+ const workerHandlers = workers.get(worker) ?? createHandlers();
164
162
 
165
163
  if (!workers.has(worker)) {
166
164
  workers.set(worker, workerHandlers);