@pisell/pisellos 3.0.76 → 3.0.77

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 (308) hide show
  1. package/dist/core/index.js +1 -2
  2. package/dist/effects/index.d.ts +3 -5
  3. package/dist/effects/index.js +8 -40
  4. package/dist/modules/Account/index.js +3 -2
  5. package/dist/modules/AccountList/index.d.ts +1 -7
  6. package/dist/modules/AccountList/index.js +14 -81
  7. package/dist/modules/AccountList/types.d.ts +0 -28
  8. package/dist/modules/AccountList/types.js +0 -8
  9. package/dist/modules/BaseModule.d.ts +0 -3
  10. package/dist/modules/BaseModule.js +0 -15
  11. package/dist/modules/Cart/index.d.ts +0 -1
  12. package/dist/modules/Cart/index.js +1 -2
  13. package/dist/modules/Discount/index.d.ts +0 -1
  14. package/dist/modules/Discount/index.js +1 -1
  15. package/dist/modules/Guests/index.js +9 -9
  16. package/dist/modules/Order/index.d.ts +1 -25
  17. package/dist/modules/Order/index.js +3 -224
  18. package/dist/modules/Order/types.d.ts +0 -45
  19. package/dist/modules/Order/types.js +0 -8
  20. package/dist/modules/Order/utils.js +1 -1
  21. package/dist/modules/Payment/index.d.ts +9 -184
  22. package/dist/modules/Payment/index.js +109 -2084
  23. package/dist/modules/Payment/types.d.ts +30 -772
  24. package/dist/modules/Payment/types.js +12 -236
  25. package/dist/modules/ProductList/index.d.ts +1 -12
  26. package/dist/modules/ProductList/index.js +15 -37
  27. package/dist/modules/Resource/index.js +1 -1
  28. package/dist/modules/Rules/index.d.ts +1 -2
  29. package/dist/modules/Rules/index.js +26 -66
  30. package/dist/modules/Rules/types.d.ts +0 -1
  31. package/dist/modules/Schedule/index.d.ts +0 -9
  32. package/dist/modules/Schedule/index.js +0 -77
  33. package/dist/modules/index.d.ts +0 -1
  34. package/dist/modules/index.js +0 -1
  35. package/dist/plugins/window.d.ts +0 -1
  36. package/dist/solution/BookingByStep/index.js +13 -43
  37. package/dist/solution/BookingByStep/utils/capacity.js +1 -1
  38. package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
  39. package/dist/solution/BookingByStep/utils/products.js +0 -10
  40. package/dist/solution/BuyTickets/index.js +8 -7
  41. package/dist/solution/ShopDiscount/index.d.ts +10 -10
  42. package/dist/solution/ShopDiscount/index.js +57 -107
  43. package/dist/solution/ShopDiscount/types.d.ts +0 -8
  44. package/dist/solution/ShopDiscount/utils.js +1 -0
  45. package/dist/solution/index.d.ts +0 -2
  46. package/dist/solution/index.js +1 -3
  47. package/dist/types/index.d.ts +1 -4
  48. package/lib/core/index.js +1 -1
  49. package/lib/effects/index.d.ts +3 -5
  50. package/lib/effects/index.js +1 -17
  51. package/lib/modules/Account/index.js +3 -2
  52. package/lib/modules/AccountList/index.d.ts +1 -7
  53. package/lib/modules/AccountList/index.js +0 -27
  54. package/lib/modules/AccountList/types.d.ts +0 -28
  55. package/lib/modules/BaseModule.d.ts +0 -3
  56. package/lib/modules/BaseModule.js +0 -9
  57. package/lib/modules/Cart/index.d.ts +0 -1
  58. package/lib/modules/Cart/index.js +2 -5
  59. package/lib/modules/Discount/index.d.ts +0 -1
  60. package/lib/modules/Discount/index.js +1 -1
  61. package/lib/modules/Guests/index.js +9 -9
  62. package/lib/modules/Order/index.d.ts +1 -25
  63. package/lib/modules/Order/index.js +1 -186
  64. package/lib/modules/Order/types.d.ts +0 -45
  65. package/lib/modules/Order/utils.js +1 -1
  66. package/lib/modules/Payment/index.d.ts +9 -184
  67. package/lib/modules/Payment/index.js +51 -1084
  68. package/lib/modules/Payment/types.d.ts +30 -772
  69. package/lib/modules/Payment/types.js +6 -79
  70. package/lib/modules/ProductList/index.d.ts +1 -12
  71. package/lib/modules/ProductList/index.js +12 -31
  72. package/lib/modules/Resource/index.js +1 -1
  73. package/lib/modules/Rules/index.d.ts +1 -2
  74. package/lib/modules/Rules/index.js +24 -41
  75. package/lib/modules/Rules/types.d.ts +0 -1
  76. package/lib/modules/Schedule/index.d.ts +0 -9
  77. package/lib/modules/Schedule/index.js +0 -60
  78. package/lib/modules/index.d.ts +0 -1
  79. package/lib/modules/index.js +0 -2
  80. package/lib/plugins/window.d.ts +0 -1
  81. package/lib/solution/BookingByStep/index.js +6 -18
  82. package/lib/solution/BookingByStep/utils/capacity.js +1 -1
  83. package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
  84. package/lib/solution/BookingByStep/utils/products.js +2 -8
  85. package/lib/solution/BuyTickets/index.js +8 -7
  86. package/lib/solution/ShopDiscount/index.d.ts +10 -10
  87. package/lib/solution/ShopDiscount/index.js +21 -47
  88. package/lib/solution/ShopDiscount/types.d.ts +0 -8
  89. package/lib/solution/index.d.ts +0 -2
  90. package/lib/solution/index.js +1 -5
  91. package/lib/types/index.d.ts +1 -4
  92. package/package.json +1 -3
  93. package/dist/modules/Customer/constants.d.ts +0 -7
  94. package/dist/modules/Customer/constants.js +0 -12
  95. package/dist/modules/Customer/index.d.ts +0 -122
  96. package/dist/modules/Customer/index.js +0 -696
  97. package/dist/modules/Customer/types.d.ts +0 -146
  98. package/dist/modules/Customer/types.js +0 -41
  99. package/dist/modules/Payment/cash.d.ts +0 -19
  100. package/dist/modules/Payment/cash.js +0 -97
  101. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
  102. package/dist/modules/Payment/cashRecommendationAlgorithm.js +0 -423
  103. package/dist/modules/Payment/eftpos.d.ts +0 -11
  104. package/dist/modules/Payment/eftpos.js +0 -80
  105. package/dist/modules/Payment/mx51.d.ts +0 -0
  106. package/dist/modules/Payment/mx51.js +0 -0
  107. package/dist/modules/Payment/utils.d.ts +0 -17
  108. package/dist/modules/Payment/utils.js +0 -62
  109. package/dist/modules/Payment/walletpass.d.ts +0 -99
  110. package/dist/modules/Payment/walletpass.js +0 -711
  111. package/dist/plugins/app-types/app/app.d.ts +0 -83
  112. package/dist/plugins/app-types/app/const.d.ts +0 -4
  113. package/dist/plugins/app-types/app/index.d.ts +0 -14
  114. package/dist/plugins/app-types/applicationManager/application.d.ts +0 -50
  115. package/dist/plugins/app-types/applicationManager/index.d.ts +0 -13
  116. package/dist/plugins/app-types/config.d.ts +0 -3
  117. package/dist/plugins/app-types/cookie/index.d.ts +0 -13
  118. package/dist/plugins/app-types/data/index.d.ts +0 -8
  119. package/dist/plugins/app-types/history/config.d.ts +0 -24
  120. package/dist/plugins/app-types/history/index.d.ts +0 -20
  121. package/dist/plugins/app-types/history/type.d.ts +0 -2
  122. package/dist/plugins/app-types/hooks/index.d.ts +0 -12
  123. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  124. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  125. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  126. package/dist/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  127. package/dist/plugins/app-types/index.d.ts +0 -6
  128. package/dist/plugins/app-types/indexDB/index.d.ts +0 -178
  129. package/dist/plugins/app-types/locales/en.d.ts +0 -3
  130. package/dist/plugins/app-types/locales/index.d.ts +0 -37
  131. package/dist/plugins/app-types/locales/original.d.ts +0 -3
  132. package/dist/plugins/app-types/locales/type.d.ts +0 -19
  133. package/dist/plugins/app-types/locales/zh-CN.d.ts +0 -3
  134. package/dist/plugins/app-types/locales/zh-HK.d.ts +0 -3
  135. package/dist/plugins/app-types/logger/feishu.d.ts +0 -11
  136. package/dist/plugins/app-types/logger/index.d.ts +0 -122
  137. package/dist/plugins/app-types/menuManager/hooks.d.ts +0 -17
  138. package/dist/plugins/app-types/menuManager/index.d.ts +0 -28
  139. package/dist/plugins/app-types/models/global.d.ts +0 -32
  140. package/dist/plugins/app-types/models/index.d.ts +0 -45
  141. package/dist/plugins/app-types/models/type.d.ts +0 -2
  142. package/dist/plugins/app-types/package.json +0 -15
  143. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  144. package/dist/plugins/app-types/pubsub/example.d.ts +0 -5
  145. package/dist/plugins/app-types/pubsub/index.d.ts +0 -63
  146. package/dist/plugins/app-types/request/cache.d.ts +0 -46
  147. package/dist/plugins/app-types/request/cancelToken.d.ts +0 -38
  148. package/dist/plugins/app-types/request/config.d.ts +0 -3
  149. package/dist/plugins/app-types/request/constants.d.ts +0 -2
  150. package/dist/plugins/app-types/request/index.d.ts +0 -24
  151. package/dist/plugins/app-types/request/pisell2Request.d.ts +0 -6
  152. package/dist/plugins/app-types/request/type.d.ts +0 -41
  153. package/dist/plugins/app-types/request/utils.d.ts +0 -46
  154. package/dist/plugins/app-types/routes/config.d.ts +0 -7
  155. package/dist/plugins/app-types/routes/index.d.ts +0 -28
  156. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  157. package/dist/plugins/app-types/socket/components/index.d.ts +0 -2
  158. package/dist/plugins/app-types/socket/constants.d.ts +0 -33
  159. package/dist/plugins/app-types/socket/events.d.ts +0 -31
  160. package/dist/plugins/app-types/socket/heartbeat.d.ts +0 -66
  161. package/dist/plugins/app-types/socket/index.d.ts +0 -61
  162. package/dist/plugins/app-types/socket/monitor.d.ts +0 -169
  163. package/dist/plugins/app-types/socket/reconnect.d.ts +0 -61
  164. package/dist/plugins/app-types/socket/socket.d.ts +0 -129
  165. package/dist/plugins/app-types/socket/types.d.ts +0 -85
  166. package/dist/plugins/app-types/storage/index.d.ts +0 -17
  167. package/dist/plugins/app-types/tasks/index.d.ts +0 -77
  168. package/dist/plugins/app-types/tasks/type.d.ts +0 -62
  169. package/dist/plugins/app-types/tasks/useTasks.d.ts +0 -5
  170. package/dist/plugins/app-types/type.d.ts +0 -2
  171. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  172. package/dist/plugins/app-types/variables/config.d.ts +0 -3
  173. package/dist/plugins/app-types/variables/index.d.ts +0 -6
  174. package/dist/plugins/app-types/variables/type.d.ts +0 -2
  175. package/dist/plugins/app-types/website/index.d.ts +0 -6
  176. package/dist/plugins/app.d.ts +0 -8
  177. package/dist/plugins/app.js +0 -1
  178. package/dist/solution/BookingTicket/index.d.ts +0 -184
  179. package/dist/solution/BookingTicket/index.js +0 -698
  180. package/dist/solution/BookingTicket/types.d.ts +0 -68
  181. package/dist/solution/BookingTicket/types.js +0 -43
  182. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  183. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +0 -159
  184. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
  185. package/dist/solution/BookingTicket/utils/scan/handleScan.js +0 -189
  186. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -85
  187. package/dist/solution/BookingTicket/utils/scan/index.js +0 -294
  188. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  189. package/dist/solution/BookingTicket/utils/scan/scanCache.js +0 -305
  190. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  191. package/dist/solution/Checkout/index.d.ts +0 -432
  192. package/dist/solution/Checkout/index.js +0 -4452
  193. package/dist/solution/Checkout/types.d.ts +0 -727
  194. package/dist/solution/Checkout/types.js +0 -104
  195. package/dist/solution/Checkout/utils/index.d.ts +0 -121
  196. package/dist/solution/Checkout/utils/index.js +0 -511
  197. package/dist/utils/task.d.ts +0 -40
  198. package/dist/utils/task.js +0 -171
  199. package/dist/utils/watch.d.ts +0 -102
  200. package/dist/utils/watch.js +0 -294
  201. package/lib/modules/Customer/constants.d.ts +0 -7
  202. package/lib/modules/Customer/constants.js +0 -39
  203. package/lib/modules/Customer/index.d.ts +0 -122
  204. package/lib/modules/Customer/index.js +0 -439
  205. package/lib/modules/Customer/types.d.ts +0 -146
  206. package/lib/modules/Customer/types.js +0 -37
  207. package/lib/modules/Payment/cash.d.ts +0 -19
  208. package/lib/modules/Payment/cash.js +0 -64
  209. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +0 -22
  210. package/lib/modules/Payment/cashRecommendationAlgorithm.js +0 -342
  211. package/lib/modules/Payment/eftpos.d.ts +0 -11
  212. package/lib/modules/Payment/eftpos.js +0 -51
  213. package/lib/modules/Payment/mx51.d.ts +0 -0
  214. package/lib/modules/Payment/mx51.js +0 -0
  215. package/lib/modules/Payment/utils.d.ts +0 -17
  216. package/lib/modules/Payment/utils.js +0 -67
  217. package/lib/modules/Payment/walletpass.d.ts +0 -99
  218. package/lib/modules/Payment/walletpass.js +0 -484
  219. package/lib/plugins/app-types/app/app.d.ts +0 -83
  220. package/lib/plugins/app-types/app/const.d.ts +0 -4
  221. package/lib/plugins/app-types/app/index.d.ts +0 -14
  222. package/lib/plugins/app-types/applicationManager/application.d.ts +0 -50
  223. package/lib/plugins/app-types/applicationManager/index.d.ts +0 -13
  224. package/lib/plugins/app-types/config.d.ts +0 -3
  225. package/lib/plugins/app-types/cookie/index.d.ts +0 -13
  226. package/lib/plugins/app-types/data/index.d.ts +0 -8
  227. package/lib/plugins/app-types/history/config.d.ts +0 -24
  228. package/lib/plugins/app-types/history/index.d.ts +0 -20
  229. package/lib/plugins/app-types/history/type.d.ts +0 -2
  230. package/lib/plugins/app-types/hooks/index.d.ts +0 -12
  231. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +0 -2
  232. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +0 -2
  233. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +0 -13
  234. package/lib/plugins/app-types/hooks/useStore/index.d.ts +0 -6
  235. package/lib/plugins/app-types/index.d.ts +0 -6
  236. package/lib/plugins/app-types/indexDB/index.d.ts +0 -178
  237. package/lib/plugins/app-types/locales/en.d.ts +0 -3
  238. package/lib/plugins/app-types/locales/index.d.ts +0 -37
  239. package/lib/plugins/app-types/locales/original.d.ts +0 -3
  240. package/lib/plugins/app-types/locales/type.d.ts +0 -19
  241. package/lib/plugins/app-types/locales/zh-CN.d.ts +0 -3
  242. package/lib/plugins/app-types/locales/zh-HK.d.ts +0 -3
  243. package/lib/plugins/app-types/logger/feishu.d.ts +0 -11
  244. package/lib/plugins/app-types/logger/index.d.ts +0 -122
  245. package/lib/plugins/app-types/menuManager/hooks.d.ts +0 -17
  246. package/lib/plugins/app-types/menuManager/index.d.ts +0 -28
  247. package/lib/plugins/app-types/models/global.d.ts +0 -32
  248. package/lib/plugins/app-types/models/index.d.ts +0 -45
  249. package/lib/plugins/app-types/models/type.d.ts +0 -2
  250. package/lib/plugins/app-types/package.json +0 -15
  251. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  252. package/lib/plugins/app-types/pubsub/example.d.ts +0 -5
  253. package/lib/plugins/app-types/pubsub/index.d.ts +0 -63
  254. package/lib/plugins/app-types/request/cache.d.ts +0 -46
  255. package/lib/plugins/app-types/request/cancelToken.d.ts +0 -38
  256. package/lib/plugins/app-types/request/config.d.ts +0 -3
  257. package/lib/plugins/app-types/request/constants.d.ts +0 -2
  258. package/lib/plugins/app-types/request/index.d.ts +0 -24
  259. package/lib/plugins/app-types/request/pisell2Request.d.ts +0 -6
  260. package/lib/plugins/app-types/request/type.d.ts +0 -41
  261. package/lib/plugins/app-types/request/utils.d.ts +0 -46
  262. package/lib/plugins/app-types/routes/config.d.ts +0 -7
  263. package/lib/plugins/app-types/routes/index.d.ts +0 -28
  264. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +0 -6
  265. package/lib/plugins/app-types/socket/components/index.d.ts +0 -2
  266. package/lib/plugins/app-types/socket/constants.d.ts +0 -33
  267. package/lib/plugins/app-types/socket/events.d.ts +0 -31
  268. package/lib/plugins/app-types/socket/heartbeat.d.ts +0 -66
  269. package/lib/plugins/app-types/socket/index.d.ts +0 -61
  270. package/lib/plugins/app-types/socket/monitor.d.ts +0 -169
  271. package/lib/plugins/app-types/socket/reconnect.d.ts +0 -61
  272. package/lib/plugins/app-types/socket/socket.d.ts +0 -129
  273. package/lib/plugins/app-types/socket/types.d.ts +0 -85
  274. package/lib/plugins/app-types/storage/index.d.ts +0 -17
  275. package/lib/plugins/app-types/tasks/index.d.ts +0 -77
  276. package/lib/plugins/app-types/tasks/type.d.ts +0 -62
  277. package/lib/plugins/app-types/tasks/useTasks.d.ts +0 -5
  278. package/lib/plugins/app-types/type.d.ts +0 -2
  279. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +0 -7
  280. package/lib/plugins/app-types/variables/config.d.ts +0 -3
  281. package/lib/plugins/app-types/variables/index.d.ts +0 -6
  282. package/lib/plugins/app-types/variables/type.d.ts +0 -2
  283. package/lib/plugins/app-types/website/index.d.ts +0 -6
  284. package/lib/plugins/app.d.ts +0 -8
  285. package/lib/plugins/app.js +0 -17
  286. package/lib/solution/BookingTicket/index.d.ts +0 -184
  287. package/lib/solution/BookingTicket/index.js +0 -426
  288. package/lib/solution/BookingTicket/types.d.ts +0 -68
  289. package/lib/solution/BookingTicket/types.js +0 -72
  290. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +0 -22
  291. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +0 -117
  292. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +0 -22
  293. package/lib/solution/BookingTicket/utils/scan/handleScan.js +0 -132
  294. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -85
  295. package/lib/solution/BookingTicket/utils/scan/index.js +0 -216
  296. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +0 -78
  297. package/lib/solution/BookingTicket/utils/scan/scanCache.js +0 -231
  298. package/lib/solution/Checkout/appointmentDemo.json +0 -1
  299. package/lib/solution/Checkout/index.d.ts +0 -432
  300. package/lib/solution/Checkout/index.js +0 -2776
  301. package/lib/solution/Checkout/types.d.ts +0 -727
  302. package/lib/solution/Checkout/types.js +0 -63
  303. package/lib/solution/Checkout/utils/index.d.ts +0 -121
  304. package/lib/solution/Checkout/utils/index.js +0 -362
  305. package/lib/utils/task.d.ts +0 -40
  306. package/lib/utils/task.js +0 -109
  307. package/lib/utils/watch.d.ts +0 -102
  308. package/lib/utils/watch.js +0 -217
@@ -1,102 +0,0 @@
1
- /**
2
- * 监听模块
3
- *
4
- */
5
- export type WatchEventCallback = (...args: any[]) => void;
6
- export type WatchEventItem = {
7
- key: string;
8
- callback: WatchEventCallback;
9
- };
10
- export interface WatchEventSubscription {
11
- unsubscribe: () => void;
12
- }
13
- declare class Watch {
14
- private events;
15
- private enableListMap;
16
- /**
17
- * 订阅事件
18
- * @param event 事件名称
19
- * @param callback 回调函数
20
- * @returns 订阅对象,可用于取消订阅
21
- */
22
- subscribe(watchKey: string, event: WatchEventItem): WatchEventSubscription;
23
- /**
24
- * 启用事件
25
- * @param watchKey 监听的key
26
- * @param event 事件名称
27
- */
28
- enableEvent(watchKey: string, eventKey: string): void;
29
- /**
30
- * 禁用某个事件
31
- * @param watchKey 监听的key
32
- * @param eventKey 事件名称
33
- */
34
- disableEvent(watchKey: string, eventKey: string): void;
35
- /**
36
- * 冻结某个监听下的所有事件
37
- * @param watchKey 监听的key
38
- */
39
- disabledAllEventByWatchKey(watchKey: string): void;
40
- /**
41
- * 启用某个监听下的所有事件
42
- * @param watchKey 监听的key
43
- */
44
- enableAllEventByWatchKey(watchKey: string): void;
45
- /**
46
- * 取消订阅事件
47
- * @param event 事件名称
48
- * @param callback 回调函数
49
- * @returns 是否成功取消订阅
50
- */
51
- unsubscribe(watchKey: string, event: WatchEventItem): void;
52
- /**
53
- * 发布事件
54
- * @param event 事件名称
55
- * @param args 事件参数
56
- */
57
- publish(watchKey: string, ...args: any[]): void;
58
- /**
59
- * 根据事件名称发布事件
60
- * @param watchKey 监听的key
61
- * @param eventKey 事件名称
62
- * @param args 事件参数
63
- */
64
- publishByEventKey(watchKey: string, eventKey: string, ...args: any[]): void;
65
- /**
66
- * 获取最后一个启用的事件
67
- * @param watchKey 监听的key
68
- * @returns 最后一个启用的事件
69
- */
70
- getLastEnableEventKey(watchKey: string): WatchEventItem['key'] | undefined;
71
- /**
72
- * 移除某个事件的所有订阅
73
- * @param event 事件名称
74
- * @returns 是否成功移除
75
- */
76
- clearEvent(watchKey: string): void;
77
- /**
78
- * 移除所有事件订阅
79
- */
80
- clearAllEvents(): void;
81
- /**
82
- * 获取事件的订阅数量
83
- * @param event 事件名称
84
- * @returns 订阅数量
85
- */
86
- getSubscriberCount(event: string): number;
87
- /**
88
- * 检查事件是否有订阅者
89
- * @param event 事件名称
90
- * @returns 是否有订阅者
91
- */
92
- hasSubscribers(event: string): boolean;
93
- /**
94
- * 一次性订阅事件,事件触发后自动取消订阅
95
- * @param event 事件名称
96
- * @param callback 回调函数
97
- * @returns 订阅对象,可用于取消订阅
98
- */
99
- once(watchKey: string, event: WatchEventItem): WatchEventSubscription;
100
- }
101
- declare const watch: Watch;
102
- export default watch;
@@ -1,217 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/utils/watch.ts
20
- var watch_exports = {};
21
- __export(watch_exports, {
22
- default: () => watch_default
23
- });
24
- module.exports = __toCommonJS(watch_exports);
25
- var Watch = class {
26
- constructor() {
27
- // 监听列表
28
- this.events = /* @__PURE__ */ new Map();
29
- // 启用列表 - 使用数组保持顺序
30
- this.enableListMap = /* @__PURE__ */ new Map();
31
- }
32
- /**
33
- * 订阅事件
34
- * @param event 事件名称
35
- * @param callback 回调函数
36
- * @returns 订阅对象,可用于取消订阅
37
- */
38
- subscribe(watchKey, event) {
39
- if (!this.events.has(watchKey)) {
40
- this.events.set(watchKey, /* @__PURE__ */ new Map());
41
- }
42
- const callbacks = this.events.get(watchKey);
43
- callbacks.set(event.key, event.callback);
44
- this.enableEvent(watchKey, event.key);
45
- return {
46
- // 取消订阅
47
- unsubscribe: () => {
48
- this.unsubscribe(watchKey, event);
49
- }
50
- };
51
- }
52
- /**
53
- * 启用事件
54
- * @param watchKey 监听的key
55
- * @param event 事件名称
56
- */
57
- enableEvent(watchKey, eventKey) {
58
- const enableList = this.enableListMap.get(watchKey);
59
- if (enableList) {
60
- if (enableList.includes(eventKey)) {
61
- return;
62
- }
63
- enableList.push(eventKey);
64
- } else {
65
- this.enableListMap.set(watchKey, [eventKey]);
66
- }
67
- }
68
- /**
69
- * 禁用某个事件
70
- * @param watchKey 监听的key
71
- * @param eventKey 事件名称
72
- */
73
- disableEvent(watchKey, eventKey) {
74
- const enableList = this.enableListMap.get(watchKey);
75
- if (enableList) {
76
- const index = enableList.indexOf(eventKey);
77
- if (index !== -1) {
78
- enableList.splice(index);
79
- }
80
- }
81
- }
82
- /**
83
- * 冻结某个监听下的所有事件
84
- * @param watchKey 监听的key
85
- */
86
- disabledAllEventByWatchKey(watchKey) {
87
- this.enableListMap.set(watchKey, []);
88
- }
89
- /**
90
- * 启用某个监听下的所有事件
91
- * @param watchKey 监听的key
92
- */
93
- enableAllEventByWatchKey(watchKey) {
94
- var _a;
95
- this.enableListMap.set(
96
- watchKey,
97
- Array.from(((_a = this.events.get(watchKey)) == null ? void 0 : _a.keys()) || [])
98
- );
99
- }
100
- /**
101
- * 取消订阅事件
102
- * @param event 事件名称
103
- * @param callback 回调函数
104
- * @returns 是否成功取消订阅
105
- */
106
- unsubscribe(watchKey, event) {
107
- const callbacks = this.events.get(watchKey);
108
- if (!callbacks) {
109
- return;
110
- }
111
- this.disableEvent(watchKey, event.key);
112
- callbacks.delete(event.key);
113
- return;
114
- }
115
- /**
116
- * 发布事件
117
- * @param event 事件名称
118
- * @param args 事件参数
119
- */
120
- publish(watchKey, ...args) {
121
- var _a;
122
- const callbacks = this.events.get(watchKey);
123
- if (!callbacks) {
124
- return;
125
- }
126
- const enableList = this.enableListMap.get(watchKey);
127
- if (!enableList || enableList.length === 0) {
128
- return;
129
- }
130
- const lastCallbackKey = enableList.at(-1);
131
- if (lastCallbackKey) {
132
- try {
133
- (_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
134
- } catch (error) {
135
- console.error(`执行事件"${watchKey}"的回调时出错:`, error);
136
- }
137
- }
138
- }
139
- /**
140
- * 根据事件名称发布事件
141
- * @param watchKey 监听的key
142
- * @param eventKey 事件名称
143
- * @param args 事件参数
144
- */
145
- publishByEventKey(watchKey, eventKey, ...args) {
146
- var _a;
147
- const callbacks = this.events.get(watchKey);
148
- if (!callbacks) {
149
- return;
150
- }
151
- (_a = callbacks.get(eventKey)) == null ? void 0 : _a(...args);
152
- }
153
- /**
154
- * 获取最后一个启用的事件
155
- * @param watchKey 监听的key
156
- * @returns 最后一个启用的事件
157
- */
158
- getLastEnableEventKey(watchKey) {
159
- const enableList = this.enableListMap.get(watchKey);
160
- console.log("enableList", enableList);
161
- if (!enableList) {
162
- return void 0;
163
- }
164
- return enableList.at(-1) || void 0;
165
- }
166
- /**
167
- * 移除某个事件的所有订阅
168
- * @param event 事件名称
169
- * @returns 是否成功移除
170
- */
171
- clearEvent(watchKey) {
172
- this.disabledAllEventByWatchKey(watchKey);
173
- this.events.delete(watchKey);
174
- }
175
- /**
176
- * 移除所有事件订阅
177
- */
178
- clearAllEvents() {
179
- this.events.clear();
180
- this.enableListMap.clear();
181
- }
182
- /**
183
- * 获取事件的订阅数量
184
- * @param event 事件名称
185
- * @returns 订阅数量
186
- */
187
- getSubscriberCount(event) {
188
- const callbacks = this.events.get(event);
189
- return callbacks ? callbacks.size : 0;
190
- }
191
- /**
192
- * 检查事件是否有订阅者
193
- * @param event 事件名称
194
- * @returns 是否有订阅者
195
- */
196
- hasSubscribers(event) {
197
- return this.getSubscriberCount(event) > 0;
198
- }
199
- /**
200
- * 一次性订阅事件,事件触发后自动取消订阅
201
- * @param event 事件名称
202
- * @param callback 回调函数
203
- * @returns 订阅对象,可用于取消订阅
204
- */
205
- once(watchKey, event) {
206
- const wrappedCallback = (...args) => {
207
- this.unsubscribe(watchKey, { key: event.key, callback: wrappedCallback });
208
- event.callback(...args);
209
- };
210
- return this.subscribe(watchKey, {
211
- key: event.key,
212
- callback: wrappedCallback
213
- });
214
- }
215
- };
216
- var watch = new Watch();
217
- var watch_default = watch;