@pisell/pisellos 0.0.324 → 0.0.326

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 (90) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Account/index.js +2 -3
  3. package/dist/modules/BaseModule.d.ts +3 -0
  4. package/dist/modules/BaseModule.js +15 -0
  5. package/dist/modules/Customer/index.js +9 -10
  6. package/dist/modules/Customer/types.d.ts +1 -1
  7. package/dist/modules/Discount/index.js +1 -1
  8. package/dist/modules/Guests/index.js +9 -9
  9. package/dist/modules/Payment/index.js +18 -18
  10. package/dist/modules/Payment/types.d.ts +7 -7
  11. package/dist/modules/Payment/walletpass.js +4 -1
  12. package/dist/modules/Product/index.d.ts +1 -1
  13. package/dist/modules/ProductList/index.js +2 -3
  14. package/dist/modules/Resource/index.js +1 -1
  15. package/dist/modules/Rules/index.js +2 -3
  16. package/dist/modules/Rules/types.d.ts +1 -1
  17. package/dist/modules/Schedule/type.d.ts +7 -7
  18. package/dist/modules/Schedule/types.d.ts +9 -9
  19. package/dist/solution/BookingByStep/index.d.ts +1 -1
  20. package/dist/solution/BookingByStep/index.js +2 -2
  21. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  22. package/dist/solution/BookingTicket/index.js +7 -7
  23. package/dist/solution/BuyTickets/index.js +7 -8
  24. package/dist/solution/Checkout/index.js +29 -29
  25. package/dist/solution/ShopDiscount/index.js +1 -1
  26. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/utils/task.d.ts +2 -2
  29. package/dist/utils/watch.d.ts +2 -2
  30. package/lib/core/index.js +28 -27
  31. package/lib/effects/index.d.ts +2 -2
  32. package/lib/effects/index.js +7 -3
  33. package/lib/modules/Account/index.js +12 -12
  34. package/lib/modules/AccountList/index.js +11 -14
  35. package/lib/modules/BaseModule.d.ts +3 -0
  36. package/lib/modules/BaseModule.js +12 -6
  37. package/lib/modules/Cart/index.js +9 -14
  38. package/lib/modules/Cart/utils/cartProduct.js +6 -3
  39. package/lib/modules/Customer/constants.js +1 -1
  40. package/lib/modules/Customer/index.js +24 -28
  41. package/lib/modules/Customer/types.d.ts +1 -1
  42. package/lib/modules/Date/index.js +6 -10
  43. package/lib/modules/Date/types.js +0 -1
  44. package/lib/modules/Discount/index.js +7 -12
  45. package/lib/modules/Guests/index.js +24 -19
  46. package/lib/modules/Order/index.js +9 -11
  47. package/lib/modules/Payment/cash.js +1 -1
  48. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  49. package/lib/modules/Payment/eftpos.js +1 -1
  50. package/lib/modules/Payment/index.js +86 -97
  51. package/lib/modules/Payment/types.d.ts +7 -7
  52. package/lib/modules/Payment/utils.js +6 -3
  53. package/lib/modules/Payment/walletpass.js +34 -32
  54. package/lib/modules/Product/index.d.ts +1 -1
  55. package/lib/modules/Product/index.js +5 -6
  56. package/lib/modules/ProductList/index.js +5 -8
  57. package/lib/modules/Resource/index.js +13 -9
  58. package/lib/modules/Rules/index.js +19 -15
  59. package/lib/modules/Rules/types.d.ts +1 -1
  60. package/lib/modules/Schedule/index.js +5 -8
  61. package/lib/modules/Schedule/type.d.ts +7 -7
  62. package/lib/modules/Schedule/types.d.ts +9 -9
  63. package/lib/modules/Schedule/utils.js +4 -2
  64. package/lib/modules/Step/index.js +4 -7
  65. package/lib/modules/Summary/index.js +4 -9
  66. package/lib/plugins/request.js +33 -34
  67. package/lib/plugins/window.js +113 -101
  68. package/lib/solution/BookingByStep/index.d.ts +1 -1
  69. package/lib/solution/BookingByStep/index.js +105 -71
  70. package/lib/solution/BookingByStep/utils/capacity.js +15 -10
  71. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  72. package/lib/solution/BookingByStep/utils/resources.js +8 -4
  73. package/lib/solution/BookingByStep/utils/stock.js +6 -3
  74. package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
  75. package/lib/solution/BookingTicket/index.js +20 -25
  76. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  77. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  78. package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
  79. package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
  80. package/lib/solution/BuyTickets/index.js +22 -23
  81. package/lib/solution/Checkout/index.js +227 -234
  82. package/lib/solution/Checkout/utils/index.js +22 -18
  83. package/lib/solution/ShopDiscount/index.js +12 -16
  84. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  85. package/lib/types/index.d.ts +1 -1
  86. package/lib/utils/task.d.ts +2 -2
  87. package/lib/utils/task.js +3 -3
  88. package/lib/utils/watch.d.ts +2 -2
  89. package/lib/utils/watch.js +7 -5
  90. package/package.json +1 -1
@@ -29,7 +29,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
29
29
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
30
30
  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); }
31
31
  import { BaseModule } from "../../modules/BaseModule";
32
- import { BookingByStepHooks, createModule } from "./types";
32
+ import { createModule } from "./types";
33
33
  import { getAvailableProductResources } from "./utils/products";
34
34
  import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection, isConflict } from "./utils/resources";
35
35
  import dayjs from 'dayjs';
@@ -136,7 +136,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
136
136
  }
137
137
  });
138
138
  this.store.schedule.loadAllSchedule();
139
- this.core.effects.emit(BookingByStepHooks.onInited, {});
139
+ this.core.effects.emit("".concat(this.name, ":onInited"), {});
140
140
  case 19:
141
141
  case "end":
142
142
  return _context.stop();
@@ -6,7 +6,7 @@ import { CartItem, ProductData } from '../../../modules';
6
6
  * 3. 格式化资源相关 格式化资源列表 --> 格式化资源 --> 获取时间切片列表 --> 判断单个时间切片是否可用 formatResources
7
7
  *
8
8
  */
9
- declare type DateType = Dayjs;
9
+ type DateType = Dayjs;
10
10
  export interface TimeSliceItem {
11
11
  start_time: string;
12
12
  end_time: string;
@@ -18,7 +18,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
18
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
19
  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); }
20
20
  import { BaseModule } from "../../modules/BaseModule";
21
- import { BookingTicketHooks, createModule } from "./types";
21
+ import { createModule } from "./types";
22
22
  import Scan from "./utils/scan";
23
23
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
24
24
  import scanCache from "./utils/scan/scanCache";
@@ -109,7 +109,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
109
109
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
110
110
  }
111
111
  });
112
- this.core.effects.emit(BookingTicketHooks.onInited, {});
112
+ this.core.effects.emit("".concat(this.name, ":onInited"), {});
113
113
  case 19:
114
114
  case "end":
115
115
  return _context.stop();
@@ -152,7 +152,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
152
152
  }));
153
153
  case 5:
154
154
  result = _context2.sent;
155
- this.core.effects.emit(BookingTicketHooks.onProductsLoaded, result);
155
+ this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
156
156
  return _context2.abrupt("return", result);
157
157
  case 10:
158
158
  _context2.prev = 10;
@@ -242,7 +242,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
242
242
  key: "setActiveCustomer",
243
243
  value: function setActiveCustomer(customer) {
244
244
  this.store.customer.setSelectedCustomer(customer);
245
- this.core.effects.emit(BookingTicketHooks.onCustomerSelected, {
245
+ this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
246
246
  customer: customer
247
247
  });
248
248
  }
@@ -267,7 +267,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
267
267
  var customer = this.store.customer.getCustomerById(customerId);
268
268
  if (customer) {
269
269
  this.store.customer.setSelectedCustomer(customer);
270
- this.core.effects.emit(BookingTicketHooks.onCustomerSelected, {
270
+ this.core.effects.emit("".concat(this.name, ":onCustomerSelected"), {
271
271
  customer: customer
272
272
  });
273
273
  }
@@ -398,7 +398,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
398
398
  return this.store.customer.loadMoreCustomers();
399
399
  case 3:
400
400
  result = _context6.sent;
401
- this.core.effects.emit(BookingTicketHooks.onCustomerListUpdate, result);
401
+ this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), result);
402
402
  return _context6.abrupt("return", result);
403
403
  case 8:
404
404
  _context6.prev = 8;
@@ -438,7 +438,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseModule) {
438
438
  return this.store.customer.resetAndLoadCustomers(params);
439
439
  case 4:
440
440
  result = _context7.sent;
441
- this.core.effects.emit(BookingTicketHooks.onCustomerListReset, result);
441
+ this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), result);
442
442
  return _context7.abrupt("return", result);
443
443
  case 9:
444
444
  _context7.prev = 9;
@@ -24,7 +24,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
24
24
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
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
26
  import { ProductList } from "../../modules/";
27
- import { BuyTicketsHooks } from "./types";
28
27
  import { BaseModule } from "../../modules/BaseModule";
29
28
  export * from "./types";
30
29
  export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
@@ -72,7 +71,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
72
71
  return this.loadProductsByIds(this.otherParams.prodctIds);
73
72
  case 11:
74
73
  _context.next = 13;
75
- return this.core.effects.emit(BuyTicketsHooks.onInited, {});
74
+ return this.core.effects.emit("".concat(this.name, ":onInited"), {});
76
75
  case 13:
77
76
  case "end":
78
77
  return _context.stop();
@@ -112,7 +111,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
112
111
  });
113
112
  this.store.mainProducts = mainProducts;
114
113
  _context2.next = 8;
115
- return this.core.effects.emit(BuyTicketsHooks.onMainProductsLoaded, {});
114
+ return this.core.effects.emit("".concat(this.name, ":onMainProductsLoaded"), {});
116
115
  case 8:
117
116
  case "end":
118
117
  return _context2.stop();
@@ -149,7 +148,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
149
148
  while (1) switch (_context4.prev = _context4.next) {
150
149
  case 0:
151
150
  _context4.next = 2;
152
- return this.core.effects.emit(BuyTicketsHooks.onDestroy, {});
151
+ return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
153
152
  case 2:
154
153
  console.log('[BuyTickets] 已销毁');
155
154
  case 3:
@@ -195,7 +194,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
195
194
  case 11:
196
195
  otherData = _context5.t1;
197
196
  _context5.next = 14;
198
- return this.core.effects.emit(BuyTicketsHooks.OnGetProducts, [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
197
+ return this.core.effects.emit("".concat(this.name, ":onGetProducts"), [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
199
198
  case 14:
200
199
  return _context5.abrupt("return", [].concat(_toConsumableArray(mainData), _toConsumableArray(otherData)));
201
200
  case 15:
@@ -259,7 +258,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
259
258
  while (1) switch (_context7.prev = _context7.next) {
260
259
  case 0:
261
260
  _context7.next = 2;
262
- return this.core.effects.emit(BuyTicketsHooks.onListSubmit, _objectSpread(_objectSpread({}, data), {}, {
261
+ return this.core.effects.emit("".concat(this.name, ":onListSubmit"), _objectSpread(_objectSpread({}, data), {}, {
263
262
  products: this.getProducts()
264
263
  }));
265
264
  case 2:
@@ -298,7 +297,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
298
297
  while (1) switch (_context8.prev = _context8.next) {
299
298
  case 0:
300
299
  _context8.next = 2;
301
- return this.core.effects.emit(BuyTicketsHooks.onCartSubmit, _objectSpread(_objectSpread({}, data), {}, {
300
+ return this.core.effects.emit("".concat(this.name, ":onCartSubmit"), _objectSpread(_objectSpread({}, data), {}, {
302
301
  products: this.getProducts()
303
302
  }));
304
303
  case 2:
@@ -320,7 +319,7 @@ export var BuyTicketsImpl = /*#__PURE__*/function (_BaseModule) {
320
319
  while (1) switch (_context9.prev = _context9.next) {
321
320
  case 0:
322
321
  _context9.next = 2;
323
- return this.core.effects.emit(BuyTicketsHooks.onCheckoutSubmit, _objectSpread(_objectSpread({}, data), {}, {
322
+ return this.core.effects.emit("".concat(this.name, ":onCheckoutSubmit"), _objectSpread(_objectSpread({}, data), {}, {
324
323
  products: this.getProducts()
325
324
  }));
326
325
  case 2:
@@ -28,7 +28,7 @@ import { BaseModule } from "../../modules/BaseModule";
28
28
  import Decimal from 'decimal.js';
29
29
  import { OrderModule } from "../../modules/Order";
30
30
  import { PaymentModule } from "../../modules/Payment";
31
- import { CheckoutHooks, CheckoutErrorType } from "./types";
31
+ import { CheckoutErrorType } from "./types";
32
32
  import { PaymentStatus, PaymentHooks } from "../../modules/Payment/types";
33
33
  import { validateCheckoutData, createCheckoutError, validateLocalOrderData, generateLocalOrderId, formatDateTime, extractAmountFromCartSummary, isVirtualOrderId, isCashPayment } from "./utils";
34
34
  import { getProductDeposit } from "../../modules/Cart/utils";
@@ -117,7 +117,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
117
117
  case 19:
118
118
  console.log('[Checkout] 初始化完成');
119
119
  _context.next = 22;
120
- return this.core.effects.emit(CheckoutHooks.OnCheckoutInitialized, {
120
+ return this.core.effects.emit("".concat(this.name, ":onCheckoutInitialized"), {
121
121
  timestamp: Date.now()
122
122
  });
123
123
  case 22:
@@ -453,7 +453,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
453
453
  });
454
454
  // 触发钱包数据初始化完成事件
455
455
  _context8.next = 16;
456
- return this.core.effects.emit(CheckoutHooks.OnWalletDataInitialized, {
456
+ return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
457
457
  orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
458
458
  customerId: walletBusinessData.customer_id,
459
459
  walletBusinessData: {
@@ -623,7 +623,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
623
623
  if (params.autoPayment) {
624
624
  // 自动支付模式标记
625
625
  }
626
- this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
626
+ this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
627
627
  order: paymentOrder,
628
628
  timestamp: Date.now()
629
629
  });
@@ -649,7 +649,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
649
649
  return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
650
650
  case 37:
651
651
  this.logError('本地订单创建失败:', _context9.t0);
652
- this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
652
+ this.core.effects.emit("".concat(this.name, ":onOrderCreationFailed"), {
653
653
  error: this.store.lastError,
654
654
  timestamp: Date.now()
655
655
  });
@@ -787,7 +787,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
787
787
 
788
788
  // 事件通知(复用创建事件,便于上层监听刷新)
789
789
  _context10.next = 38;
790
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
790
+ return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
791
791
  order: updated,
792
792
  timestamp: Date.now()
793
793
  });
@@ -875,7 +875,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
875
875
  // 清理钱包模块的所有缓存数据
876
876
  this.payment.wallet.clearAllCache();
877
877
  _context11.next = 11;
878
- return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
878
+ return this.core.effects.emit("".concat(this.name, ":onCheckoutCompleted"), {
879
879
  orderId: order.id,
880
880
  timestamp: Date.now()
881
881
  });
@@ -1064,7 +1064,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1064
1064
 
1065
1065
  // 触发订单更新事件
1066
1066
  _context13.next = 11;
1067
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1067
+ return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
1068
1068
  order: updatedOrder,
1069
1069
  timestamp: Date.now()
1070
1070
  });
@@ -1144,7 +1144,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1144
1144
 
1145
1145
  // 触发金额变更事件
1146
1146
  _context14.next = 12;
1147
- return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
1147
+ return this.core.effects.emit("".concat(this.name, ":onStateAmountChanged"), {
1148
1148
  oldAmount: oldAmount,
1149
1149
  newAmount: formattedAmount,
1150
1150
  timestamp: Date.now()
@@ -1368,7 +1368,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1368
1368
  return this.handleError(new Error("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context16.t0 instanceof Error ? _context16.t0.message : String(_context16.t0))), CheckoutErrorType.OrderCreationFailed);
1369
1369
  case 38:
1370
1370
  // 触发支付项添加事件(可以复用支付开始事件)
1371
- this.core.effects.emit(CheckoutHooks.OnPaymentItemAdded, {
1371
+ this.core.effects.emit("".concat(this.name, ":onPaymentItemAdded"), {
1372
1372
  orderUuid: this.store.currentOrder.uuid,
1373
1373
  paymentMethodCode: paymentItem.code,
1374
1374
  paymentMethodName: paymentItem.name,
@@ -1478,7 +1478,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1478
1478
  return this.updateStateAmountToRemaining(false);
1479
1479
  case 22:
1480
1480
  _context17.next = 24;
1481
- return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1481
+ return this.core.effects.emit("".concat(this.name, ":onPaymentStarted"), {
1482
1482
  orderUuid: this.store.currentOrder.uuid,
1483
1483
  paymentMethodCode: paymentItem.code,
1484
1484
  amount: "-".concat(paymentItem.amount),
@@ -1609,7 +1609,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1609
1609
  return this.updateStateAmountToRemaining(false);
1610
1610
  case 28:
1611
1611
  _context18.next = 30;
1612
- return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1612
+ return this.core.effects.emit("".concat(this.name, ":onPaymentStarted"), {
1613
1613
  orderUuid: this.store.currentOrder.uuid,
1614
1614
  paymentMethodCode: 'VOUCHER_BATCH',
1615
1615
  amount: voucherPaymentItems.reduce(function (sum, item) {
@@ -1711,7 +1711,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1711
1711
 
1712
1712
  // 触发订单更新事件
1713
1713
  _context19.next = 20;
1714
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1714
+ return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
1715
1715
  order: this.store.currentOrder,
1716
1716
  timestamp: Date.now()
1717
1717
  });
@@ -1837,7 +1837,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1837
1837
 
1838
1838
  // 触发订单更新事件
1839
1839
  _context20.next = 22;
1840
- return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1840
+ return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
1841
1841
  order: this.store.currentOrder,
1842
1842
  timestamp: Date.now()
1843
1843
  });
@@ -2106,7 +2106,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2106
2106
 
2107
2107
  // 触发订单取消事件
2108
2108
  _context22.next = 32;
2109
- return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
2109
+ return this.core.effects.emit("".concat(this.name, ":onOrderCancelled"), {
2110
2110
  orderUuid: currentOrderUuid,
2111
2111
  orderId: currentOrderId,
2112
2112
  cancelReason: cancelReason,
@@ -2277,7 +2277,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2277
2277
  console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context24.t0);
2278
2278
  case 17:
2279
2279
  _context24.next = 19;
2280
- return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
2280
+ return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
2281
2281
  orderUuid: (_this$store$currentOr20 = this.store.currentOrder) === null || _this$store$currentOr20 === void 0 ? void 0 : _this$store$currentOr20.uuid,
2282
2282
  oldNote: oldNote,
2283
2283
  newNote: note,
@@ -2324,7 +2324,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2324
2324
  checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
2325
2325
  this.store.lastError = checkoutError;
2326
2326
  _context25.next = 4;
2327
- return this.core.effects.emit(CheckoutHooks.OnError, {
2327
+ return this.core.effects.emit("".concat(this.name, ":onError"), {
2328
2328
  error: checkoutError,
2329
2329
  context: {},
2330
2330
  timestamp: Date.now()
@@ -2358,7 +2358,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2358
2358
  return this.updateStateAmountToRemaining();
2359
2359
  case 2:
2360
2360
  _context26.next = 4;
2361
- return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
2361
+ return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
2362
2362
  orderUuid: data.orderUuid,
2363
2363
  paymentMethodCode: '',
2364
2364
  amount: ((_this$store$currentOr21 = this.store.currentOrder) === null || _this$store$currentOr21 === void 0 ? void 0 : _this$store$currentOr21.total_amount) || '0',
@@ -2396,7 +2396,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2396
2396
  return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
2397
2397
  case 3:
2398
2398
  _context27.next = 5;
2399
- return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
2399
+ return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
2400
2400
  orderUuid: data.orderUuid,
2401
2401
  paymentMethodCode: '',
2402
2402
  amount: ((_this$store$currentOr22 = this.store.currentOrder) === null || _this$store$currentOr22 === void 0 ? void 0 : _this$store$currentOr22.total_amount) || '0',
@@ -2931,7 +2931,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2931
2931
 
2932
2932
  // 发出 balanceDueAmount 变更事件
2933
2933
  _context34.next = 12;
2934
- return this.core.effects.emit(CheckoutHooks.OnBalanceDueAmountChanged, {
2934
+ return this.core.effects.emit("".concat(this.name, ":onBalanceDueAmountChanged"), {
2935
2935
  oldAmount: currentBalanceDueAmount,
2936
2936
  newAmount: remainingAmount,
2937
2937
  timestamp: Date.now(),
@@ -3035,7 +3035,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3035
3035
  this.store.stateAmount = remainingAmount;
3036
3036
 
3037
3037
  // 发出 stateAmount 变更事件
3038
- this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
3038
+ this.core.effects.emit("".concat(this.name, ":onStateAmountChanged"), {
3039
3039
  oldAmount: currentStateAmount,
3040
3040
  newAmount: remainingAmount,
3041
3041
  timestamp: Date.now(),
@@ -3184,7 +3184,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3184
3184
  }
3185
3185
  case 27:
3186
3186
  _context36.next = 29;
3187
- return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3187
+ return this.core.effects.emit("".concat(this.name, ":onOrderPaymentCompleted"), {
3188
3188
  orderUuid: this.store.currentOrder.uuid,
3189
3189
  orderId: this.store.currentOrder.order_id,
3190
3190
  totalAmount: totalAmount,
@@ -3422,7 +3422,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3422
3422
  // 发送下单接口请求开始事件
3423
3423
  startTime = Date.now();
3424
3424
  _context37.next = 27;
3425
- return this.core.effects.emit(CheckoutHooks.OnOrderSubmitStart, {
3425
+ return this.core.effects.emit("".concat(this.name, ":onOrderSubmitStart"), {
3426
3426
  orderUuid: this.store.currentOrder.uuid,
3427
3427
  operation: isUpdateOperation ? 'update' : 'create',
3428
3428
  isManual: isManual,
@@ -3456,7 +3456,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3456
3456
 
3457
3457
  // 发送订单同步失败事件(网络错误或请求失败)
3458
3458
  _context37.next = 44;
3459
- return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3459
+ return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
3460
3460
  orderUuid: this.store.currentOrder.uuid,
3461
3461
  operation: isUpdateOperation ? 'update' : 'create',
3462
3462
  isManual: isManual,
@@ -3470,7 +3470,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3470
3470
  case 45:
3471
3471
  _context37.prev = 45;
3472
3472
  _context37.next = 48;
3473
- return this.core.effects.emit(CheckoutHooks.OnOrderSubmitEnd, {
3473
+ return this.core.effects.emit("".concat(this.name, ":onOrderSubmitEnd"), {
3474
3474
  success: submitSuccess,
3475
3475
  orderUuid: this.store.currentOrder.uuid,
3476
3476
  operation: isUpdateOperation ? 'update' : 'create',
@@ -3492,7 +3492,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3492
3492
  }
3493
3493
  errorMessage = ((_checkoutResponse5 = checkoutResponse) === null || _checkoutResponse5 === void 0 ? void 0 : _checkoutResponse5.message) || '订单同步失败,后端返回非成功状态'; // 发送订单同步失败事件
3494
3494
  _context37.next = 55;
3495
- return this.core.effects.emit(CheckoutHooks.OnOrderSyncFailed, {
3495
+ return this.core.effects.emit("".concat(this.name, ":onOrderSyncFailed"), {
3496
3496
  orderUuid: this.store.currentOrder.uuid,
3497
3497
  operation: isUpdateOperation ? 'update' : 'create',
3498
3498
  isManual: isManual,
@@ -3625,7 +3625,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3625
3625
 
3626
3626
  // 触发订单同步完成事件
3627
3627
  _context37.next = 106;
3628
- return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
3628
+ return this.core.effects.emit("".concat(this.name, ":onOrderSynced"), {
3629
3629
  orderUuid: this.store.currentOrder.uuid,
3630
3630
  realOrderId: realOrderId,
3631
3631
  virtualOrderId: this.store.currentOrder.order_id,
@@ -3752,7 +3752,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3752
3752
 
3753
3753
  // 触发订单备注变更事件
3754
3754
  _context39.next = 15;
3755
- return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
3755
+ return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
3756
3756
  orderUuid: this.store.currentOrder.uuid,
3757
3757
  oldNote: previousNote,
3758
3758
  newNote: note,
@@ -4044,7 +4044,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4044
4044
  break;
4045
4045
  }
4046
4046
  _context43.next = 17;
4047
- return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
4047
+ return this.core.effects.emit("".concat(this.name, ":onOrderCleared"), {
4048
4048
  previousOrder: prevOrderInfo,
4049
4049
  timestamp: Date.now()
4050
4050
  });
@@ -107,7 +107,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
107
107
  (_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
108
108
  this.core.effects.offByModuleDestroy(this.name);
109
109
  _context2.next = 7;
110
- return this.core.effects.emit(ShopDiscountHooks.onDestroy, {});
110
+ return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
111
111
  case 7:
112
112
  console.log('[ShopDiscount] 已销毁');
113
113
  case 8:
@@ -11,7 +11,7 @@ export declare enum ShopDiscountHooks {
11
11
  onRulesListChange = "shopDiscount:onRulesListChange",
12
12
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
13
13
  }
14
- export declare type Customer = {
14
+ export type Customer = {
15
15
  id: string | number;
16
16
  name: string;
17
17
  email: string;
@@ -27,7 +27,7 @@ export interface ModuleOptions {
27
27
  initialState?: Record<string, any>;
28
28
  otherParams?: Record<string, any>;
29
29
  }
30
- export declare type EventHandler = (data?: any) => void;
30
+ export type EventHandler = (data?: any) => void;
31
31
  export interface PisellCore {
32
32
  registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
@@ -1,5 +1,5 @@
1
- declare type Action = (...args: any[]) => Promise<any>;
2
- declare type Task = {
1
+ type Action = (...args: any[]) => Promise<any>;
2
+ type Task = {
3
3
  uuid: string;
4
4
  type: string;
5
5
  actionParams?: Record<string, any>;
@@ -2,8 +2,8 @@
2
2
  * 监听模块
3
3
  *
4
4
  */
5
- export declare type WatchEventCallback = (...args: any[]) => void;
6
- export declare type WatchEventItem = {
5
+ export type WatchEventCallback = (...args: any[]) => void;
6
+ export type WatchEventItem = {
7
7
  key: string;
8
8
  callback: WatchEventCallback;
9
9
  };
package/lib/core/index.js CHANGED
@@ -26,13 +26,13 @@ module.exports = __toCommonJS(core_exports);
26
26
  var import_createStore = require("../store/createStore");
27
27
  var import_effects = require("../effects");
28
28
  var PisellOSCore = class {
29
- plugins = /* @__PURE__ */ new Map();
30
- modules = /* @__PURE__ */ new Map();
31
- stores = /* @__PURE__ */ new Map();
32
- effects = new import_effects.EffectsManager();
33
- debug = false;
34
- context = {};
35
29
  constructor(options) {
30
+ this.plugins = /* @__PURE__ */ new Map();
31
+ this.modules = /* @__PURE__ */ new Map();
32
+ this.stores = /* @__PURE__ */ new Map();
33
+ this.effects = new import_effects.EffectsManager();
34
+ this.debug = false;
35
+ this.context = {};
36
36
  this.debug = (options == null ? void 0 : options.debug) || false;
37
37
  this.context = (options == null ? void 0 : options.context) || {};
38
38
  this.initialize(options);
@@ -48,7 +48,7 @@ var PisellOSCore = class {
48
48
  this.registerModule(item.module, item.options);
49
49
  });
50
50
  }
51
- this.log("PisellOS \u6838\u5FC3\u521D\u59CB\u5316\u5B8C\u6210");
51
+ this.log("PisellOS 核心初始化完成");
52
52
  }
53
53
  // 日志方法
54
54
  log(message, level = "info") {
@@ -71,12 +71,12 @@ var PisellOSCore = class {
71
71
  // 插件相关方法
72
72
  registerPlugin(plugin, options) {
73
73
  if (this.plugins.has(plugin.name)) {
74
- this.log(`\u63D2\u4EF6 ${plugin.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
74
+ this.log(`插件 ${plugin.name} 已经注册过,将被覆盖`, "warn");
75
75
  }
76
76
  if (options == null ? void 0 : options.dependencies) {
77
77
  for (const dep of options.dependencies) {
78
78
  if (!this.plugins.has(dep)) {
79
- throw new Error(`\u6CE8\u518C\u63D2\u4EF6 ${plugin.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${dep}`);
79
+ throw new Error(`注册插件 ${plugin.name} 失败:缺少依赖插件 ${dep}`);
80
80
  }
81
81
  }
82
82
  }
@@ -84,14 +84,14 @@ var PisellOSCore = class {
84
84
  const result = plugin.initialize();
85
85
  if (result instanceof Promise) {
86
86
  result.catch((err) => {
87
- this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
87
+ this.log(`插件 ${plugin.name} 初始化失败: ${err.message}`, "error");
88
88
  throw err;
89
89
  });
90
90
  }
91
91
  this.plugins.set(plugin.name, plugin);
92
- this.log(`\u63D2\u4EF6 ${plugin.name} v${plugin.version} \u6CE8\u518C\u6210\u529F`);
92
+ this.log(`插件 ${plugin.name} v${plugin.version} 注册成功`);
93
93
  } catch (error) {
94
- this.log(`\u63D2\u4EF6 ${plugin.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
94
+ this.log(`插件 ${plugin.name} 初始化过程中出错: ${error}`, "error");
95
95
  throw error;
96
96
  }
97
97
  }
@@ -104,12 +104,12 @@ var PisellOSCore = class {
104
104
  // 模块相关方法
105
105
  registerModule(module2, options) {
106
106
  if (this.modules.has(module2.name)) {
107
- this.log(`\u6A21\u5757 ${module2.name} \u5DF2\u7ECF\u6CE8\u518C\u8FC7\uFF0C\u5C06\u88AB\u8986\u76D6`, "warn");
107
+ this.log(`模块 ${module2.name} 已经注册过,将被覆盖`, "warn");
108
108
  }
109
109
  if (options == null ? void 0 : options.dependencies) {
110
110
  for (const dep of options.dependencies) {
111
111
  if (!this.modules.has(dep)) {
112
- throw new Error(`\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u6A21\u5757 ${dep}`);
112
+ throw new Error(`注册模块 ${module2.name} 失败:缺少依赖模块 ${dep}`);
113
113
  }
114
114
  }
115
115
  }
@@ -117,7 +117,7 @@ var PisellOSCore = class {
117
117
  for (const plugin of options.plugins) {
118
118
  if (!this.plugins.has(plugin)) {
119
119
  throw new Error(
120
- `\u6CE8\u518C\u6A21\u5757 ${module2.name} \u5931\u8D25\uFF1A\u7F3A\u5C11\u4F9D\u8D56\u63D2\u4EF6 ${plugin}`
120
+ `注册模块 ${module2.name} 失败:缺少依赖插件 ${plugin}`
121
121
  );
122
122
  }
123
123
  }
@@ -126,9 +126,10 @@ var PisellOSCore = class {
126
126
  (options == null ? void 0 : options.initialState) || {},
127
127
  module2.name,
128
128
  (path, value) => {
129
- console.log("core \u68C0\u6D4B\u5230\u6A21\u5757\u503C\u66F4\u65B0", module2.name, path, value);
129
+ console.log("core 检测到模块值更新", module2.name, path, value);
130
130
  this.effects.emit(`${module2.name}:changed`, { path, value });
131
- if (module2.storeChange) module2.storeChange(path, value);
131
+ if (module2.storeChange)
132
+ module2.storeChange(path, value);
132
133
  }
133
134
  );
134
135
  this.stores.set(module2.name, proxy);
@@ -136,14 +137,14 @@ var PisellOSCore = class {
136
137
  const result = module2.initialize(this, { store: proxy, ...options });
137
138
  if (result instanceof Promise) {
138
139
  result.catch((err) => {
139
- this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u5931\u8D25: ${err.message}`, "error");
140
+ this.log(`模块 ${module2.name} 初始化失败: ${err.message}`, "error");
140
141
  throw err;
141
142
  });
142
143
  }
143
144
  this.modules.set(module2.name, module2);
144
- this.log(`\u6A21\u5757 ${module2.name} v${module2.version} \u6CE8\u518C\u6210\u529F`);
145
+ this.log(`模块 ${module2.name} v${module2.version} 注册成功`);
145
146
  } catch (error) {
146
- this.log(`\u6A21\u5757 ${module2.name} \u521D\u59CB\u5316\u8FC7\u7A0B\u4E2D\u51FA\u9519: ${error}`, "error");
147
+ this.log(`模块 ${module2.name} 初始化过程中出错: ${error}`, "error");
147
148
  throw error;
148
149
  }
149
150
  }
@@ -167,9 +168,9 @@ var PisellOSCore = class {
167
168
  if (module2.destroy) {
168
169
  try {
169
170
  await Promise.resolve(module2.destroy());
170
- this.log(`\u6A21\u5757 ${name} \u5DF2\u9500\u6BC1`);
171
+ this.log(`模块 ${name} 已销毁`);
171
172
  } catch (error) {
172
- this.log(`\u9500\u6BC1\u6A21\u5757 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
173
+ this.log(`销毁模块 ${name} 时出错: ${error}`, "error");
173
174
  }
174
175
  }
175
176
  }
@@ -178,14 +179,14 @@ var PisellOSCore = class {
178
179
  if (plugin.destroy) {
179
180
  try {
180
181
  await Promise.resolve(plugin.destroy());
181
- this.log(`\u63D2\u4EF6 ${name} \u5DF2\u9500\u6BC1`);
182
+ this.log(`插件 ${name} 已销毁`);
182
183
  } catch (error) {
183
- this.log(`\u9500\u6BC1\u63D2\u4EF6 ${name} \u65F6\u51FA\u9519: ${error}`, "error");
184
+ this.log(`销毁插件 ${name} 时出错: ${error}`, "error");
184
185
  }
185
186
  }
186
187
  }
187
188
  this.plugins.clear();
188
- this.log("PisellOS \u6838\u5FC3\u5DF2\u9500\u6BC1");
189
+ this.log("PisellOS 核心已销毁");
189
190
  }
190
191
  /**
191
192
  * 验证上下文参数
@@ -195,7 +196,7 @@ var PisellOSCore = class {
195
196
  const value = this.context[rule.name];
196
197
  if (rule.required && (value === void 0 || value === null)) {
197
198
  this.log(
198
- `\u6A21\u5757 ${config.name} \u7F3A\u5C11\u5FC5\u9700\u7684\u4E0A\u4E0B\u6587\u53C2\u6570: ${rule.name}`,
199
+ `模块 ${config.name} 缺少必需的上下文参数: ${rule.name}`,
199
200
  "error"
200
201
  );
201
202
  return false;
@@ -203,7 +204,7 @@ var PisellOSCore = class {
203
204
  if (rule.validate && value !== void 0 && value !== null) {
204
205
  if (!rule.validate(value)) {
205
206
  this.log(
206
- `\u6A21\u5757 ${config.name} \u4E0A\u4E0B\u6587\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ${rule.name} - ${rule.message || "\u9A8C\u8BC1\u5931\u8D25"}`,
207
+ `模块 ${config.name} 上下文参数验证失败: ${rule.name} - ${rule.message || "验证失败"}`,
207
208
  "error"
208
209
  );
209
210
  return false;
@@ -1,8 +1,8 @@
1
- declare type EffectCallback = (payload: any) => void | Promise<void | {
1
+ type EffectCallback = (payload: any) => void | Promise<void | {
2
2
  status: boolean;
3
3
  message?: string;
4
4
  }>;
5
- declare type UnsubscribeFunction = () => void;
5
+ type UnsubscribeFunction = () => void;
6
6
  declare class EffectsManager {
7
7
  private listeners;
8
8
  on(event: string, callback: EffectCallback): UnsubscribeFunction;