Skip to content

Commit a726c70

Browse files
committed
console fixes
1 parent 6270c95 commit a726c70

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

packages/javascript-kernel/src/runtime_evaluator.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ export class JavaScriptRuntimeEvaluator {
161161
log: scopeConsole.log,
162162
info: scopeConsole.info,
163163
error: scopeConsole.error,
164-
warn: scopeConsole.warn
164+
warn: scopeConsole.warn,
165+
debug: scopeConsole.debug,
166+
dir: scopeConsole.dir,
167+
trace: scopeConsole.trace,
168+
table: scopeConsole.table
165169
};
166170

167171
const toText = (args: any[]) => {
@@ -172,6 +176,13 @@ export class JavaScriptRuntimeEvaluator {
172176
}
173177

174178
try {
179+
if (typeof arg === 'object' && arg !== null) {
180+
const bundle = this._executor.getMimeBundle(arg);
181+
const plain = bundle['text/plain'];
182+
if (typeof plain === 'string') {
183+
return plain;
184+
}
185+
}
175186
return String(arg);
176187
} catch {
177188
return '[Unprintable value]';
@@ -200,6 +211,11 @@ export class JavaScriptRuntimeEvaluator {
200211

201212
scopeConsole.warn = scopeConsole.error;
202213

214+
scopeConsole.debug = scopeConsole.log;
215+
scopeConsole.dir = scopeConsole.log;
216+
scopeConsole.trace = scopeConsole.log;
217+
scopeConsole.table = scopeConsole.log;
218+
203219
if ('onerror' in this._globalScope) {
204220
this._originalOnError = this._globalScope.onerror;
205221
this._globalScope.onerror = (message: any) => {
@@ -223,6 +239,10 @@ export class JavaScriptRuntimeEvaluator {
223239
scopeConsole.info = this._originalConsole.info;
224240
scopeConsole.error = this._originalConsole.error;
225241
scopeConsole.warn = this._originalConsole.warn;
242+
scopeConsole.debug = this._originalConsole.debug;
243+
scopeConsole.dir = this._originalConsole.dir;
244+
scopeConsole.trace = this._originalConsole.trace;
245+
scopeConsole.table = this._originalConsole.table;
226246
}
227247

228248
if ('onerror' in this._globalScope) {
@@ -275,6 +295,10 @@ export class JavaScriptRuntimeEvaluator {
275295
info: Console['info'];
276296
error: Console['error'];
277297
warn: Console['warn'];
298+
debug: Console['debug'];
299+
dir: Console['dir'];
300+
trace: Console['trace'];
301+
table: Console['table'];
278302
} | null = null;
279303
}
280304

0 commit comments

Comments
 (0)