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

Function workerCodeBody

chapter24/docs/d3-graphviz.js:1798–1841  ·  view source on GitHub ↗
(port)

Source from the content-addressed store, hash-verified

1796 /* c8 ignore start */
1797
1798 function workerCodeBody(port) {
1799 self.document = {}; // Workaround for "ReferenceError: document is not defined" in hpccWasm
1800
1801 port.addEventListener('message', function (event) {
1802 var hpccWasm = self["@hpcc-js/wasm"];
1803 if (hpccWasm == undefined && event.data.vizURL) {
1804 importScripts(event.data.vizURL);
1805 hpccWasm = self["@hpcc-js/wasm"];
1806 // This is an alternative workaround where wasmFolder() is not needed
1807 // document = {currentScript: {src: event.data.vizURL}};
1808 }
1809 if (event.data.type == "version") {
1810 hpccWasm.Graphviz.load().then(function (graphviz) {
1811 port.postMessage({
1812 type: "version",
1813 version: graphviz.version()
1814 });
1815 });
1816 return;
1817 }
1818 hpccWasm.Graphviz.load().then(function (graphviz) {
1819 var svg = graphviz.layout(event.data.dot, "svg", event.data.engine, event.data.options);
1820 if (svg) {
1821 port.postMessage({
1822 type: "done",
1823 svg: svg
1824 });
1825 } else if (event.data.vizURL) {
1826 port.postMessage({
1827 type: "init"
1828 });
1829 } else {
1830 port.postMessage({
1831 type: "skip"
1832 });
1833 }
1834 })["catch"](function (error) {
1835 port.postMessage({
1836 type: "error",
1837 error: error.message
1838 });
1839 });
1840 });
1841 }
1842 function workerCode() {
1843 var port = self;
1844 workerCodeBody(port);

Callers 2

workerCodeFunction · 0.70
sharedWorkerCodeFunction · 0.70

Calls 3

loadMethod · 0.45
versionMethod · 0.45
layoutMethod · 0.45

Tested by

no test coverage detected