@aiquants/contact-map 0.4.0 → 0.5.0

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/dist/client.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from "react";
2
2
  import { CSSProperties, ReactNode, RefObject, PointerEvent, MouseEvent } from "react";
3
3
  import { UseFuzzySearchOptions } from "@aiquants/fuzzy-search/react";
4
- import { C as ContactRecord, a as ContactMapStreamPhase, b as ContactMapSearchOutletContext, c as ContactMapOutletContext, d as ContactMapLogger, S as SerializedContactStreamRow } from "./wire-CFgYO13H.js";
4
+ import { C as ContactRecord, a as ContactMapStreamPhase, b as ContactMapSearchOutletContext, c as ContactMapOutletContext, d as ContactMapLogger, S as SerializedContactStreamRow } from "./wire-hAxBVVH6.js";
5
5
  import { DirectoryTreeLabels, DirectoryTreeVirtualScrollOptions } from "@aiquants/directory-tree";
6
6
  import * as _aiquants_virtualscroll from "@aiquants/virtualscroll";
7
7
  import { VirtualScrollLocale } from "@aiquants/virtualscroll";
@@ -93,6 +93,7 @@ type ContactMapOwnLabels = {
93
93
  readonly annotationStreamingProgress: (progress: ContactMapStreamProgress) => string;
94
94
  readonly annotationStreamingCount: (loaded: number) => string;
95
95
  readonly annotationLoadFailed: (loaded: number) => string;
96
+ readonly annotationAuthRequired: string;
96
97
  readonly annotationRetry: string;
97
98
  readonly recordUnit: (displayed: string) => string;
98
99
  readonly companyUnit: (displayed: string) => string;
@@ -375,7 +376,25 @@ type ContactMapLabelOverrides = {
375
376
  };
376
377
  declare const CONTACT_MAP_LABEL_KEYS: readonly (keyof ContactMapLabels)[];
377
378
  declare const CONTACT_MAP_LABEL_CATALOGS: Readonly<Record<ContactMapLocale, ContactMapLabels>>;
378
- declare const resolveContactMapLabels: (locale: ContactMapLocale | undefined, overrides: ContactMapLabelOverrides | undefined) => ContactMapLabels;
379
+ type ContactMapChromeSurface = {
380
+ readonly locale: string;
381
+ readonly labels: string;
382
+ };
383
+ declare const resolveContactMapLabels: (locale: ContactMapLocale | undefined, overrides: ContactMapLabelOverrides | undefined, surface?: ContactMapChromeSurface) => ContactMapLabels;
384
+ type ContactMapWorkerUrls = {
385
+ indexWorker?: string;
386
+ levenshteinWorker?: string;
387
+ treeWorker?: string;
388
+ };
389
+ type ContactMapWorkerUrlKey = keyof ContactMapWorkerUrls;
390
+ type ContactMapWorkerUrlsSurface = {
391
+ readonly setting: string;
392
+ readonly keys?: readonly ContactMapWorkerUrlKey[];
393
+ readonly hints?: Partial<Record<ContactMapWorkerUrlKey, string>>;
394
+ };
395
+ declare function assertContactMapWorkerUrls(workerUrls: unknown, surface?: ContactMapWorkerUrlsSurface): asserts workerUrls is ContactMapWorkerUrls | undefined;
396
+ declare function assertContactMapTreeWorkerUrl(treeWorkerUrl: unknown): asserts treeWorkerUrl is string | undefined;
397
+ declare const layerContactMapWorkerUrls: (provided: ContactMapWorkerUrls | undefined, own: ContactMapWorkerUrls | undefined, surface?: ContactMapWorkerUrlsSurface) => ContactMapWorkerUrls;
379
398
  interface ContactMapAppViewProps {
380
399
  renderHeader?: (props: {
381
400
  title: string;
@@ -385,11 +404,7 @@ interface ContactMapAppViewProps {
385
404
  locale?: ContactMapLocale;
386
405
  labels?: ContactMapLabelOverrides;
387
406
  streamEndpoint?: string;
388
- workerUrls?: {
389
- indexWorker?: string;
390
- levenshteinWorker?: string;
391
- treeWorker?: string;
392
- };
407
+ workerUrls?: ContactMapWorkerUrls;
393
408
  onFooterVisibilityChange?: (mode: "visible" | "mobile-hidden") => void;
394
409
  }
395
410
  declare const ContactMapAppView: (props: ContactMapAppViewProps) => react.JSX.Element;
@@ -419,14 +434,11 @@ declare const ContactMapSearchListView: ({ context }: ContactMapSearchListViewPr
419
434
  type ContactMapTab = "search" | "settings" | "statistics";
420
435
  interface ContactMapSearchPageProps {
421
436
  streamState?: ContactMapOutletContext;
422
- workerUrls?: {
423
- indexWorker?: string;
424
- levenshteinWorker?: string;
425
- };
437
+ workerUrls?: Pick<ContactMapWorkerUrls, "indexWorker" | "levenshteinWorker">;
426
438
  onFooterVisibilityChange?: (mode: "visible" | "mobile-hidden") => void;
427
439
  children?: (context: ContactMapSearchOutletContext) => ReactNode;
428
440
  }
429
- declare const ContactMapSearchPage: ({ streamState, workerUrls, onFooterVisibilityChange, children }?: ContactMapSearchPageProps) => react.JSX.Element;
441
+ declare const ContactMapSearchPage: ({ streamState, ...rest }?: ContactMapSearchPageProps) => react.JSX.Element;
430
442
  interface ContactMapSearchTabGroupProps {
431
443
  context: ContactMapSearchOutletContext;
432
444
  }
@@ -524,21 +536,13 @@ interface ContactMapConfig {
524
536
  streamEndpoint?: string;
525
537
  openEmailsWithGmail?: boolean;
526
538
  treeWorkerFactory?: () => Worker;
527
- workerUrls?: {
528
- indexWorker?: string;
529
- levenshteinWorker?: string;
530
- treeWorker?: string;
531
- };
532
- fuzzyWorkerUrls?: {
533
- indexWorkerUrl?: string;
534
- levenshteinWorkerUrl?: string;
535
- };
539
+ workerUrls?: ContactMapWorkerUrls;
536
540
  layoutSpec?: Partial<ResponsiveLayoutSpec>;
537
541
  locale?: ContactMapLocale;
538
542
  labels?: ContactMapLabelOverrides;
539
543
  }
540
544
  declare function ContactMapConfigProvider({ config, children }: {
541
- config?: ContactMapConfig;
545
+ config: ContactMapConfig;
542
546
  children: ReactNode;
543
547
  }): react.JSX.Element;
544
548
  declare function useContactMapConfig(): ContactMapConfig;
@@ -553,18 +557,19 @@ type ContactMapStreamState = {
553
557
  };
554
558
  type ContactMapStreamClientDeps = {
555
559
  fetchFn?: typeof fetch;
556
- endpoint?: string;
560
+ endpoint: string;
557
561
  initialRetryDelayMs?: number;
558
562
  maxRetryDelayMs?: number;
559
563
  maxConsecutiveFailures?: number;
560
564
  logger?: ContactMapLogger;
561
565
  };
566
+ declare function assertContactMapStreamEndpoint(endpoint: unknown): asserts endpoint is string;
562
567
  declare const deserializeStreamRecord: (row: SerializedContactStreamRow) => ContactRecord;
563
568
  declare class ContactMapStreamClient {
564
569
  private readonly recordMap;
565
570
  private readonly listeners;
566
571
  private readonly fetchFn;
567
- private readonly endpoint;
572
+ readonly endpoint: string;
568
573
  private readonly initialRetryDelayMs;
569
574
  private readonly maxRetryDelayMs;
570
575
  private readonly maxConsecutiveFailures;
@@ -576,12 +581,11 @@ declare class ContactMapStreamClient {
576
581
  private activeController;
577
582
  private wakeRetryWait;
578
583
  private state;
579
- constructor(deps?: ContactMapStreamClientDeps);
584
+ constructor(deps: ContactMapStreamClientDeps);
580
585
  getState(): ContactMapStreamState;
581
586
  getRecordMap(): ReadonlyMap<number, ContactRecord>;
582
587
  subscribe(listener: (state: ContactMapStreamState) => void): () => void;
583
588
  start(): void;
584
- retry(): void;
585
589
  retryNow(): void;
586
590
  dispose(): void;
587
591
  private readonly handleOnline;
@@ -593,11 +597,17 @@ declare class ContactMapStreamClient {
593
597
  private streamOnce;
594
598
  }
595
599
  declare const useAnimatedNumber: (targetValue: number, durationMs?: number) => number;
596
- declare const getContactMapStreamClient: (endpoint?: string) => ContactMapStreamClient;
600
+ type ContactMapStreamHandle = ContactMapStreamState & {
601
+ readonly recordMap: ReadonlyMap<number, ContactRecord>;
602
+ readonly retryNow: () => void;
603
+ };
604
+ declare const getContactMapStreamClient: (endpoint: string) => ContactMapStreamClient;
597
605
  declare const resetContactMapStreamClientForTesting: () => void;
598
- declare const getContactMapRecordMap: () => ReadonlyMap<number, ContactRecord>;
599
- declare function useContactMapStream(endpointOverride?: string): ContactMapStreamState & {
600
- retryNow: () => void;
606
+ declare function useContactMapStream(): ContactMapStreamHandle;
607
+ declare const countContactMapCompanies: (records: readonly ContactRecord[]) => number;
608
+ declare function useStreamedContactMapContext(): {
609
+ readonly context: ContactMapOutletContext;
610
+ readonly retryNow: () => void;
601
611
  };
602
612
  interface UseDynamicViewportHeightOptions {
603
613
  enableMutationObserver?: boolean;
@@ -656,6 +666,11 @@ interface TreeWorkerState {
656
666
  snapshot: TreeWorkerSnapshot | null;
657
667
  isBuilding: boolean;
658
668
  }
669
+ type TreeWorkerSource = "treeWorkerFactory" | "workerUrls.treeWorker";
670
+ interface TreeWorkerSessionOptions {
671
+ readonly workerSource: TreeWorkerSource;
672
+ readonly logger?: ContactMapLogger;
673
+ }
659
674
  declare class TreeWorkerSession {
660
675
  private worker;
661
676
  private generation;
@@ -666,12 +681,15 @@ declare class TreeWorkerSession {
666
681
  private postedNaming;
667
682
  private lastSyncedNaming;
668
683
  private consecutiveFailures;
669
- private finalizeRequested;
684
+ private finalizeRequest;
685
+ private finalizedPostedCount;
670
686
  private retryTimer;
671
687
  private readonly listeners;
672
688
  private readonly workerFactory;
689
+ private readonly workerSource;
690
+ private readonly logger;
673
691
  private state;
674
- constructor(workerFactory: () => Worker);
692
+ constructor(workerFactory: () => Worker, { workerSource, logger }: TreeWorkerSessionOptions);
675
693
  getState: () => TreeWorkerState;
676
694
  private updateState;
677
695
  subscribe: (listener: () => void) => (() => void);
@@ -681,11 +699,11 @@ declare class TreeWorkerSession {
681
699
  private readonly handleFailure;
682
700
  syncRecords(records: readonly ContactRecordForTree[], naming: ContactMapTreeNaming): void;
683
701
  finalize(): void;
684
- dispose(): void;
702
+ private cancelWorker;
703
+ stop(): void;
704
+ reset(): void;
685
705
  }
686
- declare const getTreeWorkerSession: (factory?: () => Worker, treeWorkerUrl?: string) => TreeWorkerSession;
687
- declare const syncTreeWorkerRecords: (records: readonly ContactRecordForTree[], naming: ContactMapTreeNaming) => void;
688
- declare const finalizeTreeWorker: () => void;
706
+ declare const getTreeWorkerSession: (treeWorkerUrl?: string) => TreeWorkerSession;
689
707
  declare const resetTreeWorkerSessionForTesting: () => void;
690
708
  declare function useTreeWorker(records: readonly ContactRecordForTree[], isComplete?: boolean): TreeWorkerState;
691
709
  declare const useContactMapLabels: () => ContactMapLabels;
@@ -709,4 +727,4 @@ declare const Tabs: react.ForwardRefExoticComponent<TabsPrimitive.TabsProps & re
709
727
  declare const TabsList: react.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
710
728
  declare const TabsTrigger: react.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & react.RefAttributes<HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
711
729
  declare const TabsContent: react.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & react.RefAttributes<HTMLDivElement>, "ref"> & react.RefAttributes<HTMLDivElement>>;
712
- export { AdvancedSearchSettings, type AdvancedSearchSettingsProps, BasicSearchSettings, type BasicSearchSettingsProps, CONTACT_MAP_LABEL_CATALOGS, CONTACT_MAP_LABEL_KEYS, ContactDetailGrid, type ContactDetailGridProps, type ContactDetailGridSkeletonProps, ContactDetailPanel, type ContactDetailPanelProps, ContactDetailPopup, type ContactDetailPopupProps, ContactDetailRowLayout, type ContactDetailRowLayoutProps, ContactMapAnnotation, type ContactMapAnnotationProps, ContactMapAppView, type ContactMapAppViewProps, type ContactMapConfig, ContactMapConfigProvider, type ContactMapHistoryEntry, type ContactMapLabelOverrides, type ContactMapLabels, type ContactMapLocale, type ContactMapOwnLabels, type ContactMapQueryLengthStat, ContactMapSearchListView, ContactMapSearchPage, type ContactMapSearchPageProps, ContactMapSearchTabGroup, type ContactMapSearchTabGroupProps, ContactMapSearchTreeView, type ContactMapSearchTreeViewProps, ContactMapStreamClient, type ContactMapStreamClientDeps, ContactMapStreamPhase, type ContactMapStreamProgress, type ContactMapStreamState, type ContactMapTab, HighlightedText, type HighlightedTextProps, type HorizontalDragScrollHandlers, IndexWorkerSettings, type IndexWorkerSettingsProps, LIST_COLLAPSE_THRESHOLD, LIST_DETAIL_PANEL_MIN_WIDTH, LIST_EXPAND_THRESHOLD, LIST_PANEL_MIN_WIDTH, LIST_RESIZE_HANDLE_THICKNESS, LevenshteinWorkerSettings, type LevenshteinWorkerSettingsProps, type PopupCloseOptions, Progress, type ProgressProps, SearchOptionsPanel, type SearchOptionsPanelProps, type SearchOptionsPanelTab, StatItem, type StatItemProps, StatisticsPanel, type StatisticsPanelProps, type StatisticsPanelTab, SwipeOverlay, type SwipeOverlayProps, TREE_COLLAPSE_THRESHOLD, TREE_DETAIL_PANEL_MIN_WIDTH, TREE_EXPAND_THRESHOLD, TREE_PANEL_MIN_WIDTH, TREE_RESIZE_HANDLE_THICKNESS, Tabs, TabsContent, TabsList, TabsTrigger, TreeWorkerSession, type TreeWorkerSnapshot, type TreeWorkerState, type UseDynamicViewportHeightOptions, type UseDynamicViewportHeightResult, type UseHorizontalDragScrollOptions, type UseLongPressPopupOptions, type UseLongPressPopupReturn, type UseResponsiveTwoColumnLayoutOptions, type UseResponsiveTwoColumnLayoutResult, type WorkerStatsKind, WorkerStatsSection, type WorkerStatsSectionProps, composeTreeVirtualScrollOptions, contactMapShouldRevalidate, deserializeStreamRecord, finalizeTreeWorker, getContactMapRecordMap, getContactMapStreamClient, getTreeWorkerSession, resetContactMapStreamClientForTesting, resetTreeWorkerSessionForTesting, resolveContactMapLabels, syncTreeWorkerRecords, useAnimatedNumber, useContactMapConfig, useContactMapLabels, useContactMapStream, useContactPanelSizing, useDynamicViewportHeight, useHorizontalDragScroll, useLongPressPopup, useReportPopupVisibility, useResponsiveTwoColumnLayout, useRowPopupRegistry, useTreeWorker };
730
+ export { AdvancedSearchSettings, type AdvancedSearchSettingsProps, BasicSearchSettings, type BasicSearchSettingsProps, CONTACT_MAP_LABEL_CATALOGS, CONTACT_MAP_LABEL_KEYS, ContactDetailGrid, type ContactDetailGridProps, type ContactDetailGridSkeletonProps, ContactDetailPanel, type ContactDetailPanelProps, ContactDetailPopup, type ContactDetailPopupProps, ContactDetailRowLayout, type ContactDetailRowLayoutProps, ContactMapAnnotation, type ContactMapAnnotationProps, ContactMapAppView, type ContactMapAppViewProps, type ContactMapChromeSurface, type ContactMapConfig, ContactMapConfigProvider, type ContactMapHistoryEntry, type ContactMapLabelOverrides, type ContactMapLabels, type ContactMapLocale, type ContactMapOwnLabels, type ContactMapQueryLengthStat, ContactMapSearchListView, ContactMapSearchPage, type ContactMapSearchPageProps, ContactMapSearchTabGroup, type ContactMapSearchTabGroupProps, ContactMapSearchTreeView, type ContactMapSearchTreeViewProps, ContactMapStreamClient, type ContactMapStreamClientDeps, type ContactMapStreamHandle, ContactMapStreamPhase, type ContactMapStreamProgress, type ContactMapStreamState, type ContactMapTab, type ContactMapWorkerUrlKey, type ContactMapWorkerUrls, type ContactMapWorkerUrlsSurface, HighlightedText, type HighlightedTextProps, type HorizontalDragScrollHandlers, IndexWorkerSettings, type IndexWorkerSettingsProps, LIST_COLLAPSE_THRESHOLD, LIST_DETAIL_PANEL_MIN_WIDTH, LIST_EXPAND_THRESHOLD, LIST_PANEL_MIN_WIDTH, LIST_RESIZE_HANDLE_THICKNESS, LevenshteinWorkerSettings, type LevenshteinWorkerSettingsProps, type PopupCloseOptions, Progress, type ProgressProps, SearchOptionsPanel, type SearchOptionsPanelProps, type SearchOptionsPanelTab, StatItem, type StatItemProps, StatisticsPanel, type StatisticsPanelProps, type StatisticsPanelTab, SwipeOverlay, type SwipeOverlayProps, TREE_COLLAPSE_THRESHOLD, TREE_DETAIL_PANEL_MIN_WIDTH, TREE_EXPAND_THRESHOLD, TREE_PANEL_MIN_WIDTH, TREE_RESIZE_HANDLE_THICKNESS, Tabs, TabsContent, TabsList, TabsTrigger, TreeWorkerSession, type TreeWorkerSessionOptions, type TreeWorkerSnapshot, type TreeWorkerSource, type TreeWorkerState, type UseDynamicViewportHeightOptions, type UseDynamicViewportHeightResult, type UseHorizontalDragScrollOptions, type UseLongPressPopupOptions, type UseLongPressPopupReturn, type UseResponsiveTwoColumnLayoutOptions, type UseResponsiveTwoColumnLayoutResult, type WorkerStatsKind, WorkerStatsSection, type WorkerStatsSectionProps, assertContactMapStreamEndpoint, assertContactMapTreeWorkerUrl, assertContactMapWorkerUrls, composeTreeVirtualScrollOptions, contactMapShouldRevalidate, countContactMapCompanies, deserializeStreamRecord, getContactMapStreamClient, getTreeWorkerSession, layerContactMapWorkerUrls, resetContactMapStreamClientForTesting, resetTreeWorkerSessionForTesting, resolveContactMapLabels, useAnimatedNumber, useContactMapConfig, useContactMapLabels, useContactMapStream, useContactPanelSizing, useDynamicViewportHeight, useHorizontalDragScroll, useLongPressPopup, useReportPopupVisibility, useResponsiveTwoColumnLayout, useRowPopupRegistry, useStreamedContactMapContext, useTreeWorker };