MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / initViz

Function initViz

chapter18/docs/d3-graphviz.js:880–937  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

878 }
879
880 function initViz() {
881 var _this = this;
882 // force JIT compilation of @hpcc-js/wasm
883 try {
884 xo.load().then(function (graphviz) {
885 graphviz.layout("", "svg", "dot");
886 _this.layoutSync = graphviz.layout.bind(graphviz);
887 if (_this._worker == null) {
888 _this._dispatch.call("initEnd", _this);
889 }
890 if (_this._afterInit) {
891 _this._afterInit();
892 }
893 });
894 // after the port to ESM modules, we don't know how to trigger this so
895 // we just disable it from coverage
896 /* c8 ignore start */
897 } catch (error) {
898 // we end up here when the the script tag type used to load
899 // the "@hpcc-js/wasm" script is not "application/javascript"
900 // or "text/javascript", but typically "javascript/worker". In
901 // this case the browser does not load the script since it's
902 // unnecessary because it's loaded by the web worker
903 // instead. This is expected so we just ignore the error.
904 }
905 /* c8 ignore stop */
906 if (this._worker != null) {
907 var vizURL = this._vizURL;
908 var graphvizInstance = this;
909 this._workerPort.onmessage = function (event) {
910 var callback = graphvizInstance._workerCallbacks.shift();
911 callback.call(graphvizInstance, event);
912 };
913 if (!vizURL.match(/^https?:\/\/|^\/\//i)) {
914 // Local URL. Prepend with local domain to be usable in web worker
915 vizURL = new window.URL(vizURL, document.location.href).href;
916 }
917 postMessage.call(this, {
918 type: "layout",
919 dot: "",
920 engine: 'dot',
921 vizURL: vizURL
922 }, function (event) {
923 switch (event.data.type) {
924 }
925 });
926 postMessage.call(this, {
927 type: "version"
928 }, function (event) {
929 switch (event.data.type) {
930 case "version":
931 graphvizInstance._graphvizVersion = event.data.version;
932 graphvizInstance._dispatch.call("initEnd", this);
933 break;
934 }
935 });
936 }
937 }

Callers

nothing calls this directly

Calls 4

loadMethod · 0.45
layoutMethod · 0.45
callMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected