// npm package
@antv/graphlib
<h1 align="center"> <b>@antv/graphlib</b> </h1>
versions
13
maintainers
51
license
MIT
first publish
2022-03-09
publisher
iaaron
tarball
293,850 B
AUTO-PUBLISHED·1 version indexed·latest published 2024-11-27
// publisher campaignby iaaron
9 caught packages from this accountThis is not an isolated catch. The same publisher has shipped 8 other packages that our pipeline flagged — the shape of a coordinated campaign, not a one-off. Each link below opens that sibling's analysis.
// offending code· @2.0.4· 1 file flagged
llm: benign · 0.85→ No suspicious destination, no remote-exec shape — 1 known-vendor host(s).
- @2.0.4··AUTO-PUBLISHED·publisher: iaaronheuristic 75/100static flags 1llm benign (0.85) via ollamamature-packageosv-flagged:MAL-2026-4026public-github-push
→ No suspicious destination, no remote-exec shape — 1 known-vendor host(s).
// offending code· 1 file flaggedpatterns: 1
--- install scripts --- ### prepublishOnly npm run build --- package/package.json (excerpt) --- { "name": "@antv/graphlib", "version": "2.0.4", "main": "lib/index.js", "module": "esm/index.js", "types": "lib/index.d.ts", "unpkg": "dist/index.umd.min.js", "sideEffects": false, "files": [ "lib", "esm", "dist", "src", "README.md", "LICENSE" ], "scripts": { "clean": "rimraf lib esm dist", "doc": "typedoc src/index.ts --plugin typedoc-plugin-markdown", "lint-staged": "lint-staged", "lint": "eslint ./src ./__tests__ && prettier ./src ./__tests__ --check ", "fix": "eslint ./src ./__tests__ --fix && prettier ./src ./__tests__ --write ", "size": "limit-size", "test": "jest --coverage -i", "build:umd": "rimraf ./dist && rollup -c && npm run size", "build:cjs": "rimraf ./lib && tsc --module commonjs --outDir lib", "build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm", "build": "run-p build:*", "bundle-vis": "cross-env BUNDLE_VIS=1 run-p build:umd", "prepublishOnly": "npm run build" }, "dependencies": { "@antv/event-emitter": "^0.1.3" }, "devDependencies": { "@commitlint/cli": "^11.0.0", "@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-terser": "^0.4.4", "@types/jest": "^29.5.14", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "cross-env": "^7.0.3", "eslint": "^8.57.1", "eslint-plugin-import": "^2.31.0", "husky": "^8.0.3", "jest": "^ --- bundled output (OSV-MAL flagged — LLM scope expansion) --- --- dist/graph.d.ts (bundled) --- import EventEmitter from '@antv/event-emitter'; import { GraphView } from './graphView'; import { Node, Edge, GraphChange, GraphChangedEvent, GraphOptions, ID, TreeData, PlainObject, GraphViewOptions } from './types'; export declare class Graph<N extends PlainObject, E extends PlainObject> extends EventEmitter { private nodeMap; private edgeMap; private inEdgesMap; private outEdgesMap; private bothEdgesMap; private treeIndices; private changes; private batchCount; /** * This function is called with a {@link GraphChangedEvent} each time a graph change happened. * * `event.changes` contains all the graph changes in order since last `onChanged`. */ onChanged: (event: GraphChangedEvent<N, E>) => void; /** * Create a new Graph instance. * @param options - The options to initialize a graph. See {@link GraphOptions}. * * ```ts * const graph = new Graph({ * // Optional, initial nodes. * nodes: [ * // Each node has a unique ID. * { id: 'A', foo: 1 }, * { id: 'B', foo: 1 }, * ], * // Optional, initial edges. * edges: [ * { id: 'C', source: 'B', target: 'B', weight: 1 }, * ], * // Optional, called with a GraphChangedEvent. * onChanged: (event) => { * console.log(event); * } * }); * ``` */ constructor(options?: GraphOptions<N, E>); /** * Batch several graph changes into one. * * Make several changes, but dispatch only one ChangedEvent at the end of batch: * ```ts * graph.batch(() => { * graph.addNodes([]); * graph.addEdges([]); * }); * ``` * * Batches can be nested. Only the outermost batch will dispatch a ChangedEvent: * ```ts * graph.batch(() => { * graph.addNodes([]); * graph.batch(() => { * graph.addEdges([]); --- dist/graphView.d.ts (bundled) --- import { Edge, GraphViewOptions, ID, Node, PlainObject } from './types'; export declare class GraphView<N extends PlainObject, E extends PlainObject> { private graph; private nodeFilter; private edgeFilter; cacheEnabled: boolean; private inEdgesMap; private outEdgesMap; private bothEdgesMap; private allNodesMap; private allEdgesMap; constructor(options: GraphViewOptions<N, E>); /** * Clear all cache data. Therefore `getAllNodes()` will return `[]`. * If you want to disable caching, use `graphView.cacheEnabled = false` instead. */ clearCache: () => void; /** * Fully refresh all cache data to the current graph state. */ refreshCache: () => void; /** * Instead of a fully refreshment, this method partially update the cache data by specifying * involved(added, removed, updated) nodes. It's more efficient when handling small changes * on a large graph. */ updateCache: (involvedNodeIds: Set<ID> | Array<ID>) => void; startAutoCache(): void; stopAutoCache(): void; private handleGraphChanged; private checkNodeExistence; hasNode(id: ID): boolean; areNeighbors(firstNodeId: ID, secondNodeId: ID): boolean; getNode(id: ID): Node<N>; getRelatedEdges(id: ID, direction?: 'in' | 'out' | 'both'): Edge<E>[]; getDegree(id: ID, direction?: 'in' | 'out' | 'both'): number; getSuccessors(id: ID): Node<N>[]; getPredecessors(id: ID): Node<N>[]; getNeighbors(id: ID): Node<N>[]; hasEdge(id: ID): boolean; getEdge(id: ID): Edge<E>; getEdgeDetail(id: ID): { edge: Edge<E>; source: Node<N>; target: Node<N>; }; hasTreeStructure(treeKey: string | undefined): boolean; getRoots(treeKey?: string): Node<N>[]; getChildren(id: ID, treeKey?: string): Node<N>[]; getParent(id: ID, treeKey?: string): Node<N> | null; getAllNodes(): Node<N>[]; get --- dist/index.d.ts (bundled) --- export * from './types'; export * from './graph'; export * from './graphView'; --- dist/index.umd.min.js (bundled) --- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GraphLib={})}(this,(function(e){"use strict";var t=function(){function e(){this._events={}}return e.prototype.on=function(e,t,s){return this._events[e]||(this._events[e]=[]),this._events[e].push({callback:t,once:!!s}),this},e.prototype.once=function(e,t){return this.on(e,t,!0)},e.prototype.emit=function(e){for(var t=this,s=[],d=1;d<arguments.length;d++)s[d-1]=arguments[d];var r=this._events[e]||[],a=this._events["*"]||[],h=function(d){for(var r=d.length,a=0;a<r;a++)if(d[a]){var h=d[a],i=h.callback;h.once&&(d.splice(a,1),0===d.length&&delete t._events[e],r--,a--),i.apply(t,s)}};h(r),h(a)},e.prototype.off=function(e,t){if(e)if(t){for(var s=this._events[e]||[],d=s.length,r=0;r<d;r++)s[r].callback===t&&(s.splice(r,1),d--,r--);0===s.length&&delete this._events[e]}else delete this._events[e];else this._events={};return this},e.prototype.getEvents=function(){return this._events},e}();function s(e,t,s,d){for(;e.length;){const r=e.shift();if(s(r))return!0;t.add(r.id),d(r.id).forEach((s=>{t.has(s.id)||(t.add(s.id),e.push(s))}))}return!1}function d(e,t,s,r){if(s(e))return!0;t.add(e.id);for(const a of r(e.id))if(!t.has(a.id)&&d(a,t,s,r))return!0;return!1}const r=()=>!0;class a{graph;nodeFilter;edgeFilter;cacheEnabled;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;allNodesMap=new Map;allEdgesMap=new Map;constructor(e){this.graph=e.graph;const t=e.nodeFilter||r,s=e.edgeFilter||r;this.nodeFilter=t,this.edgeFilter=e=>{const{source:d,target:r}=this.graph.getEdgeDetail(e.id);return!(!t(d)||!t(r))&&s(e,d,r)},"auto"===e.cache?(this.cacheEnabled=!0,this.startAutoCache()):"manual"===e.cache?this.cacheEnabled=!0:this.cacheEnabled=!1}clearCache=()=>{this.inEdgesMap.clear(),this.outEdgesMap.clear(),this.bothEdgesMap.clear(),this.allNodesMap.clear(),this.allEdgesMap.clear()};refreshCache --- dist/types.d.ts (bundled) --- import type { Graph } from './graph'; /** * Supported node/edge ID type. * * "1" and 1 are treated as different IDs. */ export type ID = string | number; export type PlainObject = Record<string, unknown>; export interface Node<D extends PlainObject> { /** * Every node in a graph must have a unique ID. */ id: ID; /** * Node data should be an object with string key and any value. */ data: D; } export interface Edge<D extends PlainObject> { /** * Every edge in a graph must have a unique ID. */ id: ID; /** * The ID of the starting node of the edge. */ source: ID; /** * The ID of the ending node of the edge. */ target: ID; /** * Edge data should be an object with string key and any value. */ data: D; } /** * TreeData is a nested data structure that contains nodes represent a tree. */ export interface TreeData<D> { /** * Tree node IDs must be unique within the whole graph, not only the current tree. */ id: ID; /** * An object with string key and any value. */ data: D; /** * Children nodes. Each node itself is a TreeData object, allowing for an arbitrary depth of nesting. */ children?: TreeData<D>[]; } /** Options to create a graph. */ export interface GraphOptions<N extends PlainObject, E extends PlainObject> { /** * An array of node data representing the initial nodes. * * Each node must have a unique ID. * * @example * [ * { id: 1, color: 'red' }, * { id: 2, color: 'blue' }, * ] */ nodes?: Node<N>[]; /** * An ar
