@etsoo/appscript 1.5.3 → 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.
@@ -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,8 +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);
153
+ protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string, debug?: boolean);
155
154
  private getDeviceId;
156
155
  private resetKeys;
157
156
  /**
@@ -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,6 +150,10 @@ 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
  });
@@ -136,7 +136,7 @@ export interface IApp {
136
136
  /**
137
137
  * Is debug mode
138
138
  */
139
- debug: boolean;
139
+ readonly debug: boolean;
140
140
  /**
141
141
  * IP data
142
142
  */
@@ -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,8 +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);
153
+ protected constructor(settings: S, api: IApi, notifier: INotifier<N, C>, storage: IStorage, name: string, debug?: boolean);
155
154
  private getDeviceId;
156
155
  private resetKeys;
157
156
  /**
@@ -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,6 +147,10 @@ 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
  });
@@ -136,7 +136,7 @@ export interface IApp {
136
136
  /**
137
137
  * Is debug mode
138
138
  */
139
- debug: boolean;
139
+ readonly debug: boolean;
140
140
  /**
141
141
  * IP data
142
142
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -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,6 +309,19 @@ 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
  }
package/src/app/IApp.ts CHANGED
@@ -188,7 +188,7 @@ export interface IApp {
188
188
  /**
189
189
  * Is debug mode
190
190
  */
191
- debug: boolean;
191
+ readonly debug: boolean;
192
192
 
193
193
  /**
194
194
  * IP data