@etsoo/appscript 1.4.64 → 1.4.66
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.
|
@@ -138,13 +138,11 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
138
138
|
* @returns Result
|
|
139
139
|
*/
|
|
140
140
|
static getCartData<D extends ShoppingCartItem>(storage: IStorage, id: string): ShoppingCartData<D> | undefined;
|
|
141
|
-
_owner?: ShoppingCartOwner;
|
|
142
141
|
/**
|
|
143
142
|
* Owner data
|
|
144
143
|
* 所有者信息
|
|
145
144
|
*/
|
|
146
|
-
|
|
147
|
-
set owner(value: ShoppingCartOwner | undefined);
|
|
145
|
+
owner?: ShoppingCartOwner;
|
|
148
146
|
_currency: Currency;
|
|
149
147
|
/**
|
|
150
148
|
* ISO currency id
|
|
@@ -251,6 +249,7 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
251
249
|
* @param storage Data storage
|
|
252
250
|
*/
|
|
253
251
|
constructor(key: string, state: ShoppingCartData<T>, storage?: IStorage);
|
|
252
|
+
private getCartData;
|
|
254
253
|
private setCartData;
|
|
255
254
|
private doChange;
|
|
256
255
|
/**
|
|
@@ -50,24 +50,6 @@ class ShoppingCart {
|
|
|
50
50
|
console.log('ShoppingCart constructor', error);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Owner data
|
|
55
|
-
* 所有者信息
|
|
56
|
-
*/
|
|
57
|
-
get owner() {
|
|
58
|
-
return this._owner;
|
|
59
|
-
}
|
|
60
|
-
set owner(value) {
|
|
61
|
-
var _a;
|
|
62
|
-
if (((_a = this._owner) === null || _a === void 0 ? void 0 : _a.id) === (value === null || value === void 0 ? void 0 : value.id))
|
|
63
|
-
return;
|
|
64
|
-
this._owner = value;
|
|
65
|
-
if (value) {
|
|
66
|
-
const data = ShoppingCart.getCartData(this.storage, this.identifier);
|
|
67
|
-
if (data)
|
|
68
|
-
this.setCartData(data);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
53
|
/**
|
|
72
54
|
* ISO currency id
|
|
73
55
|
* 标准货币编号
|
|
@@ -176,7 +158,6 @@ class ShoppingCart {
|
|
|
176
158
|
* @param storage Data storage
|
|
177
159
|
*/
|
|
178
160
|
constructor(key, currencyOrState, storage = new shared_1.WindowStorage()) {
|
|
179
|
-
var _a;
|
|
180
161
|
this.storage = storage;
|
|
181
162
|
this._items = [];
|
|
182
163
|
this._promotions = [];
|
|
@@ -187,9 +168,7 @@ class ShoppingCart {
|
|
|
187
168
|
this.prices = {};
|
|
188
169
|
this.key = key;
|
|
189
170
|
if (Array.isArray(currencyOrState)) {
|
|
190
|
-
this.
|
|
191
|
-
this.changeCulture(currencyOrState[1]);
|
|
192
|
-
this.setCartData((_a = this.storage.getPersistedObject(this.identifier)) !== null && _a !== void 0 ? _a : this.storage.getObject(this.identifier));
|
|
171
|
+
this.reset(currencyOrState[0], currencyOrState[1]);
|
|
193
172
|
}
|
|
194
173
|
else {
|
|
195
174
|
this.setCartData(currencyOrState);
|
|
@@ -197,6 +176,10 @@ class ShoppingCart {
|
|
|
197
176
|
this.changeCulture(currencyOrState.culture);
|
|
198
177
|
}
|
|
199
178
|
}
|
|
179
|
+
getCartData() {
|
|
180
|
+
var _a;
|
|
181
|
+
return ((_a = this.storage.getPersistedObject(this.identifier)) !== null && _a !== void 0 ? _a : this.storage.getObject(this.identifier));
|
|
182
|
+
}
|
|
200
183
|
setCartData(state) {
|
|
201
184
|
const { owner, items = [], promotions = [], formData, cache } = state !== null && state !== void 0 ? state : {};
|
|
202
185
|
this.owner = owner;
|
|
@@ -258,6 +241,7 @@ class ShoppingCart {
|
|
|
258
241
|
this.items.length = 0;
|
|
259
242
|
this.promotions.length = 0;
|
|
260
243
|
this.prices = {};
|
|
244
|
+
this.cache = undefined;
|
|
261
245
|
if (keepOwner) {
|
|
262
246
|
this.save();
|
|
263
247
|
}
|
|
@@ -309,9 +293,9 @@ class ShoppingCart {
|
|
|
309
293
|
* @param culture New culture
|
|
310
294
|
*/
|
|
311
295
|
reset(currency, culture) {
|
|
312
|
-
this.clear(true);
|
|
313
296
|
this.changeCurrency(currency);
|
|
314
297
|
this.changeCulture(culture);
|
|
298
|
+
this.setCartData(this.getCartData());
|
|
315
299
|
}
|
|
316
300
|
/**
|
|
317
301
|
* Remove item from the index
|
|
@@ -138,13 +138,11 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
138
138
|
* @returns Result
|
|
139
139
|
*/
|
|
140
140
|
static getCartData<D extends ShoppingCartItem>(storage: IStorage, id: string): ShoppingCartData<D> | undefined;
|
|
141
|
-
_owner?: ShoppingCartOwner;
|
|
142
141
|
/**
|
|
143
142
|
* Owner data
|
|
144
143
|
* 所有者信息
|
|
145
144
|
*/
|
|
146
|
-
|
|
147
|
-
set owner(value: ShoppingCartOwner | undefined);
|
|
145
|
+
owner?: ShoppingCartOwner;
|
|
148
146
|
_currency: Currency;
|
|
149
147
|
/**
|
|
150
148
|
* ISO currency id
|
|
@@ -251,6 +249,7 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
251
249
|
* @param storage Data storage
|
|
252
250
|
*/
|
|
253
251
|
constructor(key: string, state: ShoppingCartData<T>, storage?: IStorage);
|
|
252
|
+
private getCartData;
|
|
254
253
|
private setCartData;
|
|
255
254
|
private doChange;
|
|
256
255
|
/**
|
|
@@ -47,24 +47,6 @@ export class ShoppingCart {
|
|
|
47
47
|
console.log('ShoppingCart constructor', error);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Owner data
|
|
52
|
-
* 所有者信息
|
|
53
|
-
*/
|
|
54
|
-
get owner() {
|
|
55
|
-
return this._owner;
|
|
56
|
-
}
|
|
57
|
-
set owner(value) {
|
|
58
|
-
var _a;
|
|
59
|
-
if (((_a = this._owner) === null || _a === void 0 ? void 0 : _a.id) === (value === null || value === void 0 ? void 0 : value.id))
|
|
60
|
-
return;
|
|
61
|
-
this._owner = value;
|
|
62
|
-
if (value) {
|
|
63
|
-
const data = ShoppingCart.getCartData(this.storage, this.identifier);
|
|
64
|
-
if (data)
|
|
65
|
-
this.setCartData(data);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
50
|
/**
|
|
69
51
|
* ISO currency id
|
|
70
52
|
* 标准货币编号
|
|
@@ -173,7 +155,6 @@ export class ShoppingCart {
|
|
|
173
155
|
* @param storage Data storage
|
|
174
156
|
*/
|
|
175
157
|
constructor(key, currencyOrState, storage = new WindowStorage()) {
|
|
176
|
-
var _a;
|
|
177
158
|
this.storage = storage;
|
|
178
159
|
this._items = [];
|
|
179
160
|
this._promotions = [];
|
|
@@ -184,9 +165,7 @@ export class ShoppingCart {
|
|
|
184
165
|
this.prices = {};
|
|
185
166
|
this.key = key;
|
|
186
167
|
if (Array.isArray(currencyOrState)) {
|
|
187
|
-
this.
|
|
188
|
-
this.changeCulture(currencyOrState[1]);
|
|
189
|
-
this.setCartData((_a = this.storage.getPersistedObject(this.identifier)) !== null && _a !== void 0 ? _a : this.storage.getObject(this.identifier));
|
|
168
|
+
this.reset(currencyOrState[0], currencyOrState[1]);
|
|
190
169
|
}
|
|
191
170
|
else {
|
|
192
171
|
this.setCartData(currencyOrState);
|
|
@@ -194,6 +173,10 @@ export class ShoppingCart {
|
|
|
194
173
|
this.changeCulture(currencyOrState.culture);
|
|
195
174
|
}
|
|
196
175
|
}
|
|
176
|
+
getCartData() {
|
|
177
|
+
var _a;
|
|
178
|
+
return ((_a = this.storage.getPersistedObject(this.identifier)) !== null && _a !== void 0 ? _a : this.storage.getObject(this.identifier));
|
|
179
|
+
}
|
|
197
180
|
setCartData(state) {
|
|
198
181
|
const { owner, items = [], promotions = [], formData, cache } = state !== null && state !== void 0 ? state : {};
|
|
199
182
|
this.owner = owner;
|
|
@@ -255,6 +238,7 @@ export class ShoppingCart {
|
|
|
255
238
|
this.items.length = 0;
|
|
256
239
|
this.promotions.length = 0;
|
|
257
240
|
this.prices = {};
|
|
241
|
+
this.cache = undefined;
|
|
258
242
|
if (keepOwner) {
|
|
259
243
|
this.save();
|
|
260
244
|
}
|
|
@@ -306,9 +290,9 @@ export class ShoppingCart {
|
|
|
306
290
|
* @param culture New culture
|
|
307
291
|
*/
|
|
308
292
|
reset(currency, culture) {
|
|
309
|
-
this.clear(true);
|
|
310
293
|
this.changeCurrency(currency);
|
|
311
294
|
this.changeCulture(culture);
|
|
295
|
+
this.setCartData(this.getCartData());
|
|
312
296
|
}
|
|
313
297
|
/**
|
|
314
298
|
* Remove item from the index
|
package/package.json
CHANGED
|
@@ -185,25 +185,11 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
_owner?: ShoppingCartOwner;
|
|
189
188
|
/**
|
|
190
189
|
* Owner data
|
|
191
190
|
* 所有者信息
|
|
192
191
|
*/
|
|
193
|
-
|
|
194
|
-
return this._owner;
|
|
195
|
-
}
|
|
196
|
-
set owner(value) {
|
|
197
|
-
if (this._owner?.id === value?.id) return;
|
|
198
|
-
this._owner = value;
|
|
199
|
-
if (value) {
|
|
200
|
-
const data = ShoppingCart.getCartData<T>(
|
|
201
|
-
this.storage,
|
|
202
|
-
this.identifier
|
|
203
|
-
);
|
|
204
|
-
if (data) this.setCartData(data);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
192
|
+
owner?: ShoppingCartOwner;
|
|
207
193
|
|
|
208
194
|
_currency!: Currency;
|
|
209
195
|
|
|
@@ -390,19 +376,19 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
390
376
|
this.key = key;
|
|
391
377
|
|
|
392
378
|
if (Array.isArray(currencyOrState)) {
|
|
393
|
-
this.
|
|
394
|
-
this.changeCulture(currencyOrState[1]);
|
|
395
|
-
|
|
396
|
-
this.setCartData(
|
|
397
|
-
this.storage.getPersistedObject(this.identifier) ??
|
|
398
|
-
this.storage.getObject(this.identifier)
|
|
399
|
-
);
|
|
379
|
+
this.reset(currencyOrState[0], currencyOrState[1]);
|
|
400
380
|
} else {
|
|
401
381
|
this.setCartData(currencyOrState);
|
|
402
382
|
this.changeCurrency(currencyOrState.currency);
|
|
403
383
|
this.changeCulture(currencyOrState.culture);
|
|
404
384
|
}
|
|
405
385
|
}
|
|
386
|
+
private getCartData(): ShoppingCartData<T> | undefined {
|
|
387
|
+
return (
|
|
388
|
+
this.storage.getPersistedObject(this.identifier) ??
|
|
389
|
+
this.storage.getObject(this.identifier)
|
|
390
|
+
);
|
|
391
|
+
}
|
|
406
392
|
|
|
407
393
|
private setCartData(state: ShoppingCartData<T> | undefined) {
|
|
408
394
|
const {
|
|
@@ -477,6 +463,7 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
477
463
|
this.items.length = 0;
|
|
478
464
|
this.promotions.length = 0;
|
|
479
465
|
this.prices = <Record<T['id'], number>>{};
|
|
466
|
+
this.cache = undefined;
|
|
480
467
|
|
|
481
468
|
if (keepOwner) {
|
|
482
469
|
this.save();
|
|
@@ -533,9 +520,9 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
533
520
|
* @param culture New culture
|
|
534
521
|
*/
|
|
535
522
|
reset(currency: Currency, culture: string) {
|
|
536
|
-
this.clear(true);
|
|
537
523
|
this.changeCurrency(currency);
|
|
538
524
|
this.changeCulture(culture);
|
|
525
|
+
this.setCartData(this.getCartData());
|
|
539
526
|
}
|
|
540
527
|
|
|
541
528
|
/**
|