@pisell/pisellos 2.1.38 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/core/index.d.ts +8 -1
  2. package/dist/core/index.js +116 -42
  3. package/dist/effects/index.d.ts +1 -0
  4. package/dist/effects/index.js +29 -6
  5. package/dist/modules/Account/index.js +2 -3
  6. package/dist/modules/BaseModule.d.ts +3 -0
  7. package/dist/modules/BaseModule.js +15 -0
  8. package/dist/modules/Customer/index.js +9 -10
  9. package/dist/modules/Customer/types.d.ts +2 -2
  10. package/dist/modules/Customer/types.js +2 -2
  11. package/dist/modules/Discount/index.js +1 -1
  12. package/dist/modules/Guests/index.js +9 -9
  13. package/dist/modules/Order/index.js +1 -1
  14. package/dist/modules/Payment/index.js +63 -73
  15. package/dist/modules/Payment/walletpass.js +4 -1
  16. package/dist/modules/Product/index.d.ts +1 -1
  17. package/dist/modules/Product/types.d.ts +19 -0
  18. package/dist/modules/ProductList/index.js +5 -14
  19. package/dist/modules/Resource/index.js +1 -1
  20. package/dist/modules/Rules/index.js +2 -3
  21. package/dist/modules/Schedule/types.d.ts +2 -0
  22. package/dist/plugins/request.d.ts +1 -0
  23. package/dist/server/index.d.ts +152 -0
  24. package/dist/server/index.js +946 -0
  25. package/dist/server/modules/index.d.ts +16 -0
  26. package/dist/server/modules/index.js +21 -0
  27. package/dist/server/modules/menu/index.d.ts +63 -0
  28. package/dist/server/modules/menu/index.js +476 -0
  29. package/dist/server/modules/menu/types.d.ts +68 -0
  30. package/dist/server/modules/menu/types.js +16 -0
  31. package/dist/server/modules/products/index.d.ts +141 -0
  32. package/dist/server/modules/products/index.js +768 -0
  33. package/dist/server/modules/products/types.d.ts +94 -0
  34. package/dist/server/modules/products/types.js +43 -0
  35. package/dist/server/modules/quotation/index.d.ts +47 -0
  36. package/dist/server/modules/quotation/index.js +367 -0
  37. package/dist/server/modules/quotation/types.d.ts +50 -0
  38. package/dist/server/modules/quotation/types.js +20 -0
  39. package/dist/server/modules/schedule/index.d.ts +62 -0
  40. package/dist/server/modules/schedule/index.js +431 -0
  41. package/dist/server/modules/schedule/types.d.ts +1 -0
  42. package/dist/server/modules/schedule/types.js +2 -0
  43. package/dist/server/modules/schedule/utils.d.ts +32 -0
  44. package/dist/server/modules/schedule/utils.js +747 -0
  45. package/dist/server/types.d.ts +64 -0
  46. package/dist/server/types.js +1 -0
  47. package/dist/server/utils/index.d.ts +5 -0
  48. package/dist/server/utils/index.js +6 -0
  49. package/dist/server/utils/product.d.ts +18 -0
  50. package/dist/server/utils/product.js +339 -0
  51. package/dist/server/utils/schedule.d.ts +14 -0
  52. package/dist/server/utils/schedule.js +108 -0
  53. package/dist/server/utils/time.d.ts +18 -0
  54. package/dist/server/utils/time.js +53 -0
  55. package/dist/solution/BookingByStep/index.d.ts +1 -17
  56. package/dist/solution/BookingByStep/index.js +23 -468
  57. package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
  58. package/dist/solution/BookingByStep/utils/capacity.js +8 -24
  59. package/dist/solution/BookingTicket/index.d.ts +12 -0
  60. package/dist/solution/BookingTicket/index.js +122 -79
  61. package/dist/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  62. package/dist/solution/BookingTicket/utils/scan/index.js +25 -16
  63. package/dist/solution/BuyTickets/index.js +7 -8
  64. package/dist/solution/Checkout/index.d.ts +1 -46
  65. package/dist/solution/Checkout/index.js +530 -850
  66. package/dist/solution/ShopDiscount/index.js +9 -10
  67. package/dist/types/index.d.ts +27 -0
  68. package/lib/core/index.d.ts +8 -1
  69. package/lib/core/index.js +48 -1
  70. package/lib/effects/index.d.ts +1 -0
  71. package/lib/effects/index.js +13 -0
  72. package/lib/modules/Account/index.js +2 -3
  73. package/lib/modules/BaseModule.d.ts +3 -0
  74. package/lib/modules/BaseModule.js +9 -0
  75. package/lib/modules/Customer/index.js +9 -10
  76. package/lib/modules/Customer/types.d.ts +2 -2
  77. package/lib/modules/Customer/types.js +2 -2
  78. package/lib/modules/Discount/index.js +1 -1
  79. package/lib/modules/Guests/index.js +9 -9
  80. package/lib/modules/Order/index.js +1 -1
  81. package/lib/modules/Payment/index.js +56 -43
  82. package/lib/modules/Payment/walletpass.js +3 -1
  83. package/lib/modules/Product/index.d.ts +1 -1
  84. package/lib/modules/Product/types.d.ts +19 -0
  85. package/lib/modules/ProductList/index.js +4 -13
  86. package/lib/modules/Resource/index.js +1 -1
  87. package/lib/modules/Rules/index.js +2 -3
  88. package/lib/modules/Schedule/types.d.ts +2 -0
  89. package/lib/plugins/request.d.ts +1 -0
  90. package/lib/server/index.d.ts +152 -0
  91. package/lib/server/index.js +555 -0
  92. package/lib/server/modules/index.d.ts +16 -0
  93. package/lib/server/modules/index.js +47 -0
  94. package/lib/server/modules/menu/index.d.ts +63 -0
  95. package/lib/server/modules/menu/index.js +234 -0
  96. package/lib/server/modules/menu/types.d.ts +68 -0
  97. package/lib/server/modules/menu/types.js +33 -0
  98. package/lib/server/modules/products/index.d.ts +141 -0
  99. package/lib/server/modules/products/index.js +434 -0
  100. package/lib/server/modules/products/types.d.ts +94 -0
  101. package/lib/server/modules/products/types.js +35 -0
  102. package/lib/server/modules/quotation/index.d.ts +47 -0
  103. package/lib/server/modules/quotation/index.js +177 -0
  104. package/lib/server/modules/quotation/types.d.ts +50 -0
  105. package/lib/server/modules/quotation/types.js +33 -0
  106. package/lib/server/modules/schedule/index.d.ts +62 -0
  107. package/lib/server/modules/schedule/index.js +231 -0
  108. package/lib/server/modules/schedule/types.d.ts +1 -0
  109. package/lib/server/modules/schedule/types.js +23 -0
  110. package/lib/server/modules/schedule/utils.d.ts +32 -0
  111. package/lib/server/modules/schedule/utils.js +451 -0
  112. package/lib/server/types.d.ts +64 -0
  113. package/lib/server/types.js +17 -0
  114. package/lib/server/utils/index.d.ts +5 -0
  115. package/lib/server/utils/index.js +25 -0
  116. package/lib/server/utils/product.d.ts +18 -0
  117. package/lib/server/utils/product.js +262 -0
  118. package/lib/server/utils/schedule.d.ts +14 -0
  119. package/lib/server/utils/schedule.js +88 -0
  120. package/lib/server/utils/time.d.ts +18 -0
  121. package/lib/server/utils/time.js +70 -0
  122. package/lib/solution/BookingByStep/index.d.ts +1 -17
  123. package/lib/solution/BookingByStep/index.js +40 -312
  124. package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
  125. package/lib/solution/BookingByStep/utils/capacity.js +8 -21
  126. package/lib/solution/BookingTicket/index.d.ts +12 -0
  127. package/lib/solution/BookingTicket/index.js +25 -6
  128. package/lib/solution/BookingTicket/utils/scan/index.d.ts +4 -0
  129. package/lib/solution/BookingTicket/utils/scan/index.js +7 -1
  130. package/lib/solution/BuyTickets/index.js +7 -8
  131. package/lib/solution/Checkout/index.d.ts +1 -46
  132. package/lib/solution/Checkout/index.js +92 -289
  133. package/lib/solution/ShopDiscount/index.js +10 -11
  134. package/lib/types/index.d.ts +27 -0
  135. package/package.json +2 -2
@@ -25,7 +25,6 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
25
25
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
26
26
  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); }
27
27
  import { BaseModule } from "../../modules/BaseModule";
28
- import { ShopDiscountHooks } from "./types";
29
28
  import { DiscountModule } from "../../modules/Discount";
30
29
  import { RulesModule } from "../../modules/Rules";
31
30
  import Decimal from 'decimal.js';
@@ -104,7 +103,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
104
103
  (_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
105
104
  this.core.effects.offByModuleDestroy(this.name);
106
105
  _context2.next = 7;
107
- return this.core.effects.emit(ShopDiscountHooks.onDestroy, {});
106
+ return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
108
107
  case 7:
109
108
  console.log('[ShopDiscount] 已销毁');
110
109
  case 8:
@@ -192,7 +191,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
192
191
  key: "registerEventListeners",
193
192
  value: function registerEventListeners() {
194
193
  var _this2 = this;
195
- this.core.effects.on(ShopDiscountHooks.onCustomerChange, function (customer) {
194
+ this.core.effects.only("".concat(this.name, ":onCustomerChange"), function (customer) {
196
195
  var _this2$options$otherP;
197
196
  if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
198
197
  return;
@@ -223,7 +222,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
223
222
  }
224
223
  this.store.customer = customer;
225
224
  _context4.next = 4;
226
- return this.core.effects.emit(ShopDiscountHooks.onCustomerChange, customer);
225
+ return this.core.effects.emit("".concat(this.name, ":onCustomerChange"), customer);
227
226
  case 4:
228
227
  case "end":
229
228
  return _context4.stop();
@@ -448,7 +447,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
448
447
  while (1) switch (_context6.prev = _context6.next) {
449
448
  case 0:
450
449
  _context6.next = 2;
451
- return this.core.effects.emit(ShopDiscountHooks.onDiscountListChange, discountList);
450
+ return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
452
451
  case 2:
453
452
  case "end":
454
453
  return _context6.stop();
@@ -579,7 +578,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
579
578
  customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
580
579
  this.setCustomer(customer);
581
580
  _context7.next = 9;
582
- return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
581
+ return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
583
582
  case 9:
584
583
  _context7.next = 14;
585
584
  break;
@@ -616,10 +615,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
616
615
  _result2 = this.calcDiscount(this.store.productList);
617
616
  cb === null || cb === void 0 || cb(_result2);
618
617
  _context8.next = 7;
619
- return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, _result2);
618
+ return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result2);
620
619
  case 7:
621
620
  _context8.next = 9;
622
- return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
621
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
623
622
  case 9:
624
623
  case "end":
625
624
  return _context8.stop();
@@ -670,10 +669,10 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
670
669
  }
671
670
  _result3 = this.calcDiscount(this.store.productList);
672
671
  _context9.next = 15;
673
- return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, _result3);
672
+ return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
674
673
  case 15:
675
674
  _context9.next = 17;
676
- return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
675
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
677
676
  case 17:
678
677
  _context9.next = 22;
679
678
  break;
@@ -40,6 +40,7 @@ export interface PisellCore {
40
40
  effects: {
41
41
  on: (event: string, callback: (payload: any) => void) => () => void;
42
42
  once: (event: string, callback: (payload: any) => void) => () => void;
43
+ only: (event: string, callback: (payload: any) => void) => () => void;
43
44
  off: (event: string, callback: (payload: any) => void) => void;
44
45
  emit: (event: string, payload: any, value?: any) => Promise<{
45
46
  status: boolean;
@@ -74,6 +75,26 @@ export interface ModuleContextConfig {
74
75
  name: string;
75
76
  validations: ContextValidationRule[];
76
77
  }
78
+ /**
79
+ * Server 模块配置
80
+ */
81
+ export interface ServerModuleConfig {
82
+ /** 模块名称 */
83
+ name: string;
84
+ /** 是否自动预加载数据 */
85
+ preload?: boolean;
86
+ /** 模块配置参数 */
87
+ config?: Record<string, any>;
88
+ }
89
+ /**
90
+ * Server 配置选项
91
+ */
92
+ export interface ServerOptions {
93
+ /** 要启用的模块列表 */
94
+ modules?: string[] | ServerModuleConfig[];
95
+ /** 是否自动初始化数据 */
96
+ autoInitData?: boolean;
97
+ }
77
98
  export interface PisellOSOptions {
78
99
  debug?: boolean;
79
100
  plugins?: Array<{
@@ -85,4 +106,10 @@ export interface PisellOSOptions {
85
106
  options?: ModuleOptions;
86
107
  }>;
87
108
  context?: BusinessContext;
109
+ /** Server 配置 */
110
+ server?: ServerOptions;
111
+ }
112
+ export interface InitializeServerOptions {
113
+ onModuleLoad?: (module: string) => void;
114
+ onModuleLoadComplete?: (module: string) => void;
88
115
  }
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig } from '../types';
1
+ import { Plugin, PluginOptions, Module, ModuleOptions, PisellCore, PisellOSOptions, BusinessContext, ModuleContextConfig, InitializeServerOptions } from '../types';
2
2
  import { EffectsManager } from '../effects';
3
3
  /**
4
4
  * pisell OS 核心实现
@@ -10,8 +10,15 @@ declare class PisellOSCore implements PisellCore {
10
10
  effects: EffectsManager;
11
11
  private debug;
12
12
  context: BusinessContext;
13
+ server: any;
14
+ private serverOptions?;
13
15
  constructor(options?: PisellOSOptions);
14
16
  private initialize;
17
+ /**
18
+ * 初始化 Server(公开方法,需要外部显式调用并等待)
19
+ * Server 配置从构造函数传入的 options.server 中获取
20
+ */
21
+ initializeServer(options?: InitializeServerOptions): Promise<void>;
15
22
  private log;
16
23
  registerPlugin(plugin: Plugin, options?: PluginOptions): void;
17
24
  getPlugin<T extends Plugin>(name: string): T | null;
package/lib/core/index.js CHANGED
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
17
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
28
 
19
29
  // src/core/index.ts
@@ -26,6 +36,7 @@ module.exports = __toCommonJS(core_exports);
26
36
  var import_createStore = require("../store/createStore");
27
37
  var import_effects = require("../effects");
28
38
  var PisellOSCore = class {
39
+ // 保存 Server 配置
29
40
  constructor(options) {
30
41
  this.plugins = /* @__PURE__ */ new Map();
31
42
  this.modules = /* @__PURE__ */ new Map();
@@ -35,6 +46,9 @@ var PisellOSCore = class {
35
46
  this.context = {};
36
47
  this.debug = (options == null ? void 0 : options.debug) || false;
37
48
  this.context = (options == null ? void 0 : options.context) || {};
49
+ if (options == null ? void 0 : options.server) {
50
+ this.serverOptions = options.server;
51
+ }
38
52
  this.initialize(options);
39
53
  }
40
54
  initialize(options) {
@@ -48,7 +62,40 @@ var PisellOSCore = class {
48
62
  this.registerModule(item.module, item.options);
49
63
  });
50
64
  }
51
- this.log("PisellOS 核心初始化完成");
65
+ this.log("[PisellOS] 核心初始化完成");
66
+ }
67
+ /**
68
+ * 初始化 Server(公开方法,需要外部显式调用并等待)
69
+ * Server 配置从构造函数传入的 options.server 中获取
70
+ */
71
+ async initializeServer(options) {
72
+ if (this.server) {
73
+ this.log("Server 已经初始化,跳过重复初始化", "warn");
74
+ return;
75
+ }
76
+ if (!this.serverOptions) {
77
+ this.log("未提供 Server 配置,无法初始化", "warn");
78
+ return;
79
+ }
80
+ try {
81
+ const ServerModule = await import("../server");
82
+ const Server = ServerModule.default;
83
+ this.server = new Server(this);
84
+ this.log("Server 实例已创建");
85
+ if (this.serverOptions.modules) {
86
+ await this.server.initialize(
87
+ this.serverOptions.modules,
88
+ this.serverOptions.autoInitData !== false,
89
+ options
90
+ );
91
+ }
92
+ console.log("[PisellOS] ✅ Server 初始化完成,所有数据已预加载");
93
+ this.log("[PisellOS] Server 初始化完成");
94
+ } catch (error) {
95
+ console.error("[PisellOS] ❌ Server 初始化失败:", error);
96
+ this.log(`Server 初始化失败: ${error}`, "error");
97
+ throw error;
98
+ }
52
99
  }
53
100
  // 日志方法
54
101
  log(message, level = "info") {
@@ -6,6 +6,7 @@ type UnsubscribeFunction = () => void;
6
6
  declare class EffectsManager {
7
7
  private listeners;
8
8
  on(event: string, callback: EffectCallback): UnsubscribeFunction;
9
+ only(event: string, callback: EffectCallback): UnsubscribeFunction;
9
10
  off(event: string, callback: EffectCallback): void;
10
11
  offByModuleDestroy(module: string): void;
11
12
  once(event: string, callback: EffectCallback): UnsubscribeFunction;
@@ -35,6 +35,19 @@ var EffectsManager = class {
35
35
  this.off(event, callback);
36
36
  };
37
37
  }
38
+ // 设置单例监听器,只能存在一个,新的会替换旧的
39
+ only(event, callback) {
40
+ var _a, _b;
41
+ if (this.listeners.has(event)) {
42
+ (_a = this.listeners.get(event)) == null ? void 0 : _a.clear();
43
+ } else {
44
+ this.listeners.set(event, /* @__PURE__ */ new Set());
45
+ }
46
+ (_b = this.listeners.get(event)) == null ? void 0 : _b.add(callback);
47
+ return () => {
48
+ this.off(event, callback);
49
+ };
50
+ }
38
51
  off(event, callback) {
39
52
  var _a;
40
53
  (_a = this.listeners.get(event)) == null ? void 0 : _a.delete(callback);
@@ -24,7 +24,6 @@ __export(Account_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(Account_exports);
26
26
  var import_BaseModule = require("../BaseModule");
27
- var import_types = require("./types");
28
27
  __reExport(Account_exports, require("./types"), module.exports);
29
28
  var AccountModule = class extends import_BaseModule.BaseModule {
30
29
  constructor(name, version) {
@@ -59,7 +58,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
59
58
  };
60
59
  this.store.accountInfo = account;
61
60
  this.store.isLoggedIn = true;
62
- await this.core.effects.emit(import_types.AccountHooks.OnLogin, account);
61
+ await this.core.effects.emit(`${this.name}:onLogin`, account);
63
62
  }
64
63
  getCurrentAccount() {
65
64
  return this.store.accountInfo;
@@ -72,7 +71,7 @@ var AccountModule = class extends import_BaseModule.BaseModule {
72
71
  ...updates
73
72
  };
74
73
  await this.core.effects.emit(
75
- import_types.AccountHooks.OnProfileUpdate,
74
+ `${this.name}:onProfileUpdate`,
76
75
  this.store.accountInfo
77
76
  );
78
77
  }
@@ -14,4 +14,7 @@ export declare class BaseModule {
14
14
  store: any;
15
15
  cacheKey: string[];
16
16
  }): void;
17
+ effectsOn(eventType: string, callback: (payload: any) => void): () => void;
18
+ effectsOff(eventType: string, callback: (payload: any) => void): void;
19
+ effectsOnce(eventType: string, callback: (payload: any) => void): () => void;
17
20
  }
@@ -82,6 +82,15 @@ var BaseModule = class {
82
82
  }
83
83
  }
84
84
  }
85
+ effectsOn(eventType, callback) {
86
+ return this.core.effects.on(`${this.name}:${eventType}`, callback);
87
+ }
88
+ effectsOff(eventType, callback) {
89
+ return this.core.effects.off(`${this.name}:${eventType}`, callback);
90
+ }
91
+ effectsOnce(eventType, callback) {
92
+ return this.core.effects.once(`${this.name}:${eventType}`, callback);
93
+ }
85
94
  };
86
95
  // Annotate the CommonJS export names for ESM import in node:
87
96
  0 && (module.exports = {
@@ -25,7 +25,6 @@ __export(Customer_exports, {
25
25
  module.exports = __toCommonJS(Customer_exports);
26
26
  var import_lodash_es = require("lodash-es");
27
27
  var import_BaseModule = require("../BaseModule");
28
- var import_types = require("./types");
29
28
  var import_constants = require("./constants");
30
29
  __reExport(Customer_exports, require("./types"), module.exports);
31
30
  var CustomerModule = class extends import_BaseModule.BaseModule {
@@ -128,7 +127,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
128
127
  console.error(`Failed to ${operation}:`, error);
129
128
  this.store.error = error instanceof Error ? error.message : `Failed to ${operation}`;
130
129
  await this.core.effects.emit(
131
- import_types.CustomerHooks.OnCustomerListError,
130
+ `${this.name}:onCustomerListError`,
132
131
  this.store.error
133
132
  );
134
133
  }
@@ -150,7 +149,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
150
149
  this.store.hasMore = page * pageSize < total;
151
150
  this.store.customerList = (0, import_lodash_es.cloneDeep)(customerList);
152
151
  await this.core.effects.emit(
153
- import_types.CustomerHooks.OnCustomerListUpdate,
152
+ `${this.name}:onCustomerListUpdate`,
154
153
  this.store
155
154
  );
156
155
  this.triggerPaginationChange({
@@ -193,7 +192,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
193
192
  setSelectedCustomer(customer) {
194
193
  this.store.selectedCustomer = !customer ? import_constants.DEFAULT_CUSTOMER : (0, import_lodash_es.cloneDeep)(customer);
195
194
  this.core.effects.emit(
196
- import_types.CustomerHooks.OnCustomerSelected,
195
+ `${this.name}:onCustomerSelected`,
197
196
  this.store.selectedCustomer
198
197
  );
199
198
  this.storeChange();
@@ -233,7 +232,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
233
232
  this.store.loadingMore = false;
234
233
  this.store.searchParams = {};
235
234
  this.core.effects.emit(
236
- import_types.CustomerHooks.OnCustomerListUpdate,
235
+ `${this.name}:onCustomerListUpdate`,
237
236
  this.store
238
237
  );
239
238
  this.storeChange();
@@ -247,7 +246,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
247
246
  this.store.customerList = [newCustomer, ...this.store.customerList];
248
247
  this.store.total += 1;
249
248
  this.core.effects.emit(
250
- import_types.CustomerHooks.OnCustomerListUpdate,
249
+ `${this.name}:onCustomerListUpdate`,
251
250
  this.store
252
251
  );
253
252
  this.storeChange();
@@ -277,7 +276,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
277
276
  */
278
277
  triggerPaginationChange(pagination) {
279
278
  this.core.effects.emit(
280
- import_types.CustomerHooks.OnPaginationChange,
279
+ `${this.name}:onPaginationChange`,
281
280
  pagination
282
281
  );
283
282
  }
@@ -344,7 +343,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
344
343
  this.store.total = total;
345
344
  this.store.hasMore = page * pageSize < total;
346
345
  await this.core.effects.emit(
347
- import_types.CustomerHooks.OnScrollLoadMore,
346
+ `${this.name}:onScrollLoadMore`,
348
347
  {
349
348
  newCustomers,
350
349
  allCustomers: this.store.customerList,
@@ -353,7 +352,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
353
352
  }
354
353
  );
355
354
  await this.core.effects.emit(
356
- import_types.CustomerHooks.OnCustomerListUpdate,
355
+ `${this.name}:onCustomerListUpdate`,
357
356
  this.store
358
357
  );
359
358
  this.triggerPaginationChange({
@@ -395,7 +394,7 @@ var CustomerModule = class extends import_BaseModule.BaseModule {
395
394
  };
396
395
  const response = await this.getCustomerList(resetParams);
397
396
  await this.core.effects.emit(
398
- import_types.CustomerHooks.OnScrollLoadComplete,
397
+ `${this.name}:onScrollLoadComplete`,
399
398
  {
400
399
  customers: this.store.customerList,
401
400
  total: this.store.total,
@@ -1,8 +1,8 @@
1
1
  import { ICustomer } from "../AccountList/types";
2
2
  export declare enum CustomerHooks {
3
- OnCustomerListUpdate = "customer:onUpdate",
3
+ OnCustomerListUpdate = "customer:onCustomerListUpdate",
4
4
  OnCustomerListError = "customer:onError",
5
- OnCustomerSelected = "customer:onSelected",
5
+ OnCustomerSelected = "customer:onCustomerSelected",
6
6
  OnPaginationChange = "customer:onPaginationChange",
7
7
  OnScrollLoadMore = "customer:onScrollLoadMore",
8
8
  OnScrollLoadComplete = "customer:onScrollLoadComplete"
@@ -23,9 +23,9 @@ __export(types_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(types_exports);
25
25
  var CustomerHooks = /* @__PURE__ */ ((CustomerHooks2) => {
26
- CustomerHooks2["OnCustomerListUpdate"] = "customer:onUpdate";
26
+ CustomerHooks2["OnCustomerListUpdate"] = "customer:onCustomerListUpdate";
27
27
  CustomerHooks2["OnCustomerListError"] = "customer:onError";
28
- CustomerHooks2["OnCustomerSelected"] = "customer:onSelected";
28
+ CustomerHooks2["OnCustomerSelected"] = "customer:onCustomerSelected";
29
29
  CustomerHooks2["OnPaginationChange"] = "customer:onPaginationChange";
30
30
  CustomerHooks2["OnScrollLoadMore"] = "customer:onScrollLoadMore";
31
31
  CustomerHooks2["OnScrollLoadComplete"] = "customer:onScrollLoadComplete";
@@ -171,7 +171,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
171
171
  async destroy() {
172
172
  this.store.discountList = [];
173
173
  this.core.effects.offByModuleDestroy(this.name);
174
- await this.core.effects.emit(import_types.DiscountHooks.OnDestroy, {});
174
+ await this.core.effects.emit(`${this.name}:onDestroy`, {});
175
175
  console.log("[Discount] 已销毁");
176
176
  }
177
177
  async clear() {
@@ -41,8 +41,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
41
41
  }
42
42
  async addGuest(guest) {
43
43
  this.state.list.push(guest);
44
- await this.core.effects.emit(import_types.GuestHooks.OnGuestAdd, guest);
45
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
44
+ await this.core.effects.emit(`${this.name}:onGuestAdd`, guest);
45
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
46
46
  }
47
47
  async updateGuest(id, updates) {
48
48
  const index = this.state.list.findIndex((g) => g.id === id);
@@ -56,15 +56,15 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
56
56
  import_types.GuestHooks.OnGuestUpdate,
57
57
  this.state.list[index]
58
58
  );
59
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
59
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
60
60
  }
61
61
  async removeGuest(id) {
62
62
  const index = this.state.list.findIndex((g) => g.id === id);
63
63
  if (index === -1)
64
64
  return;
65
65
  const [removed] = this.state.list.splice(index, 1);
66
- await this.core.effects.emit(import_types.GuestHooks.OnGuestRemove, removed);
67
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
66
+ await this.core.effects.emit(`${this.name}:onGuestRemove`, removed);
67
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
68
68
  }
69
69
  async getGuests() {
70
70
  return this.state.list;
@@ -77,8 +77,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
77
77
  if (!guest)
78
78
  return;
79
79
  guest.items.push(item);
80
- await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
81
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
80
+ await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
81
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
82
82
  }
83
83
  async removeItemFromGuest(guestId, itemId) {
84
84
  const guest = this.state.list.find((g) => g.id === guestId);
@@ -88,8 +88,8 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
88
88
  if (index === -1)
89
89
  return;
90
90
  guest.items.splice(index, 1);
91
- await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, guest);
92
- await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
91
+ await this.core.effects.emit(`${this.name}:onGuestUpdate`, guest);
92
+ await this.core.effects.emit(`${this.name}:onGuestChange`, this.state.list);
93
93
  }
94
94
  };
95
95
  // Annotate the CommonJS export names for ESM import in node:
@@ -39,7 +39,7 @@ var import_dayjs = __toESM(require("dayjs"));
39
39
  var OrderModule = class extends import_BaseModule.BaseModule {
40
40
  // LoggerManager 实例
41
41
  constructor(name, version) {
42
- super(name, version);
42
+ super(name || "order", version);
43
43
  this.defaultName = "order";
44
44
  this.defaultVersion = "1.0.0";
45
45
  }