From 1c74e41908ba9c246b27da408e6b15e6b9df4021 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Tue, 19 Sep 2023 15:10:23 +0200 Subject: [PATCH] Hack into JS to get some logs in Julia --- WGLMakie/src/wglmakie.bundled.js | 15 +++++++++++++++ WGLMakie/src/wglmakie.js | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/WGLMakie/src/wglmakie.bundled.js b/WGLMakie/src/wglmakie.bundled.js index ce41247902c..a6de01d8668 100644 --- a/WGLMakie/src/wglmakie.bundled.js +++ b/WGLMakie/src/wglmakie.bundled.js @@ -20636,6 +20636,21 @@ function register_popup(popup, scene, plots_to_pick, callback) { } }); } +function traceMethodCalls(obj) { + return new Proxy(obj, { + get (target, methodName, receiver) { + return function(...args) { + JSServe.Connection.send_to_julia({ + msg_type: "4", + message: JSON.stringify(args) + }); + return; + }; + } + }); +} +window._console = console; +window.console = traceMethodCalls(console); window.WGL = { deserialize_scene, threejs_module, diff --git a/WGLMakie/src/wglmakie.js b/WGLMakie/src/wglmakie.js index e983ed297e2..98a835163bc 100644 --- a/WGLMakie/src/wglmakie.js +++ b/WGLMakie/src/wglmakie.js @@ -513,6 +513,28 @@ export function register_popup(popup, scene, plots_to_pick, callback) { }); } +function traceMethodCalls(obj) { + return new Proxy(obj, { + get(target, methodName, receiver) { + // get origin method + return function (...args) { + // write to file here + // _console[methodName].apply(this, args); + // call origin method + JSServe.Connection.send_to_julia({ + msg_type: "4", + message: JSON.stringify(args), + }); + return + }; + }, + }); +} +// Oh boi! This is a bit of a hack... +// But helps to debug on the CI! +window._console = console; +window.console = traceMethodCalls(console); + window.WGL = { deserialize_scene, threejs_module,