@neo4j-nvl/layout-workers
Advanced tools
Comparing version 0.2.48 to 0.2.49
export function createCoseBilkentLayoutWorker(): { | ||
onmessage: jest.Mock<any, any, any>; | ||
postMessage: jest.Mock<any, any, any>; | ||
terminate: jest.Mock<any, any, any>; | ||
port: { | ||
start: jest.Mock<any, any, any>; | ||
onmessage: jest.Mock<any, any, any>; | ||
postMessage: jest.Mock<any, any, any>; | ||
close: jest.Mock<any, any, any>; | ||
}; | ||
}; | ||
export function createHierarchicalLayoutWorker(): { | ||
onmessage: jest.Mock<any, any, any>; | ||
postMessage: jest.Mock<any, any, any>; | ||
terminate: jest.Mock<any, any, any>; | ||
port: { | ||
start: jest.Mock<any, any, any>; | ||
onmessage: jest.Mock<any, any, any>; | ||
postMessage: jest.Mock<any, any, any>; | ||
close: jest.Mock<any, any, any>; | ||
}; | ||
}; |
@@ -1,7 +0,10 @@ | ||
const workerMock = { | ||
onmessage: jest.fn(), | ||
postMessage: jest.fn(), | ||
terminate: jest.fn() | ||
const sharedWorkerMock = { | ||
port: { | ||
start: jest.fn(), | ||
onmessage: jest.fn(), | ||
postMessage: jest.fn(), | ||
close: jest.fn() | ||
} | ||
}; | ||
export const createCoseBilkentLayoutWorker = () => workerMock; | ||
export const createHierarchicalLayoutWorker = () => workerMock; | ||
export const createCoseBilkentLayoutWorker = () => sharedWorkerMock; | ||
export const createHierarchicalLayoutWorker = () => sharedWorkerMock; |
import { layout } from './cose-bilkent-layout-impl.js'; | ||
const onMessage = ({ data, target }) => { | ||
if (target.name === 'CoseBilkentLayout') { | ||
onconnect = ({ ports }) => { | ||
const port = ports[0]; | ||
port.onmessage = ({ data }) => { | ||
const { elements, spacingFactor } = data; | ||
const layoutData = layout(elements, spacingFactor); | ||
postMessage(layoutData); | ||
} | ||
port.postMessage(layoutData); | ||
}; | ||
}; | ||
self.addEventListener('message', onMessage); |
import { layout } from './dagre-layout-impl.js'; | ||
const onMessage = ({ data, target }) => { | ||
if (target.name === 'HierarchicalLayout') { | ||
onconnect = ({ ports }) => { | ||
const port = ports[0]; | ||
port.onmessage = ({ data }) => { | ||
const { nodes, nodeIds, idToPosition, rels, direction, packing, pixelRatio, forcedDelay = 0 } = data; | ||
@@ -8,10 +9,9 @@ const layoutData = layout(nodes, nodeIds, idToPosition, rels, direction, packing, pixelRatio); | ||
setTimeout(() => { | ||
postMessage(layoutData); | ||
port.postMessage(layoutData); | ||
}, forcedDelay); | ||
} | ||
else { | ||
postMessage(layoutData); | ||
port.postMessage(layoutData); | ||
} | ||
} | ||
}; | ||
}; | ||
self.addEventListener('message', onMessage); |
@@ -1,3 +0,3 @@ | ||
import { createCoseBilkentLayoutWorker } from './cosebilkent-layout/workerFactory.js'; | ||
import { createHierarchicalLayoutWorker } from './hierarchical-layout/workerFactory.js'; | ||
import { createCoseBilkentLayoutWorker } from './cosebilkent-layout/workerFactory.mjs'; | ||
import { createHierarchicalLayoutWorker } from './hierarchical-layout/workerFactory.mjs'; | ||
export { createCoseBilkentLayoutWorker, createHierarchicalLayoutWorker }; |
@@ -1,3 +0,3 @@ | ||
import { createCoseBilkentLayoutWorker } from './cosebilkent-layout/workerFactory.js'; | ||
import { createHierarchicalLayoutWorker } from './hierarchical-layout/workerFactory.js'; | ||
import { createCoseBilkentLayoutWorker } from './cosebilkent-layout/workerFactory.mjs'; | ||
import { createHierarchicalLayoutWorker } from './hierarchical-layout/workerFactory.mjs'; | ||
export { createCoseBilkentLayoutWorker, createHierarchicalLayoutWorker }; |
{ | ||
"name": "@neo4j-nvl/layout-workers", | ||
"version": "0.2.48", | ||
"version": "0.2.49", | ||
"license": "SEE LICENSE IN 'Neo4j Early Access Agreement - Visualization Library.pdf'", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
217634
540