@etsoo/appscript 1.4.99 → 1.5.1
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/LICENSE +1 -1
- package/lib/cjs/app/CoreApp.d.ts +7 -0
- package/lib/cjs/app/CoreApp.js +25 -0
- package/lib/cjs/app/IApp.d.ts +4 -0
- package/lib/mjs/app/CoreApp.d.ts +7 -0
- package/lib/mjs/app/CoreApp.js +25 -0
- package/lib/mjs/app/IApp.d.ts +4 -0
- package/package.json +10 -10
- package/src/app/CoreApp.ts +31 -0
- package/src/app/IApp.ts +5 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2004-2024 ETSOO® (亿速思维 ®), https://
|
|
3
|
+
Copyright (c) 2004-2024 ETSOO ® (亿速思维 ®), https://etsoo.com, https://etsoo.nz
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/lib/cjs/app/CoreApp.d.ts
CHANGED
|
@@ -92,6 +92,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
92
92
|
*/
|
|
93
93
|
get ipData(): IPData | undefined;
|
|
94
94
|
protected set ipData(value: IPData | undefined);
|
|
95
|
+
private _debug;
|
|
96
|
+
/**
|
|
97
|
+
* Is debug mode
|
|
98
|
+
*/
|
|
99
|
+
get debug(): boolean;
|
|
100
|
+
set debug(value: boolean);
|
|
95
101
|
private _userData?;
|
|
96
102
|
/**
|
|
97
103
|
* User data
|
|
@@ -146,6 +152,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
146
152
|
* @param name Application name
|
|
147
153
|
*/
|
|
148
154
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
|
|
155
|
+
private debugIt;
|
|
149
156
|
private getDeviceId;
|
|
150
157
|
private resetKeys;
|
|
151
158
|
/**
|
package/lib/cjs/app/CoreApp.js
CHANGED
|
@@ -56,6 +56,16 @@ 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
|
+
}
|
|
59
69
|
/**
|
|
60
70
|
* User data
|
|
61
71
|
*/
|
|
@@ -107,6 +117,7 @@ class CoreApp {
|
|
|
107
117
|
* Pending actions
|
|
108
118
|
*/
|
|
109
119
|
this.pendings = [];
|
|
120
|
+
this._debug = false;
|
|
110
121
|
this._authorized = false;
|
|
111
122
|
this._isReady = false;
|
|
112
123
|
this._isTryingLogin = false;
|
|
@@ -143,6 +154,8 @@ class CoreApp {
|
|
|
143
154
|
this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
144
155
|
// Device id
|
|
145
156
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
157
|
+
// Debug
|
|
158
|
+
this.debugIt('constructor', this.fields, this._deviceId);
|
|
146
159
|
this.setApi(api);
|
|
147
160
|
const { currentCulture, currentRegion } = settings;
|
|
148
161
|
// Load resources
|
|
@@ -152,6 +165,11 @@ class CoreApp {
|
|
|
152
165
|
this.setup();
|
|
153
166
|
});
|
|
154
167
|
}
|
|
168
|
+
debugIt(...args) {
|
|
169
|
+
if (this.debug) {
|
|
170
|
+
console.debug('CoreApp', ...args);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
155
173
|
getDeviceId() {
|
|
156
174
|
return this.deviceId.substring(0, 15);
|
|
157
175
|
}
|
|
@@ -276,6 +294,8 @@ class CoreApp {
|
|
|
276
294
|
*/
|
|
277
295
|
setApiErrorHandler(api, handlerFor401) {
|
|
278
296
|
api.onError = (error) => {
|
|
297
|
+
// Debug
|
|
298
|
+
this.debugIt('setApiErrorHandler', api, error, handlerFor401);
|
|
279
299
|
// Error code
|
|
280
300
|
const status = error.response
|
|
281
301
|
? api.transformResponse(error.response).status
|
|
@@ -314,12 +334,16 @@ class CoreApp {
|
|
|
314
334
|
setApiLoading(api) {
|
|
315
335
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
316
336
|
api.onRequest = (data) => {
|
|
337
|
+
// Debug
|
|
338
|
+
this.debugIt('setApiLoading', 'onRequest', data);
|
|
317
339
|
if (data.showLoading == null || data.showLoading) {
|
|
318
340
|
this.notifier.showLoading();
|
|
319
341
|
}
|
|
320
342
|
};
|
|
321
343
|
// onComplete, hide loading, rewrite the property to override default action
|
|
322
344
|
api.onComplete = (data) => {
|
|
345
|
+
// Debug
|
|
346
|
+
this.debugIt('setApiLoading', 'onComplete', data);
|
|
323
347
|
if (data.showLoading == null || data.showLoading) {
|
|
324
348
|
this.notifier.hideLoading();
|
|
325
349
|
}
|
|
@@ -1262,6 +1286,7 @@ class CoreApp {
|
|
|
1262
1286
|
*/
|
|
1263
1287
|
pageExit() {
|
|
1264
1288
|
this.lastWarning?.dismiss();
|
|
1289
|
+
this.notifier.hideLoading(true);
|
|
1265
1290
|
}
|
|
1266
1291
|
/**
|
|
1267
1292
|
* Refresh countdown
|
package/lib/cjs/app/IApp.d.ts
CHANGED
package/lib/mjs/app/CoreApp.d.ts
CHANGED
|
@@ -92,6 +92,12 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
92
92
|
*/
|
|
93
93
|
get ipData(): IPData | undefined;
|
|
94
94
|
protected set ipData(value: IPData | undefined);
|
|
95
|
+
private _debug;
|
|
96
|
+
/**
|
|
97
|
+
* Is debug mode
|
|
98
|
+
*/
|
|
99
|
+
get debug(): boolean;
|
|
100
|
+
set debug(value: boolean);
|
|
95
101
|
private _userData?;
|
|
96
102
|
/**
|
|
97
103
|
* User data
|
|
@@ -146,6 +152,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
|
|
|
146
152
|
* @param name Application name
|
|
147
153
|
*/
|
|
148
154
|
protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
|
|
155
|
+
private debugIt;
|
|
149
156
|
private getDeviceId;
|
|
150
157
|
private resetKeys;
|
|
151
158
|
/**
|
package/lib/mjs/app/CoreApp.js
CHANGED
|
@@ -53,6 +53,16 @@ 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
|
+
}
|
|
56
66
|
/**
|
|
57
67
|
* User data
|
|
58
68
|
*/
|
|
@@ -104,6 +114,7 @@ export class CoreApp {
|
|
|
104
114
|
* Pending actions
|
|
105
115
|
*/
|
|
106
116
|
this.pendings = [];
|
|
117
|
+
this._debug = false;
|
|
107
118
|
this._authorized = false;
|
|
108
119
|
this._isReady = false;
|
|
109
120
|
this._isTryingLogin = false;
|
|
@@ -140,6 +151,8 @@ export class CoreApp {
|
|
|
140
151
|
this.fields = appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
|
|
141
152
|
// Device id
|
|
142
153
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
154
|
+
// Debug
|
|
155
|
+
this.debugIt('constructor', this.fields, this._deviceId);
|
|
143
156
|
this.setApi(api);
|
|
144
157
|
const { currentCulture, currentRegion } = settings;
|
|
145
158
|
// Load resources
|
|
@@ -149,6 +162,11 @@ export class CoreApp {
|
|
|
149
162
|
this.setup();
|
|
150
163
|
});
|
|
151
164
|
}
|
|
165
|
+
debugIt(...args) {
|
|
166
|
+
if (this.debug) {
|
|
167
|
+
console.debug('CoreApp', ...args);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
152
170
|
getDeviceId() {
|
|
153
171
|
return this.deviceId.substring(0, 15);
|
|
154
172
|
}
|
|
@@ -273,6 +291,8 @@ export class CoreApp {
|
|
|
273
291
|
*/
|
|
274
292
|
setApiErrorHandler(api, handlerFor401) {
|
|
275
293
|
api.onError = (error) => {
|
|
294
|
+
// Debug
|
|
295
|
+
this.debugIt('setApiErrorHandler', api, error, handlerFor401);
|
|
276
296
|
// Error code
|
|
277
297
|
const status = error.response
|
|
278
298
|
? api.transformResponse(error.response).status
|
|
@@ -311,12 +331,16 @@ export class CoreApp {
|
|
|
311
331
|
setApiLoading(api) {
|
|
312
332
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
313
333
|
api.onRequest = (data) => {
|
|
334
|
+
// Debug
|
|
335
|
+
this.debugIt('setApiLoading', 'onRequest', data);
|
|
314
336
|
if (data.showLoading == null || data.showLoading) {
|
|
315
337
|
this.notifier.showLoading();
|
|
316
338
|
}
|
|
317
339
|
};
|
|
318
340
|
// onComplete, hide loading, rewrite the property to override default action
|
|
319
341
|
api.onComplete = (data) => {
|
|
342
|
+
// Debug
|
|
343
|
+
this.debugIt('setApiLoading', 'onComplete', data);
|
|
320
344
|
if (data.showLoading == null || data.showLoading) {
|
|
321
345
|
this.notifier.hideLoading();
|
|
322
346
|
}
|
|
@@ -1259,6 +1283,7 @@ export class CoreApp {
|
|
|
1259
1283
|
*/
|
|
1260
1284
|
pageExit() {
|
|
1261
1285
|
this.lastWarning?.dismiss();
|
|
1286
|
+
this.notifier.hideLoading(true);
|
|
1262
1287
|
}
|
|
1263
1288
|
/**
|
|
1264
1289
|
* Refresh countdown
|
package/lib/mjs/app/IApp.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -52,22 +52,22 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/ETSOO/AppScript#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@etsoo/notificationbase": "^1.1.
|
|
56
|
-
"@etsoo/restclient": "^1.1.
|
|
57
|
-
"@etsoo/shared": "^1.2.
|
|
55
|
+
"@etsoo/notificationbase": "^1.1.46",
|
|
56
|
+
"@etsoo/restclient": "^1.1.8",
|
|
57
|
+
"@etsoo/shared": "^1.2.44",
|
|
58
58
|
"crypto-js": "^4.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@babel/cli": "^7.24.
|
|
62
|
-
"@babel/core": "^7.
|
|
61
|
+
"@babel/cli": "^7.24.8",
|
|
62
|
+
"@babel/core": "^7.25.2",
|
|
63
63
|
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
64
|
-
"@babel/preset-env": "^7.
|
|
65
|
-
"@babel/runtime-corejs3": "^7.
|
|
64
|
+
"@babel/preset-env": "^7.25.3",
|
|
65
|
+
"@babel/runtime-corejs3": "^7.25.0",
|
|
66
66
|
"@types/crypto-js": "^4.2.2",
|
|
67
67
|
"@types/jest": "^29.5.12",
|
|
68
68
|
"jest": "^29.7.0",
|
|
69
69
|
"jest-environment-jsdom": "^29.7.0",
|
|
70
|
-
"ts-jest": "^29.
|
|
71
|
-
"typescript": "^5.4
|
|
70
|
+
"ts-jest": "^29.2.4",
|
|
71
|
+
"typescript": "^5.5.4"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -174,6 +174,18 @@ export abstract class CoreApp<
|
|
|
174
174
|
this._ipData = value;
|
|
175
175
|
}
|
|
176
176
|
|
|
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
|
+
|
|
177
189
|
private _userData?: U;
|
|
178
190
|
/**
|
|
179
191
|
* User data
|
|
@@ -293,6 +305,9 @@ export abstract class CoreApp<
|
|
|
293
305
|
// Device id
|
|
294
306
|
this._deviceId = storage.getData(this.fields.deviceId, '');
|
|
295
307
|
|
|
308
|
+
// Debug
|
|
309
|
+
this.debugIt('constructor', this.fields, this._deviceId);
|
|
310
|
+
|
|
296
311
|
this.setApi(api);
|
|
297
312
|
|
|
298
313
|
const { currentCulture, currentRegion } = settings;
|
|
@@ -307,6 +322,12 @@ export abstract class CoreApp<
|
|
|
307
322
|
);
|
|
308
323
|
}
|
|
309
324
|
|
|
325
|
+
private debugIt(...args: any[]) {
|
|
326
|
+
if (this.debug) {
|
|
327
|
+
console.debug('CoreApp', ...args);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
310
331
|
private getDeviceId() {
|
|
311
332
|
return this.deviceId.substring(0, 15);
|
|
312
333
|
}
|
|
@@ -468,6 +489,9 @@ export abstract class CoreApp<
|
|
|
468
489
|
handlerFor401?: boolean | (() => Promise<void>)
|
|
469
490
|
) {
|
|
470
491
|
api.onError = (error: ApiDataError) => {
|
|
492
|
+
// Debug
|
|
493
|
+
this.debugIt('setApiErrorHandler', api, error, handlerFor401);
|
|
494
|
+
|
|
471
495
|
// Error code
|
|
472
496
|
const status = error.response
|
|
473
497
|
? api.transformResponse(error.response).status
|
|
@@ -507,6 +531,9 @@ export abstract class CoreApp<
|
|
|
507
531
|
public setApiLoading(api: IApi) {
|
|
508
532
|
// onRequest, show loading or not, rewrite the property to override default action
|
|
509
533
|
api.onRequest = (data) => {
|
|
534
|
+
// Debug
|
|
535
|
+
this.debugIt('setApiLoading', 'onRequest', data);
|
|
536
|
+
|
|
510
537
|
if (data.showLoading == null || data.showLoading) {
|
|
511
538
|
this.notifier.showLoading();
|
|
512
539
|
}
|
|
@@ -514,6 +541,9 @@ export abstract class CoreApp<
|
|
|
514
541
|
|
|
515
542
|
// onComplete, hide loading, rewrite the property to override default action
|
|
516
543
|
api.onComplete = (data) => {
|
|
544
|
+
// Debug
|
|
545
|
+
this.debugIt('setApiLoading', 'onComplete', data);
|
|
546
|
+
|
|
517
547
|
if (data.showLoading == null || data.showLoading) {
|
|
518
548
|
this.notifier.hideLoading();
|
|
519
549
|
}
|
|
@@ -1699,6 +1729,7 @@ export abstract class CoreApp<
|
|
|
1699
1729
|
*/
|
|
1700
1730
|
pageExit() {
|
|
1701
1731
|
this.lastWarning?.dismiss();
|
|
1732
|
+
this.notifier.hideLoading(true);
|
|
1702
1733
|
}
|
|
1703
1734
|
|
|
1704
1735
|
/**
|