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.
Files changed (212) 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 +11 -5
  12. package/lib/cjs/client/addon/components/Addon.js +1 -1
  13. package/lib/cjs/client/addon/components/Icons.js +2 -2
  14. package/lib/cjs/client/addon/components/Tools.js +1 -1
  15. package/lib/cjs/client/addon/index.js +31 -0
  16. package/lib/cjs/client/addon/preset.js +3 -3
  17. package/lib/cjs/client/addon/register.js +7 -3
  18. package/lib/cjs/client/addon/withCreevey.js +57 -30
  19. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +1 -1
  20. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +1 -1
  21. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +1 -1
  22. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +1 -1
  23. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +1 -1
  24. package/lib/cjs/client/shared/components/ImagesView/index.js +4 -4
  25. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +1 -1
  26. package/lib/cjs/client/shared/components/ResultsPage.js +2 -2
  27. package/lib/cjs/client/shared/creeveyClientApi.js +6 -2
  28. package/lib/cjs/client/shared/helpers.js +22 -22
  29. package/lib/cjs/client/shared/viewMode.js +1 -1
  30. package/lib/cjs/client/web/142.js +2 -0
  31. package/lib/cjs/client/web/142.js.LICENSE.txt +12 -0
  32. package/lib/cjs/client/web/32.js +1 -0
  33. package/lib/cjs/client/web/551.js +1 -0
  34. package/lib/cjs/client/web/566.js +2 -0
  35. package/lib/cjs/client/web/566.js.LICENSE.txt +31 -0
  36. package/lib/cjs/client/web/691.js +2 -0
  37. package/lib/cjs/client/web/691.js.LICENSE.txt +8 -0
  38. package/lib/cjs/client/web/725.js +1 -0
  39. package/lib/cjs/client/web/index.html +19 -19
  40. package/lib/cjs/client/web/main.js +2 -38
  41. package/lib/cjs/client/web/main.js.LICENSE.txt +49 -0
  42. package/lib/cjs/creevey.js +3 -5
  43. package/lib/cjs/index.js +4 -4
  44. package/lib/cjs/server/config.js +1 -1
  45. package/lib/cjs/server/docker.js +3 -7
  46. package/lib/cjs/server/index.js +1 -1
  47. package/lib/cjs/server/loaders/babel/creevey-plugin.js +1 -3
  48. package/lib/cjs/server/loaders/babel/helpers.js +13 -23
  49. package/lib/cjs/server/loaders/babel/register.js +1 -3
  50. package/lib/cjs/server/loaders/webpack/compile.js +31 -24
  51. package/lib/cjs/server/loaders/webpack/creevey-loader.js +10 -5
  52. package/lib/cjs/server/loaders/webpack/dummy-hmr.js +2 -7
  53. package/lib/cjs/server/loaders/webpack/mdx-loader.js +1 -1
  54. package/lib/cjs/server/loaders/webpack/start.js +1 -1
  55. package/lib/cjs/server/logger.js +2 -1
  56. package/lib/cjs/server/master/index.js +2 -2
  57. package/lib/cjs/server/master/pool.js +9 -18
  58. package/lib/cjs/server/master/runner.js +53 -66
  59. package/lib/cjs/server/master/server.js +2 -2
  60. package/lib/cjs/server/messages.js +8 -10
  61. package/lib/cjs/server/selenium/browser.js +23 -31
  62. package/lib/cjs/server/selenium/selenoid.js +5 -7
  63. package/lib/cjs/server/stories.js +9 -20
  64. package/lib/cjs/server/storybook/entry.js +5 -3
  65. package/lib/cjs/server/storybook/helpers.js +15 -21
  66. package/lib/cjs/server/storybook/providers/browser.js +5 -9
  67. package/lib/cjs/server/storybook/providers/nodejs.js +4 -4
  68. package/lib/cjs/server/update.js +1 -5
  69. package/lib/cjs/server/utils.js +13 -15
  70. package/lib/cjs/server/worker/reporter.js +8 -20
  71. package/lib/cjs/server/worker/worker.js +6 -16
  72. package/lib/cjs/shared/index.js +89 -0
  73. package/lib/cjs/shared/serializeRegExp.js +41 -0
  74. package/lib/cjs/types.js +6 -6
  75. package/lib/esm/client/addon/Manager.js +11 -5
  76. package/lib/esm/client/addon/components/Icons.js +1 -1
  77. package/lib/esm/client/addon/index.js +2 -0
  78. package/lib/esm/client/addon/preset.js +1 -1
  79. package/lib/esm/client/addon/register.js +6 -2
  80. package/lib/esm/client/addon/withCreevey.js +55 -30
  81. package/lib/esm/client/shared/creeveyClientApi.js +6 -2
  82. package/lib/esm/client/shared/helpers.js +6 -6
  83. package/lib/esm/creevey.js +3 -5
  84. package/lib/esm/index.js +1 -3
  85. package/lib/esm/server/docker.js +2 -2
  86. package/lib/esm/server/index.js +1 -1
  87. package/lib/esm/server/loaders/babel/creevey-plugin.js +1 -3
  88. package/lib/esm/server/loaders/babel/helpers.js +12 -22
  89. package/lib/esm/server/loaders/babel/register.js +1 -3
  90. package/lib/esm/server/loaders/webpack/compile.js +31 -24
  91. package/lib/esm/server/loaders/webpack/creevey-loader.js +9 -4
  92. package/lib/esm/server/loaders/webpack/dummy-hmr.js +2 -6
  93. package/lib/esm/server/loaders/webpack/start.js +1 -1
  94. package/lib/esm/server/master/index.js +2 -2
  95. package/lib/esm/server/master/pool.js +7 -18
  96. package/lib/esm/server/master/runner.js +53 -66
  97. package/lib/esm/server/master/server.js +2 -2
  98. package/lib/esm/server/messages.js +3 -5
  99. package/lib/esm/server/selenium/browser.js +20 -28
  100. package/lib/esm/server/selenium/selenoid.js +4 -6
  101. package/lib/esm/server/stories.js +9 -20
  102. package/lib/esm/server/storybook/entry.js +4 -2
  103. package/lib/esm/server/storybook/helpers.js +7 -15
  104. package/lib/esm/server/storybook/providers/browser.js +4 -5
  105. package/lib/esm/server/storybook/providers/nodejs.js +3 -3
  106. package/lib/esm/server/update.js +1 -5
  107. package/lib/esm/server/utils.js +5 -9
  108. package/lib/esm/server/worker/reporter.js +8 -20
  109. package/lib/esm/server/worker/worker.js +6 -16
  110. package/lib/esm/shared/index.js +66 -0
  111. package/lib/esm/shared/serializeRegExp.js +23 -0
  112. package/lib/types/cli.d.ts +1 -1
  113. package/lib/types/client/addon/Manager.d.ts +37 -37
  114. package/lib/types/client/addon/components/Addon.d.ts +8 -8
  115. package/lib/types/client/addon/components/Icons.d.ts +7 -7
  116. package/lib/types/client/addon/components/Panel.d.ts +9 -9
  117. package/lib/types/client/addon/components/TestSelect.d.ts +8 -9
  118. package/lib/types/client/addon/components/Tools.d.ts +6 -6
  119. package/lib/types/client/addon/decorator.d.ts +1 -1
  120. package/lib/types/client/addon/index.d.ts +2 -0
  121. package/lib/types/client/addon/preset.d.ts +23 -24
  122. package/lib/types/client/addon/readyForCapture.d.ts +6 -6
  123. package/lib/types/client/addon/register.d.ts +3 -3
  124. package/lib/types/client/addon/utils.d.ts +2 -2
  125. package/lib/types/client/addon/withCreevey.d.ts +24 -24
  126. package/lib/types/client/shared/components/ImagesView/BlendView.d.ts +3 -3
  127. package/lib/types/client/shared/components/ImagesView/ImagesView.d.ts +24 -25
  128. package/lib/types/client/shared/components/ImagesView/SideBySideView.d.ts +3 -3
  129. package/lib/types/client/shared/components/ImagesView/SlideView.d.ts +3 -3
  130. package/lib/types/client/shared/components/ImagesView/SwapView.d.ts +3 -3
  131. package/lib/types/client/shared/components/ImagesView/index.d.ts +5 -5
  132. package/lib/types/client/shared/components/PageFooter/PageFooter.d.ts +8 -9
  133. package/lib/types/client/shared/components/PageFooter/Paging.d.ts +7 -8
  134. package/lib/types/client/shared/components/PageHeader/ImagePreview.d.ts +12 -12
  135. package/lib/types/client/shared/components/PageHeader/PageHeader.d.ts +16 -17
  136. package/lib/types/client/shared/components/ResultsPage.d.ts +18 -18
  137. package/lib/types/client/shared/creeveyClientApi.d.ts +9 -9
  138. package/lib/types/client/shared/helpers.d.ts +46 -46
  139. package/lib/types/client/shared/viewMode.d.ts +4 -4
  140. package/lib/types/client/web/CreeveyApp.d.ts +11 -12
  141. package/lib/types/client/web/CreeveyContext.d.ts +11 -11
  142. package/lib/types/client/web/CreeveyLoader.d.ts +2 -3
  143. package/lib/types/client/web/CreeveyView/SideBar/Checkbox.d.ts +19 -19
  144. package/lib/types/client/web/CreeveyView/SideBar/Search.d.ts +6 -6
  145. package/lib/types/client/web/CreeveyView/SideBar/SideBar.d.ts +14 -14
  146. package/lib/types/client/web/CreeveyView/SideBar/SideBarHeader.d.ts +12 -13
  147. package/lib/types/client/web/CreeveyView/SideBar/SuiteLink.d.ts +33 -33
  148. package/lib/types/client/web/CreeveyView/SideBar/TestLink.d.ts +7 -8
  149. package/lib/types/client/web/CreeveyView/SideBar/TestStatusIcon.d.ts +10 -10
  150. package/lib/types/client/web/CreeveyView/SideBar/TestsStatus.d.ts +9 -9
  151. package/lib/types/client/web/CreeveyView/SideBar/Toggle.d.ts +6 -6
  152. package/lib/types/client/web/CreeveyView/SideBar/index.d.ts +1 -1
  153. package/lib/types/client/web/KeyboardEventsContext.d.ts +13 -13
  154. package/lib/types/client/web/index.d.ts +4 -4
  155. package/lib/types/creevey.d.ts +1 -1
  156. package/lib/types/index.d.ts +0 -1
  157. package/lib/types/server/config.d.ts +4 -4
  158. package/lib/types/server/docker.d.ts +7 -7
  159. package/lib/types/server/extract.d.ts +2 -2
  160. package/lib/types/server/index.d.ts +2 -2
  161. package/lib/types/server/loaders/babel/creevey-plugin.d.ts +1 -1
  162. package/lib/types/server/loaders/babel/helpers.d.ts +19 -19
  163. package/lib/types/server/loaders/babel/register.d.ts +5 -5
  164. package/lib/types/server/loaders/hooks/mdx.d.ts +1 -1
  165. package/lib/types/server/loaders/hooks/svelte.d.ts +1 -1
  166. package/lib/types/server/loaders/webpack/compile.d.ts +2 -2
  167. package/lib/types/server/loaders/webpack/creevey-loader.d.ts +4 -2
  168. package/lib/types/server/loaders/webpack/dummy-hmr.d.ts +10 -10
  169. package/lib/types/server/loaders/webpack/mdx-loader.d.ts +6 -6
  170. package/lib/types/server/loaders/webpack/start.d.ts +1 -1
  171. package/lib/types/server/logger.d.ts +10 -6
  172. package/lib/types/server/master/api.d.ts +7 -7
  173. package/lib/types/server/master/index.d.ts +3 -3
  174. package/lib/types/server/master/master.d.ts +7 -7
  175. package/lib/types/server/master/pool.d.ts +31 -31
  176. package/lib/types/server/master/runner.d.ts +26 -26
  177. package/lib/types/server/master/server.d.ts +2 -2
  178. package/lib/types/server/messages.d.ts +27 -27
  179. package/lib/types/server/selenium/browser.d.ts +17 -17
  180. package/lib/types/server/selenium/index.d.ts +2 -2
  181. package/lib/types/server/selenium/selenoid.d.ts +3 -3
  182. package/lib/types/server/stories.d.ts +8 -8
  183. package/lib/types/server/storybook/entry.d.ts +18 -18
  184. package/lib/types/server/storybook/helpers.d.ts +24 -24
  185. package/lib/types/server/storybook/providers/browser.d.ts +4 -4
  186. package/lib/types/server/storybook/providers/hybrid.d.ts +4 -4
  187. package/lib/types/server/storybook/providers/nodejs.d.ts +9 -9
  188. package/lib/types/server/testsFiles/parser.d.ts +12 -12
  189. package/lib/types/server/testsFiles/register.d.ts +2 -2
  190. package/lib/types/server/update.d.ts +2 -2
  191. package/lib/types/server/utils.d.ts +20 -20
  192. package/lib/types/server/worker/chai-image.d.ts +6 -6
  193. package/lib/types/server/worker/helpers.d.ts +8 -8
  194. package/lib/types/server/worker/index.d.ts +1 -1
  195. package/lib/types/server/worker/reporter.d.ts +8 -8
  196. package/lib/types/server/worker/worker.d.ts +4 -4
  197. package/lib/types/{shared.d.ts → shared/index.d.ts} +7 -16
  198. package/lib/types/shared/serializeRegExp.d.ts +9 -0
  199. package/lib/types/types.d.ts +490 -489
  200. package/package.json +115 -102
  201. package/preset.js +9 -9
  202. package/types/babel__register.d.ts +1 -1
  203. package/types/chai.d.ts +12 -12
  204. package/types/event-source-polyfill.d.ts +6 -6
  205. package/types/mdx.d.ts +3 -2
  206. package/types/mocha.d.ts +20 -20
  207. package/types/png.d.ts +4 -4
  208. package/lib/cjs/client/web/1.js +0 -13
  209. package/lib/cjs/client/web/2.js +0 -1
  210. package/lib/cjs/shared.js +0 -124
  211. package/lib/esm/shared.js +0 -93
  212. package/storybook-static/stories.json +0 -21
@@ -1,3 +1,13 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
2
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+
7
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
8
+
9
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
10
+
1
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
12
 
3
13
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -14,11 +24,11 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
14
24
 
15
25
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
16
26
 
17
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
27
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
18
28
 
19
29
  import * as Events from '@storybook/core-events';
20
30
  import * as polyfill from 'event-source-polyfill';
21
- // import { buildQueries, within } from '@storybook/testing-library';
31
+ import { buildQueries, within } from '@storybook/testing-library';
22
32
  import { addons, makeDecorator } from '@storybook/addons';
23
33
  import { isObject, noop } from '../../types';
24
34
  import { denormalizeStoryParameters, serializeRawStories } from '../../shared';
@@ -42,8 +52,8 @@ function resetCurrentStory(_x) {
42
52
  }
43
53
 
44
54
  function _resetCurrentStory() {
45
- _resetCurrentStory = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(channel) {
46
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
55
+ _resetCurrentStory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(channel) {
56
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
47
57
  while (1) {
48
58
  switch (_context4.prev = _context4.next) {
49
59
  case 0:
@@ -185,11 +195,11 @@ export function withCreevey() {
185
195
  }
186
196
 
187
197
  function _getStories() {
188
- _getStories = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
198
+ _getStories = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
189
199
  var _window$__STORYBOOK_S;
190
200
 
191
201
  var storiesPromise, store;
192
- return regeneratorRuntime.wrap(function _callee$(_context) {
202
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
193
203
  while (1) {
194
204
  switch (_context.prev = _context.next) {
195
205
  case 0:
@@ -267,10 +277,10 @@ export function withCreevey() {
267
277
  }
268
278
 
269
279
  function _selectStory() {
270
- _selectStory = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(storyId, kind, name, shouldWaitForReady, callback) {
280
+ _selectStory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(storyId, kind, name, shouldWaitForReady, callback) {
271
281
  var channel, waitForReady, isCaptureCalled, renderPromise, errorPromise, capturePromise, _reason$stack, errorMessage;
272
282
 
273
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
283
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
274
284
  while (1) {
275
285
  switch (_context3.prev = _context3.next) {
276
286
  case 0:
@@ -312,8 +322,8 @@ export function withCreevey() {
312
322
  }, 0);
313
323
  _context3.prev = 15;
314
324
  _context3.next = 18;
315
- return Promise.race([_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
316
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
325
+ return Promise.race([_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
326
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
317
327
  while (1) {
318
328
  switch (_context2.prev = _context2.next) {
319
329
  case 0:
@@ -410,23 +420,37 @@ export function withCreevey() {
410
420
  window.__CREEVEY_INSERT_IGNORE_STYLES__ = insertIgnoreStyles;
411
421
  window.__CREEVEY_REMOVE_IGNORE_STYLES__ = removeIgnoreStyles;
412
422
  window.__CREEVEY_HAS_PLAY_COMPLETED_YET__ = hasPlayCompletedYet;
413
- window.__CREEVEY_SET_READY_FOR_CAPTURE__ = noop; // const queryAllByQuery = (container: HTMLElement, query: string): HTMLElement[] =>
414
- // [...container.querySelectorAll(query)].filter((e) => e instanceof HTMLElement) as HTMLElement[];
415
- // const getMultipleError = (_: Element | null, query: string): string => `Found multiple elements by query: ${query}`;
416
- // const getMissingError = (_: Element | null, query: string): string => `Unable to find an element by query: ${query}`;
417
- // const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = buildQueries(
418
- // queryAllByQuery,
419
- // getMultipleError,
420
- // getMissingError,
421
- // );
422
- // const queries = {
423
- // queryByQuery,
424
- // getAllByQuery,
425
- // getByQuery,
426
- // findAllByQuery,
427
- // findByQuery,
428
- // };
423
+ window.__CREEVEY_SET_READY_FOR_CAPTURE__ = noop;
429
424
 
425
+ var queryAllByQuery = function queryAllByQuery(container, query) {
426
+ return _toConsumableArray(container.querySelectorAll(query)).filter(function (e) {
427
+ return e instanceof HTMLElement;
428
+ });
429
+ };
430
+
431
+ var getMultipleError = function getMultipleError(_, query) {
432
+ return "Found multiple elements by query: ".concat(query);
433
+ };
434
+
435
+ var getMissingError = function getMissingError(_, query) {
436
+ return "Unable to find an element by query: ".concat(query);
437
+ };
438
+
439
+ var _buildQueries = buildQueries(queryAllByQuery, getMultipleError, getMissingError),
440
+ _buildQueries2 = _slicedToArray(_buildQueries, 5),
441
+ queryByQuery = _buildQueries2[0],
442
+ getAllByQuery = _buildQueries2[1],
443
+ getByQuery = _buildQueries2[2],
444
+ findAllByQuery = _buildQueries2[3],
445
+ findByQuery = _buildQueries2[4];
446
+
447
+ var queries = {
448
+ queryByQuery: queryByQuery,
449
+ getAllByQuery: getAllByQuery,
450
+ getByQuery: getByQuery,
451
+ findAllByQuery: findAllByQuery,
452
+ findByQuery: findByQuery
453
+ };
430
454
  return makeDecorator({
431
455
  name: 'withCreevey',
432
456
  parameterName: 'creevey',
@@ -445,8 +469,9 @@ export function withCreevey() {
445
469
 
446
470
  case captureElement === null:
447
471
  return Promise.resolve(document.documentElement);
448
- // case typeof captureElement == 'string':
449
- // return within<typeof queries>(context.canvasElement, queries).findByQuery(captureElement as string);
472
+
473
+ case typeof captureElement == 'string':
474
+ return within(context.canvasElement, queries).findByQuery(captureElement);
450
475
 
451
476
  case typeof captureElement == 'function':
452
477
  // TODO Define type for it
@@ -465,8 +490,8 @@ export function capture(_x7) {
465
490
  }
466
491
 
467
492
  function _capture() {
468
- _capture = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(options) {
469
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
493
+ _capture = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(options) {
494
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
470
495
  while (1) {
471
496
  switch (_context5.prev = _context5.next) {
472
497
  case 0:
@@ -1,3 +1,7 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4
+
1
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
6
 
3
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
@@ -9,9 +13,9 @@ export function initCreeveyClientApi() {
9
13
  }
10
14
 
11
15
  function _initCreeveyClientApi() {
12
- _initCreeveyClientApi = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
16
+ _initCreeveyClientApi = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13
17
  var clientApiResolver, updateListeners, statusRequest, statusResolver, ws, send;
14
- return regeneratorRuntime.wrap(function _callee$(_context) {
18
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
15
19
  while (1) {
16
20
  switch (_context.prev = _context.next) {
17
21
  case 0:
@@ -2,9 +2,9 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
2
2
 
3
3
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
4
4
 
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
 
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
7
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
8
 
9
9
  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; }
10
10
 
@@ -325,10 +325,10 @@ export function useLoadImages(s1, s2, s3) {
325
325
  }, [s1, s2, s3]);
326
326
  return loaded;
327
327
  }
328
- /**
329
- * Uses the ResizeObserver API to observe changes within the given HTML Element DOM Rect.
330
- *
331
- * @returns dimensions of element's content box (which means without paddings and border width)
328
+ /**
329
+ * Uses the ResizeObserver API to observe changes within the given HTML Element DOM Rect.
330
+ *
331
+ * @returns dimensions of element's content box (which means without paddings and border width)
332
332
  */
333
333
 
334
334
  export function useResizeObserver(elementRef, onResize) {
@@ -8,10 +8,8 @@ import { setDefaultLevel, levels } from 'loglevel';
8
8
  import { logger } from './server/logger';
9
9
 
10
10
  function shutdownOnException(reason) {
11
- var _reason$stack;
12
-
13
11
  if (isShuttingDown.current) return;
14
- const error = reason instanceof Error ? (_reason$stack = reason.stack) !== null && _reason$stack !== void 0 ? _reason$stack : reason.message : reason;
12
+ const error = reason instanceof Error ? reason.stack ?? reason.message : reason;
15
13
  logger.error(error);
16
14
  process.exitCode = -1;
17
15
  if (cluster.isWorker) emitWorkerMessage({
@@ -20,13 +18,13 @@ function shutdownOnException(reason) {
20
18
  error
21
19
  }
22
20
  });
23
- if (cluster.isMaster && !isShuttingDown.current) void shutdownWorkers();
21
+ if (cluster.isPrimary && !isShuttingDown.current) void shutdownWorkers();
24
22
  }
25
23
 
26
24
  process.on('uncaughtException', shutdownOnException);
27
25
  process.on('unhandledRejection', shutdownOnException);
28
26
  if (cluster.isWorker) process.on('SIGINT', noop);
29
- if (cluster.isMaster) process.on('SIGINT', shutdown);
27
+ if (cluster.isPrimary) process.on('SIGINT', shutdown);
30
28
  const argv = minimist(process.argv.slice(2), {
31
29
  string: ['browser', 'config', 'reporter', 'reportDir', 'screenDir'],
32
30
  boolean: ['debug', 'ui', 'saveReport', 'webpack', 'tests'],
package/lib/esm/index.js CHANGED
@@ -1,6 +1,4 @@
1
- export * from './types'; // export * from './client/addon/withCreevey';
2
- // export * from './client/addon/readyForCapture';
3
-
1
+ export * from './types';
4
2
  export { loadStories as browserStoriesProvider } from './server/storybook/providers/browser';
5
3
  export { loadStories as nodejsStoriesProvider } from './server/storybook/providers/nodejs';
6
4
  export { loadStories as hybridStoriesProvider } from './server/storybook/providers/hybrid';
@@ -1,4 +1,4 @@
1
- import cluster, { isMaster } from 'cluster';
1
+ import cluster from 'cluster';
2
2
  import { isDockerMessage } from '../types';
3
3
  import { subscribeOn, sendDockerMessage, emitDockerMessage } from './messages';
4
4
  import { isInsideDocker, LOCALHOST_REGEXP } from './utils';
@@ -91,7 +91,7 @@ export async function runImage(image, args, options, debug) {
91
91
  });
92
92
  }
93
93
  export default async function (config, browser, startContainer) {
94
- if (isMaster) {
94
+ if (cluster.isPrimary) {
95
95
  const host = await startContainer();
96
96
  let gridUrl = 'http://localhost:4444/wd/hub';
97
97
  gridUrl = isInsideDocker ? gridUrl.replace(LOCALHOST_REGEXP, host) : gridUrl;
@@ -46,7 +46,7 @@ export default async function (options) {
46
46
  return (await import('./loaders/webpack/compile')).default(config, options);
47
47
  }
48
48
 
49
- case cluster.isMaster:
49
+ case cluster.isPrimary:
50
50
  {
51
51
  logger.info('Starting Master Process');
52
52
  const resolveApi = (await import('./master/server')).default(config.reportDir, port, ui);
@@ -7,9 +7,7 @@ const reexportedStories = new Map();
7
7
  export default function () {
8
8
  return {
9
9
  pre() {
10
- var _this$opts$parents;
11
-
12
- const parents = (_this$opts$parents = this.opts.parents()) !== null && _this$opts$parents !== void 0 ? _this$opts$parents : [];
10
+ const parents = this.opts.parents() ?? [];
13
11
  const story = this.opts.story();
14
12
  this.resourcePath = this.filename;
15
13
  this.fileType = FileType.Invalid; // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -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