vizhub-core / vizhub-feedback

VizHub feedback issue tracker
32 stars 3 forks source link

Fake Console (for mobile) #308

Open curran opened 4 years ago

curran commented 3 years ago

Svelte REPL reference implementation https://github.com/sveltejs/svelte-repl/blob/2cddc8695973c99e5b32d0f5a8f56125690039e5/src/Output/srcdoc/index.html#L84

curran commented 3 years ago

Something to study https://github.com/porsager/flems

curran commented 3 years ago

Partial solution from https://github.com/datavis-tech/magic-sandbox/pull/10/files

    window.console_log_native = window.console.log
    window.console.log = function(){
      try {
        window.parent.postMessage({type: "console-log", message: [...arguments]}, "` + window.location.origin + `")
      }
      catch(err){
        window.parent.postMessage({type: "console-fail"}, "` + window.location.origin + `")
      }
      if (!${supress_console_log}){
        window.console_log_native(...arguments)
      }