@pisell/pisellos 0.0.14 → 0.0.16

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 (51) hide show
  1. package/dist/modules/AccountList/index.d.ts +5 -1
  2. package/dist/modules/AccountList/index.js +82 -36
  3. package/dist/modules/AccountList/types.d.ts +1 -0
  4. package/dist/modules/BaseModule.d.ts +6 -0
  5. package/dist/modules/BaseModule.js +41 -0
  6. package/dist/modules/Cart/index.d.ts +10 -2
  7. package/dist/modules/Cart/index.js +71 -34
  8. package/dist/modules/Cart/types.d.ts +2 -2
  9. package/dist/modules/Cart/utils.d.ts +12 -0
  10. package/dist/modules/Cart/utils.js +49 -0
  11. package/dist/modules/Date/index.d.ts +5 -0
  12. package/dist/modules/Date/index.js +35 -2
  13. package/dist/modules/Discount/index.d.ts +4 -0
  14. package/dist/modules/Discount/index.js +32 -4
  15. package/dist/modules/Discount/types.d.ts +3 -0
  16. package/dist/modules/Rules/index.js +7 -4
  17. package/dist/modules/Step/index.d.ts +4 -0
  18. package/dist/modules/Step/index.js +29 -1
  19. package/dist/modules/Summary/index.d.ts +4 -0
  20. package/dist/modules/Summary/index.js +28 -2
  21. package/dist/modules/Summary/utils.js +4 -5
  22. package/dist/solution/BookingByStep/index.d.ts +23 -4
  23. package/dist/solution/BookingByStep/index.js +152 -31
  24. package/dist/solution/BookingByStep/types.js +0 -3
  25. package/dist/solution/ShopDiscount/index.js +24 -3
  26. package/lib/modules/AccountList/index.d.ts +5 -1
  27. package/lib/modules/AccountList/index.js +33 -1
  28. package/lib/modules/AccountList/types.d.ts +1 -0
  29. package/lib/modules/BaseModule.d.ts +6 -0
  30. package/lib/modules/BaseModule.js +37 -0
  31. package/lib/modules/Cart/index.d.ts +10 -2
  32. package/lib/modules/Cart/index.js +42 -14
  33. package/lib/modules/Cart/types.d.ts +2 -2
  34. package/lib/modules/Cart/utils.d.ts +12 -0
  35. package/lib/modules/Cart/utils.js +33 -0
  36. package/lib/modules/Date/index.d.ts +5 -0
  37. package/lib/modules/Date/index.js +21 -0
  38. package/lib/modules/Discount/index.d.ts +4 -0
  39. package/lib/modules/Discount/index.js +19 -0
  40. package/lib/modules/Discount/types.d.ts +3 -0
  41. package/lib/modules/Rules/index.js +9 -4
  42. package/lib/modules/Step/index.d.ts +4 -0
  43. package/lib/modules/Step/index.js +19 -0
  44. package/lib/modules/Summary/index.d.ts +4 -0
  45. package/lib/modules/Summary/index.js +17 -0
  46. package/lib/modules/Summary/utils.js +4 -5
  47. package/lib/solution/BookingByStep/index.d.ts +23 -4
  48. package/lib/solution/BookingByStep/index.js +82 -21
  49. package/lib/solution/BookingByStep/types.js +0 -3
  50. package/lib/solution/ShopDiscount/index.js +21 -3
  51. package/package.json +1 -1
@@ -6,9 +6,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
8
  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; }
9
+ 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
11
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- 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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
12
12
  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); } }
13
13
  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); }); }; }
14
14
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -55,8 +55,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
55
55
  key: "initialize",
56
56
  value: function () {
57
57
  var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
58
- var _this2 = this;
59
- var moduleArr;
58
+ var _this$otherParams,
59
+ _this2 = this;
60
+ var targetCacheData, sessionData, data, moduleArr;
60
61
  return _regeneratorRuntime().wrap(function _callee$(_context) {
61
62
  while (1) switch (_context.prev = _context.next) {
62
63
  case 0:
@@ -74,18 +75,64 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
74
75
  }
75
76
  throw new Error("bookingByStep解决方案需要 request 插件支持");
76
77
  case 9:
77
- moduleArr = ["cart", "summary", "step", "products", "guests", "date", "accountList", "order", "payment"];
78
+ // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
79
+ // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
80
+ targetCacheData = {};
81
+ if ((_this$otherParams = this.otherParams) !== null && _this$otherParams !== void 0 && _this$otherParams.cacheId) {
82
+ sessionData = this.window.sessionStorage.getItem(this.name);
83
+ if (sessionData) {
84
+ data = JSON.parse(sessionData); // sessionData 格式:
85
+ // {
86
+ // "123123123": {
87
+ // "step": {
88
+ // stepList: [],
89
+ // currentStep: {},
90
+ // currentStepIndex: 0
91
+ // }
92
+ // "cart": {
93
+ // "list": []
94
+ // },
95
+ // "accountList": {
96
+ // "accounts": []
97
+ // },
98
+ // "date": {
99
+ // "dateList": [],
100
+ // "dateRange": []
101
+ // },
102
+ // "summary": {
103
+ // "subtotal": 1,
104
+ // "total": 1,
105
+ // "taxTitle": 1;
106
+ // "totalTaxFee": 1
107
+ // "isPriceIncludeTax": 1
108
+ // }
109
+ // }
110
+ // }
111
+ // 匹配 cacheid,如果匹配不到,直接把 sessionData 清掉即可
112
+ // 如果匹配到了,则把 sessionData 里的数据按模块塞到 store 里去
113
+ targetCacheData = data[this.otherParams.cacheId];
114
+ }
115
+ }
116
+ moduleArr = ["cart", "summary", "step", "products", "date", "accountList", "order", "payment"];
78
117
  moduleArr.forEach(function (step) {
79
118
  var targetModule = createModule(step, _this2.name);
80
119
  if (targetModule) {
120
+ var _this2$otherParams, _this2$otherParams2;
81
121
  _this2.store[step] = targetModule;
82
- _this2.core.registerModule(targetModule);
122
+ _this2.core.registerModule(targetModule, {
123
+ initialState: targetCacheData[targetModule.name],
124
+ otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
125
+ fatherModule: _this2.name,
126
+ openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
127
+ cacheId: (_this2$otherParams2 = _this2.otherParams) === null || _this2$otherParams2 === void 0 ? void 0 : _this2$otherParams2.cacheId
128
+ })
129
+ });
83
130
  } else {
84
131
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
85
132
  }
86
133
  });
87
134
  this.core.effects.emit(BookingByStepHooks.onInited, {});
88
- case 12:
135
+ case 14:
89
136
  case "end":
90
137
  return _context.stop();
91
138
  }
@@ -163,6 +210,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
163
210
  category_ids: category_ids,
164
211
  ids: product_ids,
165
212
  collection: collection
213
+ }, {
214
+ useCache: true
166
215
  });
167
216
  case 3:
168
217
  productsData = _context2.sent;
@@ -307,25 +356,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
307
356
  return _setDateRange.apply(this, arguments);
308
357
  }
309
358
  return setDateRange;
310
- }() // 获取日期模块里选中的日期
359
+ }()
360
+ }, {
361
+ key: "clearDateRange",
362
+ value: function clearDateRange() {
363
+ this.store.date.clearDateRange();
364
+ }
365
+
366
+ // 获取日期模块里选中的日期
311
367
  }, {
312
- key: "getRangeDate",
368
+ key: "getDateRange",
313
369
  value: function () {
314
- var _getRangeDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
370
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
315
371
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
316
372
  while (1) switch (_context7.prev = _context7.next) {
317
373
  case 0:
318
- return _context7.abrupt("return", "2024-01-01");
374
+ return _context7.abrupt("return", this.store.date.getDateRange());
319
375
  case 1:
320
376
  case "end":
321
377
  return _context7.stop();
322
378
  }
323
- }, _callee7);
379
+ }, _callee7, this);
324
380
  }));
325
- function getRangeDate() {
326
- return _getRangeDate.apply(this, arguments);
381
+ function getDateRange() {
382
+ return _getDateRange.apply(this, arguments);
327
383
  }
328
- return getRangeDate;
384
+ return getDateRange;
329
385
  }()
330
386
  }, {
331
387
  key: "getCart",
@@ -350,7 +406,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
350
406
  key: "getAvailableDate",
351
407
  value: function () {
352
408
  var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
353
- var _this$otherParams, _this$otherParams2;
409
+ var _this$otherParams2, _this$otherParams3;
354
410
  var params,
355
411
  products,
356
412
  startDate,
@@ -373,8 +429,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
373
429
  tempProducts = products || this.store.cart.getItems().map(function (p) {
374
430
  return p._productOrigin;
375
431
  });
376
- tempStartDate = startDate || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams = _this$otherParams.dateRange) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams[0]);
377
- tempEndDate = endDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[1]);
432
+ tempStartDate = startDate || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2 = _this$otherParams2.dateRange) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2[0]);
433
+ tempEndDate = endDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[1]);
378
434
  if (tempProducts.length) {
379
435
  _context9.next = 7;
380
436
  break;
@@ -637,7 +693,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
637
693
  // 删除购物车里某个商品
638
694
  }, {
639
695
  key: "deleteCart",
640
- value: function deleteCart(product_id) {}
696
+ value: function deleteCart(cartItemId) {
697
+ this.store.cart.removeItem(cartItemId);
698
+ }
641
699
 
642
700
  // 清空购物车
643
701
  }, {
@@ -652,6 +710,30 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
652
710
  value: function clearCartByAccount(account_id) {
653
711
  this.store.cart.clearCartByAccount(account_id);
654
712
  }
713
+
714
+ /**
715
+ * 批量更新购物车
716
+ */
717
+ }, {
718
+ key: "batchUpdateCart",
719
+ value: function batchUpdateCart(paramsList) {
720
+ var _this5 = this;
721
+ var cartItems = [];
722
+ paramsList.forEach(function (params) {
723
+ var cartItem = _this5.store.cart.formatCartItem(params);
724
+ cartItems.push(cartItem);
725
+ });
726
+ this.store.cart.batchSetItems(cartItems);
727
+ }
728
+
729
+ /**
730
+ * 从购物车中按类别删除信息
731
+ */
732
+ }, {
733
+ key: "deleteCartItemInfo",
734
+ value: function deleteCartItemInfo(types) {
735
+ this.store.cart.deleteCartItemInfo(types);
736
+ }
655
737
  }, {
656
738
  key: "destory",
657
739
  value: function destory() {
@@ -694,6 +776,39 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
694
776
  return arr;
695
777
  }
696
778
 
779
+ // 给单个购物车里的商品获取资源列表
780
+ }, {
781
+ key: "getResourcesListByCartItem",
782
+ value: function getResourcesListByCartItem(id) {
783
+ var cartItems = this.store.cart.getItems();
784
+ var dateRange = this.store.date.getDateRange();
785
+ var resources = [];
786
+ dateRange.forEach(function (n) {
787
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
788
+ });
789
+ var resourcesMap = getResourcesMap(resources);
790
+ var arr = [];
791
+ var targetCartItem = cartItems.find(function (n) {
792
+ return n._id === id;
793
+ });
794
+ if (!targetCartItem) {
795
+ throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
796
+ }
797
+ var productResources = getResourcesByProduct(resourcesMap, targetCartItem, cartItems);
798
+ if (productResources) {
799
+ return {
800
+ id: targetCartItem.id,
801
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
802
+ _id: targetCartItem._id,
803
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
804
+ product: targetCartItem._productOrigin,
805
+ resources: productResources,
806
+ holder_id: targetCartItem.holder_id,
807
+ holder_name: targetCartItem.holder_title
808
+ };
809
+ }
810
+ }
811
+
697
812
  // 通过资源列表和指定的资源 id,获取指定资源的时间切片
698
813
  }, {
699
814
  key: "getResourceTimeSlot",
@@ -888,7 +1003,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
888
1003
  }, {
889
1004
  key: "autoSelectAllProductResources",
890
1005
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
891
- var _this5 = this;
1006
+ var _this6 = this;
892
1007
  var dateRange = this.store.date.getDateRange();
893
1008
  var resources = [];
894
1009
  dateRange.forEach(function (n) {
@@ -898,27 +1013,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
898
1013
  // 一个账号一个账号处理
899
1014
  var errorList = [];
900
1015
  this.store.accountList.getAccounts().forEach(function (account) {
901
- var cartItems = _this5.store.cart.getCartByAccount(account.getId());
1016
+ var cartItems = _this6.store.cart.getCartByAccount(account.getId());
902
1017
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
903
- var allCartItems = _this5.store.cart.getItems();
1018
+ var allCartItems = _this6.store.cart.getItems();
904
1019
  cartItems.forEach(function (item) {
905
1020
  if (timeSlots) {
906
1021
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
907
- var res = _this5.autoSelectAccountResources({
1022
+ var res = _this6.autoSelectAccountResources({
908
1023
  holder_id: item.holder_id,
909
1024
  resources_code: resources_code,
910
1025
  timeSlots: timeSlots
911
1026
  });
912
1027
  if (res !== null && res !== void 0 && res.selectedResource) {
913
- console.log(_this5.store.cart.getItems());
914
- _this5.store.cart.updateItem({
1028
+ console.log(_this6.store.cart.getItems());
1029
+ _this6.store.cart.updateItem({
915
1030
  _id: item._id,
916
1031
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
917
1032
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
918
- return existingRes.resourceType !== res.selectedResource.resourceType;
1033
+ return existingRes.form_id !== res.selectedResource.form_id;
919
1034
  })), [res.selectedResource])
920
1035
  });
921
- console.log(_this5.store.cart.getItems());
1036
+ console.log(_this6.store.cart.getItems());
922
1037
  } else {
923
1038
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
924
1039
  errorList.push(item._id);
@@ -932,7 +1047,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
932
1047
  return n.code === resources_code;
933
1048
  })) === null || _productResources$fin === void 0 ? void 0 : _productResources$fin.renderList;
934
1049
  if (targetRenderList && targetRenderList.length > 0) {
935
- _this5.store.cart.updateItem({
1050
+ _this6.store.cart.updateItem({
936
1051
  _id: item._id,
937
1052
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
938
1053
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -953,7 +1068,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
953
1068
  }, {
954
1069
  key: "getTimeSlotByAllResources",
955
1070
  value: function getTimeSlotByAllResources(resources_code) {
956
- var _this6 = this;
1071
+ var _this7 = this;
957
1072
  var dateRange = this.store.date.getDateRange();
958
1073
  // 取出购物车中所有一已选择的第一步资源
959
1074
  var resources = [];
@@ -975,7 +1090,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
975
1090
  // duration = 不同账号的最长时间
976
1091
  this.store.accountList.getAccounts().forEach(function (account) {
977
1092
  var accountDuration = 0;
978
- var cartItems = _this6.store.cart.getCartByAccount(account.getId());
1093
+ var cartItems = _this7.store.cart.getCartByAccount(account.getId());
979
1094
  cartItems.forEach(function (item) {
980
1095
  var _item$_productOrigin$, _item$_productOrigin3;
981
1096
  accountDuration += (_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0;
@@ -1023,7 +1138,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1023
1138
  }, {
1024
1139
  key: "submitTimeSlot",
1025
1140
  value: function submitTimeSlot(timeSlots) {
1026
- var _this7 = this;
1141
+ var _this8 = this;
1027
1142
  var cartItems = this.store.cart.getItems();
1028
1143
  cartItems.forEach(function (item) {
1029
1144
  var newResources = cloneDeep(item._origin.resources);
@@ -1033,12 +1148,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1033
1148
  n.endTime = dayjs(n.startTime).add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref8 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes").format("YYYY-MM-DD HH:mm");
1034
1149
  delete n.times;
1035
1150
  });
1036
- _this7.store.cart.updateItem({
1151
+ _this8.store.cart.updateItem({
1037
1152
  _id: item._id,
1038
1153
  resources: newResources
1039
1154
  });
1040
1155
  });
1041
1156
  }
1157
+ }, {
1158
+ key: "clearCache",
1159
+ value: function clearCache() {}
1160
+ }, {
1161
+ key: "clearCacheByModule",
1162
+ value: function clearCacheByModule(module) {}
1042
1163
  }]);
1043
1164
  return BookingByStepImpl;
1044
1165
  }(BaseModule);
@@ -1,7 +1,6 @@
1
1
  import { ProductList, CartModule } from "../../modules";
2
2
  import { AccountListModule } from "../../modules/AccountList";
3
3
  import { DateModule } from "../../modules/Date";
4
- import { GuestListModule } from "../../modules/Guests";
5
4
  import { OrderModule } from "../../modules/Order";
6
5
  import { PaymentModule } from "../../modules/Payment";
7
6
  import { StepModule } from "../../modules/Step";
@@ -16,8 +15,6 @@ export function createModule(moduleName, solutionName, name, version) {
16
15
  return new StepModule("".concat(solutionName, "_").concat(name || moduleName), version);
17
16
  case "products":
18
17
  return new ProductList("".concat(solutionName, "_").concat(name || moduleName), version);
19
- case "guests":
20
- return new GuestListModule("".concat(solutionName, "_").concat(name || moduleName), version);
21
18
  case "date":
22
19
  return new DateModule("".concat(solutionName, "_").concat(name || moduleName), version);
23
20
  case "accountList":
@@ -154,18 +154,35 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
154
154
  }, {
155
155
  key: "registerDependentModules",
156
156
  value: function registerDependentModules() {
157
- var _this$options$otherPa, _this$options$otherPa2;
157
+ var _this$options$otherPa, _this$options$otherPa2, _this$options$otherPa3, _this$options$otherPa4, _this$options$otherPa5;
158
+ // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
159
+ // 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
160
+ var targetCacheData = {};
161
+ if ((_this$options$otherPa = this.options.otherParams) !== null && _this$options$otherPa !== void 0 && _this$options$otherPa.cacheId) {
162
+ var sessionData = this.window.sessionStorage.getItem(this.name);
163
+ if (sessionData) {
164
+ var data = JSON.parse(sessionData);
165
+ targetCacheData = data[this.options.otherParams.cacheId];
166
+ }
167
+ }
168
+
158
169
  // 注册优惠模块
159
170
  var discount = new DiscountModule("".concat(this.name, "_discount"));
160
171
  this.core.registerModule(discount, {
161
- hooks: (_this$options$otherPa = this.options.otherParams) === null || _this$options$otherPa === void 0 || (_this$options$otherPa = _this$options$otherPa.discount) === null || _this$options$otherPa === void 0 ? void 0 : _this$options$otherPa.hooks
172
+ initialState: targetCacheData[discount.name],
173
+ hooks: (_this$options$otherPa2 = this.options.otherParams) === null || _this$options$otherPa2 === void 0 || (_this$options$otherPa2 = _this$options$otherPa2.discount) === null || _this$options$otherPa2 === void 0 ? void 0 : _this$options$otherPa2.hooks,
174
+ otherParams: {
175
+ fatherModule: this.name,
176
+ openCache: (_this$options$otherPa3 = this.options.otherParams) !== null && _this$options$otherPa3 !== void 0 && _this$options$otherPa3.cacheId ? true : false,
177
+ cacheId: (_this$options$otherPa4 = this.options.otherParams) === null || _this$options$otherPa4 === void 0 ? void 0 : _this$options$otherPa4.cacheId
178
+ }
162
179
  });
163
180
  this.store.discount = discount;
164
181
 
165
182
  // 注册规则模块
166
183
  var rules = new RulesModule("".concat(this.name, "_rules"));
167
184
  this.core.registerModule(rules, {
168
- hooks: (_this$options$otherPa2 = this.options.otherParams) === null || _this$options$otherPa2 === void 0 || (_this$options$otherPa2 = _this$options$otherPa2.rules) === null || _this$options$otherPa2 === void 0 ? void 0 : _this$options$otherPa2.hooks
185
+ hooks: (_this$options$otherPa5 = this.options.otherParams) === null || _this$options$otherPa5 === void 0 || (_this$options$otherPa5 = _this$options$otherPa5.rules) === null || _this$options$otherPa5 === void 0 ? void 0 : _this$options$otherPa5.hooks
169
186
  });
170
187
  this.store.rules = rules;
171
188
  }
@@ -174,6 +191,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
174
191
  value: function registerEventListeners() {
175
192
  var _this2 = this;
176
193
  this.core.effects.on(ShopDiscountHooks.onCustomerChange, function (customer) {
194
+ var _this2$options$otherP;
195
+ if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
196
+ return;
197
+ }
177
198
  _this2.loadPrepareConfig({
178
199
  customerId: customer.id,
179
200
  action: "create",
@@ -6,10 +6,13 @@ export declare class AccountListModule extends BaseModule implements Module {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
8
8
  private store;
9
+ private cacheId;
10
+ private openCache;
11
+ private fatherModule;
9
12
  constructor(name?: string, version?: string);
10
13
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
11
14
  addAccount(account: Account): Promise<void>;
12
- updateAccount(id: string, updates: Partial<Account>): Promise<void>;
15
+ updateAccount(id: string, updates: Account): Promise<void>;
13
16
  removeAccount(id: string): Promise<void>;
14
17
  getAccounts(): AccountModule[];
15
18
  getAccount(id: string): AccountModule | null;
@@ -17,4 +20,5 @@ export declare class AccountListModule extends BaseModule implements Module {
17
20
  getState(): AccountListState;
18
21
  setActiveAccount(id: string | number): void;
19
22
  getActiveAccount(): AccountModule | null;
23
+ storeChange(): void;
20
24
  }
@@ -31,15 +31,35 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
31
31
  this.defaultName = "accountList";
32
32
  this.defaultVersion = "1.0.0";
33
33
  this.store = {
34
+ accountList: [],
35
+ // 账号的纯数据列表
34
36
  accounts: [],
37
+ // 账号的 module 列表
35
38
  isLoading: false,
36
39
  error: null
37
40
  };
41
+ this.openCache = false;
38
42
  }
39
43
  async initialize(core, options) {
44
+ var _a, _b, _c;
40
45
  this.core = core;
41
46
  this.store = options == null ? void 0 : options.store;
42
47
  this.store.accounts = [];
48
+ if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.accountList)) {
49
+ const recordList = options.initialState.accountList || [];
50
+ recordList.forEach((account) => {
51
+ this.addAccount(account);
52
+ });
53
+ } else {
54
+ this.store.accountList = [];
55
+ }
56
+ if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
57
+ this.openCache = options.otherParams.openCache;
58
+ this.cacheId = options.otherParams.cacheId;
59
+ }
60
+ if ((_c = options == null ? void 0 : options.otherParams) == null ? void 0 : _c.fatherModule) {
61
+ this.fatherModule = options.otherParams.fatherModule;
62
+ }
43
63
  }
44
64
  async addAccount(account) {
45
65
  try {
@@ -48,6 +68,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
48
68
  if (this.store.accounts.some((a) => a.getId() === account.id)) {
49
69
  throw new Error(`Account with id ${account.id} already exists`);
50
70
  }
71
+ this.store.accountList.push(account);
51
72
  const accountModule = new import_Account.AccountModule(`account_${account.id}`);
52
73
  this.core.registerModule(accountModule);
53
74
  accountModule.setAccountInfo(account);
@@ -72,7 +93,12 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
72
93
  if (!account) {
73
94
  throw new Error(`Account with id ${id} not found`);
74
95
  }
75
- Object.assign(account, updates);
96
+ account.setAccountInfo(updates);
97
+ this.store.accountList.forEach((account2) => {
98
+ if (account2.id === id) {
99
+ Object.assign(account2, updates);
100
+ }
101
+ });
76
102
  await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
77
103
  } catch (error) {
78
104
  this.store.error = error instanceof Error ? error.message : "Failed to update account";
@@ -94,6 +120,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
94
120
  ...this.store.accounts.slice(0, index),
95
121
  ...this.store.accounts.slice(index + 1)
96
122
  ];
123
+ this.store.accountList = this.store.accountList.filter((account) => account.id !== id);
97
124
  await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
98
125
  } catch (error) {
99
126
  this.store.error = error instanceof Error ? error.message : "Failed to remove account";
@@ -136,6 +163,11 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
136
163
  getActiveAccount() {
137
164
  return this.store.accounts.find((account) => account.isActive()) || null;
138
165
  }
166
+ storeChange() {
167
+ if (this.openCache) {
168
+ this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["accounts", "accountList"] });
169
+ }
170
+ }
139
171
  };
140
172
  // Annotate the CommonJS export names for ESM import in node:
141
173
  0 && (module.exports = {
@@ -19,6 +19,7 @@ export interface AccountListQuery {
19
19
  */
20
20
  export interface AccountListState {
21
21
  accounts: AccountModule[];
22
+ accountList: Account[];
22
23
  isLoading: boolean;
23
24
  error: string | null;
24
25
  }
@@ -8,4 +8,10 @@ export declare class BaseModule {
8
8
  protected core: PisellCore;
9
9
  constructor(name?: string, version?: string);
10
10
  destory(): void;
11
+ checkSaveCache({ cacheId, fatherModule, store, cacheKey }: {
12
+ cacheId: string | undefined;
13
+ fatherModule: string | undefined;
14
+ store: any;
15
+ cacheKey: string[];
16
+ }): void;
11
17
  }
@@ -34,6 +34,43 @@ var BaseModule = class {
34
34
  this.core.effects.offByModuleDestroy(this.name);
35
35
  this.core.unregisterModule(this);
36
36
  }
37
+ // 提供统一的缓存 module 里的数据的方法
38
+ checkSaveCache({ cacheId, fatherModule, store, cacheKey }) {
39
+ const window = this.core.getPlugin("window");
40
+ if (cacheId) {
41
+ if (fatherModule) {
42
+ const currentCacheData = window.sessionStorage.getItem(fatherModule);
43
+ let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
44
+ if (!currentCacheData || !currentCacheDataObj[cacheId]) {
45
+ currentCacheDataObj = {
46
+ [cacheId]: {
47
+ [this.name]: {}
48
+ }
49
+ };
50
+ }
51
+ if (!currentCacheDataObj[cacheId][this.name]) {
52
+ currentCacheDataObj[cacheId][this.name] = {};
53
+ }
54
+ cacheKey.forEach((key) => {
55
+ currentCacheDataObj[cacheId][this.name][key] = store == null ? void 0 : store[key];
56
+ });
57
+ window.sessionStorage.setItem(fatherModule, JSON.stringify(currentCacheDataObj));
58
+ } else {
59
+ let currentCacheData = window.sessionStorage.getItem(cacheId);
60
+ let currentCacheDataObj = JSON.parse(currentCacheData || "{}");
61
+ if (!currentCacheDataObj) {
62
+ currentCacheDataObj = {};
63
+ }
64
+ if (!currentCacheDataObj[this.name]) {
65
+ currentCacheDataObj[this.name] = {};
66
+ }
67
+ cacheKey.forEach((key) => {
68
+ currentCacheDataObj[this.name][key] = store[key];
69
+ });
70
+ window.sessionStorage.setItem(cacheId, JSON.stringify(currentCacheDataObj));
71
+ }
72
+ }
73
+ }
37
74
  };
38
75
  // Annotate the CommonJS export names for ESM import in node:
39
76
  0 && (module.exports = {
@@ -11,6 +11,9 @@ export declare class CartModule extends BaseModule implements Module, CartModule
11
11
  private request;
12
12
  private window;
13
13
  private store;
14
+ private cacheId;
15
+ private openCache;
16
+ private fatherModule;
14
17
  constructor(name?: string, version?: string);
15
18
  /**
16
19
  * 初始化购物车模块
@@ -36,6 +39,10 @@ export declare class CartModule extends BaseModule implements Module, CartModule
36
39
  * 获取购物车商品
37
40
  */
38
41
  getItems(): CartItem[];
42
+ /**
43
+ * 根据账户ID获取购物车
44
+ */
45
+ getCartByAccount(account_id: string | number): CartItem[];
39
46
  /**
40
47
  * 移除购物车商品
41
48
  */
@@ -45,11 +52,12 @@ export declare class CartModule extends BaseModule implements Module, CartModule
45
52
  */
46
53
  clearCartByAccount(account_id: string): void;
47
54
  /**
48
- * 根据账户ID获取购物车
55
+ * 清除购物车商品中的信息
49
56
  */
50
- getCartByAccount(account_id: string | number): CartItem[];
57
+ deleteCartItemInfo(types: "resource" | "time"): void;
51
58
  /**
52
59
  * 清除购物车
53
60
  */
54
61
  clear(): void;
62
+ storeChange(): void;
55
63
  }