@ngxs/logger-plugin 3.7.4 → 3.7.5-dev.master-17a1bb8
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 +458 -458
- package/bundles/ngxs-logger-plugin.umd.js.map +1 -1
- 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 +3 -3
- 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
|
@@ -3,489 +3,489 @@ import { InjectionToken, Injectable, Inject, Injector, NgModule } from '@angular
|
|
|
3
3
|
import { getActionTypeFromInstance, Store, NGXS_PLUGINS } from '@ngxs/store';
|
|
4
4
|
import { tap, catchError } from 'rxjs/operators';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @fileoverview added by tsickle
|
|
8
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
9
|
-
*/
|
|
10
|
-
/** @type {?} */
|
|
11
|
-
var repeat = (/**
|
|
12
|
-
* @param {?} str
|
|
13
|
-
* @param {?} times
|
|
14
|
-
* @return {?}
|
|
15
|
-
*/
|
|
16
|
-
function (str, times) { return new Array(times + 1).join(str); });
|
|
17
|
-
/** @type {?} */
|
|
18
|
-
var pad = (/**
|
|
19
|
-
* @param {?} num
|
|
20
|
-
* @param {?} maxLength
|
|
21
|
-
* @return {?}
|
|
22
|
-
*/
|
|
23
|
-
function (num, maxLength) {
|
|
24
|
-
return repeat('0', maxLength - num.toString().length) + num;
|
|
25
|
-
});
|
|
26
|
-
/**
|
|
27
|
-
* @param {?} time
|
|
28
|
-
* @return {?}
|
|
29
|
-
*/
|
|
30
|
-
function formatTime(time) {
|
|
31
|
-
return (pad(time.getHours(), 2) +
|
|
32
|
-
":" +
|
|
33
|
-
pad(time.getMinutes(), 2) +
|
|
34
|
-
":" +
|
|
35
|
-
pad(time.getSeconds(), 2) +
|
|
36
|
-
"." +
|
|
37
|
-
pad(time.getMilliseconds(), 3));
|
|
6
|
+
/**
|
|
7
|
+
* @fileoverview added by tsickle
|
|
8
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
9
|
+
*/
|
|
10
|
+
/** @type {?} */
|
|
11
|
+
var repeat = (/**
|
|
12
|
+
* @param {?} str
|
|
13
|
+
* @param {?} times
|
|
14
|
+
* @return {?}
|
|
15
|
+
*/
|
|
16
|
+
function (str, times) { return new Array(times + 1).join(str); });
|
|
17
|
+
/** @type {?} */
|
|
18
|
+
var pad = (/**
|
|
19
|
+
* @param {?} num
|
|
20
|
+
* @param {?} maxLength
|
|
21
|
+
* @return {?}
|
|
22
|
+
*/
|
|
23
|
+
function (num, maxLength) {
|
|
24
|
+
return repeat('0', maxLength - num.toString().length) + num;
|
|
25
|
+
});
|
|
26
|
+
/**
|
|
27
|
+
* @param {?} time
|
|
28
|
+
* @return {?}
|
|
29
|
+
*/
|
|
30
|
+
function formatTime(time) {
|
|
31
|
+
return (pad(time.getHours(), 2) +
|
|
32
|
+
":" +
|
|
33
|
+
pad(time.getMinutes(), 2) +
|
|
34
|
+
":" +
|
|
35
|
+
pad(time.getSeconds(), 2) +
|
|
36
|
+
"." +
|
|
37
|
+
pad(time.getMilliseconds(), 3));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/**
|
|
41
|
-
* @fileoverview added by tsickle
|
|
42
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
43
|
-
*/
|
|
44
|
-
var ActionLogger = /** @class */ (function () {
|
|
45
|
-
function ActionLogger(action, store, logWriter) {
|
|
46
|
-
this.action = action;
|
|
47
|
-
this.store = store;
|
|
48
|
-
this.logWriter = logWriter;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @param {?} state
|
|
52
|
-
* @return {?}
|
|
53
|
-
*/
|
|
54
|
-
ActionLogger.prototype.dispatched = /**
|
|
55
|
-
* @param {?} state
|
|
56
|
-
* @return {?}
|
|
57
|
-
*/
|
|
58
|
-
function (state) {
|
|
59
|
-
/** @type {?} */
|
|
60
|
-
var actionName = getActionTypeFromInstance(this.action);
|
|
61
|
-
/** @type {?} */
|
|
62
|
-
var formattedTime = formatTime(new Date());
|
|
63
|
-
/** @type {?} */
|
|
64
|
-
var message = "action " + actionName + " @ " + formattedTime;
|
|
65
|
-
this.logWriter.startGroup(message);
|
|
66
|
-
// print payload only if at least one property is supplied
|
|
67
|
-
if (this._hasPayload(this.action)) {
|
|
68
|
-
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
69
|
-
}
|
|
70
|
-
this.logWriter.logGrey('prev state', state);
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* @param {?} nextState
|
|
74
|
-
* @return {?}
|
|
75
|
-
*/
|
|
76
|
-
ActionLogger.prototype.completed = /**
|
|
77
|
-
* @param {?} nextState
|
|
78
|
-
* @return {?}
|
|
79
|
-
*/
|
|
80
|
-
function (nextState) {
|
|
81
|
-
this.logWriter.logGreen('next state', nextState);
|
|
82
|
-
this.logWriter.endGroup();
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* @param {?} error
|
|
86
|
-
* @return {?}
|
|
87
|
-
*/
|
|
88
|
-
ActionLogger.prototype.errored = /**
|
|
89
|
-
* @param {?} error
|
|
90
|
-
* @return {?}
|
|
91
|
-
*/
|
|
92
|
-
function (error) {
|
|
93
|
-
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
94
|
-
this.logWriter.logRedish('error', error);
|
|
95
|
-
this.logWriter.endGroup();
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* @private
|
|
99
|
-
* @param {?} event
|
|
100
|
-
* @return {?}
|
|
101
|
-
*/
|
|
102
|
-
ActionLogger.prototype._hasPayload = /**
|
|
103
|
-
* @private
|
|
104
|
-
* @param {?} event
|
|
105
|
-
* @return {?}
|
|
106
|
-
*/
|
|
107
|
-
function (event) {
|
|
108
|
-
/** @type {?} */
|
|
109
|
-
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
110
|
-
return nonEmptyProperties.length > 0;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* @private
|
|
114
|
-
* @param {?} event
|
|
115
|
-
* @return {?}
|
|
116
|
-
*/
|
|
117
|
-
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
118
|
-
* @private
|
|
119
|
-
* @param {?} event
|
|
120
|
-
* @return {?}
|
|
121
|
-
*/
|
|
122
|
-
function (event) {
|
|
123
|
-
/** @type {?} */
|
|
124
|
-
var keys = Object.keys(event);
|
|
125
|
-
/** @type {?} */
|
|
126
|
-
var values = keys.map((/**
|
|
127
|
-
* @param {?} key
|
|
128
|
-
* @return {?}
|
|
129
|
-
*/
|
|
130
|
-
function (key) { return event[key]; }));
|
|
131
|
-
return values.filter((/**
|
|
132
|
-
* @param {?} value
|
|
133
|
-
* @return {?}
|
|
134
|
-
*/
|
|
135
|
-
function (value) { return value !== undefined; }));
|
|
136
|
-
};
|
|
137
|
-
return ActionLogger;
|
|
138
|
-
}());
|
|
139
|
-
if (false) {
|
|
140
|
-
/**
|
|
141
|
-
* @type {?}
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
144
|
-
ActionLogger.prototype.action;
|
|
145
|
-
/**
|
|
146
|
-
* @type {?}
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
ActionLogger.prototype.store;
|
|
150
|
-
/**
|
|
151
|
-
* @type {?}
|
|
152
|
-
* @private
|
|
153
|
-
*/
|
|
154
|
-
ActionLogger.prototype.logWriter;
|
|
40
|
+
/**
|
|
41
|
+
* @fileoverview added by tsickle
|
|
42
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
43
|
+
*/
|
|
44
|
+
var ActionLogger = /** @class */ (function () {
|
|
45
|
+
function ActionLogger(action, store, logWriter) {
|
|
46
|
+
this.action = action;
|
|
47
|
+
this.store = store;
|
|
48
|
+
this.logWriter = logWriter;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @param {?} state
|
|
52
|
+
* @return {?}
|
|
53
|
+
*/
|
|
54
|
+
ActionLogger.prototype.dispatched = /**
|
|
55
|
+
* @param {?} state
|
|
56
|
+
* @return {?}
|
|
57
|
+
*/
|
|
58
|
+
function (state) {
|
|
59
|
+
/** @type {?} */
|
|
60
|
+
var actionName = getActionTypeFromInstance(this.action);
|
|
61
|
+
/** @type {?} */
|
|
62
|
+
var formattedTime = formatTime(new Date());
|
|
63
|
+
/** @type {?} */
|
|
64
|
+
var message = "action " + actionName + " @ " + formattedTime;
|
|
65
|
+
this.logWriter.startGroup(message);
|
|
66
|
+
// print payload only if at least one property is supplied
|
|
67
|
+
if (this._hasPayload(this.action)) {
|
|
68
|
+
this.logWriter.logGrey('payload', __assign({}, this.action));
|
|
69
|
+
}
|
|
70
|
+
this.logWriter.logGrey('prev state', state);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @param {?} nextState
|
|
74
|
+
* @return {?}
|
|
75
|
+
*/
|
|
76
|
+
ActionLogger.prototype.completed = /**
|
|
77
|
+
* @param {?} nextState
|
|
78
|
+
* @return {?}
|
|
79
|
+
*/
|
|
80
|
+
function (nextState) {
|
|
81
|
+
this.logWriter.logGreen('next state', nextState);
|
|
82
|
+
this.logWriter.endGroup();
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* @param {?} error
|
|
86
|
+
* @return {?}
|
|
87
|
+
*/
|
|
88
|
+
ActionLogger.prototype.errored = /**
|
|
89
|
+
* @param {?} error
|
|
90
|
+
* @return {?}
|
|
91
|
+
*/
|
|
92
|
+
function (error) {
|
|
93
|
+
this.logWriter.logRedish('next state after error', this.store.snapshot());
|
|
94
|
+
this.logWriter.logRedish('error', error);
|
|
95
|
+
this.logWriter.endGroup();
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* @private
|
|
99
|
+
* @param {?} event
|
|
100
|
+
* @return {?}
|
|
101
|
+
*/
|
|
102
|
+
ActionLogger.prototype._hasPayload = /**
|
|
103
|
+
* @private
|
|
104
|
+
* @param {?} event
|
|
105
|
+
* @return {?}
|
|
106
|
+
*/
|
|
107
|
+
function (event) {
|
|
108
|
+
/** @type {?} */
|
|
109
|
+
var nonEmptyProperties = this._getNonEmptyProperties(event);
|
|
110
|
+
return nonEmptyProperties.length > 0;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @private
|
|
114
|
+
* @param {?} event
|
|
115
|
+
* @return {?}
|
|
116
|
+
*/
|
|
117
|
+
ActionLogger.prototype._getNonEmptyProperties = /**
|
|
118
|
+
* @private
|
|
119
|
+
* @param {?} event
|
|
120
|
+
* @return {?}
|
|
121
|
+
*/
|
|
122
|
+
function (event) {
|
|
123
|
+
/** @type {?} */
|
|
124
|
+
var keys = Object.keys(event);
|
|
125
|
+
/** @type {?} */
|
|
126
|
+
var values = keys.map((/**
|
|
127
|
+
* @param {?} key
|
|
128
|
+
* @return {?}
|
|
129
|
+
*/
|
|
130
|
+
function (key) { return event[key]; }));
|
|
131
|
+
return values.filter((/**
|
|
132
|
+
* @param {?} value
|
|
133
|
+
* @return {?}
|
|
134
|
+
*/
|
|
135
|
+
function (value) { return value !== undefined; }));
|
|
136
|
+
};
|
|
137
|
+
return ActionLogger;
|
|
138
|
+
}());
|
|
139
|
+
if (false) {
|
|
140
|
+
/**
|
|
141
|
+
* @type {?}
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
ActionLogger.prototype.action;
|
|
145
|
+
/**
|
|
146
|
+
* @type {?}
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
ActionLogger.prototype.store;
|
|
150
|
+
/**
|
|
151
|
+
* @type {?}
|
|
152
|
+
* @private
|
|
153
|
+
*/
|
|
154
|
+
ActionLogger.prototype.logWriter;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
/**
|
|
158
|
-
* @fileoverview added by tsickle
|
|
159
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
160
|
-
*/
|
|
161
|
-
var LogWriter = /** @class */ (function () {
|
|
162
|
-
function LogWriter(options) {
|
|
163
|
-
this.options = options;
|
|
164
|
-
this.options = this.options || (/** @type {?} */ ({}));
|
|
165
|
-
this.logger = options.logger || console;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @param {?} message
|
|
169
|
-
* @return {?}
|
|
170
|
-
*/
|
|
171
|
-
LogWriter.prototype.startGroup = /**
|
|
172
|
-
* @param {?} message
|
|
173
|
-
* @return {?}
|
|
174
|
-
*/
|
|
175
|
-
function (message) {
|
|
176
|
-
/** @type {?} */
|
|
177
|
-
var startGroupFn = this.options.collapsed
|
|
178
|
-
? this.logger.groupCollapsed
|
|
179
|
-
: this.logger.group;
|
|
180
|
-
try {
|
|
181
|
-
startGroupFn.call(this.logger, message);
|
|
182
|
-
}
|
|
183
|
-
catch (e) {
|
|
184
|
-
console.log(message);
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
/**
|
|
188
|
-
* @return {?}
|
|
189
|
-
*/
|
|
190
|
-
LogWriter.prototype.endGroup = /**
|
|
191
|
-
* @return {?}
|
|
192
|
-
*/
|
|
193
|
-
function () {
|
|
194
|
-
try {
|
|
195
|
-
this.logger.groupEnd();
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
this.logger.log('—— log end ——');
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* @param {?} title
|
|
203
|
-
* @param {?} payload
|
|
204
|
-
* @return {?}
|
|
205
|
-
*/
|
|
206
|
-
LogWriter.prototype.logGrey = /**
|
|
207
|
-
* @param {?} title
|
|
208
|
-
* @param {?} payload
|
|
209
|
-
* @return {?}
|
|
210
|
-
*/
|
|
211
|
-
function (title, payload) {
|
|
212
|
-
/** @type {?} */
|
|
213
|
-
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
214
|
-
this.log(title, greyStyle, payload);
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* @param {?} title
|
|
218
|
-
* @param {?} payload
|
|
219
|
-
* @return {?}
|
|
220
|
-
*/
|
|
221
|
-
LogWriter.prototype.logGreen = /**
|
|
222
|
-
* @param {?} title
|
|
223
|
-
* @param {?} payload
|
|
224
|
-
* @return {?}
|
|
225
|
-
*/
|
|
226
|
-
function (title, payload) {
|
|
227
|
-
/** @type {?} */
|
|
228
|
-
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
229
|
-
this.log(title, greenStyle, payload);
|
|
230
|
-
};
|
|
231
|
-
/**
|
|
232
|
-
* @param {?} title
|
|
233
|
-
* @param {?} payload
|
|
234
|
-
* @return {?}
|
|
235
|
-
*/
|
|
236
|
-
LogWriter.prototype.logRedish = /**
|
|
237
|
-
* @param {?} title
|
|
238
|
-
* @param {?} payload
|
|
239
|
-
* @return {?}
|
|
240
|
-
*/
|
|
241
|
-
function (title, payload) {
|
|
242
|
-
/** @type {?} */
|
|
243
|
-
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
244
|
-
this.log(title, redishStyle, payload);
|
|
245
|
-
};
|
|
246
|
-
/**
|
|
247
|
-
* @param {?} title
|
|
248
|
-
* @param {?} color
|
|
249
|
-
* @param {?} payload
|
|
250
|
-
* @return {?}
|
|
251
|
-
*/
|
|
252
|
-
LogWriter.prototype.log = /**
|
|
253
|
-
* @param {?} title
|
|
254
|
-
* @param {?} color
|
|
255
|
-
* @param {?} payload
|
|
256
|
-
* @return {?}
|
|
257
|
-
*/
|
|
258
|
-
function (title, color, payload) {
|
|
259
|
-
if (this.isIE()) {
|
|
260
|
-
this.logger.log(title, payload);
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
this.logger.log('%c ' + title, color, payload);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
/**
|
|
267
|
-
* @return {?}
|
|
268
|
-
*/
|
|
269
|
-
LogWriter.prototype.isIE = /**
|
|
270
|
-
* @return {?}
|
|
271
|
-
*/
|
|
272
|
-
function () {
|
|
273
|
-
/** @type {?} */
|
|
274
|
-
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
275
|
-
? window.navigator.userAgent
|
|
276
|
-
: '';
|
|
277
|
-
/** @type {?} */
|
|
278
|
-
var msIE = false;
|
|
279
|
-
/** @type {?} */
|
|
280
|
-
var oldIE = ua.indexOf('MSIE ');
|
|
281
|
-
/** @type {?} */
|
|
282
|
-
var newIE = ua.indexOf('Trident/');
|
|
283
|
-
if (oldIE > -1 || newIE > -1) {
|
|
284
|
-
msIE = true;
|
|
285
|
-
}
|
|
286
|
-
return msIE;
|
|
287
|
-
};
|
|
288
|
-
return LogWriter;
|
|
289
|
-
}());
|
|
290
|
-
if (false) {
|
|
291
|
-
/**
|
|
292
|
-
* @type {?}
|
|
293
|
-
* @private
|
|
294
|
-
*/
|
|
295
|
-
LogWriter.prototype.logger;
|
|
296
|
-
/**
|
|
297
|
-
* @type {?}
|
|
298
|
-
* @private
|
|
299
|
-
*/
|
|
300
|
-
LogWriter.prototype.options;
|
|
157
|
+
/**
|
|
158
|
+
* @fileoverview added by tsickle
|
|
159
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
160
|
+
*/
|
|
161
|
+
var LogWriter = /** @class */ (function () {
|
|
162
|
+
function LogWriter(options) {
|
|
163
|
+
this.options = options;
|
|
164
|
+
this.options = this.options || (/** @type {?} */ ({}));
|
|
165
|
+
this.logger = options.logger || console;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* @param {?} message
|
|
169
|
+
* @return {?}
|
|
170
|
+
*/
|
|
171
|
+
LogWriter.prototype.startGroup = /**
|
|
172
|
+
* @param {?} message
|
|
173
|
+
* @return {?}
|
|
174
|
+
*/
|
|
175
|
+
function (message) {
|
|
176
|
+
/** @type {?} */
|
|
177
|
+
var startGroupFn = this.options.collapsed
|
|
178
|
+
? this.logger.groupCollapsed
|
|
179
|
+
: this.logger.group;
|
|
180
|
+
try {
|
|
181
|
+
startGroupFn.call(this.logger, message);
|
|
182
|
+
}
|
|
183
|
+
catch (e) {
|
|
184
|
+
console.log(message);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* @return {?}
|
|
189
|
+
*/
|
|
190
|
+
LogWriter.prototype.endGroup = /**
|
|
191
|
+
* @return {?}
|
|
192
|
+
*/
|
|
193
|
+
function () {
|
|
194
|
+
try {
|
|
195
|
+
this.logger.groupEnd();
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
this.logger.log('—— log end ——');
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* @param {?} title
|
|
203
|
+
* @param {?} payload
|
|
204
|
+
* @return {?}
|
|
205
|
+
*/
|
|
206
|
+
LogWriter.prototype.logGrey = /**
|
|
207
|
+
* @param {?} title
|
|
208
|
+
* @param {?} payload
|
|
209
|
+
* @return {?}
|
|
210
|
+
*/
|
|
211
|
+
function (title, payload) {
|
|
212
|
+
/** @type {?} */
|
|
213
|
+
var greyStyle = 'color: #9E9E9E; font-weight: bold';
|
|
214
|
+
this.log(title, greyStyle, payload);
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* @param {?} title
|
|
218
|
+
* @param {?} payload
|
|
219
|
+
* @return {?}
|
|
220
|
+
*/
|
|
221
|
+
LogWriter.prototype.logGreen = /**
|
|
222
|
+
* @param {?} title
|
|
223
|
+
* @param {?} payload
|
|
224
|
+
* @return {?}
|
|
225
|
+
*/
|
|
226
|
+
function (title, payload) {
|
|
227
|
+
/** @type {?} */
|
|
228
|
+
var greenStyle = 'color: #4CAF50; font-weight: bold';
|
|
229
|
+
this.log(title, greenStyle, payload);
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* @param {?} title
|
|
233
|
+
* @param {?} payload
|
|
234
|
+
* @return {?}
|
|
235
|
+
*/
|
|
236
|
+
LogWriter.prototype.logRedish = /**
|
|
237
|
+
* @param {?} title
|
|
238
|
+
* @param {?} payload
|
|
239
|
+
* @return {?}
|
|
240
|
+
*/
|
|
241
|
+
function (title, payload) {
|
|
242
|
+
/** @type {?} */
|
|
243
|
+
var redishStyle = 'color: #FD8182; font-weight: bold';
|
|
244
|
+
this.log(title, redishStyle, payload);
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* @param {?} title
|
|
248
|
+
* @param {?} color
|
|
249
|
+
* @param {?} payload
|
|
250
|
+
* @return {?}
|
|
251
|
+
*/
|
|
252
|
+
LogWriter.prototype.log = /**
|
|
253
|
+
* @param {?} title
|
|
254
|
+
* @param {?} color
|
|
255
|
+
* @param {?} payload
|
|
256
|
+
* @return {?}
|
|
257
|
+
*/
|
|
258
|
+
function (title, color, payload) {
|
|
259
|
+
if (this.isIE()) {
|
|
260
|
+
this.logger.log(title, payload);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
this.logger.log('%c ' + title, color, payload);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* @return {?}
|
|
268
|
+
*/
|
|
269
|
+
LogWriter.prototype.isIE = /**
|
|
270
|
+
* @return {?}
|
|
271
|
+
*/
|
|
272
|
+
function () {
|
|
273
|
+
/** @type {?} */
|
|
274
|
+
var ua = typeof window !== 'undefined' && window.navigator.userAgent
|
|
275
|
+
? window.navigator.userAgent
|
|
276
|
+
: '';
|
|
277
|
+
/** @type {?} */
|
|
278
|
+
var msIE = false;
|
|
279
|
+
/** @type {?} */
|
|
280
|
+
var oldIE = ua.indexOf('MSIE ');
|
|
281
|
+
/** @type {?} */
|
|
282
|
+
var newIE = ua.indexOf('Trident/');
|
|
283
|
+
if (oldIE > -1 || newIE > -1) {
|
|
284
|
+
msIE = true;
|
|
285
|
+
}
|
|
286
|
+
return msIE;
|
|
287
|
+
};
|
|
288
|
+
return LogWriter;
|
|
289
|
+
}());
|
|
290
|
+
if (false) {
|
|
291
|
+
/**
|
|
292
|
+
* @type {?}
|
|
293
|
+
* @private
|
|
294
|
+
*/
|
|
295
|
+
LogWriter.prototype.logger;
|
|
296
|
+
/**
|
|
297
|
+
* @type {?}
|
|
298
|
+
* @private
|
|
299
|
+
*/
|
|
300
|
+
LogWriter.prototype.options;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
/**
|
|
304
|
-
* @fileoverview added by tsickle
|
|
305
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
306
|
-
*/
|
|
307
|
-
/**
|
|
308
|
-
* @record
|
|
309
|
-
*/
|
|
310
|
-
function NgxsLoggerPluginOptions() { }
|
|
311
|
-
if (false) {
|
|
312
|
-
/**
|
|
313
|
-
* Auto expand logged actions
|
|
314
|
-
* @type {?|undefined}
|
|
315
|
-
*/
|
|
316
|
-
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
317
|
-
/**
|
|
318
|
-
* Provide alternate console.log implementation
|
|
319
|
-
* @type {?|undefined}
|
|
320
|
-
*/
|
|
321
|
-
NgxsLoggerPluginOptions.prototype.logger;
|
|
322
|
-
/**
|
|
323
|
-
* Disable the logger. Useful for prod mode.
|
|
324
|
-
* @type {?|undefined}
|
|
325
|
-
*/
|
|
326
|
-
NgxsLoggerPluginOptions.prototype.disabled;
|
|
327
|
-
/**
|
|
328
|
-
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
329
|
-
* @type {?|undefined}
|
|
330
|
-
*/
|
|
331
|
-
NgxsLoggerPluginOptions.prototype.filter;
|
|
332
|
-
}
|
|
333
|
-
/** @type {?} */
|
|
303
|
+
/**
|
|
304
|
+
* @fileoverview added by tsickle
|
|
305
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
306
|
+
*/
|
|
307
|
+
/**
|
|
308
|
+
* @record
|
|
309
|
+
*/
|
|
310
|
+
function NgxsLoggerPluginOptions() { }
|
|
311
|
+
if (false) {
|
|
312
|
+
/**
|
|
313
|
+
* Auto expand logged actions
|
|
314
|
+
* @type {?|undefined}
|
|
315
|
+
*/
|
|
316
|
+
NgxsLoggerPluginOptions.prototype.collapsed;
|
|
317
|
+
/**
|
|
318
|
+
* Provide alternate console.log implementation
|
|
319
|
+
* @type {?|undefined}
|
|
320
|
+
*/
|
|
321
|
+
NgxsLoggerPluginOptions.prototype.logger;
|
|
322
|
+
/**
|
|
323
|
+
* Disable the logger. Useful for prod mode.
|
|
324
|
+
* @type {?|undefined}
|
|
325
|
+
*/
|
|
326
|
+
NgxsLoggerPluginOptions.prototype.disabled;
|
|
327
|
+
/**
|
|
328
|
+
* Predicate for actions to be the logged. Takes action and state snapshot as parameters
|
|
329
|
+
* @type {?|undefined}
|
|
330
|
+
*/
|
|
331
|
+
NgxsLoggerPluginOptions.prototype.filter;
|
|
332
|
+
}
|
|
333
|
+
/** @type {?} */
|
|
334
334
|
var NGXS_LOGGER_PLUGIN_OPTIONS = new InjectionToken('NGXS_LOGGER_PLUGIN_OPTIONS');
|
|
335
335
|
|
|
336
|
-
/**
|
|
337
|
-
* @fileoverview added by tsickle
|
|
338
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
339
|
-
*/
|
|
340
|
-
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
341
|
-
function NgxsLoggerPlugin(_options, _injector) {
|
|
342
|
-
this._options = _options;
|
|
343
|
-
this._injector = _injector;
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* @param {?} state
|
|
347
|
-
* @param {?} event
|
|
348
|
-
* @param {?} next
|
|
349
|
-
* @return {?}
|
|
350
|
-
*/
|
|
351
|
-
NgxsLoggerPlugin.prototype.handle = /**
|
|
352
|
-
* @param {?} state
|
|
353
|
-
* @param {?} event
|
|
354
|
-
* @param {?} next
|
|
355
|
-
* @return {?}
|
|
356
|
-
*/
|
|
357
|
-
function (state, event, next) {
|
|
358
|
-
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
359
|
-
return next(state, event);
|
|
360
|
-
}
|
|
361
|
-
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
362
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
363
|
-
this._store = this._store || this._injector.get(Store);
|
|
364
|
-
/** @type {?} */
|
|
365
|
-
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
366
|
-
actionLogger.dispatched(state);
|
|
367
|
-
return next(state, event).pipe(tap((/**
|
|
368
|
-
* @param {?} nextState
|
|
369
|
-
* @return {?}
|
|
370
|
-
*/
|
|
371
|
-
function (nextState) {
|
|
372
|
-
actionLogger.completed(nextState);
|
|
373
|
-
})), catchError((/**
|
|
374
|
-
* @param {?} error
|
|
375
|
-
* @return {?}
|
|
376
|
-
*/
|
|
377
|
-
function (error) {
|
|
378
|
-
actionLogger.errored(error);
|
|
379
|
-
throw error;
|
|
380
|
-
})));
|
|
381
|
-
};
|
|
382
|
-
NgxsLoggerPlugin.decorators = [
|
|
383
|
-
{ type: Injectable }
|
|
384
|
-
];
|
|
385
|
-
/** @nocollapse */
|
|
386
|
-
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
387
|
-
{ type: undefined, decorators: [{ type: Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
388
|
-
{ type: Injector }
|
|
389
|
-
]; };
|
|
390
|
-
return NgxsLoggerPlugin;
|
|
391
|
-
}());
|
|
392
|
-
if (false) {
|
|
393
|
-
/**
|
|
394
|
-
* @type {?}
|
|
395
|
-
* @private
|
|
396
|
-
*/
|
|
397
|
-
NgxsLoggerPlugin.prototype._store;
|
|
398
|
-
/**
|
|
399
|
-
* @type {?}
|
|
400
|
-
* @private
|
|
401
|
-
*/
|
|
402
|
-
NgxsLoggerPlugin.prototype._logWriter;
|
|
403
|
-
/**
|
|
404
|
-
* @type {?}
|
|
405
|
-
* @private
|
|
406
|
-
*/
|
|
407
|
-
NgxsLoggerPlugin.prototype._options;
|
|
408
|
-
/**
|
|
409
|
-
* @type {?}
|
|
410
|
-
* @private
|
|
411
|
-
*/
|
|
412
|
-
NgxsLoggerPlugin.prototype._injector;
|
|
336
|
+
/**
|
|
337
|
+
* @fileoverview added by tsickle
|
|
338
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
339
|
+
*/
|
|
340
|
+
var NgxsLoggerPlugin = /** @class */ (function () {
|
|
341
|
+
function NgxsLoggerPlugin(_options, _injector) {
|
|
342
|
+
this._options = _options;
|
|
343
|
+
this._injector = _injector;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @param {?} state
|
|
347
|
+
* @param {?} event
|
|
348
|
+
* @param {?} next
|
|
349
|
+
* @return {?}
|
|
350
|
+
*/
|
|
351
|
+
NgxsLoggerPlugin.prototype.handle = /**
|
|
352
|
+
* @param {?} state
|
|
353
|
+
* @param {?} event
|
|
354
|
+
* @param {?} next
|
|
355
|
+
* @return {?}
|
|
356
|
+
*/
|
|
357
|
+
function (state, event, next) {
|
|
358
|
+
if (this._options.disabled || !(/** @type {?} */ (this._options.filter))(event, state)) {
|
|
359
|
+
return next(state, event);
|
|
360
|
+
}
|
|
361
|
+
this._logWriter = this._logWriter || new LogWriter(this._options);
|
|
362
|
+
// Retrieve lazily to avoid cyclic dependency exception
|
|
363
|
+
this._store = this._store || this._injector.get(Store);
|
|
364
|
+
/** @type {?} */
|
|
365
|
+
var actionLogger = new ActionLogger(event, this._store, this._logWriter);
|
|
366
|
+
actionLogger.dispatched(state);
|
|
367
|
+
return next(state, event).pipe(tap((/**
|
|
368
|
+
* @param {?} nextState
|
|
369
|
+
* @return {?}
|
|
370
|
+
*/
|
|
371
|
+
function (nextState) {
|
|
372
|
+
actionLogger.completed(nextState);
|
|
373
|
+
})), catchError((/**
|
|
374
|
+
* @param {?} error
|
|
375
|
+
* @return {?}
|
|
376
|
+
*/
|
|
377
|
+
function (error) {
|
|
378
|
+
actionLogger.errored(error);
|
|
379
|
+
throw error;
|
|
380
|
+
})));
|
|
381
|
+
};
|
|
382
|
+
NgxsLoggerPlugin.decorators = [
|
|
383
|
+
{ type: Injectable }
|
|
384
|
+
];
|
|
385
|
+
/** @nocollapse */
|
|
386
|
+
NgxsLoggerPlugin.ctorParameters = function () { return [
|
|
387
|
+
{ type: undefined, decorators: [{ type: Inject, args: [NGXS_LOGGER_PLUGIN_OPTIONS,] }] },
|
|
388
|
+
{ type: Injector }
|
|
389
|
+
]; };
|
|
390
|
+
return NgxsLoggerPlugin;
|
|
391
|
+
}());
|
|
392
|
+
if (false) {
|
|
393
|
+
/**
|
|
394
|
+
* @type {?}
|
|
395
|
+
* @private
|
|
396
|
+
*/
|
|
397
|
+
NgxsLoggerPlugin.prototype._store;
|
|
398
|
+
/**
|
|
399
|
+
* @type {?}
|
|
400
|
+
* @private
|
|
401
|
+
*/
|
|
402
|
+
NgxsLoggerPlugin.prototype._logWriter;
|
|
403
|
+
/**
|
|
404
|
+
* @type {?}
|
|
405
|
+
* @private
|
|
406
|
+
*/
|
|
407
|
+
NgxsLoggerPlugin.prototype._options;
|
|
408
|
+
/**
|
|
409
|
+
* @type {?}
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
NgxsLoggerPlugin.prototype._injector;
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
/**
|
|
416
|
-
* @fileoverview added by tsickle
|
|
417
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
418
|
-
*/
|
|
419
|
-
/** @type {?} */
|
|
420
|
-
var USER_OPTIONS = new InjectionToken('LOGGER_USER_OPTIONS');
|
|
421
|
-
/**
|
|
422
|
-
* @param {?} options
|
|
423
|
-
* @return {?}
|
|
424
|
-
*/
|
|
425
|
-
function loggerOptionsFactory(options) {
|
|
426
|
-
/** @type {?} */
|
|
427
|
-
var defaultLoggerOptions = {
|
|
428
|
-
logger: console,
|
|
429
|
-
collapsed: false,
|
|
430
|
-
disabled: false,
|
|
431
|
-
filter: (/**
|
|
432
|
-
* @return {?}
|
|
433
|
-
*/
|
|
434
|
-
function () { return true; })
|
|
435
|
-
};
|
|
436
|
-
return __assign({}, defaultLoggerOptions, options);
|
|
437
|
-
}
|
|
438
|
-
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
439
|
-
function NgxsLoggerPluginModule() {
|
|
440
|
-
}
|
|
441
|
-
/**
|
|
442
|
-
* @param {?=} options
|
|
443
|
-
* @return {?}
|
|
444
|
-
*/
|
|
445
|
-
NgxsLoggerPluginModule.forRoot = /**
|
|
446
|
-
* @param {?=} options
|
|
447
|
-
* @return {?}
|
|
448
|
-
*/
|
|
449
|
-
function (options) {
|
|
450
|
-
return {
|
|
451
|
-
ngModule: NgxsLoggerPluginModule,
|
|
452
|
-
providers: [
|
|
453
|
-
{
|
|
454
|
-
provide: NGXS_PLUGINS,
|
|
455
|
-
useClass: NgxsLoggerPlugin,
|
|
456
|
-
multi: true
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
provide: USER_OPTIONS,
|
|
460
|
-
useValue: options
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
464
|
-
useFactory: loggerOptionsFactory,
|
|
465
|
-
deps: [USER_OPTIONS]
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
};
|
|
469
|
-
};
|
|
470
|
-
NgxsLoggerPluginModule.decorators = [
|
|
471
|
-
{ type: NgModule }
|
|
472
|
-
];
|
|
473
|
-
return NgxsLoggerPluginModule;
|
|
415
|
+
/**
|
|
416
|
+
* @fileoverview added by tsickle
|
|
417
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
418
|
+
*/
|
|
419
|
+
/** @type {?} */
|
|
420
|
+
var USER_OPTIONS = new InjectionToken('LOGGER_USER_OPTIONS');
|
|
421
|
+
/**
|
|
422
|
+
* @param {?} options
|
|
423
|
+
* @return {?}
|
|
424
|
+
*/
|
|
425
|
+
function loggerOptionsFactory(options) {
|
|
426
|
+
/** @type {?} */
|
|
427
|
+
var defaultLoggerOptions = {
|
|
428
|
+
logger: console,
|
|
429
|
+
collapsed: false,
|
|
430
|
+
disabled: false,
|
|
431
|
+
filter: (/**
|
|
432
|
+
* @return {?}
|
|
433
|
+
*/
|
|
434
|
+
function () { return true; })
|
|
435
|
+
};
|
|
436
|
+
return __assign({}, defaultLoggerOptions, options);
|
|
437
|
+
}
|
|
438
|
+
var NgxsLoggerPluginModule = /** @class */ (function () {
|
|
439
|
+
function NgxsLoggerPluginModule() {
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* @param {?=} options
|
|
443
|
+
* @return {?}
|
|
444
|
+
*/
|
|
445
|
+
NgxsLoggerPluginModule.forRoot = /**
|
|
446
|
+
* @param {?=} options
|
|
447
|
+
* @return {?}
|
|
448
|
+
*/
|
|
449
|
+
function (options) {
|
|
450
|
+
return {
|
|
451
|
+
ngModule: NgxsLoggerPluginModule,
|
|
452
|
+
providers: [
|
|
453
|
+
{
|
|
454
|
+
provide: NGXS_PLUGINS,
|
|
455
|
+
useClass: NgxsLoggerPlugin,
|
|
456
|
+
multi: true
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
provide: USER_OPTIONS,
|
|
460
|
+
useValue: options
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
provide: NGXS_LOGGER_PLUGIN_OPTIONS,
|
|
464
|
+
useFactory: loggerOptionsFactory,
|
|
465
|
+
deps: [USER_OPTIONS]
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
};
|
|
469
|
+
};
|
|
470
|
+
NgxsLoggerPluginModule.decorators = [
|
|
471
|
+
{ type: NgModule }
|
|
472
|
+
];
|
|
473
|
+
return NgxsLoggerPluginModule;
|
|
474
474
|
}());
|
|
475
475
|
|
|
476
|
-
/**
|
|
477
|
-
* @fileoverview added by tsickle
|
|
478
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
476
|
+
/**
|
|
477
|
+
* @fileoverview added by tsickle
|
|
478
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
479
479
|
*/
|
|
480
480
|
|
|
481
|
-
/**
|
|
482
|
-
* @fileoverview added by tsickle
|
|
483
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
481
|
+
/**
|
|
482
|
+
* @fileoverview added by tsickle
|
|
483
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
484
484
|
*/
|
|
485
485
|
|
|
486
|
-
/**
|
|
487
|
-
* @fileoverview added by tsickle
|
|
488
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
486
|
+
/**
|
|
487
|
+
* @fileoverview added by tsickle
|
|
488
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
489
489
|
*/
|
|
490
490
|
|
|
491
491
|
export { NGXS_LOGGER_PLUGIN_OPTIONS, NgxsLoggerPlugin, NgxsLoggerPluginModule, USER_OPTIONS as ɵa, loggerOptionsFactory as ɵb };
|