@etsoo/appscript 1.3.92 → 1.3.93
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.
|
@@ -110,9 +110,10 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
110
110
|
* Create identifier key
|
|
111
111
|
* 创建识别键
|
|
112
112
|
* @param currency Currency
|
|
113
|
+
* @param key Additional key
|
|
113
114
|
* @returns Result
|
|
114
115
|
*/
|
|
115
|
-
static createKey(currency: string): string;
|
|
116
|
+
static createKey(currency: string, key?: string): string;
|
|
116
117
|
/**
|
|
117
118
|
* Clear shopping cart
|
|
118
119
|
* 清除购物篮
|
|
@@ -197,15 +198,17 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
197
198
|
* 构造函数
|
|
198
199
|
* @param currency Currency ISO code
|
|
199
200
|
* @param storage Data storage
|
|
201
|
+
* @param key Additional key
|
|
200
202
|
*/
|
|
201
|
-
constructor(currency: string, storage?: IStorage);
|
|
203
|
+
constructor(currency: string, storage?: IStorage, key?: string);
|
|
202
204
|
/**
|
|
203
205
|
* Constructor
|
|
204
206
|
* 构造函数
|
|
205
207
|
* @param state Initialization state
|
|
206
208
|
* @param storage Data storage
|
|
209
|
+
* @param key Additional key
|
|
207
210
|
*/
|
|
208
|
-
constructor(state: ShoppingCartData<T>, storage?: IStorage);
|
|
211
|
+
constructor(state: ShoppingCartData<T>, storage?: IStorage, key?: string);
|
|
209
212
|
private doChange;
|
|
210
213
|
/**
|
|
211
214
|
* Add item
|
|
@@ -11,10 +11,11 @@ class ShoppingCart {
|
|
|
11
11
|
* Create identifier key
|
|
12
12
|
* 创建识别键
|
|
13
13
|
* @param currency Currency
|
|
14
|
+
* @param key Additional key
|
|
14
15
|
* @returns Result
|
|
15
16
|
*/
|
|
16
|
-
static createKey(currency) {
|
|
17
|
-
return `ETSOO-CART-${currency}`;
|
|
17
|
+
static createKey(currency, key = 'KEY') {
|
|
18
|
+
return `ETSOO-CART-${key}-${currency}`;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* Clear shopping cart
|
|
@@ -78,9 +79,9 @@ class ShoppingCart {
|
|
|
78
79
|
* 构造函数
|
|
79
80
|
* @param currency Currency ISO code
|
|
80
81
|
* @param storage Data storage
|
|
81
|
-
* @param
|
|
82
|
+
* @param key Additional key
|
|
82
83
|
*/
|
|
83
|
-
constructor(currencyOrState, storage = new shared_1.WindowStorage()) {
|
|
84
|
+
constructor(currencyOrState, storage = new shared_1.WindowStorage(), key) {
|
|
84
85
|
var _a;
|
|
85
86
|
this.storage = storage;
|
|
86
87
|
/**
|
|
@@ -90,14 +91,14 @@ class ShoppingCart {
|
|
|
90
91
|
this.prices = {};
|
|
91
92
|
const isCurrency = typeof currencyOrState === 'string';
|
|
92
93
|
this.currency = isCurrency ? currencyOrState : currencyOrState.currency;
|
|
93
|
-
const
|
|
94
|
-
this.identifier =
|
|
94
|
+
const id = ShoppingCart.createKey(this.currency, key);
|
|
95
|
+
this.identifier = id;
|
|
95
96
|
this.symbol = shared_1.NumberUtils.getCurrencySymbol(this.currency);
|
|
96
97
|
let state;
|
|
97
98
|
if (isCurrency) {
|
|
98
99
|
try {
|
|
99
100
|
state =
|
|
100
|
-
(_a = storage.getPersistedObject(
|
|
101
|
+
(_a = storage.getPersistedObject(id)) !== null && _a !== void 0 ? _a : storage.getObject(id);
|
|
101
102
|
}
|
|
102
103
|
catch (error) {
|
|
103
104
|
console.log('ShoppingCart constructor', error);
|
|
@@ -110,9 +110,10 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
110
110
|
* Create identifier key
|
|
111
111
|
* 创建识别键
|
|
112
112
|
* @param currency Currency
|
|
113
|
+
* @param key Additional key
|
|
113
114
|
* @returns Result
|
|
114
115
|
*/
|
|
115
|
-
static createKey(currency: string): string;
|
|
116
|
+
static createKey(currency: string, key?: string): string;
|
|
116
117
|
/**
|
|
117
118
|
* Clear shopping cart
|
|
118
119
|
* 清除购物篮
|
|
@@ -197,15 +198,17 @@ export declare class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
197
198
|
* 构造函数
|
|
198
199
|
* @param currency Currency ISO code
|
|
199
200
|
* @param storage Data storage
|
|
201
|
+
* @param key Additional key
|
|
200
202
|
*/
|
|
201
|
-
constructor(currency: string, storage?: IStorage);
|
|
203
|
+
constructor(currency: string, storage?: IStorage, key?: string);
|
|
202
204
|
/**
|
|
203
205
|
* Constructor
|
|
204
206
|
* 构造函数
|
|
205
207
|
* @param state Initialization state
|
|
206
208
|
* @param storage Data storage
|
|
209
|
+
* @param key Additional key
|
|
207
210
|
*/
|
|
208
|
-
constructor(state: ShoppingCartData<T>, storage?: IStorage);
|
|
211
|
+
constructor(state: ShoppingCartData<T>, storage?: IStorage, key?: string);
|
|
209
212
|
private doChange;
|
|
210
213
|
/**
|
|
211
214
|
* Add item
|
|
@@ -8,10 +8,11 @@ export class ShoppingCart {
|
|
|
8
8
|
* Create identifier key
|
|
9
9
|
* 创建识别键
|
|
10
10
|
* @param currency Currency
|
|
11
|
+
* @param key Additional key
|
|
11
12
|
* @returns Result
|
|
12
13
|
*/
|
|
13
|
-
static createKey(currency) {
|
|
14
|
-
return `ETSOO-CART-${currency}`;
|
|
14
|
+
static createKey(currency, key = 'KEY') {
|
|
15
|
+
return `ETSOO-CART-${key}-${currency}`;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Clear shopping cart
|
|
@@ -75,9 +76,9 @@ export class ShoppingCart {
|
|
|
75
76
|
* 构造函数
|
|
76
77
|
* @param currency Currency ISO code
|
|
77
78
|
* @param storage Data storage
|
|
78
|
-
* @param
|
|
79
|
+
* @param key Additional key
|
|
79
80
|
*/
|
|
80
|
-
constructor(currencyOrState, storage = new WindowStorage()) {
|
|
81
|
+
constructor(currencyOrState, storage = new WindowStorage(), key) {
|
|
81
82
|
var _a;
|
|
82
83
|
this.storage = storage;
|
|
83
84
|
/**
|
|
@@ -87,14 +88,14 @@ export class ShoppingCart {
|
|
|
87
88
|
this.prices = {};
|
|
88
89
|
const isCurrency = typeof currencyOrState === 'string';
|
|
89
90
|
this.currency = isCurrency ? currencyOrState : currencyOrState.currency;
|
|
90
|
-
const
|
|
91
|
-
this.identifier =
|
|
91
|
+
const id = ShoppingCart.createKey(this.currency, key);
|
|
92
|
+
this.identifier = id;
|
|
92
93
|
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
93
94
|
let state;
|
|
94
95
|
if (isCurrency) {
|
|
95
96
|
try {
|
|
96
97
|
state =
|
|
97
|
-
(_a = storage.getPersistedObject(
|
|
98
|
+
(_a = storage.getPersistedObject(id)) !== null && _a !== void 0 ? _a : storage.getObject(id);
|
|
98
99
|
}
|
|
99
100
|
catch (error) {
|
|
100
101
|
console.log('ShoppingCart constructor', error);
|
package/package.json
CHANGED
|
@@ -130,10 +130,11 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
130
130
|
* Create identifier key
|
|
131
131
|
* 创建识别键
|
|
132
132
|
* @param currency Currency
|
|
133
|
+
* @param key Additional key
|
|
133
134
|
* @returns Result
|
|
134
135
|
*/
|
|
135
|
-
static createKey(currency: string) {
|
|
136
|
-
return `ETSOO-CART-${currency}`;
|
|
136
|
+
static createKey(currency: string, key: string = 'KEY') {
|
|
137
|
+
return `ETSOO-CART-${key}-${currency}`;
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
/**
|
|
@@ -262,41 +263,44 @@ export class ShoppingCart<T extends ShoppingCartItem> {
|
|
|
262
263
|
* 构造函数
|
|
263
264
|
* @param currency Currency ISO code
|
|
264
265
|
* @param storage Data storage
|
|
266
|
+
* @param key Additional key
|
|
265
267
|
*/
|
|
266
|
-
constructor(currency: string, storage?: IStorage);
|
|
268
|
+
constructor(currency: string, storage?: IStorage, key?: string);
|
|
267
269
|
|
|
268
270
|
/**
|
|
269
271
|
* Constructor
|
|
270
272
|
* 构造函数
|
|
271
273
|
* @param state Initialization state
|
|
272
274
|
* @param storage Data storage
|
|
275
|
+
* @param key Additional key
|
|
273
276
|
*/
|
|
274
|
-
constructor(state: ShoppingCartData<T>, storage?: IStorage);
|
|
277
|
+
constructor(state: ShoppingCartData<T>, storage?: IStorage, key?: string);
|
|
275
278
|
|
|
276
279
|
/**
|
|
277
280
|
* Constructor
|
|
278
281
|
* 构造函数
|
|
279
282
|
* @param currency Currency ISO code
|
|
280
283
|
* @param storage Data storage
|
|
281
|
-
* @param
|
|
284
|
+
* @param key Additional key
|
|
282
285
|
*/
|
|
283
286
|
constructor(
|
|
284
287
|
currencyOrState: string | ShoppingCartData<T>,
|
|
285
|
-
private readonly storage: IStorage = new WindowStorage()
|
|
288
|
+
private readonly storage: IStorage = new WindowStorage(),
|
|
289
|
+
key?: string
|
|
286
290
|
) {
|
|
287
291
|
const isCurrency = typeof currencyOrState === 'string';
|
|
288
292
|
this.currency = isCurrency ? currencyOrState : currencyOrState.currency;
|
|
289
293
|
|
|
290
|
-
const
|
|
291
|
-
this.identifier =
|
|
294
|
+
const id = ShoppingCart.createKey(this.currency, key);
|
|
295
|
+
this.identifier = id;
|
|
292
296
|
this.symbol = NumberUtils.getCurrencySymbol(this.currency);
|
|
293
297
|
|
|
294
298
|
let state: ShoppingCartData<T> | undefined;
|
|
295
299
|
if (isCurrency) {
|
|
296
300
|
try {
|
|
297
301
|
state =
|
|
298
|
-
storage.getPersistedObject<ShoppingCartData<T>>(
|
|
299
|
-
storage.getObject<ShoppingCartData<T>>(
|
|
302
|
+
storage.getPersistedObject<ShoppingCartData<T>>(id) ??
|
|
303
|
+
storage.getObject<ShoppingCartData<T>>(id);
|
|
300
304
|
} catch (error) {
|
|
301
305
|
console.log('ShoppingCart constructor', error);
|
|
302
306
|
}
|