@naniteninja/profile-comparison-lib 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +167 -167
- package/fesm2022/naniteninja-profile-comparison-lib.mjs +1241 -48
- package/fesm2022/naniteninja-profile-comparison-lib.mjs.map +1 -1
- package/index.d.ts +103 -6
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, OnInit, AfterViewInit, OnChanges, EventEmitter, ElementRef, Renderer2, ChangeDetectorRef, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { InjectionToken, OnInit, AfterViewInit, OnChanges, OnDestroy, EventEmitter, ElementRef, Renderer2, ChangeDetectorRef, NgZone, SimpleChanges } from '@angular/core';
|
|
3
|
+
import { SimulationNodeDatum, SimulationLinkDatum } from 'd3-force';
|
|
3
4
|
import { Observable, BehaviorSubject } from 'rxjs';
|
|
4
5
|
import * as i2 from '@angular/common';
|
|
5
6
|
import * as i3 from '@angular/common/http';
|
|
@@ -10,7 +11,7 @@ import * as i4 from '@angular/forms';
|
|
|
10
11
|
declare enum BackendMode {
|
|
11
12
|
/** Use the real deployed backend (default). */
|
|
12
13
|
Real = 0,
|
|
13
|
-
/** Use a local mock server at localhost:
|
|
14
|
+
/** Use a local mock server at localhost:44101. */
|
|
14
15
|
Mock = 1
|
|
15
16
|
}
|
|
16
17
|
declare const BACKEND_MODE_URLS: Record<BackendMode, string>;
|
|
@@ -174,7 +175,7 @@ interface IEnvironment {
|
|
|
174
175
|
openaiApiKey: string;
|
|
175
176
|
apiFaceplusKey?: string;
|
|
176
177
|
apiFaceplusSecret?: string;
|
|
177
|
-
/** Base URL for local mock server (e.g. http://localhost:
|
|
178
|
+
/** Base URL for local mock server (e.g. http://localhost:44101/api). Used when backend mode is "mock". */
|
|
178
179
|
backendApiUrlMock?: string;
|
|
179
180
|
/** Base URL for real deployed backend (e.g. AWS). Used when backend mode is "real". */
|
|
180
181
|
backendApiUrlReal?: string;
|
|
@@ -403,12 +404,30 @@ declare class ProfileComparisonBackendService {
|
|
|
403
404
|
static ɵprov: i0.ɵɵInjectableDeclaration<ProfileComparisonBackendService>;
|
|
404
405
|
}
|
|
405
406
|
|
|
406
|
-
|
|
407
|
+
/** Node type for the force-directed chip layout. */
|
|
408
|
+
interface ForceChipNode extends SimulationNodeDatum {
|
|
409
|
+
id: string;
|
|
410
|
+
label: string;
|
|
411
|
+
group: 'p1' | 'shared' | 'p2';
|
|
412
|
+
targetX?: number;
|
|
413
|
+
targetY?: number;
|
|
414
|
+
originalFx?: number;
|
|
415
|
+
originalFy?: number;
|
|
416
|
+
}
|
|
417
|
+
interface ForceChipLink extends SimulationLinkDatum<ForceChipNode> {
|
|
418
|
+
kind: 'cross' | 'intra';
|
|
419
|
+
strength: number;
|
|
420
|
+
distance: number;
|
|
421
|
+
similarity: number;
|
|
422
|
+
}
|
|
423
|
+
declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy {
|
|
407
424
|
private backendService;
|
|
408
425
|
private renderer;
|
|
409
426
|
private fileConversionService;
|
|
410
427
|
private imageCompressionService;
|
|
411
428
|
private cdr;
|
|
429
|
+
private ngZone;
|
|
430
|
+
private hostRef;
|
|
412
431
|
private getVerboseLogging?;
|
|
413
432
|
private static readonly DEFAULT_OBJECT_POSITION;
|
|
414
433
|
private static readonly DEFAULT_EYE_ALIGNMENT_BIAS_PX;
|
|
@@ -486,6 +505,8 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
486
505
|
person3Interests: string[];
|
|
487
506
|
user1Image: string;
|
|
488
507
|
user2Image: string;
|
|
508
|
+
get user1ImageSrc(): string;
|
|
509
|
+
get user2ImageSrc(): string;
|
|
489
510
|
private baseConfig;
|
|
490
511
|
displayPerson1Interests: string[];
|
|
491
512
|
displayPerson2Interests: string[];
|
|
@@ -508,6 +529,33 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
508
529
|
similarity: number;
|
|
509
530
|
similarityMatrixCsv: string;
|
|
510
531
|
matrixData: IMatrixData | null;
|
|
532
|
+
private static readonly SPRING_THRESHOLD;
|
|
533
|
+
private static readonly CROSS_LINK_MIN_SIMILARITY;
|
|
534
|
+
private static readonly INTRA_GROUP_THRESHOLD;
|
|
535
|
+
private static readonly SHARED_PROMOTION_THRESHOLD;
|
|
536
|
+
private static readonly MAX_CROSS_LINKS_PER_NODE;
|
|
537
|
+
private static readonly MIN_CROSS_LINKS_PER_NODE;
|
|
538
|
+
private static readonly MAX_INTRA_LINKS_PER_NODE;
|
|
539
|
+
private static readonly MAX_RELEVANT_INTERESTS_PER_SIDE;
|
|
540
|
+
private static readonly CHIP_RADIUS;
|
|
541
|
+
private static readonly CHIP_COLLISION_BORDER_PADDING;
|
|
542
|
+
private static readonly MAX_LINK_DISTANCE;
|
|
543
|
+
private static readonly CANVAS_PADDING;
|
|
544
|
+
forceNodes: ForceChipNode[];
|
|
545
|
+
forceLinks: ForceChipLink[];
|
|
546
|
+
forceCanvasHeight: number;
|
|
547
|
+
chipFontSizePx: number;
|
|
548
|
+
chipPaddingXPx: number;
|
|
549
|
+
chipPaddingYPx: number;
|
|
550
|
+
chipLineHeight: number;
|
|
551
|
+
hoveredNode: ForceChipNode | null;
|
|
552
|
+
clickedNode: ForceChipNode | null;
|
|
553
|
+
draggedNode: ForceChipNode | null;
|
|
554
|
+
isDragging: boolean;
|
|
555
|
+
private simulation;
|
|
556
|
+
private layoutRebuildRaf;
|
|
557
|
+
private nodeDragBounds;
|
|
558
|
+
get activeNode(): ForceChipNode | null;
|
|
511
559
|
/** When false, backend URL is not provided — show "Configure backend". */
|
|
512
560
|
backendConfigured: boolean;
|
|
513
561
|
/** The resolved backend URL computed from inputs and legacy token. */
|
|
@@ -528,11 +576,13 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
528
576
|
shapeTextLeft: ElementRef<HTMLElement>;
|
|
529
577
|
shapeTextRight: ElementRef<HTMLElement>;
|
|
530
578
|
shapeTextCenter: ElementRef<HTMLElement>;
|
|
531
|
-
|
|
579
|
+
chipsGrid: ElementRef<HTMLElement>;
|
|
580
|
+
constructor(backendService: ProfileComparisonBackendService, renderer: Renderer2, fileConversionService: FileConversionService, imageCompressionService: ImageCompressionService, cdr: ChangeDetectorRef, ngZone: NgZone, hostRef: ElementRef<HTMLElement>, getVerboseLogging?: (() => boolean) | undefined);
|
|
532
581
|
private log;
|
|
533
582
|
anchorSide: 'left' | 'right';
|
|
534
583
|
rawLLMOutput: string;
|
|
535
584
|
ngOnInit(): void;
|
|
585
|
+
ngOnDestroy(): void;
|
|
536
586
|
ngAfterViewInit(): void;
|
|
537
587
|
ngOnChanges(changes: SimpleChanges): void;
|
|
538
588
|
/** Use for template: hide left/right item when it's a shared (center) item. Compares case-insensitively. */
|
|
@@ -547,7 +597,21 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
547
597
|
private setOverlapSizeCssPx;
|
|
548
598
|
waitForImagesAndInitDrag(): void;
|
|
549
599
|
initDrag(): void;
|
|
600
|
+
private normalizeSimilarityToken;
|
|
601
|
+
private findLegendEntry;
|
|
602
|
+
private lookupSimilarity;
|
|
550
603
|
private getSimilarity;
|
|
604
|
+
private orderBySemanticBarycenter;
|
|
605
|
+
private orderSharedBySemanticPull;
|
|
606
|
+
private canLinkNodes;
|
|
607
|
+
private getLinkNodeId;
|
|
608
|
+
private getLinkPairKey;
|
|
609
|
+
private selectLinksWithCaps;
|
|
610
|
+
private filterCenterItemsByThreshold;
|
|
611
|
+
private scheduleForceGraphRebuild;
|
|
612
|
+
onWindowResize(): void;
|
|
613
|
+
private buildForceGraph;
|
|
614
|
+
private selectTopSharedInterestsPerSide;
|
|
551
615
|
private reorderInterestsByMatrix;
|
|
552
616
|
onViewProfile(side: 'left' | 'right'): void;
|
|
553
617
|
getPerson1UniqueInterests(): string[];
|
|
@@ -576,7 +640,40 @@ declare class ProfileComparisonLibComponent implements OnInit, AfterViewInit, On
|
|
|
576
640
|
calculateFaceAlignment(user1Data: FaceDetectionData, user2Data: FaceDetectionData): void;
|
|
577
641
|
applyDefaultAlignment(): void;
|
|
578
642
|
isValidFaceData(face: IBoundingBox): boolean;
|
|
579
|
-
|
|
643
|
+
onNodeMouseEnter(node: ForceChipNode): void;
|
|
644
|
+
onNodeMouseLeave(node: ForceChipNode): void;
|
|
645
|
+
onNodeClick(node: ForceChipNode, event: MouseEvent): void;
|
|
646
|
+
onDocumentClick(): void;
|
|
647
|
+
/**
|
|
648
|
+
* Installs (or removes) a custom d3 force that pulls every linked node toward
|
|
649
|
+
* the anchor, stopping at an orbit radius scaled by similarity:
|
|
650
|
+
* highest-sim → MIN_ORBIT (touches anchor), lowest-sim → MAX_ORBIT.
|
|
651
|
+
*
|
|
652
|
+
* While active, the xTarget/yTarget restoring forces are muted so they don't
|
|
653
|
+
* fight the attraction. They are restored the moment attraction is cleared.
|
|
654
|
+
*/
|
|
655
|
+
private updateAttractionForce;
|
|
656
|
+
isNodeConnected(node: ForceChipNode): boolean;
|
|
657
|
+
isLinkConnectedToActive(link: any): boolean;
|
|
658
|
+
/**
|
|
659
|
+
* Returns true if the link connects a p1 node to a p2 node (a direct left↔right match),
|
|
660
|
+
* as opposed to a connection involving a shared-pool chip.
|
|
661
|
+
*/
|
|
662
|
+
isCrossGroupLink(link: any): boolean;
|
|
663
|
+
/**
|
|
664
|
+
* All force links sorted so secondary (shared-chip) links render first and
|
|
665
|
+
* primary (p1↔p2 direct match) links render last — SVG paints last-child on top.
|
|
666
|
+
*/
|
|
667
|
+
get sortedForceLinks(): any[];
|
|
668
|
+
getLinkSourceX(link: any): number;
|
|
669
|
+
getLinkSourceY(link: any): number;
|
|
670
|
+
getLinkTargetX(link: any): number;
|
|
671
|
+
getLinkTargetY(link: any): number;
|
|
672
|
+
private findNode;
|
|
673
|
+
onNodeDragStart(node: ForceChipNode, event: MouseEvent | TouchEvent): void;
|
|
674
|
+
onDocumentDragMove(event: MouseEvent | TouchEvent): void;
|
|
675
|
+
onDocumentDragEnd(): void;
|
|
676
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ProfileComparisonLibComponent, [null, null, null, null, null, null, null, { optional: true; }]>;
|
|
580
677
|
static ɵcmp: i0.ɵɵComponentDeclaration<ProfileComparisonLibComponent, "lib-profile-comparison", never, { "config": { "alias": "config"; "required": false; }; "user1File": { "alias": "user1File"; "required": false; }; "user2File": { "alias": "user2File"; "required": false; }; "backendMode": { "alias": "backendMode"; "required": false; }; "backendUrl": { "alias": "backendUrl"; "required": false; }; "fadeAllEdges": { "alias": "fadeAllEdges"; "required": false; }; "person1Name": { "alias": "person1Name"; "required": false; }; "person2Name": { "alias": "person2Name"; "required": false; }; "imageProxyPath": { "alias": "imageProxyPath"; "required": false; }; }, { "matrixDataChange": "matrixDataChange"; "rawLLMOutputChange": "rawLLMOutputChange"; "viewProfileClick": "viewProfileClick"; }, never, never, false, never>;
|
|
581
678
|
}
|
|
582
679
|
|