Limit connection paint node indexes to inspected endpoints
This commit is contained in:
@@ -7,8 +7,12 @@ import {compatConnector} from './connectors.ts';
|
||||
/** Conservative cubic control hull + half stroke, in the displayed scene space.
|
||||
* Missing/custom geometry stays unknown so a host cannot interpret it as invisible. */
|
||||
function connectionPaint(projection:ReturnType<typeof projectCanvas>,registry:Registry,services:HitServices={},maxEdges=4096,maxSegments=4096,cache?:Map<string,{signature:unknown;segments:number;region?:PaintRegion}>){
|
||||
const regions:PaintRegion[]=[],unknown:string[]=[],nodes=new Map(projection.nodes.map(node=>[node.id,node]));
|
||||
if(![maxEdges,maxSegments].every(n=>Number.isSafeInteger(n)&&n>0&&n<=1000000))throw Error('invalid_paint_budget');
|
||||
const regions:PaintRegion[]=[],unknown:string[]=[],nodes=new Map<string,typeof projection.nodes[number]>(),endpoints=new Set<string>();
|
||||
// Only inspected edges need node entries. Preserve last-ID-wins behavior without
|
||||
// allocating an entry and pair array for every unrelated projected node.
|
||||
for(let i=0;i<Math.min(maxEdges,projection.edges.length);i++){const edge=projection.edges[i];endpoints.add(edge.source);endpoints.add(edge.target);}
|
||||
if(endpoints.size)for(const node of projection.nodes)if(endpoints.has(node.id))nodes.set(node.id,node);
|
||||
let remainingSegments=maxSegments,computed=0;
|
||||
for(let index=0;index<projection.edges.length;index++){
|
||||
if(index>=maxEdges){unknown.push('paint_budget');break;}const edge=projection.edges[index];
|
||||
|
||||
Reference in New Issue
Block a user