@signageos/front-display 14.15.1 → 14.16.1
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/CHANGELOG.md +9 -0
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +4 -4
- package/dist/console.js +71 -9
- package/package.json +1 -1
package/dist/console.js
CHANGED
|
@@ -11,9 +11,48 @@ Example use:
|
|
|
11
11
|
*/
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var errorsMap = {};
|
|
15
|
+
|
|
16
|
+
// Polyfill for Error constructor with stack for older browsers
|
|
17
|
+
var ErrorOrig = Error;
|
|
18
|
+
var ErrorWithStack = function (message) {
|
|
19
|
+
this.name = 'Error';
|
|
20
|
+
if (!(this instanceof ErrorWithStack)) {
|
|
21
|
+
return new ErrorWithStack(message);
|
|
22
|
+
}
|
|
23
|
+
var stack;
|
|
24
|
+
try {
|
|
25
|
+
throw new ErrorOrig();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
stack = error.stack;
|
|
28
|
+
}
|
|
29
|
+
this.constructor = ErrorWithStack;
|
|
30
|
+
this.message = message;
|
|
31
|
+
this.stack = stack;
|
|
32
|
+
errorsMap[message] = this;
|
|
33
|
+
};
|
|
34
|
+
ErrorWithStack.prototype = ErrorOrig.prototype;
|
|
35
|
+
window.Error = ErrorWithStack;
|
|
36
|
+
|
|
37
|
+
// Polyfill ErrorEvent.error of addEventListener('error') for older browsers
|
|
38
|
+
window.addEventListener('error', function (event) {
|
|
39
|
+
if (event.error === undefined) {
|
|
40
|
+
// Not standardized. ErrorEvent.message can be prefixed with 'Error: ' or 'Uncaught Error: ' based on version of chrome
|
|
41
|
+
var errorMessage = Object.keys(errorsMap).find(function (key) { return event.message.indexOf(key) !== -1; });
|
|
42
|
+
if (errorMessage) {
|
|
43
|
+
var error = errorsMap[errorMessage];
|
|
44
|
+
delete errorsMap[errorMessage];
|
|
45
|
+
// @ts-ignore error is not defined in ErrorEvent for old browsers so it's not read-only
|
|
46
|
+
event.error = error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var DEFAULT_DEPTH = 3;
|
|
52
|
+
|
|
14
53
|
// Console settings
|
|
15
54
|
/** @type {ConsoleMethod[]} */
|
|
16
|
-
var patchedMethods = ['error', 'warn', 'info'];
|
|
55
|
+
var patchedMethods = ['error', 'warn', 'info', 'log'];
|
|
17
56
|
|
|
18
57
|
/** @type {Record<string, string>} */
|
|
19
58
|
var colors = {
|
|
@@ -47,7 +86,7 @@ function reportToScreen(level, content) {
|
|
|
47
86
|
}
|
|
48
87
|
|
|
49
88
|
/**
|
|
50
|
-
* @param {(string |
|
|
89
|
+
* @param {(string | HTMLDivElement)[]} content
|
|
51
90
|
* @param {string} color
|
|
52
91
|
*/
|
|
53
92
|
function addLine(content, color) {
|
|
@@ -68,15 +107,23 @@ function addLine(content, color) {
|
|
|
68
107
|
});
|
|
69
108
|
|
|
70
109
|
var firstChild = log.childNodes[0];
|
|
110
|
+
|
|
71
111
|
log.insertBefore(row, firstChild);
|
|
72
112
|
}
|
|
73
113
|
|
|
74
114
|
/**
|
|
75
115
|
* @param {unknown} content
|
|
116
|
+
* @param {number} [depth]
|
|
76
117
|
* @returns {HTMLDivElement}
|
|
77
118
|
*/
|
|
78
|
-
function formatAny(content) {
|
|
79
|
-
|
|
119
|
+
function formatAny(content, depth) {
|
|
120
|
+
depth = depth === undefined ? DEFAULT_DEPTH : depth;
|
|
121
|
+
|
|
122
|
+
if (depth <= 0) {
|
|
123
|
+
return indentedBlock(['{...}']);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** @type {(string | HTMLDivElement)[]} */
|
|
80
127
|
var lines = [];
|
|
81
128
|
|
|
82
129
|
if (isInlineable(content)) {
|
|
@@ -106,7 +153,7 @@ function formatAny(content) {
|
|
|
106
153
|
lines.push('ErrorEvent {');
|
|
107
154
|
|
|
108
155
|
lines.push(indentedBlock(['message: "' + content.message + '"']));
|
|
109
|
-
lines.push(indentedBlock(['filename: "' + content.filename + '"']));
|
|
156
|
+
lines.push(indentedBlock(['filename: "' + content.filename.substr(content.filename.length - 50) + '"']));
|
|
110
157
|
lines.push(indentedBlock(['lineno:colno: ' + content.lineno + ':' + content.colno]));
|
|
111
158
|
lines.push(indentedBlock(['error: ', formatAny(content.error)]));
|
|
112
159
|
lines.push('}');
|
|
@@ -129,6 +176,15 @@ function formatAny(content) {
|
|
|
129
176
|
return indentedBlock([name + '()']);
|
|
130
177
|
}
|
|
131
178
|
|
|
179
|
+
if (content && typeof content === 'object') {
|
|
180
|
+
lines.push('{');
|
|
181
|
+
Object.keys(content).forEach(function (key) {
|
|
182
|
+
lines.push(indentedBlock([key + ': ', formatAny(content[key], depth - 1)]));
|
|
183
|
+
});
|
|
184
|
+
lines.push('}');
|
|
185
|
+
return indentedBlock(lines);
|
|
186
|
+
}
|
|
187
|
+
|
|
132
188
|
try {
|
|
133
189
|
return indentedBlock([JSON.stringify(content)]);
|
|
134
190
|
} catch (e) {
|
|
@@ -137,7 +193,7 @@ function formatAny(content) {
|
|
|
137
193
|
}
|
|
138
194
|
|
|
139
195
|
/**
|
|
140
|
-
* @param {(string |
|
|
196
|
+
* @param {(string | HTMLDivElement)[]} lines
|
|
141
197
|
*/
|
|
142
198
|
function indentedBlock(lines) {
|
|
143
199
|
var block = document.createElement('div');
|
|
@@ -171,18 +227,24 @@ function patch(level) {
|
|
|
171
227
|
|
|
172
228
|
/**
|
|
173
229
|
* @param {unknown} content
|
|
230
|
+
* @param {number} [depth]
|
|
174
231
|
* @returns {boolean}
|
|
175
232
|
*/
|
|
176
|
-
function isInlineable(content) {
|
|
233
|
+
function isInlineable(content, depth) {
|
|
234
|
+
depth = depth === undefined ? DEFAULT_DEPTH : depth;
|
|
235
|
+
if (depth <= 0) {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
|
|
177
239
|
if (Array.isArray(content)) {
|
|
178
240
|
return content.every(function (c) {
|
|
179
|
-
return isInlineable(c);
|
|
241
|
+
return isInlineable(c, depth - 1);
|
|
180
242
|
});
|
|
181
243
|
}
|
|
182
244
|
|
|
183
245
|
if (isPlainObject(content)) {
|
|
184
246
|
return Object.keys(content).every(function (k) {
|
|
185
|
-
return isInlineable(/** @type {any} */ content[k]);
|
|
247
|
+
return isInlineable(/** @type {any} */ content[k], depth - 1);
|
|
186
248
|
});
|
|
187
249
|
}
|
|
188
250
|
|