automata/klay-js

workerScript should be able to be set globally

forresto opened this issue · 3 comments

We set the workerScript location in klay.init:

     this.autolayouter = klay.init({
       onSuccess: this.applyAutolayout.bind(this),
       workerScript: "../bower_components/klay-js/klay-worker.js"
    });

But there should be a way to do it globally. So

window.KLAY_CONFIG = { workerScript: "./bower_components/klay-js/klay-worker.js" }

and

  if ("KLAY_CONFIG" in window && "workerScript" in window.KLAY_CONFIG) {
    workerScript = window.KLAY_CONFIG.workerScript;
  } else if ("workerScript" in params) {
    workerScript = params.workerScript;
  } else {
    workerScript = "klay-worker.js";
  }    

This was an issue in noflo/visualize b/c we're using the-graph as a bower dependency, klay.init needs to happen in the-graph custom element, and the worker script path is different b/c it is hosted here: http://noflojs.org/visualize/

(Changed to KLAY_CONFIG to mirror GSS's config.)

klay-wroker.js still is problem. Will you fix it?

Hi, I improved the the underlying library code which you can find in another repository. Maybe that helps you. If not, let me know.

See https://github.com/OpenKieler/klayjs