@ngxs/logger-plugin 3.6.2-dev.master-8e14fe1 → 3.7.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.
- package/README.md +3 -3
- package/bundles/ngxs-logger-plugin.umd.js +474 -469
- package/bundles/ngxs-logger-plugin.umd.js.map +1 -1
- package/bundles/ngxs-logger-plugin.umd.min.js +11 -11
- package/bundles/ngxs-logger-plugin.umd.min.js.map +1 -1
- package/esm2015/index.js +9 -9
- package/esm2015/ngxs-logger-plugin.js +9 -9
- package/esm2015/src/action-logger.js +101 -101
- package/esm2015/src/internals.js +32 -32
- package/esm2015/src/log-writer.js +117 -117
- package/esm2015/src/logger.module.js +58 -58
- package/esm2015/src/logger.plugin.js +82 -82
- package/esm2015/src/public_api.js +8 -8
- package/esm2015/src/symbols.js +34 -34
- package/esm5/index.js +9 -9
- package/esm5/ngxs-logger-plugin.js +9 -9
- package/esm5/src/action-logger.js +121 -121
- package/esm5/src/internals.js +34 -34
- package/esm5/src/log-writer.js +147 -147
- package/esm5/src/logger.module.js +67 -67
- package/esm5/src/logger.plugin.js +86 -86
- package/esm5/src/public_api.js +8 -8
- package/esm5/src/symbols.js +34 -34
- package/fesm2015/ngxs-logger-plugin.js +408 -408
- package/fesm2015/ngxs-logger-plugin.js.map +1 -1
- package/fesm5/ngxs-logger-plugin.js +467 -467
- package/fesm5/ngxs-logger-plugin.js.map +1 -1
- package/index.d.ts +4 -4
- package/ngxs-logger-plugin.d.ts +5 -5
- package/package.json +5 -5
- package/src/action-logger.d.ts +13 -13
- package/src/internals.d.ts +3 -3
- package/src/log-writer.d.ts +13 -13
- package/src/logger.module.d.ts +12 -12
- package/src/logger.plugin.d.ts +11 -11
- package/src/public_api.d.ts +3 -3
- package/src/symbols.d.ts +12 -12
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
}(this, function (exports, core, store, operators) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*! *****************************************************************************
|
|
8
|
-
Copyright (c) Microsoft Corporation.
|
|
9
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
10
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
11
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
16
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
20
|
***************************************************************************** */
|
|
21
21
|
/* global Reflect, Promise */
|
|
22
22
|
|
|
@@ -109,8 +109,13 @@
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
function __createBinding(o, m, k, k2) {
|
|
113
|
+
if (k2 === undefined) k2 = k;
|
|
114
|
+
o[k2] = m[k];
|
|
115
|
+
}
|
|
116
|
+
|
|
112
117
|
function __exportStar(m, exports) {
|
|
113
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
118
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
function __values(o) {
|
|
@@ -218,474 +223,474 @@
|
|
|
218
223
|
return value;
|
|
219
224
|
}
|
|
220
225
|
|
|
221
|
-
/**
|
|
222
|
-
* @fileoverview added by tsickle
|
|
223
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
224
|
-
*/
|
|
225
|
-
/** @type {?} */
|
|
226
|
-
var repeat = (/**
|
|
227
|
-
* @param {?} str
|
|
228
|
-
* @param {?} times
|
|
229
|
-
* @return {?}
|
|
230
|
-
*/
|
|
231
|
-
function (str, times) { return new Array(times + 1).join(str); });
|
|
232
|
-
/** @type {?} */
|
|
233
|
-
var pad = (/**
|
|
234
|
-
* @param {?} num
|
|
235
|
-
* @param {?} maxLength
|
|
236
|
-
* @return {?}
|
|
237
|
-
*/
|
|
238
|
-
function (num, maxLength) {
|
|
239
|
-
return repeat('0', maxLength - num.toString().length) + num;
|
|
240
|
-
});
|
|
241
|
-
/**
|
|
242
|
-
* @param {?} time
|
|
243
|
-
* @return {?}
|
|
244
|
-
*/
|
|
245
|
-
function formatTime(time) {
|
|
246
|
-
return (pad(time.getHours(), 2) +
|
|
247
|
-
":" +
|
|
248
|
-
pad(time.getMinutes(), 2) +
|
|
249
|
-
":" +
|
|
250
|
-
pad(time.getSeconds(), 2) +
|
|
251
|
-
"." +
|
|
252
|
-
pad(time.getMilliseconds(), 3));
|
|
226
|
+
/**
|
|
227
|
+
* @fileoverview added by tsickle
|
|
228
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
229
|
+
*/
|
|
230
|
+
/** @type {?} */
|
|
231
|
+
var repeat = (/**
|
|
232
|
+
* @param {?} str
|
|
233
|
+
* @param {?} times
|
|
234
|
+
* @return {?}
|
|
235
|
+
*/
|
|
236
|
+
function (str, times) { return new Array(times + 1).join(str); });
|
|
237
|
+
/** @type {?} */
|
|
238
|
+
var pad = (/**
|
|
239
|
+
* @param {?} num
|
|
240
|
+
* @param {?} maxLength
|
|
241
|
+
* @return {?}
|
|
242
|
+
*/
|
|
243
|
+
function (num, maxLength) {
|
|
244
|
+
return repeat('0', maxLength - num.toString().length) + num;
|
|
245
|
+
});
|
|
246
|
+
/**
|
|
247
|
+
* @param {?} time
|
|
248
|
+
* @return {?}
|
|
249
|
+
*/
|
|
250
|
+
function formatTime(time) {
|
|
251
|
+
return (pad(time.getHours(), 2) +
|
|
252
|
+
":" +
|
|
253
|
+
pad(time.getMinutes(), 2) +
|
|
254
|
+
":" +
|
|
255
|
+
pad(time.getSeconds(), 2) +
|
|
256
|
+
"." +
|
|
257
|
+
pad(time.getMilliseconds(), 3));
|
|
253
258
|
}
|
|
254
259
|
|
|
255
|
-
/**
|
|
256
|
-
* @fileoverview added by tsickle
|
|
257
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
258
|
-
*/
|
|
259
|
-
var ActionLogger = /** @class */ (function () {
|
|
260
|
-
function ActionLogger(action, store, logWriter) {
|
|
261
|
-
this.action = action;
|
|
262
|
-
this.store = store;
|
|
263
|
-
this.logWriter = logWriter;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* @param {?} state
|
|
267
|
-
* @return {?}
|
|
268
|
-
*/
|
|
269
|
-
ActionLogger.prototype.dispatched = /**
|
|
270
|
-
* @param {?} state
|
|
271
|
-
* @return {?}
|
|
272
|
-
*/
|
|
273
|
-
function (state) {
|
|
274
|
-
/** @type {?} */
|
|
275
|
-
var actionName = store.getActionTypeFromInstance(this.action);
|
|
276
|
-
/** @type {?} */
|
|
277
|
-
var formattedTime = formatTime(new Date());
|
|
278
|
-
/** @type {?} */
|
|
279
|
-
var message = "action " + actionName + " @ " + formattedTime;
|
|
280
|
-
this.logWriter.startGroup(message);
|
|
281
|
-
// print payload only if at least one property is supplied
|
|
282
|
-
if (this._hasPayload(this.action)) {
|
|
283
|
-
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
284
|
-
}
|
|
285
|
-
this.logWriter.logGrey('prev state', state);
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* @param {?} nextState
|
|
289
|
-
* @return {?}
|
|
290
|
-
*/
|
|
291
|
-
ActionLogger.prototype.completed = /**
|
|
292
|
-
* @param {?} nextState
|
|
293
|
-
* @return {?}
|
|
294
|
-
*/
|
|
295
|
-
function (nextState) {
|
|
296
|
-
this.logWriter.logGreen('next state', nextState);
|
|
297
|
-
this.logWriter.endGroup();
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* @param {?} error
|
|
301
|
-
* @return {?}
|
|
302
|
-
*/
|
|
303
|
-
ActionLogger.prototype.errored = /**
|
|
304
|
-
* @param {?} error
|
|
305
|
-
* @return {?}
|
|
306
|
-
*/
|
|
307
|
-
function (error) {
|
|
308
|
-
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
309
|
-
this.logWriter.logRedish('error', error);
|
|
310
|
-
this.logWriter.endGroup();
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* @private
|
|
314
|
-
* @param {?} event
|
|
315
|
-
* @return {?}
|
|
316
|
-
*/
|
|
317
|
-
ActionLogger.prototype._hasPayload = /**
|
|
318
|
-
* @private
|
|
319
|
-
* @param {?} event
|
|
320
|
-
* @return {?}
|
|
321
|
-
*/
|
|
322
|
-
function (event) {
|
|
323
|
-
/** @type {?} */
|
|
324
|
-
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
325
|
-
return nonEmptyProperties.length > 0;
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* @private
|
|
329
|
-
* @param {?} event
|
|
330
|
-
* @return {?}
|
|
331
|
-
*/
|
|
332
|
-
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
333
|
-
* @private
|
|
334
|
-
* @param {?} event
|
|
335
|
-
* @return {?}
|
|
336
|
-
*/
|
|
337
|
-
function (event) {
|
|
338
|
-
/** @type {?} */
|
|
339
|
-
var keys = Object.keys(event);
|
|
340
|
-
/** @type {?} */
|
|
341
|
-
var values = keys.map((/**
|
|
342
|
-
* @param {?} key
|
|
343
|
-
* @return {?}
|
|
344
|
-
*/
|
|
345
|
-
function (key) { return event[key]; }));
|
|
346
|
-
return values.filter((/**
|
|
347
|
-
* @param {?} value
|
|
348
|
-
* @return {?}
|
|
349
|
-
*/
|
|
350
|
-
function (value) { return
|
|
351
|
-
};
|
|
352
|
-
return ActionLogger;
|
|
353
|
-
}());
|
|
354
|
-
if (false) {
|
|
355
|
-
/**
|
|
356
|
-
* @type {?}
|
|
357
|
-
* @private
|
|
358
|
-
*/
|
|
359
|
-
ActionLogger.prototype.action;
|
|
360
|
-
/**
|
|
361
|
-
* @type {?}
|
|
362
|
-
* @private
|
|
363
|
-
*/
|
|
364
|
-
ActionLogger.prototype.store;
|
|
365
|
-
/**
|
|
366
|
-
* @type {?}
|
|
367
|
-
* @private
|
|
368
|
-
*/
|
|
369
|
-
ActionLogger.prototype.logWriter;
|
|
260
|
+
/**
|
|
261
|
+
* @fileoverview added by tsickle
|
|
262
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
263
|
+
*/
|
|
264
|
+
var ActionLogger = /** @class */ (function () {
|
|
265
|
+
function ActionLogger(action, store, logWriter) {
|
|
266
|
+
this.action = action;
|
|
267
|
+
this.store = store;
|
|
268
|
+
this.logWriter = logWriter;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* @param {?} state
|
|
272
|
+
* @return {?}
|
|
273
|
+
*/
|
|
274
|
+
ActionLogger.prototype.dispatched = /**
|
|
275
|
+
* @param {?} state
|
|
276
|
+
* @return {?}
|
|
277
|
+
*/
|
|
278
|
+
function (state) {
|
|
279
|
+
/** @type {?} */
|
|
280
|
+
var actionName = store.getActionTypeFromInstance(this.action);
|
|
281
|
+
/** @type {?} */
|
|
282
|
+
var formattedTime = formatTime(new Date());
|
|
283
|
+
/** @type {?} */
|
|
284
|
+
var message = "action " + actionName + " @ " + formattedTime;
|
|
285
|
+
this.logWriter.startGroup(message);
|
|
286
|
+
// print payload only if at least one property is supplied
|
|
287
|
+
if (this._hasPayload(this.action)) {
|
|
288
|
+
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
289
|
+
}
|
|
290
|
+
this.logWriter.logGrey('prev state', state);
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* @param {?} nextState
|
|
294
|
+
* @return {?}
|
|
295
|
+
*/
|
|
296
|
+
ActionLogger.prototype.completed = /**
|
|
297
|
+
* @param {?} nextState
|
|
298
|
+
* @return {?}
|
|
299
|
+
*/
|
|
300
|
+
function (nextState) {
|
|
301
|
+
this.logWriter.logGreen('next state', nextState);
|
|
302
|
+
this.logWriter.endGroup();
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* @param {?} error
|
|
306
|
+
* @return {?}
|
|
307
|
+
*/
|
|
308
|
+
ActionLogger.prototype.errored = /**
|
|
309
|
+
* @param {?} error
|
|
310
|
+
* @return {?}
|
|
311
|
+
*/
|
|
312
|
+
function (error) {
|
|
313
|
+
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
314
|
+
this.logWriter.logRedish('error', error);
|
|
315
|
+
this.logWriter.endGroup();
|
|
316
|
+
};
|
|
317
|
+
/**
|
|
318
|
+
* @private
|
|
319
|
+
* @param {?} event
|
|
320
|
+
* @return {?}
|
|
321
|
+
*/
|
|
322
|
+
ActionLogger.prototype._hasPayload = /**
|
|
323
|
+
* @private
|
|
324
|
+
* @param {?} event
|
|
325
|
+
* @return {?}
|
|
326
|
+
*/
|
|
327
|
+
function (event) {
|
|
328
|
+
/** @type {?} */
|
|
329
|
+
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
330
|
+
return nonEmptyProperties.length > 0;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* @private
|
|
334
|
+
* @param {?} event
|
|
335
|
+
* @return {?}
|
|
336
|
+
*/
|
|
337
|
+
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
338
|
+
* @private
|
|
339
|
+
* @param {?} event
|
|
340
|
+
* @return {?}
|
|
341
|
+
*/
|
|
342
|
+
function (event) {
|
|
343
|
+
/** @type {?} */
|
|
344
|
+
var keys = Object.keys(event);
|
|
345
|
+
/** @type {?} */
|
|
346
|
+
var values = keys.map((/**
|
|
347
|
+
* @param {?} key
|
|
348
|
+
* @return {?}
|
|
349
|
+
*/
|
|
350
|
+
function (key) { return event[key]; }));
|
|
351
|
+
return values.filter((/**
|
|
352
|
+
* @param {?} value
|
|
353
|
+
* @return {?}
|
|
354
|
+
*/
|
|
355
|
+
function (value) { return value !== undefined; }));
|
|
356
|
+
};
|
|
357
|
+
return ActionLogger;
|
|
358
|
+
}());
|
|
359
|
+
if (false) {
|
|
360
|
+
/**
|
|
361
|
+
* @type {?}
|
|
362
|
+
* @private
|
|
363
|
+
*/
|
|
364
|
+
ActionLogger.prototype.action;
|
|
365
|
+
/**
|
|
366
|
+
* @type {?}
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
ActionLogger.prototype.store;
|
|
370
|
+
/**
|
|
371
|
+
* @type {?}
|
|
372
|
+
* @private
|
|
373
|
+
*/
|
|
374
|
+
ActionLogger.prototype.logWriter;
|
|
370
375
|
}
|
|
371
376
|
|
|
372
|
-
/**
|
|
373
|
-
* @fileoverview added by tsickle
|
|
374
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
375
|
-
*/
|
|
376
|
-
var LogWriter = /** @class */ (function () {
|
|
377
|
-
function LogWriter(options) {
|
|
378
|
-
this.options = options;
|
|
379
|
-
this.options = this.options || (/** @type {?} */ ({}));
|
|
380
|
-
this.logger = options.logger || console;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* @param {?} message
|
|
384
|
-
* @return {?}
|
|
385
|
-
*/
|
|
386
|
-
LogWriter.prototype.startGroup = /**
|
|
387
|
-
* @param {?} message
|
|
388
|
-
* @return {?}
|
|
389
|
-
*/
|
|
390
|
-
function (message) {
|
|
391
|
-
/** @type {?} */
|
|
392
|
-
var startGroupFn = this.options.collapsed
|
|
393
|
-
? this.logger.groupCollapsed
|
|
394
|
-
: this.logger.group;
|
|
395
|
-
try {
|
|
396
|
-
startGroupFn.call(this.logger, message);
|
|
397
|
-
}
|
|
398
|
-
catch (e) {
|
|
399
|
-
console.log(message);
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* @return {?}
|
|
404
|
-
*/
|
|
405
|
-
LogWriter.prototype.endGroup = /**
|
|
406
|
-
* @return {?}
|
|
407
|
-
*/
|
|
408
|
-
function () {
|
|
409
|
-
try {
|
|
410
|
-
this.logger.groupEnd();
|
|
411
|
-
}
|
|
412
|
-
catch (e) {
|
|
413
|
-
this.logger.log('—— log end ——');
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
/**
|
|
417
|
-
* @param {?} title
|
|
418
|
-
* @param {?} payload
|
|
419
|
-
* @return {?}
|
|
420
|
-
*/
|
|
421
|
-
LogWriter.prototype.logGrey = /**
|
|
422
|
-
* @param {?} title
|
|
423
|
-
* @param {?} payload
|
|
424
|
-
* @return {?}
|
|
425
|
-
*/
|
|
426
|
-
function (title, payload) {
|
|
427
|
-
/** @type {?} */
|
|
428
|
-
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
429
|
-
this.log(title, greyStyle, payload);
|
|
430
|
-
};
|
|
431
|
-
/**
|
|
432
|
-
* @param {?} title
|
|
433
|
-
* @param {?} payload
|
|
434
|
-
* @return {?}
|
|
435
|
-
*/
|
|
436
|
-
LogWriter.prototype.logGreen = /**
|
|
437
|
-
* @param {?} title
|
|
438
|
-
* @param {?} payload
|
|
439
|
-
* @return {?}
|
|
440
|
-
*/
|
|
441
|
-
function (title, payload) {
|
|
442
|
-
/** @type {?} */
|
|
443
|
-
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
444
|
-
this.log(title, greenStyle, payload);
|
|
445
|
-
};
|
|
446
|
-
/**
|
|
447
|
-
* @param {?} title
|
|
448
|
-
* @param {?} payload
|
|
449
|
-
* @return {?}
|
|
450
|
-
*/
|
|
451
|
-
LogWriter.prototype.logRedish = /**
|
|
452
|
-
* @param {?} title
|
|
453
|
-
* @param {?} payload
|
|
454
|
-
* @return {?}
|
|
455
|
-
*/
|
|
456
|
-
function (title, payload) {
|
|
457
|
-
/** @type {?} */
|
|
458
|
-
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
459
|
-
this.log(title, redishStyle, payload);
|
|
460
|
-
};
|
|
461
|
-
/**
|
|
462
|
-
* @param {?} title
|
|
463
|
-
* @param {?} color
|
|
464
|
-
* @param {?} payload
|
|
465
|
-
* @return {?}
|
|
466
|
-
*/
|
|
467
|
-
LogWriter.prototype.log = /**
|
|
468
|
-
* @param {?} title
|
|
469
|
-
* @param {?} color
|
|
470
|
-
* @param {?} payload
|
|
471
|
-
* @return {?}
|
|
472
|
-
*/
|
|
473
|
-
function (title, color, payload) {
|
|
474
|
-
if (this.isIE()) {
|
|
475
|
-
this.logger.log(title, payload);
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
this.logger.log('%c ' + title, color, payload);
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
/**
|
|
482
|
-
* @return {?}
|
|
483
|
-
*/
|
|
484
|
-
LogWriter.prototype.isIE = /**
|
|
485
|
-
* @return {?}
|
|
486
|
-
*/
|
|
487
|
-
function () {
|
|
488
|
-
/** @type {?} */
|
|
489
|
-
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
490
|
-
? window.navigator.userAgent
|
|
491
|
-
: '';
|
|
492
|
-
/** @type {?} */
|
|
493
|
-
var msIE = false;
|
|
494
|
-
/** @type {?} */
|
|
495
|
-
var oldIE = ua.indexOf('MSIE ');
|
|
496
|
-
/** @type {?} */
|
|
497
|
-
var newIE = ua.indexOf('Trident/');
|
|
498
|
-
if (oldIE > -1 || newIE > -1) {
|
|
499
|
-
msIE = true;
|
|
500
|
-
}
|
|
501
|
-
return msIE;
|
|
502
|
-
};
|
|
503
|
-
return LogWriter;
|
|
504
|
-
}());
|
|
505
|
-
if (false) {
|
|
506
|
-
/**
|
|
507
|
-
* @type {?}
|
|
508
|
-
* @private
|
|
509
|
-
*/
|
|
510
|
-
LogWriter.prototype.logger;
|
|
511
|
-
/**
|
|
512
|
-
* @type {?}
|
|
513
|
-
* @private
|
|
514
|
-
*/
|
|
515
|
-
LogWriter.prototype.options;
|
|
377
|
+
/**
|
|
378
|
+
* @fileoverview added by tsickle
|
|
379
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
380
|
+
*/
|
|
381
|
+
var LogWriter = /** @class */ (function () {
|
|
382
|
+
function LogWriter(options) {
|
|
383
|
+
this.options = options;
|
|
384
|
+
this.options = this.options || (/** @type {?} */ ({}));
|
|
385
|
+
this.logger = options.logger || console;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* @param {?} message
|
|
389
|
+
* @return {?}
|
|
390
|
+
*/
|
|
391
|
+
LogWriter.prototype.startGroup = /**
|
|
392
|
+
* @param {?} message
|
|
393
|
+
* @return {?}
|
|
394
|
+
*/
|
|
395
|
+
function (message) {
|
|
396
|
+
/** @type {?} */
|
|
397
|
+
var startGroupFn = this.options.collapsed
|
|
398
|
+
? this.logger.groupCollapsed
|
|
399
|
+
: this.logger.group;
|
|
400
|
+
try {
|
|
401
|
+
startGroupFn.call(this.logger, message);
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
console.log(message);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* @return {?}
|
|
409
|
+
*/
|
|
410
|
+
LogWriter.prototype.endGroup = /**
|
|
411
|
+
* @return {?}
|
|
412
|
+
*/
|
|
413
|
+
function () {
|
|
414
|
+
try {
|
|
415
|
+
this.logger.groupEnd();
|
|
416
|
+
}
|
|
417
|
+
catch (e) {
|
|
418
|
+
this.logger.log('—— log end ——');
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* @param {?} title
|
|
423
|
+
* @param {?} payload
|
|
424
|
+
* @return {?}
|
|
425
|
+
*/
|
|
426
|
+
LogWriter.prototype.logGrey = /**
|
|
427
|
+
* @param {?} title
|
|
428
|
+
* @param {?} payload
|
|
429
|
+
* @return {?}
|
|
430
|
+
*/
|
|
431
|
+
function (title, payload) {
|
|
432
|
+
/** @type {?} */
|
|
433
|
+
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
434
|
+
this.log(title, greyStyle, payload);
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* @param {?} title
|
|
438
|
+
* @param {?} payload
|
|
439
|
+
* @return {?}
|
|
440
|
+
*/
|
|
441
|
+
LogWriter.prototype.logGreen = /**
|
|
442
|
+
* @param {?} title
|
|
443
|
+
* @param {?} payload
|
|
444
|
+
* @return {?}
|
|
445
|
+
*/
|
|
446
|
+
function (title, payload) {
|
|
447
|
+
/** @type {?} */
|
|
448
|
+
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
449
|
+
this.log(title, greenStyle, payload);
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* @param {?} title
|
|
453
|
+
* @param {?} payload
|
|
454
|
+
* @return {?}
|
|
455
|
+
*/
|
|
456
|
+
LogWriter.prototype.logRedish = /**
|
|
457
|
+
* @param {?} title
|
|
458
|
+
* @param {?} payload
|
|
459
|
+
* @return {?}
|
|
460
|
+
*/
|
|
461
|
+
function (title, payload) {
|
|
462
|
+
/** @type {?} */
|
|
463
|
+
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
464
|
+
this.log(title, redishStyle, payload);
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* @param {?} title
|
|
468
|
+
* @param {?} color
|
|
469
|
+
* @param {?} payload
|
|
470
|
+
* @return {?}
|
|
471
|
+
*/
|
|
472
|
+
LogWriter.prototype.log = /**
|
|
473
|
+
* @param {?} title
|
|
474
|
+
* @param {?} color
|
|
475
|
+
* @param {?} payload
|
|
476
|
+
* @return {?}
|
|
477
|
+
*/
|
|
478
|
+
function (title, color, payload) {
|
|
479
|
+
if (this.isIE()) {
|
|
480
|
+
this.logger.log(title, payload);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
this.logger.log('%c ' + title, color, payload);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* @return {?}
|
|
488
|
+
*/
|
|
489
|
+
LogWriter.prototype.isIE = /**
|
|
490
|
+
* @return {?}
|
|
491
|
+
*/
|
|
492
|
+
function () {
|
|
493
|
+
/** @type {?} */
|
|
494
|
+
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
495
|
+
? window.navigator.userAgent
|
|
496
|
+
: '';
|
|
497
|
+
/** @type {?} */
|
|
498
|
+
var msIE = false;
|
|
499
|
+
/** @type {?} */
|
|
500
|
+
var oldIE = ua.indexOf('MSIE ');
|
|
501
|
+
/** @type {?} */
|
|
502
|
+
var newIE = ua.indexOf('Trident/');
|
|
503
|
+
if (oldIE > -1 || newIE > -1) {
|
|
504
|
+
msIE = true;
|
|
505
|
+
}
|
|
506
|
+
return msIE;
|
|
507
|
+
};
|
|
508
|
+
return LogWriter;
|
|
509
|
+
}());
|
|
510
|
+
if (false) {
|
|
511
|
+
/**
|
|
512
|
+
* @type {?}
|
|
513
|
+
* @private
|
|
514
|
+
*/
|
|
515
|
+
LogWriter.prototype.logger;
|
|
516
|
+
/**
|
|
517
|
+
* @type {?}
|
|
518
|
+
* @private
|
|
519
|
+
*/
|
|
520
|
+
LogWriter.prototype.options;
|
|
516
521
|
}
|
|
517
522
|
|
|
518
|
-
/**
|
|
519
|
-
* @fileoverview added by tsickle
|
|
520
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
521
|
-
*/
|
|
522
|
-
/**
|
|
523
|
-
* @record
|
|
524
|
-
*/
|
|
525
|
-
function NgxsLoggerPluginOptions() { }
|
|
526
|
-
if (false) {
|
|
527
|
-
/**
|
|
528
|
-
* Auto expand logged actions
|
|
529
|
-
* @type {?|undefined}
|
|
530
|
-
*/
|
|
531
|
-
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
532
|
-
/**
|
|
533
|
-
* Provide alternate console.log implementation
|
|
534
|
-
* @type {?|undefined}
|
|
535
|
-
*/
|
|
536
|
-
NgxsLoggerPluginOptions.prototype.logger;
|
|
537
|
-
/**
|
|
538
|
-
* Disable the logger. Useful for prod mode.
|
|
539
|
-
* @type {?|undefined}
|
|
540
|
-
*/
|
|
541
|
-
NgxsLoggerPluginOptions.prototype.disabled;
|
|
542
|
-
/**
|
|
543
|
-
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
544
|
-
* @type {?|undefined}
|
|
545
|
-
*/
|
|
546
|
-
NgxsLoggerPluginOptions.prototype.filter;
|
|
547
|
-
}
|
|
548
|
-
/** @type {?} */
|
|
523
|
+
/**
|
|
524
|
+
* @fileoverview added by tsickle
|
|
525
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
526
|
+
*/
|
|
527
|
+
/**
|
|
528
|
+
* @record
|
|
529
|
+
*/
|
|
530
|
+
function NgxsLoggerPluginOptions() { }
|
|
531
|
+
if (false) {
|
|
532
|
+
/**
|
|
533
|
+
* Auto expand logged actions
|
|
534
|
+
* @type {?|undefined}
|
|
535
|
+
*/
|
|
536
|
+
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
537
|
+
/**
|
|
538
|
+
* Provide alternate console.log implementation
|
|
539
|
+
* @type {?|undefined}
|
|
540
|
+
*/
|
|
541
|
+
NgxsLoggerPluginOptions.prototype.logger;
|
|
542
|
+
/**
|
|
543
|
+
* Disable the logger. Useful for prod mode.
|
|
544
|
+
* @type {?|undefined}
|
|
545
|
+
*/
|
|
546
|
+
NgxsLoggerPluginOptions.prototype.disabled;
|
|
547
|
+
/**
|
|
548
|
+
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
549
|
+
* @type {?|undefined}
|
|
550
|
+
*/
|
|
551
|
+
NgxsLoggerPluginOptions.prototype.filter;
|
|
552
|
+
}
|
|
553
|
+
/** @type {?} */
|
|
549
554
|
var NGXS_LOGGER_PLUGIN_OPTIONS = new core.InjectionToken('NGXS_LOGGER_PLUGIN_OPTIONS');
|
|
550
555
|
|
|
551
|
-
/**
|
|
552
|
-
* @fileoverview added by tsickle
|
|
553
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
554
|
-
*/
|
|
555
|
-
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
556
|
-
function NgxsLoggerPlugin(_options, _injector) {
|
|
557
|
-
this._options = _options;
|
|
558
|
-
this._injector = _injector;
|
|
559
|
-
}
|
|
560
|
-
/**
|
|
561
|
-
* @param {?} state
|
|
562
|
-
* @param {?} event
|
|
563
|
-
* @param {?} next
|
|
564
|
-
* @return {?}
|
|
565
|
-
*/
|
|
566
|
-
NgxsLoggerPlugin.prototype.handle = /**
|
|
567
|
-
* @param {?} state
|
|
568
|
-
* @param {?} event
|
|
569
|
-
* @param {?} next
|
|
570
|
-
* @return {?}
|
|
571
|
-
*/
|
|
572
|
-
function (state, event, next) {
|
|
573
|
-
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
574
|
-
return next(state, event);
|
|
575
|
-
}
|
|
576
|
-
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
577
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
578
|
-
this._store = this._store || this._injector.get(store.Store);
|
|
579
|
-
/** @type {?} */
|
|
580
|
-
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
581
|
-
actionLogger.dispatched(state);
|
|
582
|
-
return next(state, event).pipe(operators.tap((/**
|
|
583
|
-
* @param {?} nextState
|
|
584
|
-
* @return {?}
|
|
585
|
-
*/
|
|
586
|
-
function (nextState) {
|
|
587
|
-
actionLogger.completed(nextState);
|
|
588
|
-
})), operators.catchError((/**
|
|
589
|
-
* @param {?} error
|
|
590
|
-
* @return {?}
|
|
591
|
-
*/
|
|
592
|
-
function (error) {
|
|
593
|
-
actionLogger.errored(error);
|
|
594
|
-
throw error;
|
|
595
|
-
})));
|
|
596
|
-
};
|
|
597
|
-
NgxsLoggerPlugin.decorators = [
|
|
598
|
-
{ type: core.Injectable }
|
|
599
|
-
];
|
|
600
|
-
/** @nocollapse */
|
|
601
|
-
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
602
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
603
|
-
{ type: core.Injector }
|
|
604
|
-
]; };
|
|
605
|
-
return NgxsLoggerPlugin;
|
|
606
|
-
}());
|
|
607
|
-
if (false) {
|
|
608
|
-
/**
|
|
609
|
-
* @type {?}
|
|
610
|
-
* @private
|
|
611
|
-
*/
|
|
612
|
-
NgxsLoggerPlugin.prototype._store;
|
|
613
|
-
/**
|
|
614
|
-
* @type {?}
|
|
615
|
-
* @private
|
|
616
|
-
*/
|
|
617
|
-
NgxsLoggerPlugin.prototype._logWriter;
|
|
618
|
-
/**
|
|
619
|
-
* @type {?}
|
|
620
|
-
* @private
|
|
621
|
-
*/
|
|
622
|
-
NgxsLoggerPlugin.prototype._options;
|
|
623
|
-
/**
|
|
624
|
-
* @type {?}
|
|
625
|
-
* @private
|
|
626
|
-
*/
|
|
627
|
-
NgxsLoggerPlugin.prototype._injector;
|
|
556
|
+
/**
|
|
557
|
+
* @fileoverview added by tsickle
|
|
558
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
559
|
+
*/
|
|
560
|
+
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
561
|
+
function NgxsLoggerPlugin(_options, _injector) {
|
|
562
|
+
this._options = _options;
|
|
563
|
+
this._injector = _injector;
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* @param {?} state
|
|
567
|
+
* @param {?} event
|
|
568
|
+
* @param {?} next
|
|
569
|
+
* @return {?}
|
|
570
|
+
*/
|
|
571
|
+
NgxsLoggerPlugin.prototype.handle = /**
|
|
572
|
+
* @param {?} state
|
|
573
|
+
* @param {?} event
|
|
574
|
+
* @param {?} next
|
|
575
|
+
* @return {?}
|
|
576
|
+
*/
|
|
577
|
+
function (state, event, next) {
|
|
578
|
+
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
579
|
+
return next(state, event);
|
|
580
|
+
}
|
|
581
|
+
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
582
|
+
// Retrieve lazily to avoid cyclic dependency exception
|
|
583
|
+
this._store = this._store || this._injector.get(store.Store);
|
|
584
|
+
/** @type {?} */
|
|
585
|
+
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
586
|
+
actionLogger.dispatched(state);
|
|
587
|
+
return next(state, event).pipe(operators.tap((/**
|
|
588
|
+
* @param {?} nextState
|
|
589
|
+
* @return {?}
|
|
590
|
+
*/
|
|
591
|
+
function (nextState) {
|
|
592
|
+
actionLogger.completed(nextState);
|
|
593
|
+
})), operators.catchError((/**
|
|
594
|
+
* @param {?} error
|
|
595
|
+
* @return {?}
|
|
596
|
+
*/
|
|
597
|
+
function (error) {
|
|
598
|
+
actionLogger.errored(error);
|
|
599
|
+
throw error;
|
|
600
|
+
})));
|
|
601
|
+
};
|
|
602
|
+
NgxsLoggerPlugin.decorators = [
|
|
603
|
+
{ type: core.Injectable }
|
|
604
|
+
];
|
|
605
|
+
/** @nocollapse */
|
|
606
|
+
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
607
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
608
|
+
{ type: core.Injector }
|
|
609
|
+
]; };
|
|
610
|
+
return NgxsLoggerPlugin;
|
|
611
|
+
}());
|
|
612
|
+
if (false) {
|
|
613
|
+
/**
|
|
614
|
+
* @type {?}
|
|
615
|
+
* @private
|
|
616
|
+
*/
|
|
617
|
+
NgxsLoggerPlugin.prototype._store;
|
|
618
|
+
/**
|
|
619
|
+
* @type {?}
|
|
620
|
+
* @private
|
|
621
|
+
*/
|
|
622
|
+
NgxsLoggerPlugin.prototype._logWriter;
|
|
623
|
+
/**
|
|
624
|
+
* @type {?}
|
|
625
|
+
* @private
|
|
626
|
+
*/
|
|
627
|
+
NgxsLoggerPlugin.prototype._options;
|
|
628
|
+
/**
|
|
629
|
+
* @type {?}
|
|
630
|
+
* @private
|
|
631
|
+
*/
|
|
632
|
+
NgxsLoggerPlugin.prototype._injector;
|
|
628
633
|
}
|
|
629
634
|
|
|
630
|
-
/**
|
|
631
|
-
* @fileoverview added by tsickle
|
|
632
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
633
|
-
*/
|
|
634
|
-
/** @type {?} */
|
|
635
|
-
var USER_OPTIONS = new core.InjectionToken('LOGGER_USER_OPTIONS');
|
|
636
|
-
/**
|
|
637
|
-
* @param {?} options
|
|
638
|
-
* @return {?}
|
|
639
|
-
*/
|
|
640
|
-
function loggerOptionsFactory(options) {
|
|
641
|
-
/** @type {?} */
|
|
642
|
-
var defaultLoggerOptions = {
|
|
643
|
-
logger: console,
|
|
644
|
-
collapsed: false,
|
|
645
|
-
disabled: false,
|
|
646
|
-
filter: (/**
|
|
647
|
-
* @return {?}
|
|
648
|
-
*/
|
|
649
|
-
function () { return true; })
|
|
650
|
-
};
|
|
651
|
-
return __assign({}, defaultLoggerOptions, options);
|
|
652
|
-
}
|
|
653
|
-
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
654
|
-
function NgxsLoggerPluginModule() {
|
|
655
|
-
}
|
|
656
|
-
/**
|
|
657
|
-
* @param {?=} options
|
|
658
|
-
* @return {?}
|
|
659
|
-
*/
|
|
660
|
-
NgxsLoggerPluginModule.forRoot = /**
|
|
661
|
-
* @param {?=} options
|
|
662
|
-
* @return {?}
|
|
663
|
-
*/
|
|
664
|
-
function (options) {
|
|
665
|
-
return {
|
|
666
|
-
ngModule: NgxsLoggerPluginModule,
|
|
667
|
-
providers: [
|
|
668
|
-
{
|
|
669
|
-
provide: store.NGXS_PLUGINS,
|
|
670
|
-
useClass: NgxsLoggerPlugin,
|
|
671
|
-
multi: true
|
|
672
|
-
},
|
|
673
|
-
{
|
|
674
|
-
provide: USER_OPTIONS,
|
|
675
|
-
useValue: options
|
|
676
|
-
},
|
|
677
|
-
{
|
|
678
|
-
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
679
|
-
useFactory: loggerOptionsFactory,
|
|
680
|
-
deps: [USER_OPTIONS]
|
|
681
|
-
}
|
|
682
|
-
]
|
|
683
|
-
};
|
|
684
|
-
};
|
|
685
|
-
NgxsLoggerPluginModule.decorators = [
|
|
686
|
-
{ type: core.NgModule }
|
|
687
|
-
];
|
|
688
|
-
return NgxsLoggerPluginModule;
|
|
635
|
+
/**
|
|
636
|
+
* @fileoverview added by tsickle
|
|
637
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
638
|
+
*/
|
|
639
|
+
/** @type {?} */
|
|
640
|
+
var USER_OPTIONS = new core.InjectionToken('LOGGER_USER_OPTIONS');
|
|
641
|
+
/**
|
|
642
|
+
* @param {?} options
|
|
643
|
+
* @return {?}
|
|
644
|
+
*/
|
|
645
|
+
function loggerOptionsFactory(options) {
|
|
646
|
+
/** @type {?} */
|
|
647
|
+
var defaultLoggerOptions = {
|
|
648
|
+
logger: console,
|
|
649
|
+
collapsed: false,
|
|
650
|
+
disabled: false,
|
|
651
|
+
filter: (/**
|
|
652
|
+
* @return {?}
|
|
653
|
+
*/
|
|
654
|
+
function () { return true; })
|
|
655
|
+
};
|
|
656
|
+
return __assign({}, defaultLoggerOptions, options);
|
|
657
|
+
}
|
|
658
|
+
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
659
|
+
function NgxsLoggerPluginModule() {
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* @param {?=} options
|
|
663
|
+
* @return {?}
|
|
664
|
+
*/
|
|
665
|
+
NgxsLoggerPluginModule.forRoot = /**
|
|
666
|
+
* @param {?=} options
|
|
667
|
+
* @return {?}
|
|
668
|
+
*/
|
|
669
|
+
function (options) {
|
|
670
|
+
return {
|
|
671
|
+
ngModule: NgxsLoggerPluginModule,
|
|
672
|
+
providers: [
|
|
673
|
+
{
|
|
674
|
+
provide: store.NGXS_PLUGINS,
|
|
675
|
+
useClass: NgxsLoggerPlugin,
|
|
676
|
+
multi: true
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
provide: USER_OPTIONS,
|
|
680
|
+
useValue: options
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
684
|
+
useFactory: loggerOptionsFactory,
|
|
685
|
+
deps: [USER_OPTIONS]
|
|
686
|
+
}
|
|
687
|
+
]
|
|
688
|
+
};
|
|
689
|
+
};
|
|
690
|
+
NgxsLoggerPluginModule.decorators = [
|
|
691
|
+
{ type: core.NgModule }
|
|
692
|
+
];
|
|
693
|
+
return NgxsLoggerPluginModule;
|
|
689
694
|
}());
|
|
690
695
|
|
|
691
696
|
exports.NGXS_LOGGER_PLUGIN_OPTIONS = NGXS_LOGGER_PLUGIN_OPTIONS;
|