tnp-core 13.1.17 → 13.1.20

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.
Files changed (103) hide show
  1. package/README.md +3 -3
  2. package/app.d.ts +1 -1
  3. package/app.js +6 -6
  4. package/browser/README.md +24 -24
  5. package/browser/esm2020/lib/core-config.mjs +5 -5
  6. package/browser/esm2020/lib/core-imports.mjs +107 -107
  7. package/browser/esm2020/lib/core-models.mjs +1 -1
  8. package/browser/esm2020/lib/helpers-isomorphic.mjs +34 -53
  9. package/browser/esm2020/lib/helpers-messages.mjs +434 -434
  10. package/browser/esm2020/lib/helpers.mjs +939 -939
  11. package/browser/esm2020/lib/index.mjs +7 -7
  12. package/browser/esm2020/lib/progress-data.mjs +50 -50
  13. package/browser/esm2020/public-api.mjs +1 -1
  14. package/browser/esm2020/tnp-core.mjs +4 -4
  15. package/browser/fesm2015/tnp-core.mjs +1553 -1571
  16. package/browser/fesm2015/tnp-core.mjs.map +1 -1
  17. package/browser/fesm2020/tnp-core.mjs +1551 -1569
  18. package/browser/fesm2020/tnp-core.mjs.map +1 -1
  19. package/browser/lib/core-config.d.ts +5 -5
  20. package/browser/lib/core-imports.d.ts +6 -6
  21. package/browser/lib/core-models.d.ts +42 -42
  22. package/browser/lib/helpers-isomorphic.d.ts +6 -7
  23. package/browser/lib/helpers-messages.d.ts +11 -11
  24. package/browser/lib/helpers.d.ts +33 -33
  25. package/browser/lib/index.d.ts +7 -7
  26. package/browser/lib/progress-data.d.ts +18 -18
  27. package/browser/public-api.d.ts +1 -1
  28. package/browser/tnp-core.d.ts +5 -5
  29. package/client/README.md +24 -24
  30. package/client/esm2020/lib/core-config.mjs +5 -5
  31. package/client/esm2020/lib/core-imports.mjs +107 -107
  32. package/client/esm2020/lib/core-models.mjs +1 -1
  33. package/client/esm2020/lib/helpers-isomorphic.mjs +34 -53
  34. package/client/esm2020/lib/helpers-messages.mjs +434 -434
  35. package/client/esm2020/lib/helpers.mjs +939 -939
  36. package/client/esm2020/lib/index.mjs +7 -7
  37. package/client/esm2020/lib/progress-data.mjs +50 -50
  38. package/client/esm2020/public-api.mjs +1 -1
  39. package/client/esm2020/tnp-core.mjs +4 -4
  40. package/client/fesm2015/tnp-core.mjs +1553 -1571
  41. package/client/fesm2015/tnp-core.mjs.map +1 -1
  42. package/client/fesm2020/tnp-core.mjs +1551 -1569
  43. package/client/fesm2020/tnp-core.mjs.map +1 -1
  44. package/client/lib/core-config.d.ts +5 -5
  45. package/client/lib/core-imports.d.ts +6 -6
  46. package/client/lib/core-models.d.ts +42 -42
  47. package/client/lib/helpers-isomorphic.d.ts +6 -7
  48. package/client/lib/helpers-messages.d.ts +11 -11
  49. package/client/lib/helpers.d.ts +33 -33
  50. package/client/lib/index.d.ts +7 -7
  51. package/client/lib/progress-data.d.ts +18 -18
  52. package/client/public-api.d.ts +1 -1
  53. package/client/tnp-core.d.ts +5 -5
  54. package/index.d.ts +1 -1
  55. package/index.js +5 -5
  56. package/lib/core-config.d.ts +5 -5
  57. package/lib/core-config.js +9 -9
  58. package/lib/core-imports.d.ts +31 -31
  59. package/lib/core-imports.js +113 -113
  60. package/lib/core-models.d.ts +42 -42
  61. package/lib/core-models.js +3 -3
  62. package/lib/helpers-isomorphic.d.ts +6 -9
  63. package/lib/helpers-isomorphic.js +56 -74
  64. package/lib/helpers-isomorphic.js.map +1 -1
  65. package/lib/helpers-messages.d.ts +11 -11
  66. package/lib/helpers-messages.js +474 -474
  67. package/lib/helpers.d.ts +111 -111
  68. package/lib/helpers.js +1127 -1127
  69. package/lib/index.d.ts +7 -7
  70. package/lib/index.js +13 -13
  71. package/lib/progress-data.d.ts +18 -18
  72. package/lib/progress-data.js +59 -59
  73. package/lib/public-api.d.ts +7 -7
  74. package/lib/public-api.js +13 -13
  75. package/package.json +2 -2
  76. package/package.json_devDependencies.json +202 -202
  77. package/package.json_tnp.json5 +62 -62
  78. package/tmp-environment.json +13 -12
  79. package/websql/README.md +24 -24
  80. package/websql/esm2020/lib/core-config.mjs +5 -5
  81. package/websql/esm2020/lib/core-imports.mjs +108 -108
  82. package/websql/esm2020/lib/core-models.mjs +1 -1
  83. package/websql/esm2020/lib/helpers-isomorphic.mjs +35 -55
  84. package/websql/esm2020/lib/helpers-messages.mjs +434 -434
  85. package/websql/esm2020/lib/helpers.mjs +939 -939
  86. package/websql/esm2020/lib/index.mjs +7 -7
  87. package/websql/esm2020/lib/progress-data.mjs +50 -50
  88. package/websql/esm2020/public-api.mjs +1 -1
  89. package/websql/esm2020/tnp-core.mjs +4 -4
  90. package/websql/fesm2015/tnp-core.mjs +1548 -1567
  91. package/websql/fesm2015/tnp-core.mjs.map +1 -1
  92. package/websql/fesm2020/tnp-core.mjs +1546 -1565
  93. package/websql/fesm2020/tnp-core.mjs.map +1 -1
  94. package/websql/lib/core-config.d.ts +5 -5
  95. package/websql/lib/core-imports.d.ts +8 -8
  96. package/websql/lib/core-models.d.ts +42 -42
  97. package/websql/lib/helpers-isomorphic.d.ts +6 -9
  98. package/websql/lib/helpers-messages.d.ts +11 -11
  99. package/websql/lib/helpers.d.ts +33 -33
  100. package/websql/lib/index.d.ts +7 -7
  101. package/websql/lib/progress-data.d.ts +18 -18
  102. package/websql/public-api.d.ts +1 -1
  103. package/websql/tnp-core.d.ts +5 -5
@@ -1,474 +1,474 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HelpersMessages = void 0;
4
- var tslib_1 = require("tslib");
5
- var core_imports_1 = require("./core-imports");
6
- // import { config } from 'tnp-config';
7
- // import { PROGRESS_DATA } from 'tnp-models';
8
- var index_1 = require("./index");
9
- var helpers_isomorphic_1 = require("./helpers-isomorphic");
10
- var progress_data_1 = require("./progress-data");
11
- // TODO handle global.testMode ?
12
- var KEY = {
13
- LAST_ERROR: Symbol(),
14
- LAST_INFO: Symbol(),
15
- LAST_WARN: Symbol(),
16
- LAST_LOG: Symbol(),
17
- LAST_SUCCESS: Symbol(),
18
- LAST_TASK_STARTED: Symbol(),
19
- LAST_TASK_DONE: Symbol(),
20
- };
21
- var KEY_COUNT = {
22
- LAST_ERROR: Symbol(),
23
- LAST_INFO: Symbol(),
24
- LAST_WARN: Symbol(),
25
- LAST_LOG: Symbol(),
26
- LAST_SUCCESS: Symbol(),
27
- LAST_TASK_STARTED: Symbol(),
28
- LAST_TASK_DONE: Symbol(),
29
- };
30
- //#region @backend
31
- global[KEY_COUNT.LAST_ERROR] = 0;
32
- global[KEY_COUNT.LAST_INFO] = 0;
33
- global[KEY_COUNT.LAST_WARN] = 0;
34
- global[KEY_COUNT.LAST_LOG] = 0;
35
- global[KEY_COUNT.LAST_SUCCESS] = 0;
36
- global[KEY_COUNT.LAST_TASK_STARTED] = 0;
37
- global[KEY_COUNT.LAST_TASK_DONE] = 0;
38
- var useSpinner = global['spinnerInParentProcess'];
39
- //#endregion
40
- var LIMIT = 10;
41
- // export class Log {
42
- // private static _instance: Log;
43
- // public Instance() {
44
- // if (!Log._instance) {
45
- // Log._instance = new Log();
46
- // }
47
- // return Log._instance;
48
- // }
49
- // create(name: string, level?: Level) {
50
- // if (level === void 0) {
51
- // level = Level.DATA;
52
- // }
53
- // return {
54
- // d(details: string, debugLevel?: number) {
55
- // return Helpers.log(`[${name}] ${details}`, debugLevel)
56
- // },
57
- // i(details: string) {
58
- // return Helpers.info(`[${name}] ${details}`)
59
- // },
60
- // w(details: string, noExit = false, noTrace = false) {
61
- // return Helpers.error(`[${name}] ${details}`, noExit, noTrace);
62
- // },
63
- // er(details: string, ) {
64
- // return Helpers.info(`[${name}] ${details}`)
65
- // },
66
- // }
67
- // }
68
- // }
69
- var HelpersMessages = /** @class */ (function (_super) {
70
- tslib_1.__extends(HelpersMessages, _super);
71
- function HelpersMessages() {
72
- return _super !== null && _super.apply(this, arguments) || this;
73
- }
74
- HelpersMessages.prototype.msgCacheClear = function () {
75
- //#region @backend
76
- global[KEY.LAST_LOG] = void 0;
77
- global[KEY.LAST_WARN] = void 0;
78
- global[KEY.LAST_ERROR] = void 0;
79
- global[KEY.LAST_INFO] = void 0;
80
- //#endregion
81
- };
82
- HelpersMessages.prototype.error = function (details, noExit, noTrace) {
83
- if (noExit === void 0) { noExit = false; }
84
- if (noTrace === void 0) { noTrace = false; }
85
- //#region browser mode
86
- if (index_1.Helpers.isBrowser) {
87
- console.error(details);
88
- return;
89
- }
90
- //#endregion
91
- //#region @backend
92
- // Error.stackTraceLimit = Infinity;
93
- if (!global.globalSystemToolMode) {
94
- noTrace = true;
95
- }
96
- details = transformData(details);
97
- var display = function (dot) {
98
- if (dot === void 0) { dot = false; }
99
- if (global.tnpNonInteractive) {
100
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details });
101
- }
102
- if (dot) {
103
- process.stdout.write(core_imports_1.chalk.red('.'));
104
- }
105
- else {
106
- if (useSpinner) {
107
- process === null || process === void 0 ? void 0 : process.send("error::".concat(core_imports_1.chalk.red(details)));
108
- }
109
- else {
110
- if (global.globalSystemToolMode) {
111
- if (noTrace) {
112
- !global.muteMessages && console.log(core_imports_1.chalk.red(details));
113
- }
114
- else {
115
- !global.muteMessages && console.trace(core_imports_1.chalk.red(details));
116
- }
117
- if (!noExit) {
118
- process.exit(1);
119
- }
120
- }
121
- else {
122
- console.log(details); // no formatiing debuggable code
123
- }
124
- }
125
- }
126
- };
127
- if (global[KEY.LAST_ERROR] === details) {
128
- global[KEY_COUNT.LAST_ERROR]++;
129
- if (global[KEY_COUNT.LAST_ERROR] > LIMIT) {
130
- display(true);
131
- }
132
- else {
133
- display();
134
- }
135
- }
136
- else {
137
- global[KEY_COUNT.LAST_ERROR] = 0;
138
- global[KEY.LAST_ERROR] = details;
139
- display();
140
- }
141
- //#endregion
142
- };
143
- //#endregion
144
- //#region info
145
- HelpersMessages.prototype.info = function (details, repeatable) {
146
- if (repeatable === void 0) { repeatable = false; }
147
- // //#region @backend
148
- // console.log({
149
- // shouldDiaplyInfo: details,
150
- // muteMessages: global.muteMessages,
151
- // hideInfos: global.hideInfos,
152
- // });
153
- // //#endregion
154
- if (index_1.Helpers.isBrowser) {
155
- console.info(details);
156
- return;
157
- }
158
- //#region @backend
159
- var display = function (dot) {
160
- if (dot === void 0) { dot = false; }
161
- if (global.tnpNonInteractive) {
162
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
163
- }
164
- if (dot) {
165
- process.stdout.write(core_imports_1.chalk.blue('.'));
166
- }
167
- else {
168
- if (useSpinner) {
169
- process === null || process === void 0 ? void 0 : process.send("info::".concat(core_imports_1.chalk.blue(details)));
170
- }
171
- else {
172
- if (global.globalSystemToolMode) {
173
- console.log(core_imports_1.chalk.blue(details));
174
- }
175
- else {
176
- console.log(details);
177
- }
178
- }
179
- }
180
- };
181
- if (!global.muteMessages && !global.hideInfos) {
182
- if ((global[KEY.LAST_INFO] === details) && !repeatable) {
183
- global[KEY_COUNT.LAST_INFO]++;
184
- if (global[KEY_COUNT.LAST_INFO] > LIMIT) {
185
- display(true);
186
- }
187
- else {
188
- display();
189
- }
190
- }
191
- else {
192
- global[KEY_COUNT.LAST_INFO] = 0;
193
- global[KEY.LAST_INFO] = details;
194
- display();
195
- }
196
- }
197
- //#endregion
198
- };
199
- //#endregion
200
- //#region info
201
- HelpersMessages.prototype.success = function (details) {
202
- if (index_1.Helpers.isBrowser) {
203
- console.info(details);
204
- return;
205
- }
206
- //#region @backend
207
- details = transformData(details);
208
- var display = function (dot) {
209
- if (dot === void 0) { dot = false; }
210
- if (global.tnpNonInteractive) {
211
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
212
- }
213
- if (dot) {
214
- process.stdout.write(core_imports_1.chalk.green('.'));
215
- }
216
- else {
217
- if (useSpinner) {
218
- process === null || process === void 0 ? void 0 : process.send("success::".concat(core_imports_1.chalk.green(details)));
219
- }
220
- else {
221
- if (global.globalSystemToolMode) {
222
- console.log(core_imports_1.chalk.green(details));
223
- }
224
- else {
225
- console.log(details);
226
- }
227
- }
228
- }
229
- };
230
- if (!global.muteMessages && !global.hideInfos) {
231
- if ((global[KEY.LAST_SUCCESS] === details)) {
232
- global[KEY_COUNT.LAST_SUCCESS]++;
233
- if (global[KEY_COUNT.LAST_SUCCESS] > LIMIT) {
234
- display(true);
235
- }
236
- else {
237
- display();
238
- }
239
- }
240
- else {
241
- global[KEY_COUNT.LAST_SUCCESS] = 0;
242
- global[KEY.LAST_SUCCESS] = details;
243
- display();
244
- }
245
- }
246
- //#endregion
247
- };
248
- //#endregion
249
- HelpersMessages.prototype.taskStarted = function (details) {
250
- if (index_1.Helpers.isBrowser) {
251
- console.info(details);
252
- return;
253
- }
254
- //#region @backend
255
- details = transformData(details);
256
- var display = function (dot) {
257
- if (dot === void 0) { dot = false; }
258
- if (global.tnpNonInteractive) {
259
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
260
- }
261
- if (dot) {
262
- process.stdout.write(core_imports_1.chalk.magenta('.'));
263
- }
264
- else {
265
- if (useSpinner) {
266
- process === null || process === void 0 ? void 0 : process.send("taskstart::\u25BA ".concat(core_imports_1.chalk.magenta(details)));
267
- }
268
- else {
269
- if (global.globalSystemToolMode) {
270
- console.log('- ' + core_imports_1.chalk.magenta(details));
271
- }
272
- else {
273
- console.log(details);
274
- }
275
- }
276
- }
277
- };
278
- if (!global.muteMessages && !global.hideInfos) {
279
- if ((global[KEY.LAST_TASK_STARTED] === details)) {
280
- global[KEY_COUNT.LAST_TASK_STARTED]++;
281
- if (global[KEY_COUNT.LAST_TASK_STARTED] > LIMIT) {
282
- display(true);
283
- }
284
- else {
285
- display();
286
- }
287
- }
288
- else {
289
- global[KEY_COUNT.LAST_TASK_STARTED] = 0;
290
- global[KEY.LAST_TASK_STARTED] = details;
291
- display();
292
- }
293
- }
294
- //#endregion
295
- };
296
- //#endregion
297
- HelpersMessages.prototype.taskDone = function (details) {
298
- if (index_1.Helpers.isBrowser) {
299
- console.info(details);
300
- return;
301
- }
302
- //#region @backend
303
- if (!details) {
304
- var lastStatedTask = global[KEY.LAST_TASK_STARTED];
305
- details = lastStatedTask;
306
- }
307
- details = transformData(details);
308
- var display = function (dot) {
309
- if (dot === void 0) { dot = false; }
310
- if (global.tnpNonInteractive) {
311
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
312
- }
313
- if (dot) {
314
- process.stdout.write(core_imports_1.chalk.green('.'));
315
- }
316
- else {
317
- if (useSpinner) {
318
- process === null || process === void 0 ? void 0 : process.send("taskdone::\u2713 ".concat(core_imports_1.chalk.green(details)));
319
- }
320
- else {
321
- if (global.globalSystemToolMode) {
322
- console.log('\u2713 ' + core_imports_1.chalk.green(details));
323
- }
324
- else {
325
- console.log(details);
326
- }
327
- }
328
- }
329
- };
330
- if (!global.muteMessages && !global.hideInfos) {
331
- if ((global[KEY.LAST_TASK_DONE] === details)) {
332
- global[KEY_COUNT.LAST_TASK_DONE]++;
333
- if (global[KEY_COUNT.LAST_TASK_DONE] > LIMIT) {
334
- display(true);
335
- }
336
- else {
337
- display();
338
- }
339
- }
340
- else {
341
- global[KEY_COUNT.LAST_TASK_DONE] = 0;
342
- global[KEY.LAST_TASK_DONE] = details;
343
- display();
344
- }
345
- }
346
- //#endregion
347
- };
348
- //#endregion
349
- //#region log
350
- HelpersMessages.prototype.log = function (details, debugLevel) {
351
- if (debugLevel === void 0) { debugLevel = 0; }
352
- if (index_1.Helpers.isBrowser) {
353
- console.log(details);
354
- return;
355
- }
356
- //#region @backend
357
- if (debugLevel > (global.verboseLevel || 0)) {
358
- return;
359
- }
360
- details = transformData(details);
361
- var display = function (dot) {
362
- if (dot === void 0) { dot = false; }
363
- if (global.tnpNonInteractive) {
364
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details });
365
- }
366
- if (dot) {
367
- process.stdout.write('.');
368
- }
369
- else {
370
- if (useSpinner) {
371
- process === null || process === void 0 ? void 0 : process.send("log::".concat(core_imports_1.chalk.black(details)));
372
- }
373
- else {
374
- if (global.globalSystemToolMode) {
375
- console.log(core_imports_1.chalk.black(details));
376
- }
377
- else {
378
- console.log(details);
379
- }
380
- }
381
- }
382
- };
383
- if ((!global.muteMessages && !global.hideLog)) {
384
- if (global[KEY.LAST_LOG] === details) {
385
- global[KEY_COUNT.LAST_LOG]++;
386
- if (global[KEY_COUNT.LAST_LOG] > LIMIT) {
387
- display(true);
388
- }
389
- else {
390
- display();
391
- }
392
- }
393
- else {
394
- global[KEY_COUNT.LAST_LOG] = 0;
395
- global[KEY.LAST_LOG] = details;
396
- display();
397
- }
398
- }
399
- //#endregion
400
- };
401
- //#endregion
402
- //#region warn
403
- HelpersMessages.prototype.warn = function (details, trace) {
404
- if (trace === void 0) { trace = false; }
405
- if (index_1.Helpers.isBrowser) {
406
- console.warn(details);
407
- return;
408
- }
409
- //#region @backend
410
- var display = function (dot) {
411
- if (dot === void 0) { dot = false; }
412
- if (global.tnpNonInteractive) {
413
- progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'warning' });
414
- }
415
- if (dot) {
416
- process.stdout.write(core_imports_1.chalk.yellow('.'));
417
- }
418
- else {
419
- if (useSpinner) {
420
- process === null || process === void 0 ? void 0 : process.send("warn::".concat(core_imports_1.chalk.yellow(details)));
421
- }
422
- else {
423
- if (global.globalSystemToolMode) {
424
- if (trace) {
425
- (!global.muteMessages && !global.hideWarnings) && console.trace(core_imports_1.chalk.yellow(details));
426
- }
427
- else {
428
- (!global.muteMessages && !global.hideWarnings) && console.log(core_imports_1.chalk.yellow(details));
429
- }
430
- }
431
- else {
432
- if (trace) {
433
- (!global.muteMessages && !global.hideWarnings) && console.trace(details);
434
- }
435
- else {
436
- (!global.muteMessages && !global.hideWarnings) && console.log(details);
437
- }
438
- }
439
- }
440
- }
441
- };
442
- if (global[KEY.LAST_WARN] === details) {
443
- global[KEY_COUNT.LAST_WARN]++;
444
- if (global[KEY_COUNT.LAST_WARN] > LIMIT) {
445
- display(true);
446
- }
447
- else {
448
- display();
449
- }
450
- }
451
- else {
452
- global[KEY_COUNT.LAST_WARN] = 0;
453
- global[KEY.LAST_WARN] = details;
454
- display();
455
- }
456
- //#endregion
457
- };
458
- return HelpersMessages;
459
- }(helpers_isomorphic_1.HelpersIsomorphic));
460
- exports.HelpersMessages = HelpersMessages;
461
- function transformData(details) {
462
- if (typeof details === 'object') {
463
- if (Array.isArray(details)) {
464
- return details.join('\n');
465
- }
466
- try {
467
- var json = JSON.stringify(details);
468
- details = json;
469
- }
470
- catch (error) { }
471
- }
472
- return details;
473
- }
474
- //# sourceMappingURL=C:/Users/darek/projects/npm/tnp-core/tmp-bundle-release/bundle/project/tnp-core/bundle-nocutsrc/lib/helpers-messages.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HelpersMessages = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var core_imports_1 = require("./core-imports");
6
+ // import { config } from 'tnp-config';
7
+ // import { PROGRESS_DATA } from 'tnp-models';
8
+ var index_1 = require("./index");
9
+ var helpers_isomorphic_1 = require("./helpers-isomorphic");
10
+ var progress_data_1 = require("./progress-data");
11
+ // TODO handle global.testMode ?
12
+ var KEY = {
13
+ LAST_ERROR: Symbol(),
14
+ LAST_INFO: Symbol(),
15
+ LAST_WARN: Symbol(),
16
+ LAST_LOG: Symbol(),
17
+ LAST_SUCCESS: Symbol(),
18
+ LAST_TASK_STARTED: Symbol(),
19
+ LAST_TASK_DONE: Symbol(),
20
+ };
21
+ var KEY_COUNT = {
22
+ LAST_ERROR: Symbol(),
23
+ LAST_INFO: Symbol(),
24
+ LAST_WARN: Symbol(),
25
+ LAST_LOG: Symbol(),
26
+ LAST_SUCCESS: Symbol(),
27
+ LAST_TASK_STARTED: Symbol(),
28
+ LAST_TASK_DONE: Symbol(),
29
+ };
30
+ //#region @backend
31
+ global[KEY_COUNT.LAST_ERROR] = 0;
32
+ global[KEY_COUNT.LAST_INFO] = 0;
33
+ global[KEY_COUNT.LAST_WARN] = 0;
34
+ global[KEY_COUNT.LAST_LOG] = 0;
35
+ global[KEY_COUNT.LAST_SUCCESS] = 0;
36
+ global[KEY_COUNT.LAST_TASK_STARTED] = 0;
37
+ global[KEY_COUNT.LAST_TASK_DONE] = 0;
38
+ var useSpinner = global['spinnerInParentProcess'];
39
+ //#endregion
40
+ var LIMIT = 10;
41
+ // export class Log {
42
+ // private static _instance: Log;
43
+ // public Instance() {
44
+ // if (!Log._instance) {
45
+ // Log._instance = new Log();
46
+ // }
47
+ // return Log._instance;
48
+ // }
49
+ // create(name: string, level?: Level) {
50
+ // if (level === void 0) {
51
+ // level = Level.DATA;
52
+ // }
53
+ // return {
54
+ // d(details: string, debugLevel?: number) {
55
+ // return Helpers.log(`[${name}] ${details}`, debugLevel)
56
+ // },
57
+ // i(details: string) {
58
+ // return Helpers.info(`[${name}] ${details}`)
59
+ // },
60
+ // w(details: string, noExit = false, noTrace = false) {
61
+ // return Helpers.error(`[${name}] ${details}`, noExit, noTrace);
62
+ // },
63
+ // er(details: string, ) {
64
+ // return Helpers.info(`[${name}] ${details}`)
65
+ // },
66
+ // }
67
+ // }
68
+ // }
69
+ var HelpersMessages = /** @class */ (function (_super) {
70
+ tslib_1.__extends(HelpersMessages, _super);
71
+ function HelpersMessages() {
72
+ return _super !== null && _super.apply(this, arguments) || this;
73
+ }
74
+ HelpersMessages.prototype.msgCacheClear = function () {
75
+ //#region @backend
76
+ global[KEY.LAST_LOG] = void 0;
77
+ global[KEY.LAST_WARN] = void 0;
78
+ global[KEY.LAST_ERROR] = void 0;
79
+ global[KEY.LAST_INFO] = void 0;
80
+ //#endregion
81
+ };
82
+ HelpersMessages.prototype.error = function (details, noExit, noTrace) {
83
+ if (noExit === void 0) { noExit = false; }
84
+ if (noTrace === void 0) { noTrace = false; }
85
+ //#region browser mode
86
+ if (index_1.Helpers.isBrowser) {
87
+ console.error(details);
88
+ return;
89
+ }
90
+ //#endregion
91
+ //#region @backend
92
+ // Error.stackTraceLimit = Infinity;
93
+ if (!global.globalSystemToolMode) {
94
+ noTrace = true;
95
+ }
96
+ details = transformData(details);
97
+ var display = function (dot) {
98
+ if (dot === void 0) { dot = false; }
99
+ if (global.tnpNonInteractive) {
100
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details });
101
+ }
102
+ if (dot) {
103
+ process.stdout.write(core_imports_1.chalk.red('.'));
104
+ }
105
+ else {
106
+ if (useSpinner) {
107
+ process === null || process === void 0 ? void 0 : process.send("error::".concat(core_imports_1.chalk.red(details)));
108
+ }
109
+ else {
110
+ if (global.globalSystemToolMode) {
111
+ if (noTrace) {
112
+ !global.muteMessages && console.log(core_imports_1.chalk.red(details));
113
+ }
114
+ else {
115
+ !global.muteMessages && console.trace(core_imports_1.chalk.red(details));
116
+ }
117
+ if (!noExit) {
118
+ process.exit(1);
119
+ }
120
+ }
121
+ else {
122
+ console.log(details); // no formatiing debuggable code
123
+ }
124
+ }
125
+ }
126
+ };
127
+ if (global[KEY.LAST_ERROR] === details) {
128
+ global[KEY_COUNT.LAST_ERROR]++;
129
+ if (global[KEY_COUNT.LAST_ERROR] > LIMIT) {
130
+ display(true);
131
+ }
132
+ else {
133
+ display();
134
+ }
135
+ }
136
+ else {
137
+ global[KEY_COUNT.LAST_ERROR] = 0;
138
+ global[KEY.LAST_ERROR] = details;
139
+ display();
140
+ }
141
+ //#endregion
142
+ };
143
+ //#endregion
144
+ //#region info
145
+ HelpersMessages.prototype.info = function (details, repeatable) {
146
+ if (repeatable === void 0) { repeatable = false; }
147
+ // //#region @backend
148
+ // console.log({
149
+ // shouldDiaplyInfo: details,
150
+ // muteMessages: global.muteMessages,
151
+ // hideInfos: global.hideInfos,
152
+ // });
153
+ // //#endregion
154
+ if (index_1.Helpers.isBrowser) {
155
+ console.info(details);
156
+ return;
157
+ }
158
+ //#region @backend
159
+ var display = function (dot) {
160
+ if (dot === void 0) { dot = false; }
161
+ if (global.tnpNonInteractive) {
162
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
163
+ }
164
+ if (dot) {
165
+ process.stdout.write(core_imports_1.chalk.blue('.'));
166
+ }
167
+ else {
168
+ if (useSpinner) {
169
+ process === null || process === void 0 ? void 0 : process.send("info::".concat(core_imports_1.chalk.blue(details)));
170
+ }
171
+ else {
172
+ if (global.globalSystemToolMode) {
173
+ console.log(core_imports_1.chalk.blue(details));
174
+ }
175
+ else {
176
+ console.log(details);
177
+ }
178
+ }
179
+ }
180
+ };
181
+ if (!global.muteMessages && !global.hideInfos) {
182
+ if ((global[KEY.LAST_INFO] === details) && !repeatable) {
183
+ global[KEY_COUNT.LAST_INFO]++;
184
+ if (global[KEY_COUNT.LAST_INFO] > LIMIT) {
185
+ display(true);
186
+ }
187
+ else {
188
+ display();
189
+ }
190
+ }
191
+ else {
192
+ global[KEY_COUNT.LAST_INFO] = 0;
193
+ global[KEY.LAST_INFO] = details;
194
+ display();
195
+ }
196
+ }
197
+ //#endregion
198
+ };
199
+ //#endregion
200
+ //#region info
201
+ HelpersMessages.prototype.success = function (details) {
202
+ if (index_1.Helpers.isBrowser) {
203
+ console.info(details);
204
+ return;
205
+ }
206
+ //#region @backend
207
+ details = transformData(details);
208
+ var display = function (dot) {
209
+ if (dot === void 0) { dot = false; }
210
+ if (global.tnpNonInteractive) {
211
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
212
+ }
213
+ if (dot) {
214
+ process.stdout.write(core_imports_1.chalk.green('.'));
215
+ }
216
+ else {
217
+ if (useSpinner) {
218
+ process === null || process === void 0 ? void 0 : process.send("success::".concat(core_imports_1.chalk.green(details)));
219
+ }
220
+ else {
221
+ if (global.globalSystemToolMode) {
222
+ console.log(core_imports_1.chalk.green(details));
223
+ }
224
+ else {
225
+ console.log(details);
226
+ }
227
+ }
228
+ }
229
+ };
230
+ if (!global.muteMessages && !global.hideInfos) {
231
+ if ((global[KEY.LAST_SUCCESS] === details)) {
232
+ global[KEY_COUNT.LAST_SUCCESS]++;
233
+ if (global[KEY_COUNT.LAST_SUCCESS] > LIMIT) {
234
+ display(true);
235
+ }
236
+ else {
237
+ display();
238
+ }
239
+ }
240
+ else {
241
+ global[KEY_COUNT.LAST_SUCCESS] = 0;
242
+ global[KEY.LAST_SUCCESS] = details;
243
+ display();
244
+ }
245
+ }
246
+ //#endregion
247
+ };
248
+ //#endregion
249
+ HelpersMessages.prototype.taskStarted = function (details) {
250
+ if (index_1.Helpers.isBrowser) {
251
+ console.info(details);
252
+ return;
253
+ }
254
+ //#region @backend
255
+ details = transformData(details);
256
+ var display = function (dot) {
257
+ if (dot === void 0) { dot = false; }
258
+ if (global.tnpNonInteractive) {
259
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
260
+ }
261
+ if (dot) {
262
+ process.stdout.write(core_imports_1.chalk.magenta('.'));
263
+ }
264
+ else {
265
+ if (useSpinner) {
266
+ process === null || process === void 0 ? void 0 : process.send("taskstart::\u25BA ".concat(core_imports_1.chalk.magenta(details)));
267
+ }
268
+ else {
269
+ if (global.globalSystemToolMode) {
270
+ console.log('- ' + core_imports_1.chalk.magenta(details));
271
+ }
272
+ else {
273
+ console.log(details);
274
+ }
275
+ }
276
+ }
277
+ };
278
+ if (!global.muteMessages && !global.hideInfos) {
279
+ if ((global[KEY.LAST_TASK_STARTED] === details)) {
280
+ global[KEY_COUNT.LAST_TASK_STARTED]++;
281
+ if (global[KEY_COUNT.LAST_TASK_STARTED] > LIMIT) {
282
+ display(true);
283
+ }
284
+ else {
285
+ display();
286
+ }
287
+ }
288
+ else {
289
+ global[KEY_COUNT.LAST_TASK_STARTED] = 0;
290
+ global[KEY.LAST_TASK_STARTED] = details;
291
+ display();
292
+ }
293
+ }
294
+ //#endregion
295
+ };
296
+ //#endregion
297
+ HelpersMessages.prototype.taskDone = function (details) {
298
+ if (index_1.Helpers.isBrowser) {
299
+ console.info(details);
300
+ return;
301
+ }
302
+ //#region @backend
303
+ if (!details) {
304
+ var lastStatedTask = global[KEY.LAST_TASK_STARTED];
305
+ details = lastStatedTask;
306
+ }
307
+ details = transformData(details);
308
+ var display = function (dot) {
309
+ if (dot === void 0) { dot = false; }
310
+ if (global.tnpNonInteractive) {
311
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'info' });
312
+ }
313
+ if (dot) {
314
+ process.stdout.write(core_imports_1.chalk.green('.'));
315
+ }
316
+ else {
317
+ if (useSpinner) {
318
+ process === null || process === void 0 ? void 0 : process.send("taskdone::\u2713 ".concat(core_imports_1.chalk.green(details)));
319
+ }
320
+ else {
321
+ if (global.globalSystemToolMode) {
322
+ console.log('\u2713 ' + core_imports_1.chalk.green(details));
323
+ }
324
+ else {
325
+ console.log(details);
326
+ }
327
+ }
328
+ }
329
+ };
330
+ if (!global.muteMessages && !global.hideInfos) {
331
+ if ((global[KEY.LAST_TASK_DONE] === details)) {
332
+ global[KEY_COUNT.LAST_TASK_DONE]++;
333
+ if (global[KEY_COUNT.LAST_TASK_DONE] > LIMIT) {
334
+ display(true);
335
+ }
336
+ else {
337
+ display();
338
+ }
339
+ }
340
+ else {
341
+ global[KEY_COUNT.LAST_TASK_DONE] = 0;
342
+ global[KEY.LAST_TASK_DONE] = details;
343
+ display();
344
+ }
345
+ }
346
+ //#endregion
347
+ };
348
+ //#endregion
349
+ //#region log
350
+ HelpersMessages.prototype.log = function (details, debugLevel) {
351
+ if (debugLevel === void 0) { debugLevel = 0; }
352
+ if (index_1.Helpers.isBrowser) {
353
+ console.log(details);
354
+ return;
355
+ }
356
+ //#region @backend
357
+ if (debugLevel > (global.verboseLevel || 0)) {
358
+ return;
359
+ }
360
+ details = transformData(details);
361
+ var display = function (dot) {
362
+ if (dot === void 0) { dot = false; }
363
+ if (global.tnpNonInteractive) {
364
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details });
365
+ }
366
+ if (dot) {
367
+ process.stdout.write('.');
368
+ }
369
+ else {
370
+ if (useSpinner) {
371
+ process === null || process === void 0 ? void 0 : process.send("log::".concat(core_imports_1.chalk.black(details)));
372
+ }
373
+ else {
374
+ if (global.globalSystemToolMode) {
375
+ console.log(core_imports_1.chalk.black(details));
376
+ }
377
+ else {
378
+ console.log(details);
379
+ }
380
+ }
381
+ }
382
+ };
383
+ if ((!global.muteMessages && !global.hideLog)) {
384
+ if (global[KEY.LAST_LOG] === details) {
385
+ global[KEY_COUNT.LAST_LOG]++;
386
+ if (global[KEY_COUNT.LAST_LOG] > LIMIT) {
387
+ display(true);
388
+ }
389
+ else {
390
+ display();
391
+ }
392
+ }
393
+ else {
394
+ global[KEY_COUNT.LAST_LOG] = 0;
395
+ global[KEY.LAST_LOG] = details;
396
+ display();
397
+ }
398
+ }
399
+ //#endregion
400
+ };
401
+ //#endregion
402
+ //#region warn
403
+ HelpersMessages.prototype.warn = function (details, trace) {
404
+ if (trace === void 0) { trace = false; }
405
+ if (index_1.Helpers.isBrowser) {
406
+ console.warn(details);
407
+ return;
408
+ }
409
+ //#region @backend
410
+ var display = function (dot) {
411
+ if (dot === void 0) { dot = false; }
412
+ if (global.tnpNonInteractive) {
413
+ progress_data_1.PROGRESS_DATA.log({ msg: dot ? '.' : details, type: 'warning' });
414
+ }
415
+ if (dot) {
416
+ process.stdout.write(core_imports_1.chalk.yellow('.'));
417
+ }
418
+ else {
419
+ if (useSpinner) {
420
+ process === null || process === void 0 ? void 0 : process.send("warn::".concat(core_imports_1.chalk.yellow(details)));
421
+ }
422
+ else {
423
+ if (global.globalSystemToolMode) {
424
+ if (trace) {
425
+ (!global.muteMessages && !global.hideWarnings) && console.trace(core_imports_1.chalk.yellow(details));
426
+ }
427
+ else {
428
+ (!global.muteMessages && !global.hideWarnings) && console.log(core_imports_1.chalk.yellow(details));
429
+ }
430
+ }
431
+ else {
432
+ if (trace) {
433
+ (!global.muteMessages && !global.hideWarnings) && console.trace(details);
434
+ }
435
+ else {
436
+ (!global.muteMessages && !global.hideWarnings) && console.log(details);
437
+ }
438
+ }
439
+ }
440
+ }
441
+ };
442
+ if (global[KEY.LAST_WARN] === details) {
443
+ global[KEY_COUNT.LAST_WARN]++;
444
+ if (global[KEY_COUNT.LAST_WARN] > LIMIT) {
445
+ display(true);
446
+ }
447
+ else {
448
+ display();
449
+ }
450
+ }
451
+ else {
452
+ global[KEY_COUNT.LAST_WARN] = 0;
453
+ global[KEY.LAST_WARN] = details;
454
+ display();
455
+ }
456
+ //#endregion
457
+ };
458
+ return HelpersMessages;
459
+ }(helpers_isomorphic_1.HelpersIsomorphic));
460
+ exports.HelpersMessages = HelpersMessages;
461
+ function transformData(details) {
462
+ if (typeof details === 'object') {
463
+ if (Array.isArray(details)) {
464
+ return details.join('\n');
465
+ }
466
+ try {
467
+ var json = JSON.stringify(details);
468
+ details = json;
469
+ }
470
+ catch (error) { }
471
+ }
472
+ return details;
473
+ }
474
+ //# sourceMappingURL=/Users/dfilipiak/projects/npm/tnp-core/tmp-bundle-release/bundle/project/tnp-core/bundle-nocutsrc/lib/helpers-messages.js.map