@etsoo/appscript 1.4.98 → 1.5.0

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.
@@ -22,13 +22,13 @@ jobs:
22
22
  steps:
23
23
  # https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
24
24
  # so your workflow can access it.
25
- - uses: actions/checkout@v2
25
+ - uses: actions/checkout@v4
26
26
 
27
27
  # Set up your GitHub Actions workflow with a specific version of node.js
28
28
  # Setup .npmrc file to publish to npm
29
- - uses: actions/setup-node@v1
29
+ - uses: actions/setup-node@v4
30
30
  with:
31
- node-version: '18.x'
31
+ node-version: '20.x'
32
32
  registry-url: 'https://registry.npmjs.org'
33
33
 
34
34
  # Named after Continuous Integration, installs dependencies directly from package-lock.json
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2004-2024 ETSOO® (亿速思维 ®), https://www.etsoo.com
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
@@ -92,6 +92,10 @@ 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
+ /**
96
+ * Is debug mode
97
+ */
98
+ debug: boolean;
95
99
  private _userData?;
96
100
  /**
97
101
  * User data
@@ -146,6 +150,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
146
150
  * @param name Application name
147
151
  */
148
152
  protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
153
+ private debugIt;
149
154
  private getDeviceId;
150
155
  private resetKeys;
151
156
  /**
@@ -107,6 +107,10 @@ class CoreApp {
107
107
  * Pending actions
108
108
  */
109
109
  this.pendings = [];
110
+ /**
111
+ * Is debug mode
112
+ */
113
+ this.debug = false;
110
114
  this._authorized = false;
111
115
  this._isReady = false;
112
116
  this._isTryingLogin = false;
@@ -143,6 +147,8 @@ class CoreApp {
143
147
  this.fields = IApp_1.appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
144
148
  // Device id
145
149
  this._deviceId = storage.getData(this.fields.deviceId, '');
150
+ // Debug
151
+ this.debugIt('constructor', this.fields, this._deviceId);
146
152
  this.setApi(api);
147
153
  const { currentCulture, currentRegion } = settings;
148
154
  // Load resources
@@ -152,6 +158,11 @@ class CoreApp {
152
158
  this.setup();
153
159
  });
154
160
  }
161
+ debugIt(...args) {
162
+ if (this.debug) {
163
+ console.debug('CoreApp', ...args);
164
+ }
165
+ }
155
166
  getDeviceId() {
156
167
  return this.deviceId.substring(0, 15);
157
168
  }
@@ -276,6 +287,8 @@ class CoreApp {
276
287
  */
277
288
  setApiErrorHandler(api, handlerFor401) {
278
289
  api.onError = (error) => {
290
+ // Debug
291
+ this.debugIt('setApiErrorHandler', api, error, handlerFor401);
279
292
  // Error code
280
293
  const status = error.response
281
294
  ? api.transformResponse(error.response).status
@@ -314,12 +327,16 @@ class CoreApp {
314
327
  setApiLoading(api) {
315
328
  // onRequest, show loading or not, rewrite the property to override default action
316
329
  api.onRequest = (data) => {
330
+ // Debug
331
+ this.debugIt('setApiLoading', 'onRequest', data);
317
332
  if (data.showLoading == null || data.showLoading) {
318
333
  this.notifier.showLoading();
319
334
  }
320
335
  };
321
336
  // onComplete, hide loading, rewrite the property to override default action
322
337
  api.onComplete = (data) => {
338
+ // Debug
339
+ this.debugIt('setApiLoading', 'onComplete', data);
323
340
  if (data.showLoading == null || data.showLoading) {
324
341
  this.notifier.hideLoading();
325
342
  }
@@ -1262,6 +1279,7 @@ class CoreApp {
1262
1279
  */
1263
1280
  pageExit() {
1264
1281
  this.lastWarning?.dismiss();
1282
+ this.notifier.hideLoading(true);
1265
1283
  }
1266
1284
  /**
1267
1285
  * Refresh countdown
@@ -133,6 +133,10 @@ export interface IApp {
133
133
  * Pending actions
134
134
  */
135
135
  readonly pendings: (() => any)[];
136
+ /**
137
+ * Is debug mode
138
+ */
139
+ debug: boolean;
136
140
  /**
137
141
  * IP data
138
142
  */
@@ -92,6 +92,10 @@ 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
+ /**
96
+ * Is debug mode
97
+ */
98
+ debug: boolean;
95
99
  private _userData?;
96
100
  /**
97
101
  * User data
@@ -146,6 +150,7 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
146
150
  * @param name Application name
147
151
  */
148
152
  protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string);
153
+ private debugIt;
149
154
  private getDeviceId;
150
155
  private resetKeys;
151
156
  /**
@@ -104,6 +104,10 @@ export class CoreApp {
104
104
  * Pending actions
105
105
  */
106
106
  this.pendings = [];
107
+ /**
108
+ * Is debug mode
109
+ */
110
+ this.debug = false;
107
111
  this._authorized = false;
108
112
  this._isReady = false;
109
113
  this._isTryingLogin = false;
@@ -140,6 +144,8 @@ export class CoreApp {
140
144
  this.fields = appFields.reduce((a, v) => ({ ...a, [v]: 'smarterp-' + v + '-' + name }), {});
141
145
  // Device id
142
146
  this._deviceId = storage.getData(this.fields.deviceId, '');
147
+ // Debug
148
+ this.debugIt('constructor', this.fields, this._deviceId);
143
149
  this.setApi(api);
144
150
  const { currentCulture, currentRegion } = settings;
145
151
  // Load resources
@@ -149,6 +155,11 @@ export class CoreApp {
149
155
  this.setup();
150
156
  });
151
157
  }
158
+ debugIt(...args) {
159
+ if (this.debug) {
160
+ console.debug('CoreApp', ...args);
161
+ }
162
+ }
152
163
  getDeviceId() {
153
164
  return this.deviceId.substring(0, 15);
154
165
  }
@@ -273,6 +284,8 @@ export class CoreApp {
273
284
  */
274
285
  setApiErrorHandler(api, handlerFor401) {
275
286
  api.onError = (error) => {
287
+ // Debug
288
+ this.debugIt('setApiErrorHandler', api, error, handlerFor401);
276
289
  // Error code
277
290
  const status = error.response
278
291
  ? api.transformResponse(error.response).status
@@ -311,12 +324,16 @@ export class CoreApp {
311
324
  setApiLoading(api) {
312
325
  // onRequest, show loading or not, rewrite the property to override default action
313
326
  api.onRequest = (data) => {
327
+ // Debug
328
+ this.debugIt('setApiLoading', 'onRequest', data);
314
329
  if (data.showLoading == null || data.showLoading) {
315
330
  this.notifier.showLoading();
316
331
  }
317
332
  };
318
333
  // onComplete, hide loading, rewrite the property to override default action
319
334
  api.onComplete = (data) => {
335
+ // Debug
336
+ this.debugIt('setApiLoading', 'onComplete', data);
320
337
  if (data.showLoading == null || data.showLoading) {
321
338
  this.notifier.hideLoading();
322
339
  }
@@ -1259,6 +1276,7 @@ export class CoreApp {
1259
1276
  */
1260
1277
  pageExit() {
1261
1278
  this.lastWarning?.dismiss();
1279
+ this.notifier.hideLoading(true);
1262
1280
  }
1263
1281
  /**
1264
1282
  * Refresh countdown
@@ -133,6 +133,10 @@ export interface IApp {
133
133
  * Pending actions
134
134
  */
135
135
  readonly pendings: (() => any)[];
136
+ /**
137
+ * Is debug mode
138
+ */
139
+ debug: boolean;
136
140
  /**
137
141
  * IP data
138
142
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.4.98",
3
+ "version": "1.5.0",
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.43",
56
- "@etsoo/restclient": "^1.1.6",
57
- "@etsoo/shared": "^1.2.42",
55
+ "@etsoo/notificationbase": "^1.1.45",
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.7",
62
- "@babel/core": "^7.24.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.24.7",
65
- "@babel/runtime-corejs3": "^7.24.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.1.4",
71
- "typescript": "^5.4.5"
70
+ "ts-jest": "^29.2.4",
71
+ "typescript": "^5.5.4"
72
72
  }
73
73
  }
@@ -174,6 +174,11 @@ export abstract class CoreApp<
174
174
  this._ipData = value;
175
175
  }
176
176
 
177
+ /**
178
+ * Is debug mode
179
+ */
180
+ debug: boolean = false;
181
+
177
182
  private _userData?: U;
178
183
  /**
179
184
  * User data
@@ -293,6 +298,9 @@ export abstract class CoreApp<
293
298
  // Device id
294
299
  this._deviceId = storage.getData(this.fields.deviceId, '');
295
300
 
301
+ // Debug
302
+ this.debugIt('constructor', this.fields, this._deviceId);
303
+
296
304
  this.setApi(api);
297
305
 
298
306
  const { currentCulture, currentRegion } = settings;
@@ -307,6 +315,12 @@ export abstract class CoreApp<
307
315
  );
308
316
  }
309
317
 
318
+ private debugIt(...args: any[]) {
319
+ if (this.debug) {
320
+ console.debug('CoreApp', ...args);
321
+ }
322
+ }
323
+
310
324
  private getDeviceId() {
311
325
  return this.deviceId.substring(0, 15);
312
326
  }
@@ -468,6 +482,9 @@ export abstract class CoreApp<
468
482
  handlerFor401?: boolean | (() => Promise<void>)
469
483
  ) {
470
484
  api.onError = (error: ApiDataError) => {
485
+ // Debug
486
+ this.debugIt('setApiErrorHandler', api, error, handlerFor401);
487
+
471
488
  // Error code
472
489
  const status = error.response
473
490
  ? api.transformResponse(error.response).status
@@ -507,6 +524,9 @@ export abstract class CoreApp<
507
524
  public setApiLoading(api: IApi) {
508
525
  // onRequest, show loading or not, rewrite the property to override default action
509
526
  api.onRequest = (data) => {
527
+ // Debug
528
+ this.debugIt('setApiLoading', 'onRequest', data);
529
+
510
530
  if (data.showLoading == null || data.showLoading) {
511
531
  this.notifier.showLoading();
512
532
  }
@@ -514,6 +534,9 @@ export abstract class CoreApp<
514
534
 
515
535
  // onComplete, hide loading, rewrite the property to override default action
516
536
  api.onComplete = (data) => {
537
+ // Debug
538
+ this.debugIt('setApiLoading', 'onComplete', data);
539
+
517
540
  if (data.showLoading == null || data.showLoading) {
518
541
  this.notifier.hideLoading();
519
542
  }
@@ -1699,6 +1722,7 @@ export abstract class CoreApp<
1699
1722
  */
1700
1723
  pageExit() {
1701
1724
  this.lastWarning?.dismiss();
1725
+ this.notifier.hideLoading(true);
1702
1726
  }
1703
1727
 
1704
1728
  /**
package/src/app/IApp.ts CHANGED
@@ -185,6 +185,11 @@ export interface IApp {
185
185
  */
186
186
  readonly pendings: (() => any)[];
187
187
 
188
+ /**
189
+ * Is debug mode
190
+ */
191
+ debug: boolean;
192
+
188
193
  /**
189
194
  * IP data
190
195
  */