creevey 0.9.0-non-webpack.0 → 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.
- package/lib/cjs/client/addon/Manager.js +121 -275
- package/lib/cjs/client/addon/components/Addon.js +17 -38
- package/lib/cjs/client/addon/components/Icons.js +10 -6
- package/lib/cjs/client/addon/components/Panel.js +17 -13
- package/lib/cjs/client/addon/components/TestSelect.js +11 -9
- package/lib/cjs/client/addon/components/Tools.js +21 -40
- package/lib/cjs/client/addon/decorator.js +1 -1
- package/lib/cjs/client/addon/index.js +2 -2
- package/lib/cjs/client/addon/preset.js +11 -30
- package/lib/cjs/client/addon/register.js +45 -73
- package/lib/cjs/client/addon/utils.js +1 -1
- package/lib/cjs/client/addon/withCreevey.js +153 -360
- package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
- package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
- package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
- package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
- package/lib/cjs/client/shared/components/ImagesView/index.js +5 -5
- package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
- package/lib/cjs/client/shared/components/ResultsPage.js +38 -68
- package/lib/cjs/client/shared/creeveyClientApi.js +55 -86
- package/lib/cjs/client/shared/helpers.js +123 -194
- package/lib/cjs/client/shared/viewMode.js +4 -4
- package/lib/cjs/shared/index.js +26 -14
- package/lib/cjs/shared/serializeRegExp.js +5 -4
- package/lib/esm/client/addon/Manager.js +121 -275
- package/lib/esm/client/addon/components/Addon.js +15 -34
- package/lib/esm/client/addon/components/Icons.js +10 -6
- package/lib/esm/client/addon/components/Panel.js +17 -13
- package/lib/esm/client/addon/components/TestSelect.js +11 -9
- package/lib/esm/client/addon/components/Tools.js +19 -36
- package/lib/esm/client/addon/decorator.js +1 -1
- package/lib/esm/client/addon/preset.js +9 -24
- package/lib/esm/client/addon/register.js +42 -70
- package/lib/esm/client/addon/utils.js +1 -1
- package/lib/esm/client/addon/withCreevey.js +148 -357
- package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
- package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
- package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
- package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
- package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
- package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
- package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
- package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
- package/lib/esm/client/shared/components/ResultsPage.js +36 -64
- package/lib/esm/client/shared/creeveyClientApi.js +57 -88
- package/lib/esm/client/shared/helpers.js +123 -194
- package/lib/esm/client/shared/viewMode.js +4 -4
- package/lib/esm/shared/index.js +26 -14
- package/lib/esm/shared/serializeRegExp.js +5 -4
- package/package.json +1 -1
- package/preset.js +1 -1
@@ -20,91 +20,43 @@ var _shared = require("../../shared");
|
|
20
20
|
|
21
21
|
var _helpers = require("../shared/helpers");
|
22
22
|
|
23
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
23
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
24
24
|
|
25
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
26
26
|
|
27
|
-
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; }
|
28
|
-
|
29
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
30
|
-
|
31
|
-
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."); }
|
32
|
-
|
33
|
-
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; }
|
34
|
-
|
35
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
36
|
-
|
37
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
38
|
-
|
39
|
-
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."); }
|
40
|
-
|
41
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
42
|
-
|
43
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
44
|
-
|
45
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
46
|
-
|
47
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
48
|
-
|
49
|
-
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); } }
|
50
|
-
|
51
|
-
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); }); }; }
|
52
|
-
|
53
|
-
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); }
|
54
|
-
|
55
|
-
if ((typeof process === "undefined" ? "undefined" : _typeof(process)) != 'object' || typeof process.version != 'string') {
|
27
|
+
if (typeof process != 'object' || typeof process.version != 'string') {
|
56
28
|
// NOTE If you don't use babel-polyfill or any other polyfills that add EventSource for IE11
|
57
29
|
// You don't get hot reload in IE11. So put polyfill for that to better UX
|
58
30
|
// Don't load in nodejs environment
|
59
31
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
60
|
-
|
61
|
-
|
32
|
+
const {
|
33
|
+
NativeEventSource,
|
34
|
+
EventSourcePolyfill
|
35
|
+
} = polyfill; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
62
36
|
|
63
37
|
window.EventSource = NativeEventSource || EventSourcePolyfill;
|
64
38
|
}
|
65
39
|
|
66
|
-
|
67
|
-
|
68
|
-
function resetCurrentStory(_x) {
|
69
|
-
return _resetCurrentStory.apply(this, arguments);
|
70
|
-
}
|
40
|
+
const disableAnimationsStyles = "\n*,\n*:hover,\n*::before,\n*::after {\n animation-delay: -0.0001ms !important;\n animation-duration: 0s !important;\n animation-play-state: paused !important;\n cursor: none !important;\n caret-color: transparent !important;\n transition: 0s !important;\n}\n";
|
71
41
|
|
72
|
-
function
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
return channel.emit(Events.SET_CURRENT_STORY, {
|
80
|
-
storyId: true,
|
81
|
-
name: '',
|
82
|
-
kind: ''
|
83
|
-
});
|
84
|
-
}, 0);
|
85
|
-
return _context4.abrupt("return", new Promise(function (resolve) {
|
86
|
-
return channel.once(Events.STORY_MISSING, resolve);
|
87
|
-
}));
|
88
|
-
|
89
|
-
case 2:
|
90
|
-
case "end":
|
91
|
-
return _context4.stop();
|
92
|
-
}
|
93
|
-
}
|
94
|
-
}, _callee4);
|
95
|
-
}));
|
96
|
-
return _resetCurrentStory.apply(this, arguments);
|
42
|
+
async function resetCurrentStory(channel) {
|
43
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
44
|
+
storyId: true,
|
45
|
+
name: '',
|
46
|
+
kind: ''
|
47
|
+
}), 0);
|
48
|
+
return new Promise(resolve => channel.once(Events.STORY_MISSING, resolve));
|
97
49
|
}
|
98
50
|
|
99
51
|
function catchRenderError(channel) {
|
100
|
-
|
101
|
-
|
102
|
-
return rejectCallback = reject;
|
103
|
-
});
|
52
|
+
let rejectCallback;
|
53
|
+
const promise = new Promise((_resolve, reject) => rejectCallback = reject);
|
104
54
|
|
105
55
|
function errorHandler(_ref) {
|
106
|
-
|
107
|
-
|
56
|
+
let {
|
57
|
+
title,
|
58
|
+
description
|
59
|
+
} = _ref;
|
108
60
|
rejectCallback({
|
109
61
|
message: title,
|
110
62
|
stack: description
|
@@ -128,10 +80,8 @@ function catchRenderError(channel) {
|
|
128
80
|
}
|
129
81
|
|
130
82
|
function waitForStoryRendered(channel) {
|
131
|
-
|
132
|
-
|
133
|
-
return resolveCallback = resolve;
|
134
|
-
});
|
83
|
+
let resolveCallback;
|
84
|
+
const promise = new Promise(resolve => resolveCallback = resolve);
|
135
85
|
|
136
86
|
function renderHandler() {
|
137
87
|
resolveCallback();
|
@@ -149,13 +99,11 @@ function waitForStoryRendered(channel) {
|
|
149
99
|
|
150
100
|
function waitForFontsLoaded() {
|
151
101
|
if (!document.fonts) return;
|
152
|
-
|
153
|
-
return font.status == 'loading';
|
154
|
-
});
|
102
|
+
const areFontsLoading = Array.from(document.fonts).some(font => font.status == 'loading');
|
155
103
|
|
156
104
|
if (areFontsLoading) {
|
157
|
-
return new Promise(
|
158
|
-
|
105
|
+
return new Promise(resolve => {
|
106
|
+
const fontsLoadedHandler = () => {
|
159
107
|
document.fonts.removeEventListener('loadingdone', fontsLoadedHandler);
|
160
108
|
resolve();
|
161
109
|
};
|
@@ -166,247 +114,137 @@ function waitForFontsLoaded() {
|
|
166
114
|
}
|
167
115
|
|
168
116
|
function waitForCaptureCall() {
|
169
|
-
return new Promise(
|
170
|
-
return captureResolver = resolve;
|
171
|
-
});
|
117
|
+
return new Promise(resolve => captureResolver = resolve);
|
172
118
|
}
|
173
119
|
|
174
120
|
function initCreeveyState() {
|
175
121
|
var _window$localStorage$;
|
176
122
|
|
177
|
-
|
123
|
+
const prevState = JSON.parse((_window$localStorage$ = window.localStorage.getItem('Creevey_Tests')) !== null && _window$localStorage$ !== void 0 ? _window$localStorage$ : '{}');
|
178
124
|
if (prevState.creeveyHost) window.__CREEVEY_SERVER_HOST__ = prevState.creeveyHost;
|
179
125
|
if (prevState.creeveyPort) window.__CREEVEY_SERVER_PORT__ = prevState.creeveyPort;
|
180
126
|
if (prevState.setStoriesCounter) setStoriesCounter = prevState.setStoriesCounter;
|
181
127
|
if (prevState.isTestBrowser) isTestBrowser = prevState.isTestBrowser;
|
182
|
-
window.addEventListener('beforeunload',
|
128
|
+
window.addEventListener('beforeunload', () => {
|
183
129
|
window.localStorage.setItem('Creevey_Tests', JSON.stringify({
|
184
130
|
creeveyHost: window.__CREEVEY_SERVER_HOST__,
|
185
131
|
creeveyPort: window.__CREEVEY_SERVER_PORT__,
|
186
|
-
setStoriesCounter
|
187
|
-
isTestBrowser
|
132
|
+
setStoriesCounter,
|
133
|
+
isTestBrowser
|
188
134
|
}));
|
189
135
|
});
|
190
136
|
}
|
191
137
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
138
|
+
let isTestBrowser = false;
|
139
|
+
let captureResolver;
|
140
|
+
let waitForCreevey;
|
141
|
+
let creeveyReady;
|
142
|
+
let setStoriesCounter = 0;
|
197
143
|
|
198
144
|
function withCreevey() {
|
199
|
-
|
200
|
-
|
145
|
+
let currentStory = '';
|
146
|
+
let isAnimationDisabled = false;
|
201
147
|
initCreeveyState();
|
202
148
|
|
203
149
|
function disableAnimation() {
|
204
150
|
isAnimationDisabled = true;
|
205
|
-
|
206
|
-
|
151
|
+
const style = document.createElement('style');
|
152
|
+
const textNode = document.createTextNode(disableAnimationsStyles);
|
207
153
|
style.setAttribute('type', 'text/css');
|
208
154
|
style.appendChild(textNode);
|
209
155
|
document.head.appendChild(style);
|
210
156
|
}
|
211
157
|
|
212
|
-
function getStories() {
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
_context.next = 9;
|
250
|
-
return store.cacheAllCSFFiles();
|
251
|
-
|
252
|
-
case 9:
|
253
|
-
_addons.addons.getChannel().emit(Events.SET_STORIES, store.getSetStoriesPayload());
|
254
|
-
|
255
|
-
_context.next = 13;
|
256
|
-
break;
|
257
|
-
|
258
|
-
case 12:
|
259
|
-
return _context.abrupt("return");
|
260
|
-
|
261
|
-
case 13:
|
262
|
-
_addons.addons.getChannel().on(Events.SET_STORIES, function (data) {
|
263
|
-
// TODO Figure out how to get only updated stories
|
264
|
-
// TODO Subscribe on hmr? like use dummy-hmr
|
265
|
-
setStoriesCounter += 1;
|
266
|
-
var stories = (0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data));
|
267
|
-
var storiesByFiles = new Map();
|
268
|
-
Object.values(stories).forEach(function (story) {
|
269
|
-
var storiesFromFile = storiesByFiles.get(story.parameters.fileName);
|
270
|
-
if (storiesFromFile) storiesFromFile.push(story);else storiesByFiles.set(story.parameters.fileName, [story]);
|
271
|
-
});
|
272
|
-
void fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/stories"), {
|
273
|
-
method: 'POST',
|
274
|
-
headers: {
|
275
|
-
'Content-Type': 'application/json'
|
276
|
-
},
|
277
|
-
body: JSON.stringify({
|
278
|
-
setStoriesCounter: setStoriesCounter,
|
279
|
-
stories: _toConsumableArray(storiesByFiles.entries())
|
280
|
-
})
|
281
|
-
});
|
282
|
-
});
|
283
|
-
|
284
|
-
return _context.abrupt("return", storiesPromise);
|
285
|
-
|
286
|
-
case 15:
|
287
|
-
case "end":
|
288
|
-
return _context.stop();
|
289
|
-
}
|
290
|
-
}
|
291
|
-
}, _callee);
|
292
|
-
}));
|
293
|
-
return _getStories.apply(this, arguments);
|
294
|
-
}
|
158
|
+
async function getStories() {
|
159
|
+
var _window$__STORYBOOK_S;
|
160
|
+
|
161
|
+
const storiesPromise = new Promise(resolve => _addons.addons.getChannel().once(Events.SET_STORIES, data => resolve((0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data)))));
|
162
|
+
const store = (_window$__STORYBOOK_S = window.__STORYBOOK_STORY_STORE__) !== null && _window$__STORYBOOK_S !== void 0 ? _window$__STORYBOOK_S : {}; // @ts-expect-error `pushToManager` exists only in Storybook 6.0 - 6.3
|
163
|
+
|
164
|
+
if (store.pushToManager) {
|
165
|
+
// @ts-expect-error `pushToManager` exists only in Storybook 6.0 - 6.3
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
167
|
+
store.pushToManager();
|
168
|
+
} else if (store.cacheAllCSFFiles) {
|
169
|
+
await store.cacheAllCSFFiles();
|
170
|
+
|
171
|
+
_addons.addons.getChannel().emit(Events.SET_STORIES, store.getSetStoriesPayload());
|
172
|
+
} else return;
|
173
|
+
|
174
|
+
_addons.addons.getChannel().on(Events.SET_STORIES, data => {
|
175
|
+
// TODO Figure out how to get only updated stories
|
176
|
+
// TODO Subscribe on hmr? like use dummy-hmr
|
177
|
+
setStoriesCounter += 1;
|
178
|
+
const stories = (0, _shared.serializeRawStories)((0, _shared.denormalizeStoryParameters)(data));
|
179
|
+
const storiesByFiles = new Map();
|
180
|
+
Object.values(stories).forEach(story => {
|
181
|
+
const storiesFromFile = storiesByFiles.get(story.parameters.fileName);
|
182
|
+
if (storiesFromFile) storiesFromFile.push(story);else storiesByFiles.set(story.parameters.fileName, [story]);
|
183
|
+
});
|
184
|
+
void fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/stories"), {
|
185
|
+
method: 'POST',
|
186
|
+
headers: {
|
187
|
+
'Content-Type': 'application/json'
|
188
|
+
},
|
189
|
+
body: JSON.stringify({
|
190
|
+
setStoriesCounter,
|
191
|
+
stories: [...storiesByFiles.entries()]
|
192
|
+
})
|
193
|
+
});
|
194
|
+
});
|
295
195
|
|
296
|
-
|
297
|
-
return _selectStory.apply(this, arguments);
|
196
|
+
return storiesPromise;
|
298
197
|
}
|
299
198
|
|
300
|
-
function
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
});
|
337
|
-
setTimeout(function () {
|
338
|
-
return channel.emit(Events.SET_CURRENT_STORY, {
|
339
|
-
storyId: storyId,
|
340
|
-
name: name,
|
341
|
-
kind: kind
|
342
|
-
});
|
343
|
-
}, 0);
|
344
|
-
_context3.prev = 15;
|
345
|
-
_context3.next = 18;
|
346
|
-
return Promise.race([_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
347
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
348
|
-
while (1) {
|
349
|
-
switch (_context2.prev = _context2.next) {
|
350
|
-
case 0:
|
351
|
-
_context2.next = 2;
|
352
|
-
return Promise.race([renderPromise, capturePromise]);
|
353
|
-
|
354
|
-
case 2:
|
355
|
-
_context2.next = 4;
|
356
|
-
return waitForFontsLoaded();
|
357
|
-
|
358
|
-
case 4:
|
359
|
-
_context2.next = 6;
|
360
|
-
return waitForReady;
|
361
|
-
|
362
|
-
case 6:
|
363
|
-
case "end":
|
364
|
-
return _context2.stop();
|
365
|
-
}
|
366
|
-
}
|
367
|
-
}, _callee2);
|
368
|
-
}))(), errorPromise]);
|
369
|
-
|
370
|
-
case 18:
|
371
|
-
callback([null, isCaptureCalled]);
|
372
|
-
_context3.next = 25;
|
373
|
-
break;
|
374
|
-
|
375
|
-
case 21:
|
376
|
-
_context3.prev = 21;
|
377
|
-
_context3.t0 = _context3["catch"](15);
|
378
|
-
// NOTE Event `STORY_THREW_EXCEPTION` triggered only in react and vue frameworks and return Error instance
|
379
|
-
// NOTE Event `STORY_ERRORED` return error-like object without `name` field
|
380
|
-
errorMessage = _context3.t0 instanceof Error ? (_reason$stack = _context3.t0.stack) !== null && _reason$stack !== void 0 ? _reason$stack : _context3.t0.message : (0, _types.isObject)(_context3.t0) ? "".concat(_context3.t0.message, "\n ").concat(_context3.t0.stack) : _context3.t0;
|
381
|
-
callback([errorMessage]);
|
382
|
-
|
383
|
-
case 25:
|
384
|
-
_context3.prev = 25;
|
385
|
-
renderPromise.cancel();
|
386
|
-
errorPromise.cancel();
|
387
|
-
return _context3.finish(25);
|
388
|
-
|
389
|
-
case 29:
|
390
|
-
case "end":
|
391
|
-
return _context3.stop();
|
392
|
-
}
|
393
|
-
}
|
394
|
-
}, _callee3, null, [[15, 21, 25, 29]]);
|
395
|
-
}));
|
396
|
-
return _selectStory.apply(this, arguments);
|
199
|
+
async function selectStory(storyId, kind, name, shouldWaitForReady, callback) {
|
200
|
+
if (!isAnimationDisabled) disableAnimation();
|
201
|
+
isTestBrowser = true;
|
202
|
+
|
203
|
+
const channel = _addons.addons.getChannel();
|
204
|
+
|
205
|
+
const waitForReady = shouldWaitForReady ? new Promise(resolve => window.__CREEVEY_SET_READY_FOR_CAPTURE__ = resolve) : Promise.resolve();
|
206
|
+
if (storyId == currentStory) await resetCurrentStory(channel);else currentStory = storyId;
|
207
|
+
let isCaptureCalled = false;
|
208
|
+
const renderPromise = waitForStoryRendered(channel);
|
209
|
+
const errorPromise = catchRenderError(channel);
|
210
|
+
const capturePromise = waitForCaptureCall().then(() => isCaptureCalled = true);
|
211
|
+
setTimeout(() => channel.emit(Events.SET_CURRENT_STORY, {
|
212
|
+
storyId,
|
213
|
+
name,
|
214
|
+
kind
|
215
|
+
}), 0);
|
216
|
+
|
217
|
+
try {
|
218
|
+
await Promise.race([(async () => {
|
219
|
+
await Promise.race([renderPromise, capturePromise]);
|
220
|
+
await waitForFontsLoaded();
|
221
|
+
await waitForReady;
|
222
|
+
})(), errorPromise]);
|
223
|
+
callback([null, isCaptureCalled]);
|
224
|
+
} catch (reason) {
|
225
|
+
var _reason$stack;
|
226
|
+
|
227
|
+
// NOTE Event `STORY_THREW_EXCEPTION` triggered only in react and vue frameworks and return Error instance
|
228
|
+
// NOTE Event `STORY_ERRORED` return error-like object without `name` field
|
229
|
+
const errorMessage = reason instanceof Error ? (_reason$stack = reason.stack) !== null && _reason$stack !== void 0 ? _reason$stack : reason.message : (0, _types.isObject)(reason) ? "".concat(reason.message, "\n ").concat(reason.stack) : reason;
|
230
|
+
callback([errorMessage]);
|
231
|
+
} finally {
|
232
|
+
renderPromise.cancel();
|
233
|
+
errorPromise.cancel();
|
234
|
+
}
|
397
235
|
}
|
398
236
|
|
399
237
|
function updateGlobals(globals) {
|
400
238
|
_addons.addons.getChannel().emit(Events.UPDATE_GLOBALS, {
|
401
|
-
globals
|
239
|
+
globals
|
402
240
|
});
|
403
241
|
}
|
404
242
|
|
405
243
|
function insertIgnoreStyles(ignoreSelectors) {
|
406
|
-
|
244
|
+
const stylesElement = document.createElement('style');
|
407
245
|
stylesElement.setAttribute('type', 'text/css');
|
408
246
|
document.head.appendChild(stylesElement);
|
409
|
-
ignoreSelectors.forEach(
|
247
|
+
ignoreSelectors.forEach(selector => {
|
410
248
|
stylesElement.innerHTML += "\n ".concat(selector, " {\n background: #000 !important;\n box-shadow: none !important;\n text-shadow: none !important;\n outline: 0 !important;\n color: rgba(0,0,0,0) !important;\n }\n ").concat(selector, " *, ").concat(selector, "::before, ").concat(selector, "::after {\n visibility: hidden !important;\n }\n ");
|
411
249
|
});
|
412
250
|
return stylesElement;
|
@@ -420,17 +258,17 @@ function withCreevey() {
|
|
420
258
|
|
421
259
|
function hasPlayCompletedYet(callback) {
|
422
260
|
creeveyReady();
|
423
|
-
|
424
|
-
|
261
|
+
let isCaptureCalled = false;
|
262
|
+
let isPlayCompleted = false;
|
425
263
|
|
426
|
-
|
264
|
+
const channel = _addons.addons.getChannel();
|
427
265
|
|
428
|
-
void waitForStoryRendered(channel).then(
|
266
|
+
void waitForStoryRendered(channel).then(() => {
|
429
267
|
if (isCaptureCalled) return;
|
430
268
|
isPlayCompleted = true;
|
431
269
|
callback(true);
|
432
270
|
});
|
433
|
-
void waitForCaptureCall().then(
|
271
|
+
void waitForCaptureCall().then(() => {
|
434
272
|
if (isPlayCompleted) return;
|
435
273
|
isCaptureCalled = true;
|
436
274
|
callback(false);
|
@@ -445,47 +283,32 @@ function withCreevey() {
|
|
445
283
|
window.__CREEVEY_HAS_PLAY_COMPLETED_YET__ = hasPlayCompletedYet;
|
446
284
|
window.__CREEVEY_SET_READY_FOR_CAPTURE__ = _types.noop;
|
447
285
|
|
448
|
-
|
449
|
-
return _toConsumableArray(container.querySelectorAll(query)).filter(function (e) {
|
450
|
-
return e instanceof HTMLElement;
|
451
|
-
});
|
452
|
-
};
|
286
|
+
const queryAllByQuery = (container, query) => [...container.querySelectorAll(query)].filter(e => e instanceof HTMLElement);
|
453
287
|
|
454
|
-
|
455
|
-
return "Found multiple elements by query: ".concat(query);
|
456
|
-
};
|
288
|
+
const getMultipleError = (_, query) => "Found multiple elements by query: ".concat(query);
|
457
289
|
|
458
|
-
|
459
|
-
return "Unable to find an element by query: ".concat(query);
|
460
|
-
};
|
290
|
+
const getMissingError = (_, query) => "Unable to find an element by query: ".concat(query);
|
461
291
|
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
var queries = {
|
471
|
-
queryByQuery: queryByQuery,
|
472
|
-
getAllByQuery: getAllByQuery,
|
473
|
-
getByQuery: getByQuery,
|
474
|
-
findAllByQuery: findAllByQuery,
|
475
|
-
findByQuery: findByQuery
|
292
|
+
const [queryByQuery, getAllByQuery, getByQuery, findAllByQuery, findByQuery] = (0, _testingLibrary.buildQueries)(queryAllByQuery, getMultipleError, getMissingError);
|
293
|
+
const queries = {
|
294
|
+
queryByQuery,
|
295
|
+
getAllByQuery,
|
296
|
+
getByQuery,
|
297
|
+
findAllByQuery,
|
298
|
+
findByQuery
|
476
299
|
};
|
477
300
|
return (0, _addons.makeDecorator)({
|
478
301
|
name: 'withCreevey',
|
479
302
|
parameterName: 'creevey',
|
480
|
-
wrapper:
|
303
|
+
wrapper: (getStory, context) => {
|
481
304
|
var _ref2;
|
482
305
|
|
483
306
|
// TODO Define proper types, like captureElement is a promise
|
484
|
-
|
485
|
-
|
486
|
-
|
307
|
+
const {
|
308
|
+
captureElement
|
309
|
+
} = context.parameters.creevey = (_ref2 = context.parameters.creevey) !== null && _ref2 !== void 0 ? _ref2 : {};
|
487
310
|
Object.defineProperty(context.parameters.creevey, 'captureElement', {
|
488
|
-
get
|
311
|
+
get() {
|
489
312
|
switch (true) {
|
490
313
|
case captureElement === undefined:
|
491
314
|
return Promise.resolve(context.canvasElement);
|
@@ -501,6 +324,7 @@ function withCreevey() {
|
|
501
324
|
return Promise.resolve(captureElement(context));
|
502
325
|
}
|
503
326
|
},
|
327
|
+
|
504
328
|
enumerable: true,
|
505
329
|
configurable: true
|
506
330
|
});
|
@@ -509,50 +333,19 @@ function withCreevey() {
|
|
509
333
|
});
|
510
334
|
}
|
511
335
|
|
512
|
-
function capture(
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
return _context5.abrupt("return");
|
528
|
-
|
529
|
-
case 2:
|
530
|
-
captureResolver();
|
531
|
-
waitForCreevey = new Promise(function (resolve) {
|
532
|
-
return creeveyReady = resolve;
|
533
|
-
});
|
534
|
-
_context5.next = 6;
|
535
|
-
return fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/capture"), {
|
536
|
-
method: 'POST',
|
537
|
-
headers: {
|
538
|
-
'Content-Type': 'application/json'
|
539
|
-
},
|
540
|
-
body: JSON.stringify({
|
541
|
-
workerId: window.__CREEVEY_WORKER_ID__,
|
542
|
-
options: options
|
543
|
-
})
|
544
|
-
});
|
545
|
-
|
546
|
-
case 6:
|
547
|
-
_context5.next = 8;
|
548
|
-
return waitForCreevey;
|
549
|
-
|
550
|
-
case 8:
|
551
|
-
case "end":
|
552
|
-
return _context5.stop();
|
553
|
-
}
|
554
|
-
}
|
555
|
-
}, _callee5);
|
556
|
-
}));
|
557
|
-
return _capture.apply(this, arguments);
|
336
|
+
async function capture(options) {
|
337
|
+
if (!isTestBrowser) return;
|
338
|
+
captureResolver();
|
339
|
+
waitForCreevey = new Promise(resolve => creeveyReady = resolve);
|
340
|
+
await fetch("http://".concat((0, _helpers.getConnectionUrl)(), "/capture"), {
|
341
|
+
method: 'POST',
|
342
|
+
headers: {
|
343
|
+
'Content-Type': 'application/json'
|
344
|
+
},
|
345
|
+
body: JSON.stringify({
|
346
|
+
workerId: window.__CREEVEY_WORKER_ID__,
|
347
|
+
options
|
348
|
+
})
|
349
|
+
});
|
350
|
+
await waitForCreevey;
|
558
351
|
}
|