@genesislcap/foundation-errors 9.0.1-alpha-b5c5eb7.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 +5 -0
- package/dist/1.0.0.remoteEntry.js +1 -0
- package/dist/145.145.25912f2c12344fb25e16.js +2 -0
- package/dist/145.e7ed8da0367f1288ec24cf6472d1f047.js.map +1 -0
- package/dist/191.191.da8a5884febca6f1a439.js +2 -0
- package/dist/191.efd2fea1a42a47cddbf6e6ab15fbf2bb.js.map +1 -0
- package/dist/366.366.82702b77300a9353fc87.js +2 -0
- package/dist/366.a181180b871f72ff9f4ad3e3f3ea3734.js.map +1 -0
- package/dist/755.62d9698f4e62142b980949b517fded3f.js.map +1 -0
- package/dist/755.755.f8db61516204a76477a8.js +2 -0
- package/dist/dashboard.json +1 -0
- package/dist/dts/banner/error-banner-builder.d.ts +10 -0
- package/dist/dts/banner/error-banner-builder.d.ts.map +1 -0
- package/dist/dts/banner/index.d.ts +2 -0
- package/dist/dts/banner/index.d.ts.map +1 -0
- package/dist/dts/dialog/error-dialog-builder.d.ts +10 -0
- package/dist/dts/dialog/error-dialog-builder.d.ts.map +1 -0
- package/dist/dts/dialog/error-dialog-launcher.d.ts +10 -0
- package/dist/dts/dialog/error-dialog-launcher.d.ts.map +1 -0
- package/dist/dts/dialog/index.d.ts +3 -0
- package/dist/dts/dialog/index.d.ts.map +1 -0
- package/dist/dts/error-builder.d.ts +23 -0
- package/dist/dts/error-builder.d.ts.map +1 -0
- package/dist/dts/error-launcher.d.ts +10 -0
- package/dist/dts/error-launcher.d.ts.map +1 -0
- package/dist/dts/error-util.d.ts +25 -0
- package/dist/dts/error-util.d.ts.map +1 -0
- package/dist/dts/index.d.ts +9 -0
- package/dist/dts/index.d.ts.map +1 -0
- package/dist/dts/index.federated.d.ts +1 -0
- package/dist/dts/index.federated.d.ts.map +1 -0
- package/dist/dts/logger.d.ts +2 -0
- package/dist/dts/logger.d.ts.map +1 -0
- package/dist/dts/notification/index.d.ts +3 -0
- package/dist/dts/notification/index.d.ts.map +1 -0
- package/dist/dts/notification/notification-builder.d.ts +12 -0
- package/dist/dts/notification/notification-builder.d.ts.map +1 -0
- package/dist/dts/notification/notification-launcher.d.ts +10 -0
- package/dist/dts/notification/notification-launcher.d.ts.map +1 -0
- package/dist/dts/snackbar/index.d.ts +3 -0
- package/dist/dts/snackbar/index.d.ts.map +1 -0
- package/dist/dts/snackbar/snackbar-builder.d.ts +27 -0
- package/dist/dts/snackbar/snackbar-builder.d.ts.map +1 -0
- package/dist/dts/snackbar/snackbar-launcher.d.ts +10 -0
- package/dist/dts/snackbar/snackbar-launcher.d.ts.map +1 -0
- package/dist/dts/tsdoc-metadata.json +11 -0
- package/dist/dts/types.d.ts +52 -0
- package/dist/dts/types.d.ts.map +1 -0
- package/dist/esm/banner/error-banner-builder.js +25 -0
- package/dist/esm/banner/error-banner-builder.js.map +1 -0
- package/dist/esm/banner/index.js +2 -0
- package/dist/esm/banner/index.js.map +1 -0
- package/dist/esm/dialog/error-dialog-builder.js +25 -0
- package/dist/esm/dialog/error-dialog-builder.js.map +1 -0
- package/dist/esm/dialog/error-dialog-launcher.js +17 -0
- package/dist/esm/dialog/error-dialog-launcher.js.map +1 -0
- package/dist/esm/dialog/index.js +3 -0
- package/dist/esm/dialog/index.js.map +1 -0
- package/dist/esm/error-builder.js +74 -0
- package/dist/esm/error-builder.js.map +1 -0
- package/dist/esm/error-launcher.js +34 -0
- package/dist/esm/error-launcher.js.map +1 -0
- package/dist/esm/error-util.js +43 -0
- package/dist/esm/error-util.js.map +1 -0
- package/dist/esm/index.federated.js +2 -0
- package/dist/esm/index.federated.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.js +3 -0
- package/dist/esm/logger.js.map +1 -0
- package/dist/esm/notification/index.js +3 -0
- package/dist/esm/notification/index.js.map +1 -0
- package/dist/esm/notification/notification-builder.js +29 -0
- package/dist/esm/notification/notification-builder.js.map +1 -0
- package/dist/esm/notification/notification-launcher.js +40 -0
- package/dist/esm/notification/notification-launcher.js.map +1 -0
- package/dist/esm/snackbar/index.js +3 -0
- package/dist/esm/snackbar/index.js.map +1 -0
- package/dist/esm/snackbar/snackbar-builder.js +42 -0
- package/dist/esm/snackbar/snackbar-builder.js.map +1 -0
- package/dist/esm/snackbar/snackbar-launcher.js +16 -0
- package/dist/esm/snackbar/snackbar-launcher.js.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/foundation-errors.api.json +2483 -0
- package/dist/foundation-errors.d.ts +205 -0
- package/dist/foundation-errors.iife.min.js +1 -0
- package/dist/foundation-errors.js +1240 -0
- package/dist/foundation-errors.min.js +1 -0
- package/dist/foundationErrors.3332a181471a7c01e0521b713cbe35e9.js.map +1 -0
- package/dist/index.ejs +23 -0
- package/dist/index.html +10 -0
- package/dist/info.ejs +13 -0
- package/dist/info.html +14 -0
- package/dist/main.5ba41fdd245152fbed9605c3b9e25cee.js.map +1 -0
- package/dist/main.729daae38fba054a7206.js +2 -0
- package/dist/npm.consola.713.6bcc5abc1500250af5f5.js +2 -0
- package/dist/npm.consola.de429dd64b8dd7d3424e047e422d6ee1.js.map +1 -0
- package/dist/npm.microsoft.127.821cbcff47e0a34e88c9.js +3 -0
- package/dist/npm.microsoft.127.821cbcff47e0a34e88c9.js.LICENSE.txt +14 -0
- package/dist/npm.microsoft.4ae729aafa2e074df718ae9a73d16fa1.js.map +1 -0
- package/dist/remoteEntry.js +2 -0
- package/dist/serve.json +3 -0
- package/docs/api/foundation-errors.confirmingaction.action.md +11 -0
- package/docs/api/foundation-errors.confirmingaction.label.md +11 -0
- package/docs/api/foundation-errors.confirmingaction.md +19 -0
- package/docs/api/foundation-errors.dismissingaction.action.md +11 -0
- package/docs/api/foundation-errors.dismissingaction.label.md +11 -0
- package/docs/api/foundation-errors.dismissingaction.md +19 -0
- package/docs/api/foundation-errors.errorbanner.confirmingactions.md +11 -0
- package/docs/api/foundation-errors.errorbanner.dismissingaction.md +11 -0
- package/docs/api/foundation-errors.errorbanner.md +19 -0
- package/docs/api/foundation-errors.errorbannerbuilder.build.md +15 -0
- package/docs/api/foundation-errors.errorbannerbuilder.md +20 -0
- package/docs/api/foundation-errors.errorbannerbuilder.withconfirmingaction.md +22 -0
- package/docs/api/foundation-errors.errorbannerbuilder.withdismissingaction.md +22 -0
- package/docs/api/foundation-errors.errorboundaryevent.md +18 -0
- package/docs/api/foundation-errors.errorbuilder.build.md +15 -0
- package/docs/api/foundation-errors.errorbuilder.md +26 -0
- package/docs/api/foundation-errors.errorbuilder.withalert.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withbanner.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withdialog.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.witherrordetails.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withloglevel.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withnotification.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withsnackbar.md +22 -0
- package/docs/api/foundation-errors.errorbuilder.withtitle.md +22 -0
- package/docs/api/foundation-errors.errordialog.confirmingactions.md +11 -0
- package/docs/api/foundation-errors.errordialog.dismissingaction.md +11 -0
- package/docs/api/foundation-errors.errordialog.md +19 -0
- package/docs/api/foundation-errors.errordialogbuilder.build.md +15 -0
- package/docs/api/foundation-errors.errordialogbuilder.md +20 -0
- package/docs/api/foundation-errors.errordialogbuilder.withconfirmingaction.md +22 -0
- package/docs/api/foundation-errors.errordialogbuilder.withdismissingaction.md +22 -0
- package/docs/api/foundation-errors.errordialogelement.md +15 -0
- package/docs/api/foundation-errors.errorelement.md +15 -0
- package/docs/api/foundation-errors.errornotification.autoclose.md +11 -0
- package/docs/api/foundation-errors.errornotification.closetimeout.md +11 -0
- package/docs/api/foundation-errors.errornotification.md +20 -0
- package/docs/api/foundation-errors.errornotification.type.md +11 -0
- package/docs/api/foundation-errors.errorstructure.config.md +18 -0
- package/docs/api/foundation-errors.errorstructure.errordetails.md +11 -0
- package/docs/api/foundation-errors.errorstructure.loglevel.md +11 -0
- package/docs/api/foundation-errors.errorstructure.md +21 -0
- package/docs/api/foundation-errors.errorstructure.title.md +11 -0
- package/docs/api/foundation-errors.geterrorbannerbuilder.md +11 -0
- package/docs/api/foundation-errors.geterrorbuilder.md +11 -0
- package/docs/api/foundation-errors.geterrorcontainer.md +13 -0
- package/docs/api/foundation-errors.geterrordetails.md +13 -0
- package/docs/api/foundation-errors.geterrordialogbuilder.md +11 -0
- package/docs/api/foundation-errors.getloglevel.md +13 -0
- package/docs/api/foundation-errors.getnotificationbuilder.md +11 -0
- package/docs/api/foundation-errors.getsnackbarbuilder.md +11 -0
- package/docs/api/foundation-errors.md +58 -0
- package/docs/api/foundation-errors.notificationbuilder.build.md +15 -0
- package/docs/api/foundation-errors.notificationbuilder.md +21 -0
- package/docs/api/foundation-errors.notificationbuilder.withautoclose.md +22 -0
- package/docs/api/foundation-errors.notificationbuilder.withclosetimeout.md +22 -0
- package/docs/api/foundation-errors.notificationbuilder.withtype.md +22 -0
- package/docs/api/foundation-errors.showdialog.md +13 -0
- package/docs/api/foundation-errors.showerror.md +13 -0
- package/docs/api/foundation-errors.shownotification.md +13 -0
- package/docs/api/foundation-errors.showsnackbar.md +13 -0
- package/docs/api/foundation-errors.snackbar.confirmingactions.md +11 -0
- package/docs/api/foundation-errors.snackbar.md +19 -0
- package/docs/api/foundation-errors.snackbar.type.md +11 -0
- package/docs/api/foundation-errors.snackbarbuilder.build.md +19 -0
- package/docs/api/foundation-errors.snackbarbuilder.md +20 -0
- package/docs/api/foundation-errors.snackbarbuilder.withconfirmingaction.md +25 -0
- package/docs/api/foundation-errors.snackbarbuilder.withtype.md +25 -0
- package/docs/api/index.md +12 -0
- package/docs/api-report.md +193 -0
- package/jsdom.setup.ts +1 -0
- package/license.txt +46 -0
- package/package.json +101 -0
|
@@ -0,0 +1,1240 @@
|
|
|
1
|
+
var ErrorBoundaryEvent;
|
|
2
|
+
(function (ErrorBoundaryEvent) {
|
|
3
|
+
ErrorBoundaryEvent["ERROR_BOUNDARY_EVENT"] = "error-boundary-event";
|
|
4
|
+
})(ErrorBoundaryEvent || (ErrorBoundaryEvent = {}));
|
|
5
|
+
|
|
6
|
+
const LogLevel = {};
|
|
7
|
+
LogLevel[LogLevel.Fatal = 0] = 'Fatal';
|
|
8
|
+
LogLevel[LogLevel.Error = 0] = 'Error';
|
|
9
|
+
LogLevel[LogLevel.Warn = 1] = 'Warn';
|
|
10
|
+
LogLevel[LogLevel.Log = 2] = 'Log';
|
|
11
|
+
LogLevel[LogLevel.Info = 3] = 'Info';
|
|
12
|
+
LogLevel[LogLevel.Success = 3] = 'Success';
|
|
13
|
+
LogLevel[LogLevel.Debug = 4] = 'Debug';
|
|
14
|
+
LogLevel[LogLevel.Trace = 5] = 'Trace';
|
|
15
|
+
LogLevel[LogLevel.Silent = -Infinity] = 'Silent';
|
|
16
|
+
LogLevel[LogLevel.Verbose = Infinity] = 'Verbose';
|
|
17
|
+
|
|
18
|
+
var Types = {
|
|
19
|
+
// Silent
|
|
20
|
+
silent: {
|
|
21
|
+
level: -1
|
|
22
|
+
},
|
|
23
|
+
// Level 0
|
|
24
|
+
fatal: {
|
|
25
|
+
level: LogLevel.Fatal
|
|
26
|
+
},
|
|
27
|
+
error: {
|
|
28
|
+
level: LogLevel.Error
|
|
29
|
+
},
|
|
30
|
+
// Level 1
|
|
31
|
+
warn: {
|
|
32
|
+
level: LogLevel.Warn
|
|
33
|
+
},
|
|
34
|
+
// Level 2
|
|
35
|
+
log: {
|
|
36
|
+
level: LogLevel.Log
|
|
37
|
+
},
|
|
38
|
+
// Level 3
|
|
39
|
+
info: {
|
|
40
|
+
level: LogLevel.Info
|
|
41
|
+
},
|
|
42
|
+
success: {
|
|
43
|
+
level: LogLevel.Success
|
|
44
|
+
},
|
|
45
|
+
// Level 4
|
|
46
|
+
debug: {
|
|
47
|
+
level: LogLevel.Debug
|
|
48
|
+
},
|
|
49
|
+
// Level 5
|
|
50
|
+
trace: {
|
|
51
|
+
level: LogLevel.Trace
|
|
52
|
+
},
|
|
53
|
+
// Verbose
|
|
54
|
+
verbose: {
|
|
55
|
+
level: LogLevel.Trace
|
|
56
|
+
},
|
|
57
|
+
// Legacy
|
|
58
|
+
ready: {
|
|
59
|
+
level: LogLevel.Info
|
|
60
|
+
},
|
|
61
|
+
start: {
|
|
62
|
+
level: LogLevel.Info
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function isPlainObject(obj) {
|
|
67
|
+
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// TODO: remove for consola@3
|
|
71
|
+
function isLogObj(arg) {
|
|
72
|
+
// Should be plain object
|
|
73
|
+
if (!isPlainObject(arg)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Should contains either 'message' or 'args' field
|
|
78
|
+
if (!arg.message && !arg.args) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Handle non-standard error objects
|
|
83
|
+
if (arg.stack) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
let paused = false;
|
|
90
|
+
const queue = [];
|
|
91
|
+
class Consola {
|
|
92
|
+
constructor(options = {}) {
|
|
93
|
+
this._reporters = options.reporters || [];
|
|
94
|
+
this._types = options.types || Types;
|
|
95
|
+
this.level = options.level !== undefined ? options.level : 3;
|
|
96
|
+
this._defaults = options.defaults || {};
|
|
97
|
+
this._async = options.async !== undefined ? options.async : undefined;
|
|
98
|
+
this._stdout = options.stdout;
|
|
99
|
+
this._stderr = options.stderr;
|
|
100
|
+
this._mockFn = options.mockFn;
|
|
101
|
+
this._throttle = options.throttle || 1000;
|
|
102
|
+
this._throttleMin = options.throttleMin || 5;
|
|
103
|
+
|
|
104
|
+
// Create logger functions for current instance
|
|
105
|
+
for (const type in this._types) {
|
|
106
|
+
const defaults = {
|
|
107
|
+
type,
|
|
108
|
+
...this._types[type],
|
|
109
|
+
...this._defaults
|
|
110
|
+
};
|
|
111
|
+
this[type] = this._wrapLogFn(defaults);
|
|
112
|
+
this[type].raw = this._wrapLogFn(defaults, true);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Use _mockFn if is set
|
|
116
|
+
if (this._mockFn) {
|
|
117
|
+
this.mockTypes();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Keep serialized version of last log
|
|
121
|
+
this._lastLogSerialized = undefined;
|
|
122
|
+
this._lastLog = undefined;
|
|
123
|
+
this._lastLogTime = undefined;
|
|
124
|
+
this._lastLogCount = 0;
|
|
125
|
+
this._throttleTimeout = undefined;
|
|
126
|
+
}
|
|
127
|
+
get stdout() {
|
|
128
|
+
return this._stdout || console._stdout; // eslint-disable-line no-console
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
get stderr() {
|
|
132
|
+
return this._stderr || console._stderr; // eslint-disable-line no-console
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
create(options) {
|
|
136
|
+
return new Consola(Object.assign({
|
|
137
|
+
reporters: this._reporters,
|
|
138
|
+
level: this.level,
|
|
139
|
+
types: this._types,
|
|
140
|
+
defaults: this._defaults,
|
|
141
|
+
stdout: this._stdout,
|
|
142
|
+
stderr: this._stderr,
|
|
143
|
+
mockFn: this._mockFn
|
|
144
|
+
}, options));
|
|
145
|
+
}
|
|
146
|
+
withDefaults(defaults) {
|
|
147
|
+
return this.create({
|
|
148
|
+
defaults: Object.assign({}, this._defaults, defaults)
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
withTag(tag) {
|
|
152
|
+
return this.withDefaults({
|
|
153
|
+
tag: this._defaults.tag ? this._defaults.tag + ':' + tag : tag
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
addReporter(reporter) {
|
|
157
|
+
this._reporters.push(reporter);
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
removeReporter(reporter) {
|
|
161
|
+
if (reporter) {
|
|
162
|
+
const i = this._reporters.indexOf(reporter);
|
|
163
|
+
if (i >= 0) {
|
|
164
|
+
return this._reporters.splice(i, 1);
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
this._reporters.splice(0);
|
|
168
|
+
}
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
setReporters(reporters) {
|
|
172
|
+
this._reporters = Array.isArray(reporters) ? reporters : [reporters];
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
wrapAll() {
|
|
176
|
+
this.wrapConsole();
|
|
177
|
+
this.wrapStd();
|
|
178
|
+
}
|
|
179
|
+
restoreAll() {
|
|
180
|
+
this.restoreConsole();
|
|
181
|
+
this.restoreStd();
|
|
182
|
+
}
|
|
183
|
+
wrapConsole() {
|
|
184
|
+
for (const type in this._types) {
|
|
185
|
+
// Backup original value
|
|
186
|
+
if (!console['__' + type]) {
|
|
187
|
+
// eslint-disable-line no-console
|
|
188
|
+
console['__' + type] = console[type]; // eslint-disable-line no-console
|
|
189
|
+
}
|
|
190
|
+
// Override
|
|
191
|
+
console[type] = this[type].raw; // eslint-disable-line no-console
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
restoreConsole() {
|
|
196
|
+
for (const type in this._types) {
|
|
197
|
+
// Restore if backup is available
|
|
198
|
+
if (console['__' + type]) {
|
|
199
|
+
// eslint-disable-line no-console
|
|
200
|
+
console[type] = console['__' + type]; // eslint-disable-line no-console
|
|
201
|
+
delete console['__' + type]; // eslint-disable-line no-console
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
wrapStd() {
|
|
207
|
+
this._wrapStream(this.stdout, 'log');
|
|
208
|
+
this._wrapStream(this.stderr, 'log');
|
|
209
|
+
}
|
|
210
|
+
_wrapStream(stream, type) {
|
|
211
|
+
if (!stream) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Backup original value
|
|
216
|
+
if (!stream.__write) {
|
|
217
|
+
stream.__write = stream.write;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Override
|
|
221
|
+
stream.write = data => {
|
|
222
|
+
this[type].raw(String(data).trim());
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
restoreStd() {
|
|
226
|
+
this._restoreStream(this.stdout);
|
|
227
|
+
this._restoreStream(this.stderr);
|
|
228
|
+
}
|
|
229
|
+
_restoreStream(stream) {
|
|
230
|
+
if (!stream) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (stream.__write) {
|
|
234
|
+
stream.write = stream.__write;
|
|
235
|
+
delete stream.__write;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
pauseLogs() {
|
|
239
|
+
paused = true;
|
|
240
|
+
}
|
|
241
|
+
resumeLogs() {
|
|
242
|
+
paused = false;
|
|
243
|
+
|
|
244
|
+
// Process queue
|
|
245
|
+
const _queue = queue.splice(0);
|
|
246
|
+
for (const item of _queue) {
|
|
247
|
+
item[0]._logFn(item[1], item[2]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
mockTypes(mockFn) {
|
|
251
|
+
this._mockFn = mockFn || this._mockFn;
|
|
252
|
+
if (typeof this._mockFn !== 'function') {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
for (const type in this._types) {
|
|
256
|
+
this[type] = this._mockFn(type, this._types[type]) || this[type];
|
|
257
|
+
this[type].raw = this[type];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
_wrapLogFn(defaults, isRaw) {
|
|
261
|
+
return (...args) => {
|
|
262
|
+
if (paused) {
|
|
263
|
+
queue.push([this, defaults, args, isRaw]);
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
return this._logFn(defaults, args, isRaw);
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
_logFn(defaults, args, isRaw) {
|
|
270
|
+
if (defaults.level > this.level) {
|
|
271
|
+
return this._async ? Promise.resolve(false) : false;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Construct a new log object
|
|
275
|
+
const logObj = Object.assign({
|
|
276
|
+
date: new Date(),
|
|
277
|
+
args: []
|
|
278
|
+
}, defaults);
|
|
279
|
+
|
|
280
|
+
// Consume arguments
|
|
281
|
+
if (!isRaw && args.length === 1 && isLogObj(args[0])) {
|
|
282
|
+
Object.assign(logObj, args[0]);
|
|
283
|
+
} else {
|
|
284
|
+
logObj.args = Array.from(args);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Aliases
|
|
288
|
+
if (logObj.message) {
|
|
289
|
+
logObj.args.unshift(logObj.message);
|
|
290
|
+
delete logObj.message;
|
|
291
|
+
}
|
|
292
|
+
if (logObj.additional) {
|
|
293
|
+
if (!Array.isArray(logObj.additional)) {
|
|
294
|
+
logObj.additional = logObj.additional.split('\n');
|
|
295
|
+
}
|
|
296
|
+
logObj.args.push('\n' + logObj.additional.join('\n'));
|
|
297
|
+
delete logObj.additional;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Normalize type and tag to lowercase
|
|
301
|
+
logObj.type = typeof logObj.type === 'string' ? logObj.type.toLowerCase() : '';
|
|
302
|
+
logObj.tag = typeof logObj.tag === 'string' ? logObj.tag.toLowerCase() : '';
|
|
303
|
+
|
|
304
|
+
// Resolve log
|
|
305
|
+
/**
|
|
306
|
+
* @param newLog false if the throttle expired and
|
|
307
|
+
* we don't want to log a duplicate
|
|
308
|
+
*/
|
|
309
|
+
const resolveLog = (newLog = false) => {
|
|
310
|
+
const repeated = this._lastLogCount - this._throttleMin;
|
|
311
|
+
if (this._lastLog && repeated > 0) {
|
|
312
|
+
const args = [...this._lastLog.args];
|
|
313
|
+
if (repeated > 1) {
|
|
314
|
+
args.push(`(repeated ${repeated} times)`);
|
|
315
|
+
}
|
|
316
|
+
this._log({
|
|
317
|
+
...this._lastLog,
|
|
318
|
+
args
|
|
319
|
+
});
|
|
320
|
+
this._lastLogCount = 1;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Log
|
|
324
|
+
if (newLog) {
|
|
325
|
+
this._lastLog = logObj;
|
|
326
|
+
if (this._async) {
|
|
327
|
+
return this._logAsync(logObj);
|
|
328
|
+
} else {
|
|
329
|
+
this._log(logObj);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// Throttle
|
|
335
|
+
clearTimeout(this._throttleTimeout);
|
|
336
|
+
const diffTime = this._lastLogTime ? logObj.date - this._lastLogTime : 0;
|
|
337
|
+
this._lastLogTime = logObj.date;
|
|
338
|
+
if (diffTime < this._throttle) {
|
|
339
|
+
try {
|
|
340
|
+
const serializedLog = JSON.stringify([logObj.type, logObj.tag, logObj.args]);
|
|
341
|
+
const isSameLog = this._lastLogSerialized === serializedLog;
|
|
342
|
+
this._lastLogSerialized = serializedLog;
|
|
343
|
+
if (isSameLog) {
|
|
344
|
+
this._lastLogCount++;
|
|
345
|
+
if (this._lastLogCount > this._throttleMin) {
|
|
346
|
+
// Auto-resolve when throttle is timed out
|
|
347
|
+
this._throttleTimeout = setTimeout(resolveLog, this._throttle);
|
|
348
|
+
return; // SPAM!
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
} catch (_) {
|
|
352
|
+
// Circular References
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
resolveLog(true);
|
|
356
|
+
}
|
|
357
|
+
_log(logObj) {
|
|
358
|
+
for (const reporter of this._reporters) {
|
|
359
|
+
reporter.log(logObj, {
|
|
360
|
+
async: false,
|
|
361
|
+
stdout: this.stdout,
|
|
362
|
+
stderr: this.stderr
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
_logAsync(logObj) {
|
|
367
|
+
return Promise.all(this._reporters.map(reporter => reporter.log(logObj, {
|
|
368
|
+
async: true,
|
|
369
|
+
stdout: this.stdout,
|
|
370
|
+
stderr: this.stderr
|
|
371
|
+
})));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// Legacy support
|
|
376
|
+
Consola.prototype.add = Consola.prototype.addReporter;
|
|
377
|
+
Consola.prototype.remove = Consola.prototype.removeReporter;
|
|
378
|
+
Consola.prototype.clear = Consola.prototype.removeReporter;
|
|
379
|
+
Consola.prototype.withScope = Consola.prototype.withTag;
|
|
380
|
+
Consola.prototype.mock = Consola.prototype.mockTypes;
|
|
381
|
+
Consola.prototype.pause = Consola.prototype.pauseLogs;
|
|
382
|
+
Consola.prototype.resume = Consola.prototype.resumeLogs;
|
|
383
|
+
|
|
384
|
+
class BrowserReporter {
|
|
385
|
+
constructor(options) {
|
|
386
|
+
this.options = Object.assign({}, options);
|
|
387
|
+
this.defaultColor = '#7f8c8d'; // Gray
|
|
388
|
+
this.levelColorMap = {
|
|
389
|
+
0: '#c0392b',
|
|
390
|
+
// Red
|
|
391
|
+
1: '#f39c12',
|
|
392
|
+
// Yellow
|
|
393
|
+
3: '#00BCD4' // Cyan
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
this.typeColorMap = {
|
|
397
|
+
success: '#2ecc71' // Green
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
log(logObj) {
|
|
402
|
+
const consoleLogFn = logObj.level < 1
|
|
403
|
+
// eslint-disable-next-line no-console
|
|
404
|
+
? console.__error || console.error
|
|
405
|
+
// eslint-disable-next-line no-console
|
|
406
|
+
: logObj.level === 1 && console.warn ? console.__warn || console.warn : console.__log || console.log;
|
|
407
|
+
|
|
408
|
+
// Type
|
|
409
|
+
const type = logObj.type !== 'log' ? logObj.type : '';
|
|
410
|
+
|
|
411
|
+
// Tag
|
|
412
|
+
const tag = logObj.tag ? logObj.tag : '';
|
|
413
|
+
|
|
414
|
+
// Styles
|
|
415
|
+
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
|
|
416
|
+
const style = `
|
|
417
|
+
background: ${color};
|
|
418
|
+
border-radius: 0.5em;
|
|
419
|
+
color: white;
|
|
420
|
+
font-weight: bold;
|
|
421
|
+
padding: 2px 0.5em;
|
|
422
|
+
`;
|
|
423
|
+
const badge = `%c${[tag, type].filter(Boolean).join(':')}`;
|
|
424
|
+
|
|
425
|
+
// Log to the console
|
|
426
|
+
if (typeof logObj.args[0] === 'string') {
|
|
427
|
+
consoleLogFn(`${badge}%c ${logObj.args[0]}`, style,
|
|
428
|
+
// Empty string as style resets to default console style
|
|
429
|
+
'', ...logObj.args.slice(1));
|
|
430
|
+
} else {
|
|
431
|
+
consoleLogFn(badge, style, ...logObj.args);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function createConsola() {
|
|
437
|
+
const consola = new Consola({
|
|
438
|
+
reporters: [new BrowserReporter()]
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// Expose constructors
|
|
442
|
+
consola.Consola = Consola;
|
|
443
|
+
consola.LogLevel = LogLevel;
|
|
444
|
+
consola.BrowserReporter = BrowserReporter;
|
|
445
|
+
return consola;
|
|
446
|
+
}
|
|
447
|
+
var consola = typeof window !== 'undefined' && window.consola || createConsola();
|
|
448
|
+
|
|
449
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
450
|
+
|
|
451
|
+
var consola_browser = {
|
|
452
|
+
exports: {}
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
(function (module, exports) {
|
|
456
|
+
!function (t, e) {
|
|
457
|
+
module.exports = e() ;
|
|
458
|
+
}(commonjsGlobal, function () {
|
|
459
|
+
|
|
460
|
+
function t(t, e) {
|
|
461
|
+
if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
|
|
462
|
+
}
|
|
463
|
+
function e(t, e) {
|
|
464
|
+
for (var r = 0; r < e.length; r++) {
|
|
465
|
+
var o = e[r];
|
|
466
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function r(t, r, o) {
|
|
470
|
+
return r && e(t.prototype, r), o && e(t, o), t;
|
|
471
|
+
}
|
|
472
|
+
function o(t, e, r) {
|
|
473
|
+
return e in t ? Object.defineProperty(t, e, {
|
|
474
|
+
value: r,
|
|
475
|
+
enumerable: !0,
|
|
476
|
+
configurable: !0,
|
|
477
|
+
writable: !0
|
|
478
|
+
}) : t[e] = r, t;
|
|
479
|
+
}
|
|
480
|
+
function n(t, e) {
|
|
481
|
+
var r = Object.keys(t);
|
|
482
|
+
if (Object.getOwnPropertySymbols) {
|
|
483
|
+
var o = Object.getOwnPropertySymbols(t);
|
|
484
|
+
e && (o = o.filter(function (e) {
|
|
485
|
+
return Object.getOwnPropertyDescriptor(t, e).enumerable;
|
|
486
|
+
})), r.push.apply(r, o);
|
|
487
|
+
}
|
|
488
|
+
return r;
|
|
489
|
+
}
|
|
490
|
+
function s(t) {
|
|
491
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
492
|
+
var r = null != arguments[e] ? arguments[e] : {};
|
|
493
|
+
e % 2 ? n(Object(r), !0).forEach(function (e) {
|
|
494
|
+
o(t, e, r[e]);
|
|
495
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(r)) : n(Object(r)).forEach(function (e) {
|
|
496
|
+
Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(r, e));
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return t;
|
|
500
|
+
}
|
|
501
|
+
function i(t) {
|
|
502
|
+
return function (t) {
|
|
503
|
+
if (Array.isArray(t)) return l(t);
|
|
504
|
+
}(t) || function (t) {
|
|
505
|
+
if ("undefined" != typeof Symbol && Symbol.iterator in Object(t)) return Array.from(t);
|
|
506
|
+
}(t) || a(t) || function () {
|
|
507
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
508
|
+
}();
|
|
509
|
+
}
|
|
510
|
+
function a(t, e) {
|
|
511
|
+
if (t) {
|
|
512
|
+
if ("string" == typeof t) return l(t, e);
|
|
513
|
+
var r = Object.prototype.toString.call(t).slice(8, -1);
|
|
514
|
+
return "Object" === r && t.constructor && (r = t.constructor.name), "Map" === r || "Set" === r ? Array.from(t) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? l(t, e) : void 0;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
function l(t, e) {
|
|
518
|
+
(null == e || e > t.length) && (e = t.length);
|
|
519
|
+
for (var r = 0, o = new Array(e); r < e; r++) o[r] = t[r];
|
|
520
|
+
return o;
|
|
521
|
+
}
|
|
522
|
+
function u(t) {
|
|
523
|
+
if ("undefined" == typeof Symbol || null == t[Symbol.iterator]) {
|
|
524
|
+
if (Array.isArray(t) || (t = a(t))) {
|
|
525
|
+
var e = 0,
|
|
526
|
+
r = function () {};
|
|
527
|
+
return {
|
|
528
|
+
s: r,
|
|
529
|
+
n: function () {
|
|
530
|
+
return e >= t.length ? {
|
|
531
|
+
done: !0
|
|
532
|
+
} : {
|
|
533
|
+
done: !1,
|
|
534
|
+
value: t[e++]
|
|
535
|
+
};
|
|
536
|
+
},
|
|
537
|
+
e: function (t) {
|
|
538
|
+
throw t;
|
|
539
|
+
},
|
|
540
|
+
f: r
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
544
|
+
}
|
|
545
|
+
var o,
|
|
546
|
+
n,
|
|
547
|
+
s = !0,
|
|
548
|
+
i = !1;
|
|
549
|
+
return {
|
|
550
|
+
s: function () {
|
|
551
|
+
o = t[Symbol.iterator]();
|
|
552
|
+
},
|
|
553
|
+
n: function () {
|
|
554
|
+
var t = o.next();
|
|
555
|
+
return s = t.done, t;
|
|
556
|
+
},
|
|
557
|
+
e: function (t) {
|
|
558
|
+
i = !0, n = t;
|
|
559
|
+
},
|
|
560
|
+
f: function () {
|
|
561
|
+
try {
|
|
562
|
+
s || null == o.return || o.return();
|
|
563
|
+
} finally {
|
|
564
|
+
if (i) throw n;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
var c = {};
|
|
570
|
+
c[c.Fatal = 0] = "Fatal", c[c.Error = 0] = "Error", c[c.Warn = 1] = "Warn", c[c.Log = 2] = "Log", c[c.Info = 3] = "Info", c[c.Success = 3] = "Success", c[c.Debug = 4] = "Debug", c[c.Trace = 5] = "Trace", c[c.Silent = -1 / 0] = "Silent", c[c.Verbose = 1 / 0] = "Verbose";
|
|
571
|
+
var f = {
|
|
572
|
+
silent: {
|
|
573
|
+
level: -1
|
|
574
|
+
},
|
|
575
|
+
fatal: {
|
|
576
|
+
level: c.Fatal
|
|
577
|
+
},
|
|
578
|
+
error: {
|
|
579
|
+
level: c.Error
|
|
580
|
+
},
|
|
581
|
+
warn: {
|
|
582
|
+
level: c.Warn
|
|
583
|
+
},
|
|
584
|
+
log: {
|
|
585
|
+
level: c.Log
|
|
586
|
+
},
|
|
587
|
+
info: {
|
|
588
|
+
level: c.Info
|
|
589
|
+
},
|
|
590
|
+
success: {
|
|
591
|
+
level: c.Success
|
|
592
|
+
},
|
|
593
|
+
debug: {
|
|
594
|
+
level: c.Debug
|
|
595
|
+
},
|
|
596
|
+
trace: {
|
|
597
|
+
level: c.Trace
|
|
598
|
+
},
|
|
599
|
+
verbose: {
|
|
600
|
+
level: c.Trace
|
|
601
|
+
},
|
|
602
|
+
ready: {
|
|
603
|
+
level: c.Info
|
|
604
|
+
},
|
|
605
|
+
start: {
|
|
606
|
+
level: c.Info
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
function h(t) {
|
|
610
|
+
return e = t, "[object Object]" === Object.prototype.toString.call(e) && !(!t.message && !t.args) && !t.stack;
|
|
611
|
+
var e;
|
|
612
|
+
}
|
|
613
|
+
var p = !1,
|
|
614
|
+
y = [],
|
|
615
|
+
d = function () {
|
|
616
|
+
function e() {
|
|
617
|
+
var r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
618
|
+
for (var o in t(this, e), this._reporters = r.reporters || [], this._types = r.types || f, this.level = void 0 !== r.level ? r.level : 3, this._defaults = r.defaults || {}, this._async = void 0 !== r.async ? r.async : void 0, this._stdout = r.stdout, this._stderr = r.stderr, this._mockFn = r.mockFn, this._throttle = r.throttle || 1e3, this._throttleMin = r.throttleMin || 5, this._types) {
|
|
619
|
+
var n = s(s({
|
|
620
|
+
type: o
|
|
621
|
+
}, this._types[o]), this._defaults);
|
|
622
|
+
this[o] = this._wrapLogFn(n), this[o].raw = this._wrapLogFn(n, !0);
|
|
623
|
+
}
|
|
624
|
+
this._mockFn && this.mockTypes(), this._lastLogSerialized = void 0, this._lastLog = void 0, this._lastLogTime = void 0, this._lastLogCount = 0, this._throttleTimeout = void 0;
|
|
625
|
+
}
|
|
626
|
+
return r(e, [{
|
|
627
|
+
key: "create",
|
|
628
|
+
value: function (t) {
|
|
629
|
+
return new e(Object.assign({
|
|
630
|
+
reporters: this._reporters,
|
|
631
|
+
level: this.level,
|
|
632
|
+
types: this._types,
|
|
633
|
+
defaults: this._defaults,
|
|
634
|
+
stdout: this._stdout,
|
|
635
|
+
stderr: this._stderr,
|
|
636
|
+
mockFn: this._mockFn
|
|
637
|
+
}, t));
|
|
638
|
+
}
|
|
639
|
+
}, {
|
|
640
|
+
key: "withDefaults",
|
|
641
|
+
value: function (t) {
|
|
642
|
+
return this.create({
|
|
643
|
+
defaults: Object.assign({}, this._defaults, t)
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}, {
|
|
647
|
+
key: "withTag",
|
|
648
|
+
value: function (t) {
|
|
649
|
+
return this.withDefaults({
|
|
650
|
+
tag: this._defaults.tag ? this._defaults.tag + ":" + t : t
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
}, {
|
|
654
|
+
key: "addReporter",
|
|
655
|
+
value: function (t) {
|
|
656
|
+
return this._reporters.push(t), this;
|
|
657
|
+
}
|
|
658
|
+
}, {
|
|
659
|
+
key: "removeReporter",
|
|
660
|
+
value: function (t) {
|
|
661
|
+
if (t) {
|
|
662
|
+
var e = this._reporters.indexOf(t);
|
|
663
|
+
if (e >= 0) return this._reporters.splice(e, 1);
|
|
664
|
+
} else this._reporters.splice(0);
|
|
665
|
+
return this;
|
|
666
|
+
}
|
|
667
|
+
}, {
|
|
668
|
+
key: "setReporters",
|
|
669
|
+
value: function (t) {
|
|
670
|
+
return this._reporters = Array.isArray(t) ? t : [t], this;
|
|
671
|
+
}
|
|
672
|
+
}, {
|
|
673
|
+
key: "wrapAll",
|
|
674
|
+
value: function () {
|
|
675
|
+
this.wrapConsole(), this.wrapStd();
|
|
676
|
+
}
|
|
677
|
+
}, {
|
|
678
|
+
key: "restoreAll",
|
|
679
|
+
value: function () {
|
|
680
|
+
this.restoreConsole(), this.restoreStd();
|
|
681
|
+
}
|
|
682
|
+
}, {
|
|
683
|
+
key: "wrapConsole",
|
|
684
|
+
value: function () {
|
|
685
|
+
for (var t in this._types) console["__" + t] || (console["__" + t] = console[t]), console[t] = this[t].raw;
|
|
686
|
+
}
|
|
687
|
+
}, {
|
|
688
|
+
key: "restoreConsole",
|
|
689
|
+
value: function () {
|
|
690
|
+
for (var t in this._types) console["__" + t] && (console[t] = console["__" + t], delete console["__" + t]);
|
|
691
|
+
}
|
|
692
|
+
}, {
|
|
693
|
+
key: "wrapStd",
|
|
694
|
+
value: function () {
|
|
695
|
+
this._wrapStream(this.stdout, "log"), this._wrapStream(this.stderr, "log");
|
|
696
|
+
}
|
|
697
|
+
}, {
|
|
698
|
+
key: "_wrapStream",
|
|
699
|
+
value: function (t, e) {
|
|
700
|
+
var r = this;
|
|
701
|
+
t && (t.__write || (t.__write = t.write), t.write = function (t) {
|
|
702
|
+
r[e].raw(String(t).trim());
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
}, {
|
|
706
|
+
key: "restoreStd",
|
|
707
|
+
value: function () {
|
|
708
|
+
this._restoreStream(this.stdout), this._restoreStream(this.stderr);
|
|
709
|
+
}
|
|
710
|
+
}, {
|
|
711
|
+
key: "_restoreStream",
|
|
712
|
+
value: function (t) {
|
|
713
|
+
t && t.__write && (t.write = t.__write, delete t.__write);
|
|
714
|
+
}
|
|
715
|
+
}, {
|
|
716
|
+
key: "pauseLogs",
|
|
717
|
+
value: function () {
|
|
718
|
+
p = !0;
|
|
719
|
+
}
|
|
720
|
+
}, {
|
|
721
|
+
key: "resumeLogs",
|
|
722
|
+
value: function () {
|
|
723
|
+
p = !1;
|
|
724
|
+
var t,
|
|
725
|
+
e = u(y.splice(0));
|
|
726
|
+
try {
|
|
727
|
+
for (e.s(); !(t = e.n()).done;) {
|
|
728
|
+
var r = t.value;
|
|
729
|
+
r[0]._logFn(r[1], r[2]);
|
|
730
|
+
}
|
|
731
|
+
} catch (t) {
|
|
732
|
+
e.e(t);
|
|
733
|
+
} finally {
|
|
734
|
+
e.f();
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}, {
|
|
738
|
+
key: "mockTypes",
|
|
739
|
+
value: function (t) {
|
|
740
|
+
if (this._mockFn = t || this._mockFn, "function" == typeof this._mockFn) for (var e in this._types) this[e] = this._mockFn(e, this._types[e]) || this[e], this[e].raw = this[e];
|
|
741
|
+
}
|
|
742
|
+
}, {
|
|
743
|
+
key: "_wrapLogFn",
|
|
744
|
+
value: function (t, e) {
|
|
745
|
+
var r = this;
|
|
746
|
+
return function () {
|
|
747
|
+
for (var o = arguments.length, n = new Array(o), s = 0; s < o; s++) n[s] = arguments[s];
|
|
748
|
+
if (!p) return r._logFn(t, n, e);
|
|
749
|
+
y.push([r, t, n, e]);
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
}, {
|
|
753
|
+
key: "_logFn",
|
|
754
|
+
value: function (t, e, r) {
|
|
755
|
+
var o = this;
|
|
756
|
+
if (t.level > this.level) return !!this._async && Promise.resolve(!1);
|
|
757
|
+
var n = Object.assign({
|
|
758
|
+
date: new Date(),
|
|
759
|
+
args: []
|
|
760
|
+
}, t);
|
|
761
|
+
!r && 1 === e.length && h(e[0]) ? Object.assign(n, e[0]) : n.args = Array.from(e), n.message && (n.args.unshift(n.message), delete n.message), n.additional && (Array.isArray(n.additional) || (n.additional = n.additional.split("\n")), n.args.push("\n" + n.additional.join("\n")), delete n.additional), n.type = "string" == typeof n.type ? n.type.toLowerCase() : "", n.tag = "string" == typeof n.tag ? n.tag.toLowerCase() : "";
|
|
762
|
+
var a = function () {
|
|
763
|
+
var t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0],
|
|
764
|
+
e = o._lastLogCount - o._throttleMin;
|
|
765
|
+
if (o._lastLog && e > 0) {
|
|
766
|
+
var r = i(o._lastLog.args);
|
|
767
|
+
e > 1 && r.push("(repeated ".concat(e, " times)")), o._log(s(s({}, o._lastLog), {}, {
|
|
768
|
+
args: r
|
|
769
|
+
})), o._lastLogCount = 1;
|
|
770
|
+
}
|
|
771
|
+
if (t) {
|
|
772
|
+
if (o._lastLog = n, o._async) return o._logAsync(n);
|
|
773
|
+
o._log(n);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
clearTimeout(this._throttleTimeout);
|
|
777
|
+
var l = this._lastLogTime ? n.date - this._lastLogTime : 0;
|
|
778
|
+
if (this._lastLogTime = n.date, l < this._throttle) try {
|
|
779
|
+
var u = JSON.stringify([n.type, n.tag, n.args]),
|
|
780
|
+
c = this._lastLogSerialized === u;
|
|
781
|
+
if (this._lastLogSerialized = u, c && (this._lastLogCount++, this._lastLogCount > this._throttleMin)) return void (this._throttleTimeout = setTimeout(a, this._throttle));
|
|
782
|
+
} catch (t) {}
|
|
783
|
+
a(!0);
|
|
784
|
+
}
|
|
785
|
+
}, {
|
|
786
|
+
key: "_log",
|
|
787
|
+
value: function (t) {
|
|
788
|
+
var e,
|
|
789
|
+
r = u(this._reporters);
|
|
790
|
+
try {
|
|
791
|
+
for (r.s(); !(e = r.n()).done;) {
|
|
792
|
+
e.value.log(t, {
|
|
793
|
+
async: !1,
|
|
794
|
+
stdout: this.stdout,
|
|
795
|
+
stderr: this.stderr
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
} catch (t) {
|
|
799
|
+
r.e(t);
|
|
800
|
+
} finally {
|
|
801
|
+
r.f();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}, {
|
|
805
|
+
key: "_logAsync",
|
|
806
|
+
value: function (t) {
|
|
807
|
+
var e = this;
|
|
808
|
+
return Promise.all(this._reporters.map(function (r) {
|
|
809
|
+
return r.log(t, {
|
|
810
|
+
async: !0,
|
|
811
|
+
stdout: e.stdout,
|
|
812
|
+
stderr: e.stderr
|
|
813
|
+
});
|
|
814
|
+
}));
|
|
815
|
+
}
|
|
816
|
+
}, {
|
|
817
|
+
key: "stdout",
|
|
818
|
+
get: function () {
|
|
819
|
+
return this._stdout || console._stdout;
|
|
820
|
+
}
|
|
821
|
+
}, {
|
|
822
|
+
key: "stderr",
|
|
823
|
+
get: function () {
|
|
824
|
+
return this._stderr || console._stderr;
|
|
825
|
+
}
|
|
826
|
+
}]), e;
|
|
827
|
+
}();
|
|
828
|
+
d.prototype.add = d.prototype.addReporter, d.prototype.remove = d.prototype.removeReporter, d.prototype.clear = d.prototype.removeReporter, d.prototype.withScope = d.prototype.withTag, d.prototype.mock = d.prototype.mockTypes, d.prototype.pause = d.prototype.pauseLogs, d.prototype.resume = d.prototype.resumeLogs;
|
|
829
|
+
var v,
|
|
830
|
+
g = function () {
|
|
831
|
+
function e(r) {
|
|
832
|
+
t(this, e), this.options = Object.assign({}, r), this.defaultColor = "#7f8c8d", this.levelColorMap = {
|
|
833
|
+
0: "#c0392b",
|
|
834
|
+
1: "#f39c12",
|
|
835
|
+
3: "#00BCD4"
|
|
836
|
+
}, this.typeColorMap = {
|
|
837
|
+
success: "#2ecc71"
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
return r(e, [{
|
|
841
|
+
key: "log",
|
|
842
|
+
value: function (t) {
|
|
843
|
+
var e = t.level < 1 ? console.__error || console.error : 1 === t.level && console.warn ? console.__warn || console.warn : console.__log || console.log,
|
|
844
|
+
r = "log" !== t.type ? t.type : "",
|
|
845
|
+
o = t.tag ? t.tag : "",
|
|
846
|
+
n = this.typeColorMap[t.type] || this.levelColorMap[t.level] || this.defaultColor,
|
|
847
|
+
s = "\n background: ".concat(n, ";\n border-radius: 0.5em;\n color: white;\n font-weight: bold;\n padding: 2px 0.5em;\n "),
|
|
848
|
+
a = "%c".concat([o, r].filter(Boolean).join(":"));
|
|
849
|
+
"string" == typeof t.args[0] ? e.apply(void 0, ["".concat(a, "%c ").concat(t.args[0]), s, ""].concat(i(t.args.slice(1)))) : e.apply(void 0, [a, s].concat(i(t.args)));
|
|
850
|
+
}
|
|
851
|
+
}]), e;
|
|
852
|
+
}();
|
|
853
|
+
return "undefined" != typeof window && window.consola || ((v = new d({
|
|
854
|
+
reporters: [new g()]
|
|
855
|
+
})).Consola = d, v.LogLevel = c, v.BrowserReporter = g, v);
|
|
856
|
+
});
|
|
857
|
+
})(consola_browser);
|
|
858
|
+
|
|
859
|
+
const logLevelDebug = 4;
|
|
860
|
+
const defaultLoggerOptions = {
|
|
861
|
+
level: logLevelDebug
|
|
862
|
+
};
|
|
863
|
+
function createLogger(name, options = defaultLoggerOptions) {
|
|
864
|
+
const baseLogger = consola.create(options);
|
|
865
|
+
const logger = baseLogger.withTag(name);
|
|
866
|
+
return logger;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
class ErrorBuilder {
|
|
870
|
+
withTitle(title) {
|
|
871
|
+
this.title = title;
|
|
872
|
+
return this;
|
|
873
|
+
}
|
|
874
|
+
withErrorDetails(errorDetails) {
|
|
875
|
+
this.errorDetails = errorDetails;
|
|
876
|
+
return this;
|
|
877
|
+
}
|
|
878
|
+
withLogLevel(logLevel) {
|
|
879
|
+
this.logLevel = logLevel;
|
|
880
|
+
return this;
|
|
881
|
+
}
|
|
882
|
+
withAlert(alert) {
|
|
883
|
+
this.alert = alert;
|
|
884
|
+
return this;
|
|
885
|
+
}
|
|
886
|
+
withNotification(notification) {
|
|
887
|
+
this.notification = notification;
|
|
888
|
+
return this;
|
|
889
|
+
}
|
|
890
|
+
withBanner(banner) {
|
|
891
|
+
this.banner = banner;
|
|
892
|
+
return this;
|
|
893
|
+
}
|
|
894
|
+
withSnackbar(snackbar) {
|
|
895
|
+
this.snackbar = snackbar;
|
|
896
|
+
return this;
|
|
897
|
+
}
|
|
898
|
+
withDialog(dialog) {
|
|
899
|
+
this.dialog = dialog;
|
|
900
|
+
return this;
|
|
901
|
+
}
|
|
902
|
+
build() {
|
|
903
|
+
if (!this.title) {
|
|
904
|
+
throw new Error('Title is required');
|
|
905
|
+
}
|
|
906
|
+
if (!this.errorDetails) {
|
|
907
|
+
throw new Error(`Missing required param 'errorDetails'`);
|
|
908
|
+
}
|
|
909
|
+
let errorStructure = {
|
|
910
|
+
title: this.title,
|
|
911
|
+
errorDetails: this.errorDetails
|
|
912
|
+
};
|
|
913
|
+
let config = {};
|
|
914
|
+
if (this.logLevel in consola_browser.exports.LogLevel) {
|
|
915
|
+
errorStructure = Object.assign({
|
|
916
|
+
logLevel: this.logLevel
|
|
917
|
+
}, errorStructure);
|
|
918
|
+
}
|
|
919
|
+
if (this.alert) {
|
|
920
|
+
config = Object.assign({
|
|
921
|
+
alert: this.alert
|
|
922
|
+
}, config);
|
|
923
|
+
errorStructure = Object.assign({
|
|
924
|
+
config
|
|
925
|
+
}, errorStructure);
|
|
926
|
+
}
|
|
927
|
+
if (this.notification) {
|
|
928
|
+
config = Object.assign({
|
|
929
|
+
notification: this.notification
|
|
930
|
+
}, config);
|
|
931
|
+
errorStructure = Object.assign({
|
|
932
|
+
config
|
|
933
|
+
}, errorStructure);
|
|
934
|
+
}
|
|
935
|
+
if (this.banner) {
|
|
936
|
+
config = Object.assign({
|
|
937
|
+
banner: this.banner
|
|
938
|
+
}, config);
|
|
939
|
+
errorStructure = Object.assign({
|
|
940
|
+
config
|
|
941
|
+
}, errorStructure);
|
|
942
|
+
}
|
|
943
|
+
if (this.snackbar) {
|
|
944
|
+
config = Object.assign({
|
|
945
|
+
snackbar: this.snackbar
|
|
946
|
+
}, config);
|
|
947
|
+
errorStructure = Object.assign({
|
|
948
|
+
config
|
|
949
|
+
}, errorStructure);
|
|
950
|
+
}
|
|
951
|
+
if (this.dialog) {
|
|
952
|
+
config = Object.assign({
|
|
953
|
+
dialog: this.dialog
|
|
954
|
+
}, config);
|
|
955
|
+
errorStructure = Object.assign({
|
|
956
|
+
config
|
|
957
|
+
}, errorStructure);
|
|
958
|
+
}
|
|
959
|
+
return errorStructure;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
const getErrorBuilder = () => new ErrorBuilder();
|
|
963
|
+
|
|
964
|
+
class NotificationBuilder {
|
|
965
|
+
withAutoClose(autoClose) {
|
|
966
|
+
this.autoClose = autoClose;
|
|
967
|
+
return this;
|
|
968
|
+
}
|
|
969
|
+
withCloseTimeout(closeTimeout) {
|
|
970
|
+
this.closeTimeout = closeTimeout;
|
|
971
|
+
return this;
|
|
972
|
+
}
|
|
973
|
+
withType(type) {
|
|
974
|
+
this.type = type;
|
|
975
|
+
return this;
|
|
976
|
+
}
|
|
977
|
+
build() {
|
|
978
|
+
let notification = {};
|
|
979
|
+
if (this.autoClose) {
|
|
980
|
+
notification = Object.assign({
|
|
981
|
+
autoClose: this.autoClose
|
|
982
|
+
}, notification);
|
|
983
|
+
}
|
|
984
|
+
if (this.closeTimeout) {
|
|
985
|
+
notification = Object.assign({
|
|
986
|
+
closeTimeout: this.closeTimeout
|
|
987
|
+
}, notification);
|
|
988
|
+
}
|
|
989
|
+
if (this.type) {
|
|
990
|
+
notification = Object.assign({
|
|
991
|
+
type: this.type
|
|
992
|
+
}, notification);
|
|
993
|
+
}
|
|
994
|
+
return notification;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
const getNotificationBuilder = () => new NotificationBuilder();
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Retrieves the error details from an ErrorStructure object
|
|
1001
|
+
* @public
|
|
1002
|
+
* @param details - The ErrorStructure object
|
|
1003
|
+
* @returns The title and error details concatenated as a string, or default values ('Error: Something went wrong') if not present
|
|
1004
|
+
*/
|
|
1005
|
+
const getErrorDetails = details => {
|
|
1006
|
+
var _a, _b;
|
|
1007
|
+
const title = (_a = details === null || details === void 0 ? void 0 : details.title) !== null && _a !== void 0 ? _a : 'Error';
|
|
1008
|
+
const errorDetails = (_b = details === null || details === void 0 ? void 0 : details.errorDetails) !== null && _b !== void 0 ? _b : 'Something went wrong';
|
|
1009
|
+
return `${title}: ${errorDetails}`;
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* Retrieves the log level from an ErrorStructure object
|
|
1013
|
+
* @public
|
|
1014
|
+
* @param details - The ErrorStructure object
|
|
1015
|
+
* @returns The log level or the default value (LogLevel.Error) if not present
|
|
1016
|
+
*/
|
|
1017
|
+
const getLoglevel = details => {
|
|
1018
|
+
var _a;
|
|
1019
|
+
return (details === null || details === void 0 ? void 0 : details.logLevel) || ((_a = details === null || details === void 0 ? void 0 : details.config) === null || _a === void 0 ? void 0 : _a.logLevel) || consola_browser.exports.LogLevel.Error;
|
|
1020
|
+
};
|
|
1021
|
+
/**
|
|
1022
|
+
* Get/Create the error container in the DOM
|
|
1023
|
+
* @public
|
|
1024
|
+
* @param id - The id of the container
|
|
1025
|
+
* @param tagName - The tag name to create prefix for the design system provider
|
|
1026
|
+
* @returns
|
|
1027
|
+
*/
|
|
1028
|
+
const getErrorContainer = (id, tagName) => {
|
|
1029
|
+
const tagPrefix = tagName.split('-')[0];
|
|
1030
|
+
let container = document.querySelector(`#${id}`);
|
|
1031
|
+
if (!container) {
|
|
1032
|
+
container = document.createElement('div');
|
|
1033
|
+
container.setAttribute('id', id);
|
|
1034
|
+
const dsProvider = document.createElement(`${tagPrefix}-design-system-provider`);
|
|
1035
|
+
dsProvider.appendChild(container);
|
|
1036
|
+
document.body.appendChild(dsProvider);
|
|
1037
|
+
}
|
|
1038
|
+
return container;
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Shows the error notification
|
|
1043
|
+
* @public
|
|
1044
|
+
* @param error - The ErrorStructure object
|
|
1045
|
+
* @param tagName - The tag name to create prefix for the design system provider & error component
|
|
1046
|
+
* @returns
|
|
1047
|
+
* */
|
|
1048
|
+
const showNotification = (error, tagName) => {
|
|
1049
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1050
|
+
const tagPrefix = tagName.split('-')[0];
|
|
1051
|
+
const container = getErrorContainer('notify-container', tagName);
|
|
1052
|
+
if (container) {
|
|
1053
|
+
container.style.position = 'fixed';
|
|
1054
|
+
container.style.top = '0';
|
|
1055
|
+
container.style.right = '0';
|
|
1056
|
+
}
|
|
1057
|
+
const toastNotify = document.createElement(`${tagPrefix}-toast`);
|
|
1058
|
+
const errorTitle = document.createElement('div');
|
|
1059
|
+
errorTitle.setAttribute('slot', 'top');
|
|
1060
|
+
errorTitle.textContent = (_a = error.title) !== null && _a !== void 0 ? _a : 'Error';
|
|
1061
|
+
const errorDetails = document.createElement('div');
|
|
1062
|
+
errorDetails.setAttribute('slot', 'content');
|
|
1063
|
+
errorDetails.textContent = (error === null || error === void 0 ? void 0 : error.errorDetails) || '';
|
|
1064
|
+
const errorDate = document.createElement('div');
|
|
1065
|
+
errorDate.setAttribute('slot', 'date');
|
|
1066
|
+
errorDate.textContent = new Date().toLocaleTimeString();
|
|
1067
|
+
toastNotify.setAttribute('notify', ((_c = (_b = error === null || error === void 0 ? void 0 : error.config) === null || _b === void 0 ? void 0 : _b.notification) === null || _c === void 0 ? void 0 : _c.type) || '');
|
|
1068
|
+
((_e = (_d = error === null || error === void 0 ? void 0 : error.config) === null || _d === void 0 ? void 0 : _d.notification) === null || _e === void 0 ? void 0 : _e.autoClose) ? toastNotify.setAttribute('auto-close', `${(_g = (_f = error === null || error === void 0 ? void 0 : error.config) === null || _f === void 0 ? void 0 : _f.notification) === null || _g === void 0 ? void 0 : _g.autoClose}`) : '';
|
|
1069
|
+
((_j = (_h = error === null || error === void 0 ? void 0 : error.config) === null || _h === void 0 ? void 0 : _h.notification) === null || _j === void 0 ? void 0 : _j.closeTimeout) ? toastNotify.setAttribute('close-timeout', `${(_l = (_k = error === null || error === void 0 ? void 0 : error.config) === null || _k === void 0 ? void 0 : _k.notification) === null || _l === void 0 ? void 0 : _l.closeTimeout}`) : '';
|
|
1070
|
+
toastNotify.appendChild(errorTitle);
|
|
1071
|
+
toastNotify.appendChild(errorDetails);
|
|
1072
|
+
toastNotify.appendChild(errorDate);
|
|
1073
|
+
container.appendChild(toastNotify);
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
class ErrorBannerBuilder {
|
|
1077
|
+
withDismissingAction(dismissingAction) {
|
|
1078
|
+
this.dismissingAction = dismissingAction;
|
|
1079
|
+
return this;
|
|
1080
|
+
}
|
|
1081
|
+
withConfirmingAction(confirmingAction) {
|
|
1082
|
+
if (!this.confirmingActions) {
|
|
1083
|
+
this.confirmingActions = [];
|
|
1084
|
+
}
|
|
1085
|
+
this.confirmingActions.push(confirmingAction);
|
|
1086
|
+
return this;
|
|
1087
|
+
}
|
|
1088
|
+
build() {
|
|
1089
|
+
let errorBanner = {};
|
|
1090
|
+
if (this.dismissingAction) {
|
|
1091
|
+
errorBanner = Object.assign({
|
|
1092
|
+
dismissingAction: this.dismissingAction
|
|
1093
|
+
}, errorBanner);
|
|
1094
|
+
}
|
|
1095
|
+
if (this.confirmingActions) {
|
|
1096
|
+
errorBanner = Object.assign({
|
|
1097
|
+
confirmingActions: this.confirmingActions
|
|
1098
|
+
}, errorBanner);
|
|
1099
|
+
}
|
|
1100
|
+
return errorBanner;
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
const getErrorBannerBuilder = () => new ErrorBannerBuilder();
|
|
1104
|
+
|
|
1105
|
+
class ErrorDialogBuilder {
|
|
1106
|
+
withDismissingAction(dismissingAction) {
|
|
1107
|
+
this.dismissingAction = dismissingAction;
|
|
1108
|
+
return this;
|
|
1109
|
+
}
|
|
1110
|
+
withConfirmingAction(confirmingAction) {
|
|
1111
|
+
if (!this.confirmingActions) {
|
|
1112
|
+
this.confirmingActions = [];
|
|
1113
|
+
}
|
|
1114
|
+
this.confirmingActions.push(confirmingAction);
|
|
1115
|
+
return this;
|
|
1116
|
+
}
|
|
1117
|
+
build() {
|
|
1118
|
+
let errorDialog = {};
|
|
1119
|
+
if (this.dismissingAction) {
|
|
1120
|
+
errorDialog = Object.assign({
|
|
1121
|
+
dismissingAction: this.dismissingAction
|
|
1122
|
+
}, errorDialog);
|
|
1123
|
+
}
|
|
1124
|
+
if (this.confirmingActions) {
|
|
1125
|
+
errorDialog = Object.assign({
|
|
1126
|
+
confirmingActions: this.confirmingActions
|
|
1127
|
+
}, errorDialog);
|
|
1128
|
+
}
|
|
1129
|
+
return errorDialog;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
const getErrorDialogBuilder = () => new ErrorDialogBuilder();
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Shows the error dialog
|
|
1136
|
+
* @public
|
|
1137
|
+
* @param error - The ErrorStructure object
|
|
1138
|
+
* @param tagName - The tag name to create prefix for the design system provider & error component
|
|
1139
|
+
* @returns
|
|
1140
|
+
* */
|
|
1141
|
+
const showDialog = (error, tagName) => {
|
|
1142
|
+
const tagPrefix = tagName.split('-')[0];
|
|
1143
|
+
const dialog = document.createElement(`${tagPrefix}-error-dialog`);
|
|
1144
|
+
const container = getErrorContainer('dialog-container', tagName);
|
|
1145
|
+
container.appendChild(dialog);
|
|
1146
|
+
dialog.error = error;
|
|
1147
|
+
dialog.show();
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
class SnackbarBuilder {
|
|
1151
|
+
/**
|
|
1152
|
+
* Add type to snackbar
|
|
1153
|
+
* @public
|
|
1154
|
+
* @param type
|
|
1155
|
+
* @returns
|
|
1156
|
+
*/
|
|
1157
|
+
withType(type) {
|
|
1158
|
+
this.type = type;
|
|
1159
|
+
return this;
|
|
1160
|
+
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Add confirming action to snackbar
|
|
1163
|
+
* @public
|
|
1164
|
+
* @param confirmingAction
|
|
1165
|
+
* @returns
|
|
1166
|
+
* */
|
|
1167
|
+
withConfirmingAction(confirmingAction) {
|
|
1168
|
+
if (!this.confirmingActions) {
|
|
1169
|
+
this.confirmingActions = [];
|
|
1170
|
+
}
|
|
1171
|
+
this.confirmingActions.push(confirmingAction);
|
|
1172
|
+
return this;
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Build snackbar
|
|
1176
|
+
* @public
|
|
1177
|
+
* @returns Snackbar
|
|
1178
|
+
* */
|
|
1179
|
+
build() {
|
|
1180
|
+
let snackbar = {};
|
|
1181
|
+
if (this.confirmingActions) {
|
|
1182
|
+
snackbar = Object.assign({
|
|
1183
|
+
confirmingActions: this.confirmingActions
|
|
1184
|
+
}, snackbar);
|
|
1185
|
+
}
|
|
1186
|
+
if (this.type !== undefined) {
|
|
1187
|
+
snackbar = Object.assign({
|
|
1188
|
+
type: this.type
|
|
1189
|
+
}, snackbar);
|
|
1190
|
+
}
|
|
1191
|
+
return snackbar;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
const getSnackbarBuilder = () => new SnackbarBuilder();
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* Shows the snackbar
|
|
1198
|
+
* @public
|
|
1199
|
+
* @param error - The ErrorStructure object
|
|
1200
|
+
* @param tagName - The tag name to create prefix for the design system provider & error component
|
|
1201
|
+
* @returns
|
|
1202
|
+
* */
|
|
1203
|
+
const showSnackbar = (error, tagName) => {
|
|
1204
|
+
const tagPrefix = tagName.split('-')[0];
|
|
1205
|
+
const snackbar = document.createElement(`${tagPrefix}-snackbar`);
|
|
1206
|
+
const container = getErrorContainer('snack-container', tagName);
|
|
1207
|
+
container.appendChild(snackbar);
|
|
1208
|
+
snackbar.error = error;
|
|
1209
|
+
};
|
|
1210
|
+
|
|
1211
|
+
const logger = createLogger('foundation-error');
|
|
1212
|
+
const errorTypeToComponentMap = {
|
|
1213
|
+
alert: error => {
|
|
1214
|
+
alert(getErrorDetails(error));
|
|
1215
|
+
},
|
|
1216
|
+
notification: showNotification,
|
|
1217
|
+
dialog: showDialog,
|
|
1218
|
+
snackbar: showSnackbar
|
|
1219
|
+
};
|
|
1220
|
+
/**
|
|
1221
|
+
* Shows the error in the appropriate component
|
|
1222
|
+
* @public
|
|
1223
|
+
* @param error - The ErrorStructure object
|
|
1224
|
+
* @param tagName - The tag name to create prefix for the design system provider *
|
|
1225
|
+
* @returns
|
|
1226
|
+
* */
|
|
1227
|
+
const showError = (error, tagName) => {
|
|
1228
|
+
logger.log({
|
|
1229
|
+
message: getErrorDetails(error),
|
|
1230
|
+
level: getLoglevel(error)
|
|
1231
|
+
});
|
|
1232
|
+
const keys = Object.keys((error === null || error === void 0 ? void 0 : error.config) || {});
|
|
1233
|
+
keys.forEach(key => {
|
|
1234
|
+
if (errorTypeToComponentMap[key]) {
|
|
1235
|
+
errorTypeToComponentMap[key](error, tagName);
|
|
1236
|
+
}
|
|
1237
|
+
});
|
|
1238
|
+
};
|
|
1239
|
+
|
|
1240
|
+
export { ErrorBannerBuilder, ErrorBoundaryEvent, ErrorBuilder, ErrorDialogBuilder, NotificationBuilder, SnackbarBuilder, getErrorBannerBuilder, getErrorBuilder, getErrorContainer, getErrorDetails, getErrorDialogBuilder, getLoglevel, getNotificationBuilder, getSnackbarBuilder, showDialog, showError, showNotification, showSnackbar };
|