@etsoo/appscript 1.5.2 → 1.5.4
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/lib/cjs/app/CoreApp.d.ts +6 -8
- package/lib/cjs/app/CoreApp.js +20 -20
- package/lib/cjs/app/IApp.d.ts +1 -1
- package/lib/mjs/app/CoreApp.d.ts +6 -8
- package/lib/mjs/app/CoreApp.js +20 -20
- package/lib/mjs/app/IApp.d.ts +1 -1
- package/package.json +1 -1
- package/src/app/CoreApp.ts +56 -22
- package/src/app/IApp.ts +1 -1
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
62
62
|
* Pending actions
|
|
63
63
|
*/
|
|
64
64
|
readonly pendings: (() => any)[];
|
|
65
|
+
/**
|
|
66
|
+
* Debug mode
|
|
67
|
+
*/
|
|
68
|
+
readonly debug: boolean;
|
|
65
69
|
private _culture;
|
|
66
70
|
/**
|
|
67
71
|
* Culture, like zh-CN
|
|
@@ -92,12 +96,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
92
96
|
*/
|
|
93
97
|
get ipData(): IPData | undefined;
|
|
94
98
|
protected set ipData(value: IPData | undefined);
|
|
95
|
-
private _debug;
|
|
96
|
-
/**
|
|
97
|
-
* Is debug mode
|
|
98
|
-
*/
|
|
99
|
-
get debug(): boolean;
|
|
100
|
-
set debug(value: boolean);
|
|
101
99
|
private _userData?;
|
|
102
100
|
/**
|
|
103
101
|
* User data
|
|
@@ -150,9 +148,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
150
148
|
* @param notifier Notifier
|
|
151
149
|
* @param storage Storage
|
|
152
150
|
* @param name Application name
|
|
151
|
+
* @param debug Debug mode
|
|
153
152
|
*/
|
|
154
|
-
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
|
|
155
|
-
private debugIt;
|
|
153
|
+
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string, debug?: boolean);
|
|
156
154
|
private getDeviceId;
|
|
157
155
|
private resetKeys;
|
|
158
156
|
/**
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -56,16 +56,6 @@ class CoreApp {
|
|
|
56
56
|
set ipData(value) {
|
|
57
57
|
this._ipData = value;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Is debug mode
|
|
61
|
-
*/
|
|
62
|
-
get debug() {
|
|
63
|
-
return this._debug;
|
|
64
|
-
}
|
|
65
|
-
set debug(value) {
|
|
66
|
-
this._debug = value;
|
|
67
|
-
this.notifier.debug = value;
|
|
68
|
-
}
|
|
69
59
|
/**
|
|
70
60
|
* User data
|
|
71
61
|
*/
|
|
@@ -111,13 +101,13 @@ class CoreApp {
|
|
|
111
101
|
* @param notifier Notifier
|
|
112
102
|
* @param storage Storage
|
|
113
103
|
* @param name Application name
|
|
104
|
+
* @param debug Debug mode
|
|
114
105
|
*/
|
|
115
|
-
constructor(settings, api, notifier, storage, name) {
|
|
106
|
+
constructor(settings, api, notifier, storage, name, debug = false) {
|
|
116
107
|
/**
|
|
117
108
|
* Pending actions
|
|
118
109
|
*/
|
|
119
110
|
this.pendings = [];
|
|
120
|
-
this._debug = false;
|
|
121
111
|
this._authorized = false;
|
|
122
112
|
this._isReady = false;
|
|
123
113
|
this._isTryingLogin = false;
|
|
@@ -150,6 +140,7 @@ class CoreApp {
|
|
|
150
140
|
this.notifier = notifier;
|
|
151
141
|
this.storage = storage;
|
|
152
142
|
this.name = name;
|
|
143
|
+
this.debug = debug;
|
|
153
144
|
// Fields, attach with the name identifier
|
|
154
145
|
this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
155
146
|
// Device id
|
|
@@ -159,15 +150,14 @@ class CoreApp {
|
|
|
159
150
|
// Load resources
|
|
160
151
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(([cj, _resources]) => {
|
|
161
152
|
CJ = cj.default;
|
|
153
|
+
// Debug
|
|
154
|
+
if (this.debug) {
|
|
155
|
+
console.debug('CoreApp.constructor.ready', this._deviceId, this.fields, cj, currentCulture, currentRegion);
|
|
156
|
+
}
|
|
162
157
|
this.changeRegion(currentRegion);
|
|
163
158
|
this.setup();
|
|
164
159
|
});
|
|
165
160
|
}
|
|
166
|
-
debugIt(...args) {
|
|
167
|
-
if (this.debug) {
|
|
168
|
-
console.debug('CoreApp', ...args);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
161
|
getDeviceId() {
|
|
172
162
|
return this.deviceId.substring(0, 15);
|
|
173
163
|
}
|
|
@@ -293,7 +283,9 @@ class CoreApp {
|
|
|
293
283
|
setApiErrorHandler(api, handlerFor401) {
|
|
294
284
|
api.onError = (error) => {
|
|
295
285
|
// Debug
|
|
296
|
-
this.
|
|
286
|
+
if (this.debug) {
|
|
287
|
+
console.debug('CoreApp.setApiErrorHandler', api, error, handlerFor401);
|
|
288
|
+
}
|
|
297
289
|
// Error code
|
|
298
290
|
const status = error.response
|
|
299
291
|
? api.transformResponse(error.response).status
|
|
@@ -333,7 +325,9 @@ class CoreApp {
|
|
|
333
325
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
334
326
|
api.onRequest = (data) => {
|
|
335
327
|
// Debug
|
|
336
|
-
this.
|
|
328
|
+
if (this.debug) {
|
|
329
|
+
console.debug('CoreApp.setApiLoading.onRequest', api, data, this.notifier.loadingCount);
|
|
330
|
+
}
|
|
337
331
|
if (data.showLoading == null || data.showLoading) {
|
|
338
332
|
this.notifier.showLoading();
|
|
339
333
|
}
|
|
@@ -341,9 +335,15 @@ class CoreApp {
|
|
|
341
335
|
// onComplete, hide loading, rewrite the property to override default action
|
|
342
336
|
api.onComplete = (data) => {
|
|
343
337
|
// Debug
|
|
344
|
-
this.
|
|
338
|
+
if (this.debug) {
|
|
339
|
+
console.debug('CoreApp.setApiLoading.onComplete', api, data, this.notifier.loadingCount, this.lastCalled);
|
|
340
|
+
}
|
|
345
341
|
if (data.showLoading == null || data.showLoading) {
|
|
346
342
|
this.notifier.hideLoading();
|
|
343
|
+
// Debug
|
|
344
|
+
if (this.debug) {
|
|
345
|
+
console.debug('CoreApp.setApiLoading.onComplete.showLoading', api, this.notifier.loadingCount);
|
|
346
|
+
}
|
|
347
347
|
}
|
|
348
348
|
this.lastCalled = true;
|
|
349
349
|
};
|
package/lib/cjs/app/IApp.d.ts
CHANGED
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
62
62
|
* Pending actions
|
|
63
63
|
*/
|
|
64
64
|
readonly pendings: (() => any)[];
|
|
65
|
+
/**
|
|
66
|
+
* Debug mode
|
|
67
|
+
*/
|
|
68
|
+
readonly debug: boolean;
|
|
65
69
|
private _culture;
|
|
66
70
|
/**
|
|
67
71
|
* Culture, like zh-CN
|
|
@@ -92,12 +96,6 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
92
96
|
*/
|
|
93
97
|
get ipData(): IPData | undefined;
|
|
94
98
|
protected set ipData(value: IPData | undefined);
|
|
95
|
-
private _debug;
|
|
96
|
-
/**
|
|
97
|
-
* Is debug mode
|
|
98
|
-
*/
|
|
99
|
-
get debug(): boolean;
|
|
100
|
-
set debug(value: boolean);
|
|
101
99
|
private _userData?;
|
|
102
100
|
/**
|
|
103
101
|
* User data
|
|
@@ -150,9 +148,9 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
150
148
|
* @param notifier Notifier
|
|
151
149
|
* @param storage Storage
|
|
152
150
|
* @param name Application name
|
|
151
|
+
* @param debug Debug mode
|
|
153
152
|
*/
|
|
154
|
-
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
|
|
155
|
-
private debugIt;
|
|
153
|
+
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string, debug?: boolean);
|
|
156
154
|
private getDeviceId;
|
|
157
155
|
private resetKeys;
|
|
158
156
|
/**
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -53,16 +53,6 @@ export class CoreApp {
|
|
|
53
53
|
set ipData(value) {
|
|
54
54
|
this._ipData = value;
|
|
55
55
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Is debug mode
|
|
58
|
-
*/
|
|
59
|
-
get debug() {
|
|
60
|
-
return this._debug;
|
|
61
|
-
}
|
|
62
|
-
set debug(value) {
|
|
63
|
-
this._debug = value;
|
|
64
|
-
this.notifier.debug = value;
|
|
65
|
-
}
|
|
66
56
|
/**
|
|
67
57
|
* User data
|
|
68
58
|
*/
|
|
@@ -108,13 +98,13 @@ export class CoreApp {
|
|
|
108
98
|
* @param notifier Notifier
|
|
109
99
|
* @param storage Storage
|
|
110
100
|
* @param name Application name
|
|
101
|
+
* @param debug Debug mode
|
|
111
102
|
*/
|
|
112
|
-
constructor(settings, api, notifier, storage, name) {
|
|
103
|
+
constructor(settings, api, notifier, storage, name, debug = false) {
|
|
113
104
|
/**
|
|
114
105
|
* Pending actions
|
|
115
106
|
*/
|
|
116
107
|
this.pendings = [];
|
|
117
|
-
this._debug = false;
|
|
118
108
|
this._authorized = false;
|
|
119
109
|
this._isReady = false;
|
|
120
110
|
this._isTryingLogin = false;
|
|
@@ -147,6 +137,7 @@ export class CoreApp {
|
|
|
147
137
|
this.notifier = notifier;
|
|
148
138
|
this.storage = storage;
|
|
149
139
|
this.name = name;
|
|
140
|
+
this.debug = debug;
|
|
150
141
|
// Fields, attach with the name identifier
|
|
151
142
|
this.fields = appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
152
143
|
// Device id
|
|
@@ -156,15 +147,14 @@ export class CoreApp {
|
|
|
156
147
|
// Load resources
|
|
157
148
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(([cj, _resources]) => {
|
|
158
149
|
CJ = cj.default;
|
|
150
|
+
// Debug
|
|
151
|
+
if (this.debug) {
|
|
152
|
+
console.debug('CoreApp.constructor.ready', this._deviceId, this.fields, cj, currentCulture, currentRegion);
|
|
153
|
+
}
|
|
159
154
|
this.changeRegion(currentRegion);
|
|
160
155
|
this.setup();
|
|
161
156
|
});
|
|
162
157
|
}
|
|
163
|
-
debugIt(...args) {
|
|
164
|
-
if (this.debug) {
|
|
165
|
-
console.debug('CoreApp', ...args);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
158
|
getDeviceId() {
|
|
169
159
|
return this.deviceId.substring(0, 15);
|
|
170
160
|
}
|
|
@@ -290,7 +280,9 @@ export class CoreApp {
|
|
|
290
280
|
setApiErrorHandler(api, handlerFor401) {
|
|
291
281
|
api.onError = (error) => {
|
|
292
282
|
// Debug
|
|
293
|
-
this.
|
|
283
|
+
if (this.debug) {
|
|
284
|
+
console.debug('CoreApp.setApiErrorHandler', api, error, handlerFor401);
|
|
285
|
+
}
|
|
294
286
|
// Error code
|
|
295
287
|
const status = error.response
|
|
296
288
|
? api.transformResponse(error.response).status
|
|
@@ -330,7 +322,9 @@ export class CoreApp {
|
|
|
330
322
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
331
323
|
api.onRequest = (data) => {
|
|
332
324
|
// Debug
|
|
333
|
-
this.
|
|
325
|
+
if (this.debug) {
|
|
326
|
+
console.debug('CoreApp.setApiLoading.onRequest', api, data, this.notifier.loadingCount);
|
|
327
|
+
}
|
|
334
328
|
if (data.showLoading == null || data.showLoading) {
|
|
335
329
|
this.notifier.showLoading();
|
|
336
330
|
}
|
|
@@ -338,9 +332,15 @@ export class CoreApp {
|
|
|
338
332
|
// onComplete, hide loading, rewrite the property to override default action
|
|
339
333
|
api.onComplete = (data) => {
|
|
340
334
|
// Debug
|
|
341
|
-
this.
|
|
335
|
+
if (this.debug) {
|
|
336
|
+
console.debug('CoreApp.setApiLoading.onComplete', api, data, this.notifier.loadingCount, this.lastCalled);
|
|
337
|
+
}
|
|
342
338
|
if (data.showLoading == null || data.showLoading) {
|
|
343
339
|
this.notifier.hideLoading();
|
|
340
|
+
// Debug
|
|
341
|
+
if (this.debug) {
|
|
342
|
+
console.debug('CoreApp.setApiLoading.onComplete.showLoading', api, this.notifier.loadingCount);
|
|
343
|
+
}
|
|
344
344
|
}
|
|
345
345
|
this.lastCalled = true;
|
|
346
346
|
};
|
package/lib/mjs/app/IApp.d.ts
CHANGED
package/package.json
CHANGED
package/src/app/CoreApp.ts
CHANGED
|
@@ -124,6 +124,11 @@ export abstract class CoreApp<
|
|
|
124
124
|
*/
|
|
125
125
|
readonly pendings: (() => any)[] = [];
|
|
126
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Debug mode
|
|
129
|
+
*/
|
|
130
|
+
readonly debug: boolean;
|
|
131
|
+
|
|
127
132
|
private _culture!: string;
|
|
128
133
|
/**
|
|
129
134
|
* Culture, like zh-CN
|
|
@@ -174,18 +179,6 @@ export abstract class CoreApp<
|
|
|
174
179
|
this._ipData = value;
|
|
175
180
|
}
|
|
176
181
|
|
|
177
|
-
private _debug: boolean = false;
|
|
178
|
-
/**
|
|
179
|
-
* Is debug mode
|
|
180
|
-
*/
|
|
181
|
-
get debug() {
|
|
182
|
-
return this._debug;
|
|
183
|
-
}
|
|
184
|
-
set debug(value: boolean) {
|
|
185
|
-
this._debug = value;
|
|
186
|
-
this.notifier.debug = value;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
182
|
private _userData?: U;
|
|
190
183
|
/**
|
|
191
184
|
* User data
|
|
@@ -272,13 +265,15 @@ export abstract class CoreApp<
|
|
|
272
265
|
* @param notifier Notifier
|
|
273
266
|
* @param storage Storage
|
|
274
267
|
* @param name Application name
|
|
268
|
+
* @param debug Debug mode
|
|
275
269
|
*/
|
|
276
270
|
protected constructor(
|
|
277
271
|
settings: S,
|
|
278
272
|
api: IApi,
|
|
279
273
|
notifier: INotifier<N, C>,
|
|
280
274
|
storage: IStorage,
|
|
281
|
-
name: string
|
|
275
|
+
name: string,
|
|
276
|
+
debug: boolean = false
|
|
282
277
|
) {
|
|
283
278
|
if (settings?.regions?.length === 0) {
|
|
284
279
|
throw new Error('No regions defined');
|
|
@@ -295,6 +290,7 @@ export abstract class CoreApp<
|
|
|
295
290
|
this.notifier = notifier;
|
|
296
291
|
this.storage = storage;
|
|
297
292
|
this.name = name;
|
|
293
|
+
this.debug = debug;
|
|
298
294
|
|
|
299
295
|
// Fields, attach with the name identifier
|
|
300
296
|
this.fields = appFields.reduce(
|
|
@@ -313,18 +309,25 @@ export abstract class CoreApp<
|
|
|
313
309
|
Promise.all([loadCrypto(), this.changeCulture(currentCulture)]).then(
|
|
314
310
|
([cj, _resources]) => {
|
|
315
311
|
CJ = cj.default;
|
|
312
|
+
|
|
313
|
+
// Debug
|
|
314
|
+
if (this.debug) {
|
|
315
|
+
console.debug(
|
|
316
|
+
'CoreApp.constructor.ready',
|
|
317
|
+
this._deviceId,
|
|
318
|
+
this.fields,
|
|
319
|
+
cj,
|
|
320
|
+
currentCulture,
|
|
321
|
+
currentRegion
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
316
325
|
this.changeRegion(currentRegion);
|
|
317
326
|
this.setup();
|
|
318
327
|
}
|
|
319
328
|
);
|
|
320
329
|
}
|
|
321
330
|
|
|
322
|
-
private debugIt(...args: any[]) {
|
|
323
|
-
if (this.debug) {
|
|
324
|
-
console.debug('CoreApp', ...args);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
331
|
private getDeviceId() {
|
|
329
332
|
return this.deviceId.substring(0, 15);
|
|
330
333
|
}
|
|
@@ -487,7 +490,14 @@ export abstract class CoreApp<
|
|
|
487
490
|
) {
|
|
488
491
|
api.onError = (error: ApiDataError) => {
|
|
489
492
|
// Debug
|
|
490
|
-
this.
|
|
493
|
+
if (this.debug) {
|
|
494
|
+
console.debug(
|
|
495
|
+
'CoreApp.setApiErrorHandler',
|
|
496
|
+
api,
|
|
497
|
+
error,
|
|
498
|
+
handlerFor401
|
|
499
|
+
);
|
|
500
|
+
}
|
|
491
501
|
|
|
492
502
|
// Error code
|
|
493
503
|
const status = error.response
|
|
@@ -529,7 +539,14 @@ export abstract class CoreApp<
|
|
|
529
539
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
530
540
|
api.onRequest = (data) => {
|
|
531
541
|
// Debug
|
|
532
|
-
this.
|
|
542
|
+
if (this.debug) {
|
|
543
|
+
console.debug(
|
|
544
|
+
'CoreApp.setApiLoading.onRequest',
|
|
545
|
+
api,
|
|
546
|
+
data,
|
|
547
|
+
this.notifier.loadingCount
|
|
548
|
+
);
|
|
549
|
+
}
|
|
533
550
|
|
|
534
551
|
if (data.showLoading == null || data.showLoading) {
|
|
535
552
|
this.notifier.showLoading();
|
|
@@ -539,10 +556,27 @@ export abstract class CoreApp<
|
|
|
539
556
|
// onComplete, hide loading, rewrite the property to override default action
|
|
540
557
|
api.onComplete = (data) => {
|
|
541
558
|
// Debug
|
|
542
|
-
this.
|
|
559
|
+
if (this.debug) {
|
|
560
|
+
console.debug(
|
|
561
|
+
'CoreApp.setApiLoading.onComplete',
|
|
562
|
+
api,
|
|
563
|
+
data,
|
|
564
|
+
this.notifier.loadingCount,
|
|
565
|
+
this.lastCalled
|
|
566
|
+
);
|
|
567
|
+
}
|
|
543
568
|
|
|
544
569
|
if (data.showLoading == null || data.showLoading) {
|
|
545
570
|
this.notifier.hideLoading();
|
|
571
|
+
|
|
572
|
+
// Debug
|
|
573
|
+
if (this.debug) {
|
|
574
|
+
console.debug(
|
|
575
|
+
'CoreApp.setApiLoading.onComplete.showLoading',
|
|
576
|
+
api,
|
|
577
|
+
this.notifier.loadingCount
|
|
578
|
+
);
|
|
579
|
+
}
|
|
546
580
|
}
|
|
547
581
|
this.lastCalled = true;
|
|
548
582
|
};
|