
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
react-phylogeny-tree-gl
Advanced tools
React integration of phylocanvas.gl. Component and hook for phylogenetic tree visualistion.
React integration of phylocanvas.gl. Components (and hooks) for phylogenetic tree visualisation for Newick tree format.
It handles up to 100 000+ leaves.
yarn add react-phylogeny-tree-gl
PhylogenyTreeIt includes zoom buttons, context menu (adds context menu plugin to plugins array) and support redoUndo plugin with control buttons.
Props:
initProps: phylocanvas.gl properties used for initialisation. Should be ref. stable (eg. memoized), if changes phylocanvas instance is reinitialisedcontrolledProps: phylocanvas.gl properties, when change phylocanvas.gl tree.setProps method is called with new value. During initialisation props initProps and controlledProps are merged {...initProps, ...controlledProps}.plugins: array of phylocanvas.gl plugins, viz section Plugins bellow
hooks: array of hooks, viz section Hooks bellow. Should be ref stable.zoomButtons: boolean, when interactive (in initProps) and zoomButtons are true buttons for zoom appears.zoomButtonsStyle: CSSProperties object passed to zoom buttons container.ref reference which expose getTree function which returns phylocanvas.gl instance and allows us to perform imperative operations on it.There have to be source prop in either in initProps or controlledProps. The source type is:
type Newick = string;
type BiojsTree = {
children: BiojsTree[];
name: string | number;
branch_length: number;
};
type Source =
| Newick
| {
type: 'newick';
data: Newick;
original?: Source;
}
| {
type: 'biojs';
data: BiojsTree;
original?: Source;
};
For correct function of zoom buttons, context menu and redo-undo control buttons it is necessary.
import 'react-phylogeny-tree-gl/styles.css';
PhylogenyTreeWithoutMenuusePhylogenyTreeWithMenuused by PhylogenyTree component. Utilise usePhylogenyTree to instantiate phylocanvas.gl.
usePhylogenyTreeinstantiate phylocanvas.gl
phylocanvas.gl supported plugins of type:
export type Plugins<
P extends PhylocanvasInitProps,
M extends Record<string, (...args: unknown[]) => unknown>
> = ((tree: Phylocanvas<P, M>, decorate: Decorate<P, M>) => void)[];
export type Decorate<
P extends PhylocanvasInitProps = PhylocanvasInitProps,
M extends Record<string, (...args: unknown[]) => unknown> = Record<
string,
(...args: unknown[]) => unknown
>
> = <MethodName extends keyof (M & PhylocanvasMethods<P>)>(
fnName: MethodName,
fn: (
delegate: (M & PhylocanvasMethods<P>)[MethodName],
args: Parameters<(PhylocanvasMethods<P> & M)[MethodName]>
) => unknown
) => void;
scalebarShows scalebar at right corner
onClickHighlightOffspringscreateOnSelectPlugincreateOnViewSubtreePluginimport from react-phylogeny-tree.gl/hooks. Pass in array with stable reference between rerenders (memoize). Their type is:
type Hooks<P extends PhylocanvasProps, M> = ((
getTree: () => Phylocanvas<P, M> | null,
props: P & PhylocanvasProps
) => void)[];
useLeafSubtreereact hook which wraps setRootNLevelsUp. Needs to receive folowing object under key leafSubtree from props.
leafSubtree: {
leafID?: string;
noLevels?: number;
minLeafToRootLength?: number;
setLeafLabels?: (ids: (string | number)[]) => void;
};
useAutoResizereact hook for autoresizing canvas when window size changes.
import React from 'react';
import PhylogenyTree from 'react-phylogeny-tree-gl';
import { useLeafSubtree, useAutoResize } from 'react-phylogeny-tree-gl/hooks';
import {
createOnSelectPlugin,
createOnViewSubtreePlugin,
createOnRedrawReRootTreePlugin,
createRedoUndoPlugin,
onClickHighlightOffsprings,
scalebar,
} from 'react-phylogeny-tree-gl/plugins';
import { PhylogenyTreeRef, UndoRedoMethods } from 'react-phylogeny-tree-gl/types';
type TreeNodeColors = {
[id: string]: { fillColour: string } | null;
};
type TreeProps = {
newick: string;
leafColors: TreeNodeColors;
selectedLeafs: string[];
subtreeBaseLeaf: string | undefined;
rootId?: string;
noLevelsUp: number;
minBranchLength: number;
};
export type RefProps = {
source: string;
interactive: boolean;
nodeSize: number;
haloRadius: number;
haloWidth: number;
scalebar: boolean;
highlightColour: [number, number, number, number];
rootId: string;
selectedIds: string[];
styles: TreeNodeColors;
leafSubtree: {
leafID: string;
noLevels: number;
minLeafToRootLength: number;
};
};
export type TreeRef = PhylogenyTreeRef<RefProps, UndoRedoMethods>;
const hooks = [useAutoResize, useLeafSubtree];
export const Tree = React.forwardRef(TreeComponent);
function TreeComponent(
{
newick,
rootId,
leafColors,
selectedLeafs,
subtreeBaseLeaf,
noLevelsUp,
minBranchLength,
}: TreeProps,
ref?: React.RefObject<TreeRef>
): JSX.Element {
const showHelp = React.useContext(ShowHelpContext);
const initOptions = React.useMemo(
() => ({
source: newick,
rootId: null,
interactive: true,
nodeSize: 7,
haloRadius: 6,
haloWidth: 2,
scalebar: true,
highlightColour: tuple(52, 182, 199, 255),
}),
[newick]
);
const controlledOptions = React.useMemo(
() => ({
selectedIds: selectedLeafs,
styles: leafColors,
leafSubtree: {
leafID: subtreeBaseLeaf,
noLevels: noLevelsUp,
minLeafToRootLength: minBranchLength,
},
}),
[leafColors, minBranchLength, noLevelsUp, selectedLeafs, subtreeBaseLeaf]
);
const plugins = React.useMemo(() => {
return [
createRedoUndoPlugin(),
createOnSelectPlugin((_tree, selectedLeafLabels) => {
if (selectedLeafLabels && selectedLeafLabels.length) {
console.log(selectedLeafLabels)
}
}),
createOnViewSubtreePlugin((tree, leafsInTree) => {
console.log(leafsInTree)
}),
createOnRedrawReRootTreePlugin((tree, leafsInTree) => {
console.log(leafsInTree, tree.props.rootId, false);
}),
onClickHighlightOffsprings,
scalebar,
];
}, []);
React.useEffect(() => {
if (ref.current) {
const tree = ref.current.getTree();
if (tree.props.rootId !== rootId) {
tree.setRoot(rootId);
}
}
}, [rootId, ref]);
return (
<div style={position: 'relative'}>
<PhylogenyTree
ref={ref}
initProps={initOptions}
controlledProps={controlledOptions}
hooks={hooks}
plugins={plugins}
/>
</div>
);
}
const tuple = <T extends unknown[]>(...args: T): T => args;
FAQs
React integration of phylocanvas.gl. Component and hook for phylogenetic tree visualistion.
We found that react-phylogeny-tree-gl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.