@pisell/pisellos 0.0.5 → 0.0.7

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 (75) hide show
  1. package/dist/core/index.d.ts +1 -0
  2. package/dist/core/index.js +7 -1
  3. package/dist/effects/index.d.ts +1 -1
  4. package/dist/effects/index.js +4 -5
  5. package/dist/modules/Account/index.d.ts +7 -1
  6. package/dist/modules/Account/index.js +67 -17
  7. package/dist/modules/Account/types.d.ts +2 -1
  8. package/dist/modules/AccountList/index.d.ts +18 -0
  9. package/dist/modules/AccountList/index.js +264 -0
  10. package/dist/modules/AccountList/types.d.ts +37 -0
  11. package/dist/modules/AccountList/types.js +17 -0
  12. package/dist/modules/BaseModule.js +1 -0
  13. package/dist/modules/Cart/index.d.ts +3 -1
  14. package/dist/modules/Cart/index.js +53 -12
  15. package/dist/modules/Cart/types.d.ts +3 -3
  16. package/dist/modules/Date/types.d.ts +2 -1
  17. package/dist/modules/Date/types.js +1 -0
  18. package/dist/modules/ProductList/index.d.ts +1 -1
  19. package/dist/modules/ProductList/index.js +20 -12
  20. package/dist/modules/Resource/index.d.ts +7 -5
  21. package/dist/modules/Resource/index.js +17 -20
  22. package/dist/modules/Resource/utils.d.ts +23 -0
  23. package/dist/modules/Resource/utils.js +28 -0
  24. package/dist/modules/Step/index.d.ts +19 -0
  25. package/dist/modules/Step/index.js +107 -0
  26. package/dist/modules/Step/tyeps.d.ts +18 -0
  27. package/dist/modules/Step/tyeps.js +1 -0
  28. package/dist/plugins/request.d.ts +1 -1
  29. package/dist/solution/BookingByStep/index.d.ts +29 -1
  30. package/dist/solution/BookingByStep/index.js +363 -12
  31. package/dist/solution/BookingByStep/types.d.ts +6 -2
  32. package/dist/solution/BookingByStep/types.js +29 -0
  33. package/dist/solution/BookingByStep/utils/resources.d.ts +61 -0
  34. package/dist/solution/BookingByStep/utils/resources.js +380 -0
  35. package/dist/solution/BuyTickets/index.js +1 -1
  36. package/dist/store/createStore.js +1 -1
  37. package/dist/types/index.d.ts +2 -1
  38. package/lib/core/index.d.ts +1 -0
  39. package/lib/core/index.js +5 -1
  40. package/lib/effects/index.d.ts +1 -1
  41. package/lib/effects/index.js +1 -2
  42. package/lib/modules/Account/index.d.ts +7 -1
  43. package/lib/modules/Account/index.js +34 -18
  44. package/lib/modules/Account/types.d.ts +2 -1
  45. package/lib/modules/AccountList/index.d.ts +18 -0
  46. package/lib/modules/AccountList/index.js +126 -0
  47. package/lib/modules/AccountList/types.d.ts +37 -0
  48. package/lib/modules/AccountList/types.js +33 -0
  49. package/lib/modules/BaseModule.js +1 -0
  50. package/lib/modules/Cart/index.d.ts +3 -1
  51. package/lib/modules/Cart/index.js +13 -3
  52. package/lib/modules/Cart/types.d.ts +3 -3
  53. package/lib/modules/Date/types.d.ts +2 -1
  54. package/lib/modules/Date/types.js +1 -0
  55. package/lib/modules/ProductList/index.d.ts +1 -1
  56. package/lib/modules/ProductList/index.js +8 -7
  57. package/lib/modules/Resource/index.d.ts +7 -5
  58. package/lib/modules/Resource/index.js +16 -20
  59. package/lib/modules/Resource/utils.d.ts +23 -0
  60. package/lib/modules/Resource/utils.js +39 -0
  61. package/lib/modules/Step/index.d.ts +19 -0
  62. package/lib/modules/Step/index.js +76 -0
  63. package/lib/modules/Step/tyeps.d.ts +18 -0
  64. package/lib/modules/Step/tyeps.js +17 -0
  65. package/lib/plugins/request.d.ts +1 -1
  66. package/lib/solution/BookingByStep/index.d.ts +29 -1
  67. package/lib/solution/BookingByStep/index.js +99 -5
  68. package/lib/solution/BookingByStep/types.d.ts +6 -2
  69. package/lib/solution/BookingByStep/types.js +33 -2
  70. package/lib/solution/BookingByStep/utils/resources.d.ts +61 -0
  71. package/lib/solution/BookingByStep/utils/resources.js +215 -0
  72. package/lib/solution/BuyTickets/index.js +1 -1
  73. package/lib/store/createStore.js +1 -1
  74. package/lib/types/index.d.ts +2 -1
  75. package/package.json +9 -8
@@ -0,0 +1,37 @@
1
+ import { Account, AccountModule } from "../Account";
2
+ export declare enum AccountListHooks {
3
+ OnAccountListUpdate = "accountList:onUpdate",
4
+ OnAccountListError = "accountList:onError"
5
+ }
6
+ /**
7
+ * 账户列表查询参数
8
+ */
9
+ export interface AccountListQuery {
10
+ page?: number;
11
+ pageSize?: number;
12
+ search?: string;
13
+ sortBy?: string;
14
+ sortOrder?: 'asc' | 'desc';
15
+ filters?: Record<string, any>;
16
+ }
17
+ /**
18
+ * 账户列表状态
19
+ */
20
+ export interface AccountListState {
21
+ accounts: AccountModule[];
22
+ isLoading: boolean;
23
+ error: string | null;
24
+ }
25
+ /**
26
+ * 账户列表模块 API
27
+ */
28
+ export interface AccountListModuleAPI {
29
+ addAccount: (account: Account) => Promise<void>;
30
+ updateAccount: (id: string, updates: Partial<AccountModule>) => Promise<void>;
31
+ removeAccount: (id: string) => Promise<void>;
32
+ getAccounts: () => AccountModule[];
33
+ getAccount: (id: string) => AccountModule | null;
34
+ clearAccounts: () => Promise<void>;
35
+ addAccounts: (accounts: AccountModule[]) => Promise<void>;
36
+ getState: () => AccountListState;
37
+ }
@@ -0,0 +1,17 @@
1
+ export var AccountListHooks = /*#__PURE__*/function (AccountListHooks) {
2
+ AccountListHooks["OnAccountListUpdate"] = "accountList:onUpdate";
3
+ AccountListHooks["OnAccountListError"] = "accountList:onError";
4
+ return AccountListHooks;
5
+ }({});
6
+
7
+ /**
8
+ * 账户列表查询参数
9
+ */
10
+
11
+ /**
12
+ * 账户列表状态
13
+ */
14
+
15
+ /**
16
+ * 账户列表模块 API
17
+ */
@@ -21,6 +21,7 @@ export var BaseModule = /*#__PURE__*/function () {
21
21
  key: "destory",
22
22
  value: function destory() {
23
23
  this.core.effects.offByModuleDestroy(this.name);
24
+ this.core.unregisterModule(this);
24
25
  }
25
26
  }]);
26
27
  return BaseModule;
@@ -28,6 +28,8 @@ export declare class CartModule extends BaseModule implements Module {
28
28
  getItemCount(): number;
29
29
  getTotalPrice(): number;
30
30
  getItems(): Promise<CartItem[]>;
31
- updateItemQuantity(id: string, quantity: number): Promise<void>;
31
+ updateItem(id: string, item: CartItem): Promise<void>;
32
32
  removeItem(id: string): Promise<void>;
33
+ storeTemp(key: string, value: any): Promise<void>;
34
+ getTemp(key?: string): Promise<any>;
33
35
  }
@@ -1,6 +1,4 @@
1
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
2
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
3
  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
4
  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); }
@@ -49,7 +47,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
49
47
  getItemCount: _this.getItemCount.bind(_assertThisInitialized(_this)),
50
48
  getTotalPrice: _this.getTotalPrice.bind(_assertThisInitialized(_this)),
51
49
  getItems: _this.getItems.bind(_assertThisInitialized(_this)),
52
- updateItemQuantity: _this.updateItemQuantity.bind(_assertThisInitialized(_this)),
50
+ updateItem: _this.updateItem.bind(_assertThisInitialized(_this)),
53
51
  removeItem: _this.removeItem.bind(_assertThisInitialized(_this))
54
52
  });
55
53
  return _this;
@@ -83,8 +81,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
83
81
  }
84
82
  throw new Error('购物车模块需要 window 插件支持');
85
83
  case 8:
84
+ this.store.temp = {};
86
85
  console.log('[CartModule] 初始化完成');
87
- case 9:
86
+ case 10:
88
87
  case "end":
89
88
  return _context.stop();
90
89
  }
@@ -180,9 +179,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
180
179
  return getItems;
181
180
  }()
182
181
  }, {
183
- key: "updateItemQuantity",
182
+ key: "updateItem",
184
183
  value: function () {
185
- var _updateItemQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, quantity) {
184
+ var _updateItem = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(id, item) {
186
185
  var items, itemIndex;
187
186
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
188
187
  while (1) switch (_context5.prev = _context5.next) {
@@ -195,9 +194,7 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
195
194
  _context5.next = 7;
196
195
  break;
197
196
  }
198
- items[itemIndex] = _objectSpread(_objectSpread({}, items[itemIndex]), {}, {
199
- quantity: quantity
200
- });
197
+ items[itemIndex] = item;
201
198
  this.store.list = items;
202
199
  _context5.next = 7;
203
200
  return this.core.effects.emit(CartHooks.OnCartUpdateItem, items);
@@ -207,10 +204,10 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
207
204
  }
208
205
  }, _callee5, this);
209
206
  }));
210
- function updateItemQuantity(_x4, _x5) {
211
- return _updateItemQuantity.apply(this, arguments);
207
+ function updateItem(_x4, _x5) {
208
+ return _updateItem.apply(this, arguments);
212
209
  }
213
- return updateItemQuantity;
210
+ return updateItem;
214
211
  }()
215
212
  }, {
216
213
  key: "removeItem",
@@ -237,6 +234,50 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
237
234
  }
238
235
  return removeItem;
239
236
  }()
237
+ }, {
238
+ key: "storeTemp",
239
+ value: function () {
240
+ var _storeTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, value) {
241
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
242
+ while (1) switch (_context7.prev = _context7.next) {
243
+ case 0:
244
+ this.store.temp[key] = value;
245
+ case 1:
246
+ case "end":
247
+ return _context7.stop();
248
+ }
249
+ }, _callee7, this);
250
+ }));
251
+ function storeTemp(_x7, _x8) {
252
+ return _storeTemp.apply(this, arguments);
253
+ }
254
+ return storeTemp;
255
+ }()
256
+ }, {
257
+ key: "getTemp",
258
+ value: function () {
259
+ var _getTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(key) {
260
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
261
+ while (1) switch (_context8.prev = _context8.next) {
262
+ case 0:
263
+ if (key) {
264
+ _context8.next = 2;
265
+ break;
266
+ }
267
+ return _context8.abrupt("return", this.store.temp);
268
+ case 2:
269
+ return _context8.abrupt("return", this.store.temp[key]);
270
+ case 3:
271
+ case "end":
272
+ return _context8.stop();
273
+ }
274
+ }, _callee8, this);
275
+ }));
276
+ function getTemp(_x9) {
277
+ return _getTemp.apply(this, arguments);
278
+ }
279
+ return getTemp;
280
+ }()
240
281
  }]);
241
282
  return CartModule;
242
283
  }(BaseModule);
@@ -10,7 +10,6 @@ export declare enum CartHooks {
10
10
  */
11
11
  export interface CartItem {
12
12
  id: string;
13
- name: string;
14
13
  price: number;
15
14
  quantity: number;
16
15
  product: ProductData;
@@ -19,8 +18,9 @@ export interface CartItem {
19
18
  * 购物车状态接口
20
19
  */
21
20
  export interface CartState {
22
- list: CartItem[];
21
+ list: any[];
23
22
  total: number;
23
+ temp: Record<string, any>;
24
24
  }
25
25
  /**
26
26
  * 购物车模块 API
@@ -30,6 +30,6 @@ export interface CartModuleAPI {
30
30
  getItemCount: () => number;
31
31
  getTotalPrice: () => number;
32
32
  getItems: () => Promise<CartItem[]>;
33
- updateItemQuantity: (id: string, quantity: number) => Promise<void>;
33
+ updateItem: (id: string, item: CartItem) => Promise<void>;
34
34
  removeItem: (id: string) => Promise<void>;
35
35
  }
@@ -1,6 +1,7 @@
1
1
  export declare enum DateHooks {
2
2
  OnDateChange = "date:onDateChange",
3
- OnTimeSlotChange = "date:onTimeSlotChange"
3
+ OnTimeSlotChange = "date:onTimeSlotChange",
4
+ OnGetDateList = "date:onGetDateList"
4
5
  }
5
6
  /**
6
7
  * 时间槽位
@@ -1,6 +1,7 @@
1
1
  export var DateHooks = /*#__PURE__*/function (DateHooks) {
2
2
  DateHooks["OnDateChange"] = "date:onDateChange";
3
3
  DateHooks["OnTimeSlotChange"] = "date:onTimeSlotChange";
4
+ DateHooks["OnGetDateList"] = "date:onGetDateList";
4
5
  return DateHooks;
5
6
  }({});
6
7
 
@@ -12,5 +12,5 @@ export declare class ProductList extends BaseModule implements Module {
12
12
  storeChange(path?: string, value?: any): Promise<void>;
13
13
  getProducts(): Promise<ProductData[]>;
14
14
  getProduct(id: number): Promise<Product | undefined>;
15
- addProduct(): Promise<void>;
15
+ addProduct(products: ProductData[]): Promise<void>;
16
16
  }
@@ -1,7 +1,11 @@
1
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ 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."); }
4
+ 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); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ 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; }
2
8
  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; }
3
- 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; }
4
- 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; }
5
9
  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); } }
6
10
  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); }); }; }
7
11
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -41,11 +45,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
41
45
  while (1) switch (_context.prev = _context.next) {
42
46
  case 0:
43
47
  this.core = core;
44
- this.store = _objectSpread(_objectSpread({}, options.store || {}), {}, {
45
- productMap: new Map()
46
- });
48
+ this.store = options.store;
49
+ this.store.productMap = new Map();
50
+ this.store.list = [];
47
51
  this.storeChange();
48
- case 3:
52
+ case 5:
49
53
  case "end":
50
54
  return _context.stop();
51
55
  }
@@ -60,13 +64,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
60
64
  key: "storeChange",
61
65
  value: function () {
62
66
  var _storeChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(path, value) {
63
- var _this2 = this;
67
+ var _this$store$list,
68
+ _this2 = this;
64
69
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
65
70
  while (1) switch (_context2.prev = _context2.next) {
66
71
  case 0:
67
- this.store.list.forEach(function (product) {
72
+ (_this$store$list = this.store.list) === null || _this$store$list === void 0 || _this$store$list.forEach(function (product) {
68
73
  if (!_this2.store.productMap.has("product-".concat(product.id))) {
69
- var newProductModule = new Product("product-".concat(product.id.toString()));
74
+ var newProductModule = new Product("product_".concat(product.id.toString()));
70
75
  _this2.core.registerModule(newProductModule, {
71
76
  initialState: product
72
77
  });
@@ -139,16 +144,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
139
144
  }, {
140
145
  key: "addProduct",
141
146
  value: function () {
142
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
147
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(products) {
143
148
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
144
149
  while (1) switch (_context5.prev = _context5.next) {
145
150
  case 0:
151
+ // 加到 list 以后上面的storeChange 会自动初始化商品详情的 module 实例
152
+ this.store.list = [].concat(_toConsumableArray(this.store.list), _toConsumableArray(products));
153
+ case 1:
146
154
  case "end":
147
155
  return _context5.stop();
148
156
  }
149
- }, _callee5);
157
+ }, _callee5, this);
150
158
  }));
151
- function addProduct() {
159
+ function addProduct(_x6) {
152
160
  return _addProduct.apply(this, arguments);
153
161
  }
154
162
  return addProduct;
@@ -1,10 +1,12 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { Resource, ResourceTimeSlot, ResourceListModuleAPI } from './types';
4
- export declare class ResourceListModule extends BaseModule implements Module, ResourceListModuleAPI {
5
- private state;
6
- constructor();
7
- initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
3
+ import { Resource, ResourceTimeSlot } from './types';
4
+ export declare class ResourceListModule extends BaseModule implements Module {
5
+ protected defaultName: string;
6
+ protected defaultVersion: string;
7
+ private store;
8
+ constructor(name: string, version: string);
9
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
8
10
  getResources(): Promise<Resource[]>;
9
11
  selectResource(resourceId: string): Promise<void>;
10
12
  getSelectedResource(): Resource | null;
@@ -1,7 +1,7 @@
1
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 _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; }
3
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; }
4
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 _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; }
5
5
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
6
  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); }); }; }
7
7
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -22,14 +22,13 @@ import { ResourceHooks } from "./types";
22
22
  export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
23
23
  _inherits(ResourceListModule, _BaseModule);
24
24
  var _super = _createSuper(ResourceListModule);
25
- function ResourceListModule() {
25
+ function ResourceListModule(name, version) {
26
26
  var _this;
27
27
  _classCallCheck(this, ResourceListModule);
28
- _this = _super.call(this, 'resource', '1.0.0');
29
- _defineProperty(_assertThisInitialized(_this), "state", {
30
- list: [],
31
- selectedResource: null
32
- });
28
+ _this = _super.call(this, name, version);
29
+ _defineProperty(_assertThisInitialized(_this), "defaultName", 'resourceList');
30
+ _defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
31
+ _defineProperty(_assertThisInitialized(_this), "store", void 0);
33
32
  return _this;
34
33
  }
35
34
  _createClass(ResourceListModule, [{
@@ -40,9 +39,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
40
39
  while (1) switch (_context.prev = _context.next) {
41
40
  case 0:
42
41
  this.core = core;
43
- if (options !== null && options !== void 0 && options.initialState) {
44
- this.state = _objectSpread(_objectSpread({}, this.state), options.initialState);
45
- }
42
+ this.store = options.store;
46
43
  case 2:
47
44
  case "end":
48
45
  return _context.stop();
@@ -61,7 +58,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
61
58
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
62
59
  while (1) switch (_context2.prev = _context2.next) {
63
60
  case 0:
64
- return _context2.abrupt("return", this.state.list);
61
+ return _context2.abrupt("return", this.store.list);
65
62
  case 1:
66
63
  case "end":
67
64
  return _context2.stop();
@@ -81,7 +78,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
81
78
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
82
79
  while (1) switch (_context3.prev = _context3.next) {
83
80
  case 0:
84
- resource = this.state.list.find(function (r) {
81
+ resource = this.store.list.find(function (r) {
85
82
  return r.id === resourceId;
86
83
  });
87
84
  if (resource) {
@@ -90,7 +87,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
90
87
  }
91
88
  return _context3.abrupt("return");
92
89
  case 3:
93
- this.state.selectedResource = resource;
90
+ this.store.selectedResource = resource;
94
91
  _context3.next = 6;
95
92
  return this.core.effects.emit(ResourceHooks.OnResourceSelect, resource);
96
93
  case 6:
@@ -107,7 +104,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
107
104
  }, {
108
105
  key: "getSelectedResource",
109
106
  value: function getSelectedResource() {
110
- return this.state.selectedResource;
107
+ return this.store.selectedResource;
111
108
  }
112
109
  }, {
113
110
  key: "checkAvailability",
@@ -117,7 +114,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
117
114
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
118
115
  while (1) switch (_context4.prev = _context4.next) {
119
116
  case 0:
120
- resource = this.state.list.find(function (r) {
117
+ resource = this.store.list.find(function (r) {
121
118
  return r.id === resourceId;
122
119
  });
123
120
  if (resource) {
@@ -148,7 +145,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
148
145
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
149
146
  while (1) switch (_context5.prev = _context5.next) {
150
147
  case 0:
151
- resource = this.state.list.find(function (r) {
148
+ resource = this.store.list.find(function (r) {
152
149
  return r.id === resourceId;
153
150
  });
154
151
  if (resource) {
@@ -174,7 +171,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
174
171
  }, {
175
172
  key: "getAvailableCapacity",
176
173
  value: function getAvailableCapacity(resourceId, timeSlot) {
177
- var resource = this.state.list.find(function (r) {
174
+ var resource = this.store.list.find(function (r) {
178
175
  return r.id === resourceId;
179
176
  });
180
177
  if (!resource) return 0;
@@ -191,7 +188,7 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
191
188
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
192
189
  while (1) switch (_context6.prev = _context6.next) {
193
190
  case 0:
194
- index = this.state.list.findIndex(function (r) {
191
+ index = this.store.list.findIndex(function (r) {
195
192
  return r.id === resourceId;
196
193
  });
197
194
  if (!(index === -1)) {
@@ -200,9 +197,9 @@ export var ResourceListModule = /*#__PURE__*/function (_BaseModule) {
200
197
  }
201
198
  return _context6.abrupt("return");
202
199
  case 3:
203
- this.state.list[index] = _objectSpread(_objectSpread({}, this.state.list[index]), updates);
200
+ this.store.list[index] = _objectSpread(_objectSpread({}, this.store.list[index]), updates);
204
201
  _context6.next = 6;
205
- return this.core.effects.emit(ResourceHooks.OnResourceChange, this.state.list[index]);
202
+ return this.core.effects.emit(ResourceHooks.OnResourceChange, this.store.list[index]);
206
203
  case 6:
207
204
  case "end":
208
205
  return _context6.stop();
@@ -0,0 +1,23 @@
1
+ interface Resource {
2
+ id: string;
3
+ [key: string]: any;
4
+ }
5
+ /**
6
+ * @title: 获取资源map
7
+ * @description:
8
+ * @param {any} resourceList
9
+ * @return {*}
10
+ * @Author: zhiwei.Wang
11
+ */
12
+ export declare const getResourcesMap: (resourceList: Resource[]) => Record<string, Resource>;
13
+ /**
14
+ * @title: 根据ids筛选资源列表
15
+ * @description:
16
+ * @param {any} resourcesMap
17
+ * @param {any} ids
18
+ * @return {*}
19
+ * @Author: zhiwei.Wang
20
+ * @Date: 2024-09-19 20:23
21
+ */
22
+ export declare const getResourcesByIds: (resourcesMap: Record<string, Resource>, ids: number[]) => Resource[];
23
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @title: 获取资源map
3
+ * @description:
4
+ * @param {any} resourceList
5
+ * @return {*}
6
+ * @Author: zhiwei.Wang
7
+ */
8
+ export var getResourcesMap = function getResourcesMap(resourceList) {
9
+ return resourceList.reduce(function (pre, item) {
10
+ pre[item.id] = item;
11
+ return pre;
12
+ }, {});
13
+ };
14
+
15
+ /**
16
+ * @title: 根据ids筛选资源列表
17
+ * @description:
18
+ * @param {any} resourcesMap
19
+ * @param {any} ids
20
+ * @return {*}
21
+ * @Author: zhiwei.Wang
22
+ * @Date: 2024-09-19 20:23
23
+ */
24
+ export var getResourcesByIds = function getResourcesByIds(resourcesMap, ids) {
25
+ return (ids || []).map(function (id) {
26
+ return resourcesMap[id];
27
+ });
28
+ };
@@ -0,0 +1,19 @@
1
+ import { Module, PisellCore, ModuleOptions } from "../../types";
2
+ import { BaseModule } from "../BaseModule";
3
+ import { IStep, IStepModuleAPI } from "./tyeps";
4
+ export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
5
+ protected defaultName: string;
6
+ protected defaultVersion: string;
7
+ private store;
8
+ constructor(name?: string, version?: string);
9
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
10
+ init(steps: IStep[]): void;
11
+ private setSteps;
12
+ private setCurrentStep;
13
+ getStepList(): IStep[];
14
+ getCurrentStep(): IStep;
15
+ getCurrentStepIndex(): number;
16
+ prevStep(): void;
17
+ nextStep(): void;
18
+ gotoStep(stepIndex: number): void;
19
+ }