@pisell/pisellos 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/AccountList/index.d.ts +0 -2
- package/dist/modules/AccountList/index.js +9 -15
- package/dist/modules/AccountList/types.d.ts +0 -1
- package/dist/solution/BookingByStep/index.js +2 -2
- package/dist/solution/ShopDiscount/index.js +2 -2
- package/lib/modules/AccountList/index.d.ts +0 -2
- package/lib/modules/AccountList/index.js +9 -11
- package/lib/modules/AccountList/types.d.ts +0 -1
- package/lib/solution/BookingByStep/index.js +1 -1
- package/lib/solution/ShopDiscount/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { AccountModule, Account } from '../Account';
|
|
3
3
|
import { BaseModule } from '../BaseModule';
|
|
4
|
-
import { AccountListState } from './types';
|
|
5
4
|
export declare class AccountListModule extends BaseModule implements Module {
|
|
6
5
|
protected defaultName: string;
|
|
7
6
|
protected defaultVersion: string;
|
|
@@ -17,7 +16,6 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
17
16
|
getAccounts(): AccountModule[];
|
|
18
17
|
getAccount(id: string): AccountModule | null;
|
|
19
18
|
clearAccounts(): Promise<void>;
|
|
20
|
-
getState(): AccountListState;
|
|
21
19
|
setActiveAccount(id: string | number): void;
|
|
22
20
|
getActiveAccount(): AccountModule | null;
|
|
23
21
|
storeChange(): void;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
2
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
3
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -23,6 +21,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
23
21
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
23
|
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); }
|
|
24
|
+
import { cloneDeep } from 'lodash-es';
|
|
26
25
|
import { AccountModule } from "../Account";
|
|
27
26
|
import { BaseModule } from "../BaseModule";
|
|
28
27
|
import { AccountListHooks } from "./types";
|
|
@@ -62,14 +61,14 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
62
61
|
case 0:
|
|
63
62
|
this.core = core;
|
|
64
63
|
this.store = options === null || options === void 0 ? void 0 : options.store;
|
|
65
|
-
this.store.accounts = [];
|
|
66
|
-
this.store.accountList = [];
|
|
67
64
|
if (Array.isArray(options === null || options === void 0 || (_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.accountList)) {
|
|
68
|
-
recordList = options.initialState.accountList || [];
|
|
65
|
+
recordList = cloneDeep(options.initialState.accountList || []);
|
|
66
|
+
this.store.accounts = [];
|
|
69
67
|
recordList.forEach(function (account) {
|
|
70
68
|
_this2.addAccount(account);
|
|
71
69
|
});
|
|
72
70
|
} else {
|
|
71
|
+
this.store.accounts = [];
|
|
73
72
|
this.store.accountList = [];
|
|
74
73
|
}
|
|
75
74
|
if (options !== null && options !== void 0 && (_options$otherParams = options.otherParams) !== null && _options$otherParams !== void 0 && _options$otherParams.cacheId) {
|
|
@@ -79,7 +78,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
79
78
|
if (options !== null && options !== void 0 && (_options$otherParams2 = options.otherParams) !== null && _options$otherParams2 !== void 0 && _options$otherParams2.fatherModule) {
|
|
80
79
|
this.fatherModule = options.otherParams.fatherModule;
|
|
81
80
|
}
|
|
82
|
-
case
|
|
81
|
+
case 5:
|
|
83
82
|
case "end":
|
|
84
83
|
return _context.stop();
|
|
85
84
|
}
|
|
@@ -113,7 +112,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
113
112
|
accountModule = new AccountModule("account_".concat(account.id));
|
|
114
113
|
this.core.registerModule(accountModule);
|
|
115
114
|
accountModule.setAccountInfo(account);
|
|
116
|
-
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts), [accountModule]);
|
|
115
|
+
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts || []), [accountModule]);
|
|
117
116
|
_context2.next = 13;
|
|
118
117
|
return this.core.effects.emit(AccountListHooks.OnAccountListUpdate, this.store);
|
|
119
118
|
case 13:
|
|
@@ -221,7 +220,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
221
220
|
throw new Error("Account with id ".concat(id, " not found"));
|
|
222
221
|
case 6:
|
|
223
222
|
this.store.accounts[index].destory();
|
|
224
|
-
this.store.accounts = [].concat(_toConsumableArray(this.store.accounts.slice(0, index)), _toConsumableArray(this.store.accounts.slice(index + 1)));
|
|
223
|
+
this.store.accounts = [].concat(_toConsumableArray((this.store.accounts || []).slice(0, index)), _toConsumableArray((this.store.accounts || []).slice(index + 1)));
|
|
225
224
|
this.store.accountList = this.store.accountList.filter(function (account) {
|
|
226
225
|
return account.id !== id;
|
|
227
226
|
});
|
|
@@ -254,7 +253,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
253
|
}, {
|
|
255
254
|
key: "getAccounts",
|
|
256
255
|
value: function getAccounts() {
|
|
257
|
-
return _toConsumableArray(this.store.accounts);
|
|
256
|
+
return _toConsumableArray(this.store.accounts || []);
|
|
258
257
|
}
|
|
259
258
|
}, {
|
|
260
259
|
key: "getAccount",
|
|
@@ -300,11 +299,6 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
299
|
}
|
|
301
300
|
return clearAccounts;
|
|
302
301
|
}()
|
|
303
|
-
}, {
|
|
304
|
-
key: "getState",
|
|
305
|
-
value: function getState() {
|
|
306
|
-
return _objectSpread({}, this.store);
|
|
307
|
-
}
|
|
308
302
|
}, {
|
|
309
303
|
key: "setActiveAccount",
|
|
310
304
|
value: function setActiveAccount(id) {
|
|
@@ -331,7 +325,7 @@ export var AccountListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
331
325
|
cacheId: this.cacheId,
|
|
332
326
|
fatherModule: this.fatherModule,
|
|
333
327
|
store: this.store,
|
|
334
|
-
cacheKey: ['
|
|
328
|
+
cacheKey: ['accountList']
|
|
335
329
|
});
|
|
336
330
|
}
|
|
337
331
|
}
|
|
@@ -90,10 +90,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
90
90
|
moduleArr.forEach(function (step) {
|
|
91
91
|
var targetModule = createModule(step, _this2.name);
|
|
92
92
|
if (targetModule) {
|
|
93
|
-
var _this2$otherParams, _this2$otherParams2;
|
|
93
|
+
var _targetCacheData, _this2$otherParams, _this2$otherParams2;
|
|
94
94
|
_this2.store[step] = targetModule;
|
|
95
95
|
_this2.core.registerModule(targetModule, {
|
|
96
|
-
initialState: targetCacheData[targetModule.name],
|
|
96
|
+
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[targetModule.name],
|
|
97
97
|
otherParams: _objectSpread(_objectSpread({}, _this2.otherParams), {}, {
|
|
98
98
|
fatherModule: _this2.name,
|
|
99
99
|
openCache: (_this2$otherParams = _this2.otherParams) !== null && _this2$otherParams !== void 0 && _this2$otherParams.cacheId ? true : false,
|
|
@@ -154,7 +154,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
154
154
|
}, {
|
|
155
155
|
key: "registerDependentModules",
|
|
156
156
|
value: function registerDependentModules() {
|
|
157
|
-
var _this$options$otherPa, _this$options$otherPa2, _this$options$otherPa3, _this$options$otherPa4, _this$options$otherPa5;
|
|
157
|
+
var _this$options$otherPa, _targetCacheData, _this$options$otherPa2, _this$options$otherPa3, _this$options$otherPa4, _this$options$otherPa5;
|
|
158
158
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
159
159
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
160
160
|
var targetCacheData = {};
|
|
@@ -169,7 +169,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
169
169
|
// 注册优惠模块
|
|
170
170
|
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
171
171
|
this.core.registerModule(discount, {
|
|
172
|
-
initialState: targetCacheData[discount.name],
|
|
172
|
+
initialState: (_targetCacheData = targetCacheData) === null || _targetCacheData === void 0 ? void 0 : _targetCacheData[discount.name],
|
|
173
173
|
hooks: (_this$options$otherPa2 = this.options.otherParams) === null || _this$options$otherPa2 === void 0 || (_this$options$otherPa2 = _this$options$otherPa2.discount) === null || _this$options$otherPa2 === void 0 ? void 0 : _this$options$otherPa2.hooks,
|
|
174
174
|
otherParams: {
|
|
175
175
|
fatherModule: this.name,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { AccountModule, Account } from '../Account';
|
|
3
3
|
import { BaseModule } from '../BaseModule';
|
|
4
|
-
import { AccountListState } from './types';
|
|
5
4
|
export declare class AccountListModule extends BaseModule implements Module {
|
|
6
5
|
protected defaultName: string;
|
|
7
6
|
protected defaultVersion: string;
|
|
@@ -17,7 +16,6 @@ export declare class AccountListModule extends BaseModule implements Module {
|
|
|
17
16
|
getAccounts(): AccountModule[];
|
|
18
17
|
getAccount(id: string): AccountModule | null;
|
|
19
18
|
clearAccounts(): Promise<void>;
|
|
20
|
-
getState(): AccountListState;
|
|
21
19
|
setActiveAccount(id: string | number): void;
|
|
22
20
|
getActiveAccount(): AccountModule | null;
|
|
23
21
|
storeChange(): void;
|
|
@@ -22,6 +22,7 @@ __export(AccountList_exports, {
|
|
|
22
22
|
AccountListModule: () => AccountListModule
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(AccountList_exports);
|
|
25
|
+
var import_lodash_es = require("lodash-es");
|
|
25
26
|
var import_Account = require("../Account");
|
|
26
27
|
var import_BaseModule = require("../BaseModule");
|
|
27
28
|
var import_types = require("./types");
|
|
@@ -44,14 +45,14 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
44
45
|
var _a, _b, _c;
|
|
45
46
|
this.core = core;
|
|
46
47
|
this.store = options == null ? void 0 : options.store;
|
|
47
|
-
this.store.accounts = [];
|
|
48
|
-
this.store.accountList = [];
|
|
49
48
|
if (Array.isArray((_a = options == null ? void 0 : options.initialState) == null ? void 0 : _a.accountList)) {
|
|
50
|
-
const recordList = options.initialState.accountList || [];
|
|
49
|
+
const recordList = (0, import_lodash_es.cloneDeep)(options.initialState.accountList || []);
|
|
50
|
+
this.store.accounts = [];
|
|
51
51
|
recordList.forEach((account) => {
|
|
52
52
|
this.addAccount(account);
|
|
53
53
|
});
|
|
54
54
|
} else {
|
|
55
|
+
this.store.accounts = [];
|
|
55
56
|
this.store.accountList = [];
|
|
56
57
|
}
|
|
57
58
|
if ((_b = options == null ? void 0 : options.otherParams) == null ? void 0 : _b.cacheId) {
|
|
@@ -74,7 +75,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
74
75
|
const accountModule = new import_Account.AccountModule(`account_${account.id}`);
|
|
75
76
|
this.core.registerModule(accountModule);
|
|
76
77
|
accountModule.setAccountInfo(account);
|
|
77
|
-
this.store.accounts = [...this.store.accounts, accountModule];
|
|
78
|
+
this.store.accounts = [...this.store.accounts || [], accountModule];
|
|
78
79
|
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
79
80
|
if (this.store.accounts.length === 1) {
|
|
80
81
|
this.setActiveAccount(accountModule.getId());
|
|
@@ -118,8 +119,8 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
118
119
|
}
|
|
119
120
|
this.store.accounts[index].destory();
|
|
120
121
|
this.store.accounts = [
|
|
121
|
-
...this.store.accounts.slice(0, index),
|
|
122
|
-
...this.store.accounts.slice(index + 1)
|
|
122
|
+
...(this.store.accounts || []).slice(0, index),
|
|
123
|
+
...(this.store.accounts || []).slice(index + 1)
|
|
123
124
|
];
|
|
124
125
|
this.store.accountList = this.store.accountList.filter((account) => account.id !== id);
|
|
125
126
|
await this.core.effects.emit(import_types.AccountListHooks.OnAccountListUpdate, this.store);
|
|
@@ -131,7 +132,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
getAccounts() {
|
|
134
|
-
return [...this.store.accounts];
|
|
135
|
+
return [...this.store.accounts || []];
|
|
135
136
|
}
|
|
136
137
|
getAccount(id) {
|
|
137
138
|
return this.store.accounts.find((account) => account.getId() === id) || null;
|
|
@@ -149,9 +150,6 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
149
150
|
this.store.isLoading = false;
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
|
-
getState() {
|
|
153
|
-
return { ...this.store };
|
|
154
|
-
}
|
|
155
153
|
setActiveAccount(id) {
|
|
156
154
|
this.store.accounts.forEach((account) => {
|
|
157
155
|
if (account.getId() === id) {
|
|
@@ -166,7 +164,7 @@ var AccountListModule = class extends import_BaseModule.BaseModule {
|
|
|
166
164
|
}
|
|
167
165
|
storeChange() {
|
|
168
166
|
if (this.openCache) {
|
|
169
|
-
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["
|
|
167
|
+
this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["accountList"] });
|
|
170
168
|
}
|
|
171
169
|
}
|
|
172
170
|
};
|
|
@@ -82,7 +82,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
82
82
|
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
83
83
|
if (targetModule) {
|
|
84
84
|
this.store[step] = targetModule;
|
|
85
|
-
this.core.registerModule(targetModule, { initialState: targetCacheData[targetModule.name], otherParams: {
|
|
85
|
+
this.core.registerModule(targetModule, { initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name], otherParams: {
|
|
86
86
|
...this.otherParams,
|
|
87
87
|
fatherModule: this.name,
|
|
88
88
|
openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
|
|
@@ -93,7 +93,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
93
93
|
}
|
|
94
94
|
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
95
95
|
this.core.registerModule(discount, {
|
|
96
|
-
initialState: targetCacheData[discount.name],
|
|
96
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
|
|
97
97
|
hooks: (_c = (_b = this.options.otherParams) == null ? void 0 : _b.discount) == null ? void 0 : _c.hooks,
|
|
98
98
|
otherParams: {
|
|
99
99
|
fatherModule: this.name,
|