@pisell/pisellos 0.0.5
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/README.md +180 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +360 -0
- package/dist/effects/index.d.ts +17 -0
- package/dist/effects/index.js +162 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +17 -0
- package/dist/modules/Account/index.d.ts +21 -0
- package/dist/modules/Account/index.js +212 -0
- package/dist/modules/Account/types.d.ts +41 -0
- package/dist/modules/Account/types.js +19 -0
- package/dist/modules/BaseModule.d.ts +11 -0
- package/dist/modules/BaseModule.js +27 -0
- package/dist/modules/Cart/index.d.ts +33 -0
- package/dist/modules/Cart/index.js +242 -0
- package/dist/modules/Cart/types.d.ts +35 -0
- package/dist/modules/Cart/types.js +19 -0
- package/dist/modules/Date/index.d.ts +17 -0
- package/dist/modules/Date/index.js +133 -0
- package/dist/modules/Date/types.d.ts +32 -0
- package/dist/modules/Date/types.js +17 -0
- package/dist/modules/Guests/index.d.ts +17 -0
- package/dist/modules/Guests/index.js +259 -0
- package/dist/modules/Guests/types.d.ts +43 -0
- package/dist/modules/Guests/types.js +23 -0
- package/dist/modules/Order/index.d.ts +17 -0
- package/dist/modules/Order/index.js +228 -0
- package/dist/modules/Order/types.d.ts +57 -0
- package/dist/modules/Order/types.js +29 -0
- package/dist/modules/Payment/index.d.ts +18 -0
- package/dist/modules/Payment/index.js +243 -0
- package/dist/modules/Payment/types.d.ts +49 -0
- package/dist/modules/Payment/types.js +31 -0
- package/dist/modules/Product/index.d.ts +39 -0
- package/dist/modules/Product/index.js +118 -0
- package/dist/modules/Product/types.d.ts +387 -0
- package/dist/modules/Product/types.js +1 -0
- package/dist/modules/ProductList/index.d.ts +16 -0
- package/dist/modules/ProductList/index.js +158 -0
- package/dist/modules/ProductList/types.d.ts +9 -0
- package/dist/modules/ProductList/types.js +5 -0
- package/dist/modules/Resource/index.d.ts +15 -0
- package/dist/modules/Resource/index.js +219 -0
- package/dist/modules/Resource/types.d.ts +44 -0
- package/dist/modules/Resource/types.js +22 -0
- package/dist/modules/index.d.ts +3 -0
- package/dist/modules/index.js +3 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/request.d.ts +127 -0
- package/dist/plugins/request.js +592 -0
- package/dist/plugins/window.d.ts +115 -0
- package/dist/plugins/window.js +328 -0
- package/dist/solution/BookingByStep/index.d.ts +12 -0
- package/dist/solution/BookingByStep/index.js +77 -0
- package/dist/solution/BookingByStep/types.d.ts +27 -0
- package/dist/solution/BookingByStep/types.js +10 -0
- package/dist/solution/BuyTickets/index.d.ts +26 -0
- package/dist/solution/BuyTickets/index.js +339 -0
- package/dist/solution/BuyTickets/types.d.ts +24 -0
- package/dist/solution/BuyTickets/types.js +19 -0
- package/dist/solution/PlaceOrder/index.d.ts +0 -0
- package/dist/solution/PlaceOrder/index.js +54 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/store/createStore.d.ts +3 -0
- package/dist/store/createStore.js +43 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.js +1 -0
- package/lib/core/index.d.ts +30 -0
- package/lib/core/index.js +212 -0
- package/lib/effects/index.d.ts +17 -0
- package/lib/effects/index.js +78 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +51 -0
- package/lib/modules/Account/index.d.ts +21 -0
- package/lib/modules/Account/index.js +93 -0
- package/lib/modules/Account/types.d.ts +41 -0
- package/lib/modules/Account/types.js +35 -0
- package/lib/modules/BaseModule.d.ts +11 -0
- package/lib/modules/BaseModule.js +40 -0
- package/lib/modules/Cart/index.d.ts +33 -0
- package/lib/modules/Cart/index.js +104 -0
- package/lib/modules/Cart/types.d.ts +35 -0
- package/lib/modules/Cart/types.js +35 -0
- package/lib/modules/Date/index.d.ts +17 -0
- package/lib/modules/Date/index.js +75 -0
- package/lib/modules/Date/types.d.ts +32 -0
- package/lib/modules/Date/types.js +33 -0
- package/lib/modules/Guests/index.d.ts +17 -0
- package/lib/modules/Guests/index.js +95 -0
- package/lib/modules/Guests/types.d.ts +43 -0
- package/lib/modules/Guests/types.js +35 -0
- package/lib/modules/Order/index.d.ts +17 -0
- package/lib/modules/Order/index.js +95 -0
- package/lib/modules/Order/types.d.ts +57 -0
- package/lib/modules/Order/types.js +35 -0
- package/lib/modules/Payment/index.d.ts +18 -0
- package/lib/modules/Payment/index.js +103 -0
- package/lib/modules/Payment/types.d.ts +49 -0
- package/lib/modules/Payment/types.js +35 -0
- package/lib/modules/Product/index.d.ts +39 -0
- package/lib/modules/Product/index.js +87 -0
- package/lib/modules/Product/types.d.ts +387 -0
- package/lib/modules/Product/types.js +17 -0
- package/lib/modules/ProductList/index.d.ts +16 -0
- package/lib/modules/ProductList/index.js +71 -0
- package/lib/modules/ProductList/types.d.ts +9 -0
- package/lib/modules/ProductList/types.js +33 -0
- package/lib/modules/Resource/index.d.ts +15 -0
- package/lib/modules/Resource/index.js +91 -0
- package/lib/modules/Resource/types.d.ts +44 -0
- package/lib/modules/Resource/types.js +34 -0
- package/lib/modules/index.d.ts +3 -0
- package/lib/modules/index.js +27 -0
- package/lib/plugins/index.d.ts +2 -0
- package/lib/plugins/index.js +25 -0
- package/lib/plugins/request.d.ts +127 -0
- package/lib/plugins/request.js +297 -0
- package/lib/plugins/window.d.ts +115 -0
- package/lib/plugins/window.js +252 -0
- package/lib/solution/BookingByStep/index.d.ts +12 -0
- package/lib/solution/BookingByStep/index.js +53 -0
- package/lib/solution/BookingByStep/types.d.ts +27 -0
- package/lib/solution/BookingByStep/types.js +38 -0
- package/lib/solution/BuyTickets/index.d.ts +26 -0
- package/lib/solution/BuyTickets/index.js +122 -0
- package/lib/solution/BuyTickets/types.d.ts +24 -0
- package/lib/solution/BuyTickets/types.js +40 -0
- package/lib/solution/PlaceOrder/index.d.ts +0 -0
- package/lib/solution/PlaceOrder/index.js +0 -0
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +23 -0
- package/lib/store/createStore.d.ts +3 -0
- package/lib/store/createStore.js +46 -0
- package/lib/types/index.d.ts +85 -0
- package/lib/types/index.js +17 -0
- package/package.json +65 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
+
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."); }
|
|
6
|
+
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); }
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
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); } }
|
|
12
|
+
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); }); }; }
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
20
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
+
import { ProductList } from "../../modules/";
|
|
27
|
+
import { BuyTicketsHooks } from "./types";
|
|
28
|
+
import { BaseModule } from "../../modules/BaseModule";
|
|
29
|
+
export * from "./types";
|
|
30
|
+
export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
|
|
31
|
+
_inherits(BuyTicketsImpl, _BaseModule);
|
|
32
|
+
var _super = _createSuper(BuyTicketsImpl);
|
|
33
|
+
function BuyTicketsImpl(name, version) {
|
|
34
|
+
var _this;
|
|
35
|
+
_classCallCheck(this, BuyTicketsImpl);
|
|
36
|
+
_this = _super.call(this, name, version);
|
|
37
|
+
// 提供给 baseModule 用的默认名称 和 默认版本
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'buyTickets');
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "isSolution", true);
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
43
|
+
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
45
|
+
return _this;
|
|
46
|
+
}
|
|
47
|
+
_createClass(BuyTicketsImpl, [{
|
|
48
|
+
key: "initialize",
|
|
49
|
+
value: function () {
|
|
50
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
51
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
52
|
+
while (1) switch (_context.prev = _context.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
this.core = core;
|
|
55
|
+
this.store = options.store || {};
|
|
56
|
+
this.otherParams = options.otherParams || {};
|
|
57
|
+
console.log('[BuyTickets] 初始化完成');
|
|
58
|
+
// 获取依赖的插件
|
|
59
|
+
this.request = core.getPlugin('request');
|
|
60
|
+
this.window = core.getPlugin('window');
|
|
61
|
+
if (this.request) {
|
|
62
|
+
_context.next = 8;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
throw new Error('购物车模块需要 request 插件支持');
|
|
66
|
+
case 8:
|
|
67
|
+
if (!this.otherParams.prodctIds) {
|
|
68
|
+
_context.next = 11;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
_context.next = 11;
|
|
72
|
+
return this.loadProductsByIds(this.otherParams.prodctIds);
|
|
73
|
+
case 11:
|
|
74
|
+
_context.next = 13;
|
|
75
|
+
return this.core.effects.emit(BuyTicketsHooks.onInited, {});
|
|
76
|
+
case 13:
|
|
77
|
+
case "end":
|
|
78
|
+
return _context.stop();
|
|
79
|
+
}
|
|
80
|
+
}, _callee, this);
|
|
81
|
+
}));
|
|
82
|
+
function initialize(_x, _x2) {
|
|
83
|
+
return _initialize.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
return initialize;
|
|
86
|
+
}() // 通过 ids 获取产品,在当前解决方案下,获取到的就是主商品
|
|
87
|
+
}, {
|
|
88
|
+
key: "loadProductsByIds",
|
|
89
|
+
value: function () {
|
|
90
|
+
var _loadProductsByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(ids) {
|
|
91
|
+
var productsData, mainProducts;
|
|
92
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
93
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
_context2.next = 2;
|
|
96
|
+
return this.request.post("".concat(this.core.context.apiBasePath, "/shop/product/query"), {
|
|
97
|
+
ids: ids,
|
|
98
|
+
open_quotation: 1,
|
|
99
|
+
open_bundle: 1,
|
|
100
|
+
with: ['bundleGroup.bundleItem'],
|
|
101
|
+
status: 'published',
|
|
102
|
+
num: 10,
|
|
103
|
+
skip: 1
|
|
104
|
+
});
|
|
105
|
+
case 2:
|
|
106
|
+
productsData = _context2.sent;
|
|
107
|
+
mainProducts = new ProductList("product-kiosk-main-list");
|
|
108
|
+
this.core.registerModule(mainProducts, {
|
|
109
|
+
initialState: {
|
|
110
|
+
list: productsData.data.list
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
this.store.mainProducts = mainProducts;
|
|
114
|
+
_context2.next = 8;
|
|
115
|
+
return this.core.effects.emit(BuyTicketsHooks.onMainProductsLoaded, {});
|
|
116
|
+
case 8:
|
|
117
|
+
case "end":
|
|
118
|
+
return _context2.stop();
|
|
119
|
+
}
|
|
120
|
+
}, _callee2, this);
|
|
121
|
+
}));
|
|
122
|
+
function loadProductsByIds(_x3) {
|
|
123
|
+
return _loadProductsByIds.apply(this, arguments);
|
|
124
|
+
}
|
|
125
|
+
return loadProductsByIds;
|
|
126
|
+
}() // 通过 ids 获取产品,在当前解决方案下,获取到的就是其他商品
|
|
127
|
+
}, {
|
|
128
|
+
key: "loadProductsByCategory",
|
|
129
|
+
value: function () {
|
|
130
|
+
var _loadProductsByCategory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(categoryId) {
|
|
131
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
132
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context3.stop();
|
|
136
|
+
}
|
|
137
|
+
}, _callee3);
|
|
138
|
+
}));
|
|
139
|
+
function loadProductsByCategory(_x4) {
|
|
140
|
+
return _loadProductsByCategory.apply(this, arguments);
|
|
141
|
+
}
|
|
142
|
+
return loadProductsByCategory;
|
|
143
|
+
}()
|
|
144
|
+
}, {
|
|
145
|
+
key: "destroy",
|
|
146
|
+
value: function () {
|
|
147
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
148
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
149
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
150
|
+
case 0:
|
|
151
|
+
_context4.next = 2;
|
|
152
|
+
return this.core.effects.emit(BuyTicketsHooks.onDestroy, {});
|
|
153
|
+
case 2:
|
|
154
|
+
console.log('[BuyTickets] 已销毁');
|
|
155
|
+
case 3:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context4.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee4, this);
|
|
160
|
+
}));
|
|
161
|
+
function destroy() {
|
|
162
|
+
return _destroy.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
return destroy;
|
|
165
|
+
}() // 获取当前绑定的所有商品
|
|
166
|
+
}, {
|
|
167
|
+
key: "getProducts",
|
|
168
|
+
value: function () {
|
|
169
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
170
|
+
var _this$store$otherProd;
|
|
171
|
+
var mainData, otherData;
|
|
172
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
173
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
174
|
+
case 0:
|
|
175
|
+
_context5.next = 2;
|
|
176
|
+
return this.store.mainProducts.getProducts();
|
|
177
|
+
case 2:
|
|
178
|
+
_context5.t0 = _context5.sent;
|
|
179
|
+
if (_context5.t0) {
|
|
180
|
+
_context5.next = 5;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
_context5.t0 = [];
|
|
184
|
+
case 5:
|
|
185
|
+
mainData = _context5.t0;
|
|
186
|
+
_context5.next = 8;
|
|
187
|
+
return (_this$store$otherProd = this.store.otherProducts) === null || _this$store$otherProd === void 0 ? void 0 : _this$store$otherProd.getProducts();
|
|
188
|
+
case 8:
|
|
189
|
+
_context5.t1 = _context5.sent;
|
|
190
|
+
if (_context5.t1) {
|
|
191
|
+
_context5.next = 11;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
_context5.t1 = [];
|
|
195
|
+
case 11:
|
|
196
|
+
otherData = _context5.t1;
|
|
197
|
+
_context5.next = 14;
|
|
198
|
+
return this.core.effects.emit(BuyTicketsHooks.OnGetProducts, [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
|
|
199
|
+
case 14:
|
|
200
|
+
return _context5.abrupt("return", [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
|
|
201
|
+
case 15:
|
|
202
|
+
case "end":
|
|
203
|
+
return _context5.stop();
|
|
204
|
+
}
|
|
205
|
+
}, _callee5, this);
|
|
206
|
+
}));
|
|
207
|
+
function getProducts() {
|
|
208
|
+
return _getProducts.apply(this, arguments);
|
|
209
|
+
}
|
|
210
|
+
return getProducts;
|
|
211
|
+
}() // 根据 id 获取商品详情,他会尝试先去主列表里找,找不到再去子列表,还找不到就报错
|
|
212
|
+
}, {
|
|
213
|
+
key: "getProduct",
|
|
214
|
+
value: function () {
|
|
215
|
+
var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
216
|
+
var _this$store$mainProdu, _this$store$otherProd2;
|
|
217
|
+
var mainProduct, otherProduct;
|
|
218
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
219
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
_context6.next = 2;
|
|
222
|
+
return (_this$store$mainProdu = this.store.mainProducts) === null || _this$store$mainProdu === void 0 ? void 0 : _this$store$mainProdu.getProduct(id);
|
|
223
|
+
case 2:
|
|
224
|
+
mainProduct = _context6.sent;
|
|
225
|
+
_context6.next = 5;
|
|
226
|
+
return (_this$store$otherProd2 = this.store.otherProducts) === null || _this$store$otherProd2 === void 0 ? void 0 : _this$store$otherProd2.getProduct(id);
|
|
227
|
+
case 5:
|
|
228
|
+
otherProduct = _context6.sent;
|
|
229
|
+
if (!mainProduct) {
|
|
230
|
+
_context6.next = 8;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
return _context6.abrupt("return", mainProduct);
|
|
234
|
+
case 8:
|
|
235
|
+
if (!otherProduct) {
|
|
236
|
+
_context6.next = 10;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
return _context6.abrupt("return", otherProduct);
|
|
240
|
+
case 10:
|
|
241
|
+
return _context6.abrupt("return", Promise.reject('Not fund product for id: ' + id));
|
|
242
|
+
case 11:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context6.stop();
|
|
245
|
+
}
|
|
246
|
+
}, _callee6, this);
|
|
247
|
+
}));
|
|
248
|
+
function getProduct(_x5) {
|
|
249
|
+
return _getProduct.apply(this, arguments);
|
|
250
|
+
}
|
|
251
|
+
return getProduct;
|
|
252
|
+
}() // 商品列表页提交
|
|
253
|
+
}, {
|
|
254
|
+
key: "listSubmit",
|
|
255
|
+
value: function () {
|
|
256
|
+
var _listSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(data) {
|
|
257
|
+
var res;
|
|
258
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
259
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
260
|
+
case 0:
|
|
261
|
+
_context7.next = 2;
|
|
262
|
+
return this.core.effects.emit(BuyTicketsHooks.onListSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
263
|
+
products: this.getProducts()
|
|
264
|
+
}));
|
|
265
|
+
case 2:
|
|
266
|
+
res = _context7.sent;
|
|
267
|
+
if (!(res.status === false)) {
|
|
268
|
+
_context7.next = 5;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
return _context7.abrupt("return", res);
|
|
272
|
+
case 5:
|
|
273
|
+
// 这里要搞一下缓存,等会,缓存往这写还是往哪儿写啊?
|
|
274
|
+
this.window.localStorage.setItem('buyTickets:listSubmit', JSON.stringify(_objectSpread(_objectSpread({}, data), {}, {
|
|
275
|
+
products: this.getProducts()
|
|
276
|
+
})));
|
|
277
|
+
// 如果外部没有阻拦,则默认调用后端的保存至购物车接口,然后通知页面 push 到购物车页面
|
|
278
|
+
// 游乐场逻辑:这里会被 hook 先拦截一次,业务层展示 add other product
|
|
279
|
+
// 然后第二次继续被拦截,业务层把这里的数据推给 native 的购物车
|
|
280
|
+
console.log('listSubmit 应该走逻辑层的 API 发请求了');
|
|
281
|
+
// fetch('')
|
|
282
|
+
case 7:
|
|
283
|
+
case "end":
|
|
284
|
+
return _context7.stop();
|
|
285
|
+
}
|
|
286
|
+
}, _callee7, this);
|
|
287
|
+
}));
|
|
288
|
+
function listSubmit(_x6) {
|
|
289
|
+
return _listSubmit.apply(this, arguments);
|
|
290
|
+
}
|
|
291
|
+
return listSubmit;
|
|
292
|
+
}() // 购物车提交
|
|
293
|
+
}, {
|
|
294
|
+
key: "cartSubmit",
|
|
295
|
+
value: function () {
|
|
296
|
+
var _cartSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(data) {
|
|
297
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
298
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
299
|
+
case 0:
|
|
300
|
+
_context8.next = 2;
|
|
301
|
+
return this.core.effects.emit(BuyTicketsHooks.onCartSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
302
|
+
products: this.getProducts()
|
|
303
|
+
}));
|
|
304
|
+
case 2:
|
|
305
|
+
case "end":
|
|
306
|
+
return _context8.stop();
|
|
307
|
+
}
|
|
308
|
+
}, _callee8, this);
|
|
309
|
+
}));
|
|
310
|
+
function cartSubmit(_x7) {
|
|
311
|
+
return _cartSubmit.apply(this, arguments);
|
|
312
|
+
}
|
|
313
|
+
return cartSubmit;
|
|
314
|
+
}() // 结算提交
|
|
315
|
+
}, {
|
|
316
|
+
key: "checkoutSubmit",
|
|
317
|
+
value: function () {
|
|
318
|
+
var _checkoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(data) {
|
|
319
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
320
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
321
|
+
case 0:
|
|
322
|
+
_context9.next = 2;
|
|
323
|
+
return this.core.effects.emit(BuyTicketsHooks.onCheckoutSubmit, _objectSpread(_objectSpread({}, data), {}, {
|
|
324
|
+
products: this.getProducts()
|
|
325
|
+
}));
|
|
326
|
+
case 2:
|
|
327
|
+
case "end":
|
|
328
|
+
return _context9.stop();
|
|
329
|
+
}
|
|
330
|
+
}, _callee9, this);
|
|
331
|
+
}));
|
|
332
|
+
function checkoutSubmit(_x8) {
|
|
333
|
+
return _checkoutSubmit.apply(this, arguments);
|
|
334
|
+
}
|
|
335
|
+
return checkoutSubmit;
|
|
336
|
+
}()
|
|
337
|
+
}]);
|
|
338
|
+
return BuyTicketsImpl;
|
|
339
|
+
}(BaseModule);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ProductData } from '../../modules';
|
|
2
|
+
import { ProductList } from '../../modules';
|
|
3
|
+
/**
|
|
4
|
+
* 购票流程hook
|
|
5
|
+
*/
|
|
6
|
+
export declare enum BuyTicketsHooks {
|
|
7
|
+
onInited = "buyTickets:onInited",
|
|
8
|
+
onDestroy = "buyTickets:onDestroy",
|
|
9
|
+
onMainProductsLoaded = "buyTickets:onMainProductsLoaded",
|
|
10
|
+
onOtherProductsLoaded = "buyTickets:onOtherProductsLoaded",
|
|
11
|
+
OnGetProducts = "buyTickets:onGetProducts",
|
|
12
|
+
OnGetProduct = "buyTickets:onGetProduct",
|
|
13
|
+
onListSubmit = "buyTickets:onListSubmit",
|
|
14
|
+
onCartSubmit = "buyTickets:onCartubmit",
|
|
15
|
+
onCheckoutSubmit = "buyTickets:onCheckoutSubmit"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 票务状态接口
|
|
19
|
+
*/
|
|
20
|
+
export interface TicketState {
|
|
21
|
+
products: ProductData[];
|
|
22
|
+
mainProducts: ProductList;
|
|
23
|
+
otherProducts: ProductList;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 购票流程hook
|
|
3
|
+
*/
|
|
4
|
+
export var BuyTicketsHooks = /*#__PURE__*/function (BuyTicketsHooks) {
|
|
5
|
+
BuyTicketsHooks["onInited"] = "buyTickets:onInited";
|
|
6
|
+
BuyTicketsHooks["onDestroy"] = "buyTickets:onDestroy";
|
|
7
|
+
BuyTicketsHooks["onMainProductsLoaded"] = "buyTickets:onMainProductsLoaded";
|
|
8
|
+
BuyTicketsHooks["onOtherProductsLoaded"] = "buyTickets:onOtherProductsLoaded";
|
|
9
|
+
BuyTicketsHooks["OnGetProducts"] = "buyTickets:onGetProducts";
|
|
10
|
+
BuyTicketsHooks["OnGetProduct"] = "buyTickets:onGetProduct";
|
|
11
|
+
BuyTicketsHooks["onListSubmit"] = "buyTickets:onListSubmit";
|
|
12
|
+
BuyTicketsHooks["onCartSubmit"] = "buyTickets:onCartubmit";
|
|
13
|
+
BuyTicketsHooks["onCheckoutSubmit"] = "buyTickets:onCheckoutSubmit";
|
|
14
|
+
return BuyTicketsHooks;
|
|
15
|
+
}({});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 票务状态接口
|
|
19
|
+
*/
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// // 只是一个示例工程
|
|
2
|
+
|
|
3
|
+
// import { Module, PisellCore, ModuleOptions } from '../types';
|
|
4
|
+
// import { CartModuleAPI } from '../modules/cart';
|
|
5
|
+
// import { StockModuleAPI } from '../modules/stock';
|
|
6
|
+
// import { CheckoutModuleAPI } from '../modules/checkout';
|
|
7
|
+
|
|
8
|
+
// class OrderSolution implements Module {
|
|
9
|
+
// name = 'orderSolution';
|
|
10
|
+
// version = '1.0.0';
|
|
11
|
+
|
|
12
|
+
// private core!: PisellCore;
|
|
13
|
+
// private cart!: CartModuleAPI;
|
|
14
|
+
// private stock!: StockModuleAPI;
|
|
15
|
+
// private checkout!: CheckoutModuleAPI;
|
|
16
|
+
|
|
17
|
+
// public exports = {
|
|
18
|
+
// submitOrder: this.submitOrder.bind(this),
|
|
19
|
+
// };
|
|
20
|
+
|
|
21
|
+
// async initialize(core: PisellCore): Promise<void> {
|
|
22
|
+
// this.core = core;
|
|
23
|
+
|
|
24
|
+
// // 获取依赖的模块 API
|
|
25
|
+
// this.cart = core.getModuleExports<CartModuleAPI>('cart');
|
|
26
|
+
// this.stock = core.getModuleExports<StockModuleAPI>('stock');
|
|
27
|
+
// this.checkout = core.getModuleExports<CheckoutModuleAPI>('checkout');
|
|
28
|
+
|
|
29
|
+
// console.log('[OrderSolution] 初始化完成');
|
|
30
|
+
// }
|
|
31
|
+
|
|
32
|
+
// async destroy(): Promise<void> {
|
|
33
|
+
// console.log('[OrderSolution] 已销毁');
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
// /**
|
|
37
|
+
// * 下单流程(商品 → 库存校验 → 结算 → 提交)
|
|
38
|
+
// */
|
|
39
|
+
// async submitOrder(): Promise<void> {
|
|
40
|
+
// const cartItems = await this.cart.getItems();
|
|
41
|
+
|
|
42
|
+
// const stockResult = await this.stock.checkAvailability(cartItems);
|
|
43
|
+
// if (!stockResult.ok) {
|
|
44
|
+
// throw new Error('部分商品库存不足');
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
// const summary = await this.checkout.calculate(cartItems);
|
|
48
|
+
|
|
49
|
+
// await this.checkout.submit(summary);
|
|
50
|
+
// console.log('[OrderSolution] 下单完成');
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
// export default new OrderSolution();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BuyTickets';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./BuyTickets";
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// type StoreLog = {
|
|
2
|
+
// type: "get" | "set" | "delete",
|
|
3
|
+
// path: string,
|
|
4
|
+
// value?: any,
|
|
5
|
+
// timestamp: number,
|
|
6
|
+
// };
|
|
7
|
+
|
|
8
|
+
// 给各模块创建 store
|
|
9
|
+
export function createStore(initialState, moduleName, onChange) {
|
|
10
|
+
// 关于logs这里先注释,后面不是这么玩的,应该是通过插件直接写
|
|
11
|
+
// const logs: StoreLog[] = [];
|
|
12
|
+
|
|
13
|
+
var handler = {
|
|
14
|
+
get: function get(target, prop, receiver) {
|
|
15
|
+
var value = Reflect.get(target, prop, receiver);
|
|
16
|
+
// logs.push({ type: "get", path: `${moduleName}.${String(prop)}`, timestamp: Date.now() });
|
|
17
|
+
return value;
|
|
18
|
+
},
|
|
19
|
+
set: function set(target, prop, value, receiver) {
|
|
20
|
+
// logs.push({
|
|
21
|
+
// type: "set",
|
|
22
|
+
// path: `${moduleName}.${String(prop)}`,
|
|
23
|
+
// value,
|
|
24
|
+
// timestamp: Date.now(),
|
|
25
|
+
// });
|
|
26
|
+
var result = Reflect.set(target, prop, value, receiver);
|
|
27
|
+
onChange === null || onChange === void 0 || onChange("".concat(moduleName, ".").concat(String(prop)), value);
|
|
28
|
+
return result;
|
|
29
|
+
},
|
|
30
|
+
deleteProperty: function deleteProperty(target, prop) {
|
|
31
|
+
// logs.push({
|
|
32
|
+
// type: "delete",
|
|
33
|
+
// path: `${moduleName}.${String(prop)}`,
|
|
34
|
+
// timestamp: Date.now(),
|
|
35
|
+
// });
|
|
36
|
+
return Reflect.deleteProperty(target, prop);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var proxy = new Proxy(initialState, handler);
|
|
40
|
+
return {
|
|
41
|
+
proxy: proxy
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pisell OS 核心类型定义
|
|
3
|
+
*/
|
|
4
|
+
export interface Plugin {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
initialize: () => Promise<void> | void;
|
|
8
|
+
destroy?: () => Promise<void> | void;
|
|
9
|
+
}
|
|
10
|
+
export interface PluginOptions {
|
|
11
|
+
dependencies?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface Module {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
initialize: (core: PisellCore, options: ModuleOptions) => Promise<void> | void;
|
|
17
|
+
destroy?: () => Promise<void> | void;
|
|
18
|
+
exports?: Record<string, any>;
|
|
19
|
+
isSolution?: boolean;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export interface ModuleOptions {
|
|
23
|
+
dependencies?: string[];
|
|
24
|
+
plugins?: string[];
|
|
25
|
+
hooks?: any;
|
|
26
|
+
store?: Record<string, any>;
|
|
27
|
+
initialState?: Record<string, any>;
|
|
28
|
+
otherParams?: Record<string, any>;
|
|
29
|
+
}
|
|
30
|
+
export type EventHandler = (data?: any) => void;
|
|
31
|
+
export interface PisellCore {
|
|
32
|
+
registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
|
|
33
|
+
getPlugin: <T extends Plugin>(name: string) => T | null;
|
|
34
|
+
hasPlugin: (name: string) => boolean;
|
|
35
|
+
registerModule: (module: Module, options?: ModuleOptions) => void;
|
|
36
|
+
getModule: <T extends Module>(name: string) => T | null;
|
|
37
|
+
getModuleExports: <T = any>(name: string) => T | null;
|
|
38
|
+
hasModule: (name: string) => boolean;
|
|
39
|
+
effects: {
|
|
40
|
+
on: (event: string, callback: (payload: any) => void) => void;
|
|
41
|
+
emit: (event: string, payload: any) => Promise<{
|
|
42
|
+
status: boolean;
|
|
43
|
+
data: any;
|
|
44
|
+
}>;
|
|
45
|
+
offByModuleDestroy: (module: string) => void;
|
|
46
|
+
};
|
|
47
|
+
context: BusinessContext;
|
|
48
|
+
validateContext: (config: ModuleContextConfig) => boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 业务上下文接口
|
|
52
|
+
*/
|
|
53
|
+
export interface BusinessContext {
|
|
54
|
+
userId?: string;
|
|
55
|
+
companyId?: string;
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 上下文验证规则
|
|
60
|
+
*/
|
|
61
|
+
export interface ContextValidationRule {
|
|
62
|
+
name: string;
|
|
63
|
+
required: boolean;
|
|
64
|
+
validate?: (value: any) => boolean;
|
|
65
|
+
message?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 模块上下文配置
|
|
69
|
+
*/
|
|
70
|
+
export interface ModuleContextConfig {
|
|
71
|
+
name: string;
|
|
72
|
+
validations: ContextValidationRule[];
|
|
73
|
+
}
|
|
74
|
+
export interface PisellOSOptions {
|
|
75
|
+
debug?: boolean;
|
|
76
|
+
plugins?: Array<{
|
|
77
|
+
plugin: Plugin;
|
|
78
|
+
options?: PluginOptions;
|
|
79
|
+
}>;
|
|
80
|
+
modules?: Array<{
|
|
81
|
+
module: Module;
|
|
82
|
+
options?: ModuleOptions;
|
|
83
|
+
}>;
|
|
84
|
+
context?: BusinessContext;
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig } from '../types';
|
|
2
|
+
import { EffectsManager } from '../effects';
|
|
3
|
+
/**
|
|
4
|
+
* pisell OS 核心实现
|
|
5
|
+
*/
|
|
6
|
+
declare class PisellOSCore implements PisellCore {
|
|
7
|
+
private plugins;
|
|
8
|
+
private modules;
|
|
9
|
+
private stores;
|
|
10
|
+
effects: EffectsManager;
|
|
11
|
+
private debug;
|
|
12
|
+
context: BusinessContext;
|
|
13
|
+
constructor(options?: PisellOSOptions);
|
|
14
|
+
private initialize;
|
|
15
|
+
private log;
|
|
16
|
+
registerPlugin(plugin: Plugin, options?: PluginOptions): void;
|
|
17
|
+
getPlugin<T extends Plugin>(name: string): T | null;
|
|
18
|
+
hasPlugin(name: string): boolean;
|
|
19
|
+
registerModule(module: Module, options?: ModuleOptions): void;
|
|
20
|
+
getModule<T extends Module>(name: string): T | null;
|
|
21
|
+
getModuleExports<T = any>(name: string): T | null;
|
|
22
|
+
hasModule(name: string): boolean;
|
|
23
|
+
destroy(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* 验证上下文参数
|
|
26
|
+
*/
|
|
27
|
+
validateContext(config: ModuleContextConfig): boolean;
|
|
28
|
+
}
|
|
29
|
+
export { PisellOSCore };
|
|
30
|
+
export default PisellOSCore;
|