@semiont/react-ui 0.2.35-build.95 → 0.2.35-build.97

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/index.d.mts CHANGED
@@ -11,23 +11,20 @@ import { SemiontApiClient, ValidationResult } from '@semiont/api-client';
11
11
  import * as _codemirror_state from '@codemirror/state';
12
12
  import { HighlightStyle } from '@codemirror/language';
13
13
  import { WidgetType } from '@codemirror/view';
14
- import { Root } from 'hast';
15
- import { Root as Root$1 } from 'mdast';
16
- import { VFile } from 'vfile';
17
14
  import { TagSchema } from '@semiont/ontology';
18
15
  export { TAG_SCHEMAS, TagCategory, TagSchema, getAllTagSchemas, getSchemaCategory as getTagCategory, getTagSchema, getTagSchemasByDomain, isValidCategory } from '@semiont/ontology';
19
16
 
20
- type Annotation$m = components['schemas']['Annotation'];
17
+ type Annotation$n = components['schemas']['Annotation'];
21
18
  /**
22
19
  * Collection of all annotation types for a resource.
23
20
  * Replaces separate highlights, references, assessments, comments, tags props.
24
21
  */
25
22
  interface AnnotationsCollection {
26
- highlights: Annotation$m[];
27
- references: Annotation$m[];
28
- assessments: Annotation$m[];
29
- comments: Annotation$m[];
30
- tags: Annotation$m[];
23
+ highlights: Annotation$n[];
24
+ references: Annotation$n[];
25
+ assessments: Annotation$n[];
26
+ comments: Annotation$n[];
27
+ tags: Annotation$n[];
31
28
  }
32
29
  /**
33
30
  * Event handlers for annotation interactions.
@@ -35,7 +32,7 @@ interface AnnotationsCollection {
35
32
  */
36
33
  interface AnnotationHandlers {
37
34
  /** Unified click handler - routes based on annotation type and current mode */
38
- onClick?: (annotation: Annotation$m, event?: React.MouseEvent) => void;
35
+ onClick?: (annotation: Annotation$n, event?: React.MouseEvent) => void;
39
36
  /** Unified hover handler for all annotation types */
40
37
  onHover?: (annotationId: string | null) => void;
41
38
  /** Hover handler specifically for comment panel highlighting */
@@ -84,7 +81,7 @@ interface UICreateAnnotationParams {
84
81
  * - linking: Shows Quick Reference popup FIRST, creates when user confirms
85
82
  */
86
83
  interface AnnotationCreationHandler {
87
- onCreate?: (params: UICreateAnnotationParams) => void | Promise<void> | Promise<Annotation$m | undefined>;
84
+ onCreate?: (params: UICreateAnnotationParams) => void | Promise<void> | Promise<Annotation$n | undefined>;
88
85
  }
89
86
  /**
90
87
  * UI state for annotation toolbar and interactions.
@@ -119,7 +116,7 @@ interface AnnotationConfig {
119
116
  annotateMode?: boolean;
120
117
  }
121
118
 
122
- type Annotation$l = components['schemas']['Annotation'];
119
+ type Annotation$m = components['schemas']['Annotation'];
123
120
  /**
124
121
  * Parameters for creating an annotation
125
122
  */
@@ -166,7 +163,7 @@ interface AnnotationManager {
166
163
  * @param params - Creation parameters (rUri, motivation, selector, body)
167
164
  * @returns Promise resolving to the created annotation, or undefined if creation fails
168
165
  */
169
- createAnnotation: (params: CreateAnnotationParams) => Promise<Annotation$l | undefined>;
166
+ createAnnotation: (params: CreateAnnotationParams) => Promise<Annotation$m | undefined>;
170
167
  /**
171
168
  * Delete an annotation
172
169
  * @param params - Deletion parameters (annotationId, rUri)
@@ -270,7 +267,7 @@ interface NavigationProps {
270
267
  */
271
268
 
272
269
  type SemiontResource$4 = components['schemas']['ResourceDescriptor'];
273
- type Annotation$k = components['schemas']['Annotation'];
270
+ type Annotation$l = components['schemas']['Annotation'];
274
271
  type Motivation$8 = components['schemas']['Motivation'];
275
272
  /**
276
273
  * Selection for creating annotations
@@ -298,7 +295,7 @@ interface TextSelection {
298
295
  * No aliasing, wrappers, or compatibility layers elsewhere.
299
296
  */
300
297
 
301
- type Annotation$j = components['schemas']['Annotation'];
298
+ type Annotation$k = components['schemas']['Annotation'];
302
299
  type Motivation$7 = components['schemas']['Motivation'];
303
300
  /**
304
301
  * Detection configuration for SSE-based annotation detection
@@ -335,7 +332,7 @@ interface Annotator {
335
332
  isClickable: boolean;
336
333
  hasHoverInteraction: boolean;
337
334
  hasSidePanel: boolean;
338
- matchesAnnotation: (annotation: Annotation$j) => boolean;
335
+ matchesAnnotation: (annotation: Annotation$k) => boolean;
339
336
  announceOnCreate: string;
340
337
  detection?: DetectionConfig;
341
338
  create: CreateConfig;
@@ -794,17 +791,17 @@ declare const jsonLightHighlightStyle: HighlightStyle;
794
791
  * - Entity type badges
795
792
  */
796
793
 
797
- type Annotation$i = components['schemas']['Annotation'];
794
+ type Annotation$j = components['schemas']['Annotation'];
798
795
  /**
799
796
  * Reference Resolution Widget
800
797
  * Shows a small indicator next to references with hover preview
801
798
  */
802
799
  declare class ReferenceResolutionWidget extends WidgetType {
803
- readonly annotation: Annotation$i;
800
+ readonly annotation: Annotation$j;
804
801
  readonly targetDocumentName?: string | undefined;
805
802
  readonly eventBus?: EventBus | undefined;
806
803
  readonly isGenerating?: boolean | undefined;
807
- constructor(annotation: Annotation$i, targetDocumentName?: string | undefined, eventBus?: EventBus | undefined, isGenerating?: boolean | undefined);
804
+ constructor(annotation: Annotation$j, targetDocumentName?: string | undefined, eventBus?: EventBus | undefined, isGenerating?: boolean | undefined);
808
805
  eq(other: ReferenceResolutionWidget): boolean;
809
806
  toDOM(): HTMLSpanElement;
810
807
  private showPreview;
@@ -936,14 +933,22 @@ declare const QUERY_KEYS: {
936
933
  };
937
934
  };
938
935
 
939
- declare function rehypeRenderAnnotations(): (tree: Root, file: any) => void;
940
-
941
936
  /**
942
- * Simplified annotation format for remark plugin.
943
- * This is NOT the W3C Annotation - it's a pre-processed format with offset/length
944
- * for efficient markdown text processing.
937
+ * Annotation overlay: decouples annotation highlighting from markdown rendering.
938
+ *
939
+ * Instead of weaving annotations into the markdown AST via remark/rehype plugins
940
+ * (which forces O(ASTnodes × annotations) work on every render), this module:
941
+ *
942
+ * 1. Builds a source→rendered offset map once after the markdown DOM paints
943
+ * 2. Resolves W3C TextPositionSelector offsets to DOM Ranges via binary search
944
+ * 3. Wraps matched ranges with <span> elements carrying data-annotation-* attributes
945
+ *
946
+ * Markdown renders once (cached by React.memo). Annotation changes only touch
947
+ * the overlay spans — no markdown re-parse, no AST walk.
945
948
  */
946
- interface PreparedAnnotation {
949
+
950
+ type Annotation$i = components['schemas']['Annotation'];
951
+ interface OverlayAnnotation {
947
952
  id: string;
948
953
  exact: string;
949
954
  offset: number;
@@ -951,10 +956,53 @@ interface PreparedAnnotation {
951
956
  type: string;
952
957
  source: string | null;
953
958
  }
954
- interface RemarkAnnotationsOptions {
955
- annotations: PreparedAnnotation[];
959
+ interface TextNodeEntry {
960
+ node: Text;
961
+ start: number;
962
+ end: number;
956
963
  }
957
- declare function remarkAnnotations(options: RemarkAnnotationsOptions): (tree: Root$1, _file: VFile) => void;
964
+ /**
965
+ * Build a map from markdown source offsets to rendered text offsets.
966
+ * Character-by-character alignment: walks source and rendered text in parallel,
967
+ * matching characters and skipping markdown syntax in the source.
968
+ *
969
+ * Complexity: O(sourceLength) — runs once per content change.
970
+ */
971
+ declare function buildSourceToRenderedMap(markdownSource: string, container: HTMLElement): Map<number, number>;
972
+ /**
973
+ * Build a sorted array of text nodes with cumulative rendered offsets
974
+ * for efficient offset→node lookups via binary search.
975
+ *
976
+ * Complexity: O(textNodes) — runs once per overlay application.
977
+ */
978
+ declare function buildTextNodeIndex(container: HTMLElement): TextNodeEntry[];
979
+ /**
980
+ * Resolve annotations to DOM Ranges using the cached offset map.
981
+ *
982
+ * Complexity: O(annotations × log(textNodes)).
983
+ */
984
+ declare function resolveAnnotationRanges(annotations: OverlayAnnotation[], offsetMap: Map<number, number>, textNodeIndex: TextNodeEntry[]): Map<string, {
985
+ range: Range;
986
+ annotation: OverlayAnnotation;
987
+ }>;
988
+ /**
989
+ * Wrap annotation Ranges with styled <span> elements.
990
+ * Handles cross-element ranges by splitting into per-text-node segments.
991
+ */
992
+ declare function applyHighlights(ranges: Map<string, {
993
+ range: Range;
994
+ annotation: OverlayAnnotation;
995
+ }>): void;
996
+ /**
997
+ * Remove all annotation highlight spans, restoring the original DOM.
998
+ * Unwraps spans and merges adjacent text nodes.
999
+ */
1000
+ declare function clearHighlights(container: HTMLElement): void;
1001
+ /**
1002
+ * Convert W3C Annotations to the simplified overlay format.
1003
+ * Extracts TextPositionSelector offsets and annotation type.
1004
+ */
1005
+ declare function toOverlayAnnotations(annotations: Annotation$i[]): OverlayAnnotation[];
958
1006
 
959
1007
  /**
960
1008
  * Resource utilities
@@ -2008,7 +2056,11 @@ interface Props$6 {
2008
2056
  hoverDelayMs?: number;
2009
2057
  }
2010
2058
  /**
2011
- * View component for browsing annotated resources in read-only mode
2059
+ * View component for browsing annotated resources in read-only mode.
2060
+ *
2061
+ * Two-layer rendering:
2062
+ * - Layer 1: Markdown renders once (MemoizedMarkdown, cached by content)
2063
+ * - Layer 2: Annotation overlay applied via DOM Range API after paint
2012
2064
  *
2013
2065
  * @emits attend:click - User clicked on annotation. Payload: { annotationId: string, motivation: Motivation }
2014
2066
  * @emits attend:hover - User hovered over annotation. Payload: { annotationId: string | null }
@@ -2016,7 +2068,7 @@ interface Props$6 {
2016
2068
  * @subscribes attend:hover - Highlight annotation on hover. Payload: { annotationId: string | null }
2017
2069
  * @subscribes attend:focus - Scroll to and highlight annotation. Payload: { annotationId: string }
2018
2070
  */
2019
- declare function BrowseView({ content, mimeType, resourceUri, annotations, selectedClick, annotateMode, hoverDelayMs }: Props$6): react_jsx_runtime.JSX.Element;
2071
+ declare const BrowseView: React$1.NamedExoticComponent<Props$6>;
2020
2072
 
2021
2073
  type TranslateFn$4 = (key: string, params?: Record<string, string | number>) => string;
2022
2074
  interface Props$5 {
@@ -3893,4 +3945,4 @@ interface ResolutionFlowState {
3893
3945
  */
3894
3946
  declare function useResolutionFlow(rUri: ResourceUri): ResolutionFlowState;
3895
3947
 
3896
- export { ANNOTATORS, AUTH_EVENTS, AVAILABLE_LOCALES, AdminDevOpsPage, type AdminDevOpsPageProps, AdminSecurityPage, type AdminSecurityPageProps, type AdminUser, type AdminUserStats, AdminUsersPage, type AdminUsersPageProps, AnnotateReferencesProgressWidget, AnnotateToolbar, AnnotateView, type Annotation$k as Annotation, type AnnotationConfig, type AnnotationCreationHandler, type AnnotationFlowState, type AnnotationHandlers, AnnotationHistory, type AnnotationManager, AnnotationOverlay, AnnotationProvider, type AnnotationProviderProps, type AnnotationUIState, type AnnotationsCollection, type Annotator, ApiClientProvider, type ApiClientProviderProps, AssessmentEntry, AssessmentPanel, AssistSection, AsyncErrorBoundary, type AttentionFlowState, AuthErrorDisplay, type AuthErrorDisplayProps, type AuthEventDetail, type AuthEventType, AuthTokenProvider, type AuthTokenProviderProps, type AvailableLocale, type BorderRadiusToken, BrowseView, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type CacheManager, CacheProvider, type CacheProviderProps, type ClickAction, CodeMirrorRenderer, CollaborationPanel, CollapsibleResourceNavigation, type CollapsibleResourceNavigationProps, type ColorToken, CommentEntry, CommentsPanel, ComposeLoadingState, type ComposeLoadingStateProps, type ContextCorrelationFlowConfig, type ContextCorrelationFlowState, type CreateAnnotationParams, type CreateConfig, type DeleteAnnotationParams, type DetectionConfig, type DevOpsFeature, type DrawingMode, EntityTagsPage, type EntityTagsPageProps, EntityTypeBadges, ErrorBoundary, Footer, type GenerationFlowState, type GenerationOptions, HOVER_DELAY_MS, HighlightEntry, HighlightPanel, HistoryEvent, type HoverEmitterProps, type HoverHandlers, ImageURLSchema, ImageViewer, JsonLdPanel, JsonLdView, type KeyboardShortcut, KeyboardShortcutsHelpModal, LeftSidebar, type LinkComponentProps, LiveRegionProvider, type Motivation$8 as Motivation, type NavigationItem, NavigationMenu, type NavigationMenuHelper, type NavigationProps, type OAuthProvider, type OAuthUser, OAuthUserSchema, ObservableLink, type ObservableLinkProps, type OpenResource, OpenResourcesManager, OpenResourcesProvider, PageLayout, PanelHeader, type PanelNavigationState, PopupContainer, PopupHeader, type PreparedAnnotation, ProposeEntitiesModal, QUERY_KEYS, RecentDocumentsPage, type RecentDocumentsPageProps, ReferenceEntry, ReferenceResolutionWidget, ReferencesPanel, ResizeHandle, type ResolutionFlowState, type ResolvedTheme, ResourceAnnotationsProvider, ResourceCard, type ResourceCardProps, ResourceComposePage, type ResourceComposePageProps, ResourceDiscoveryPage, type ResourceDiscoveryPageProps, ResourceErrorState, type ResourceErrorStateProps, ResourceInfoPanel, ResourceLoadingState, ResourceSearchModal, type ResourceSearchModalProps, ResourceTagsInline, ResourceViewer, ResourceViewerPage, type ResourceViewerPageProps, type RouteBuilder, type SaveResourceParams, SearchModal, type SearchModalProps, SelectedTextDisplay, type SelectionMotivation, type SelectorType, SemiontBranding, SemiontFavicon, type SemiontResource$4 as SemiontResource, SessionExpiryBanner, SessionManager, SessionProvider, SessionTimer, SettingsPanel, type ShadowToken, type ShapeType, SignInForm, type SignInFormProps, SignUpForm, type SignUpFormProps, SimpleNavigation, type SimpleNavigationItem, type SimpleNavigationProps, SkipLinks, SortableResourceTab, type SortableResourceTabProps, type SpacingToken, StatisticsPanel, StatusDisplay, type StreamStatus, SvgDrawingCanvas, TagEntry, TagSchemasPage, type TagSchemasPageProps, TaggingPanel, type TextSegment, type TextSelection, type Theme, ThemeProvider, ToastContainer, type ToastMessage, ToastProvider, type ToastType, Toolbar, type ToolbarPanelType, type TransitionToken, TranslationManager, TranslationProvider, type TranslationProviderProps, type TypographyToken, type UICreateAnnotationParams, UnifiedAnnotationsPanel, UnifiedHeader, type UseResourceContentResult, UserMenuSkeleton, WelcomePage, type WelcomePageProps, buttonStyles, createHoverHandlers, cssVariables, dispatch401Error, dispatch403Error, dispatchAuthEvent, faviconPaths, formatTime, generateCSSVariables, getResourceIcon, getSelectedShapeForSelectorType, getSelectorType, getShortcutDisplay, getSupportedShapes, isShapeSupported, jsonLightHighlightStyle, jsonLightTheme, onAuthEvent, rehypeRenderAnnotations, remarkAnnotations, sanitizeImageURL, saveSelectedShapeForSelectorType, supportsDetection, tokens, useAdmin, useAnnotationFlow, useAnnotationManager, useAnnotations, useApiClient, useAttentionFlow, useAuthApi, useAuthToken, useCacheManager, useContextCorrelationFlow, useDebounce, useDebouncedCallback, useDocumentAnnouncements, useDoubleKeyPress, useDropdown, useEntityTypes, useEventSubscription, useEventSubscriptions, useFormAnnouncements, useGenerationFlow, useHealth, useHoverDelay, useHoverEmitter, useIsTyping, useKeyboardShortcuts, useLanguageChangeAnnouncements, useLineNumbers, useLiveRegion, useLoadingState, useLocalStorage, useObservableExternalNavigation, useObservableRouter, useOpenResources, usePanelNavigation, usePanelWidth, usePreloadTranslations, useResolutionFlow, useResourceAnnotations, useResourceContent, useResourceEvents, useResourceLoadingAnnouncements, useResources, useRovingTabIndex, useSearchAnnouncements, useSessionContext, useSessionExpiry, useTheme, useToast, useTranslations };
3948
+ export { ANNOTATORS, AUTH_EVENTS, AVAILABLE_LOCALES, AdminDevOpsPage, type AdminDevOpsPageProps, AdminSecurityPage, type AdminSecurityPageProps, type AdminUser, type AdminUserStats, AdminUsersPage, type AdminUsersPageProps, AnnotateReferencesProgressWidget, AnnotateToolbar, AnnotateView, type Annotation$l as Annotation, type AnnotationConfig, type AnnotationCreationHandler, type AnnotationFlowState, type AnnotationHandlers, AnnotationHistory, type AnnotationManager, AnnotationOverlay, AnnotationProvider, type AnnotationProviderProps, type AnnotationUIState, type AnnotationsCollection, type Annotator, ApiClientProvider, type ApiClientProviderProps, AssessmentEntry, AssessmentPanel, AssistSection, AsyncErrorBoundary, type AttentionFlowState, AuthErrorDisplay, type AuthErrorDisplayProps, type AuthEventDetail, type AuthEventType, AuthTokenProvider, type AuthTokenProviderProps, type AvailableLocale, type BorderRadiusToken, BrowseView, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type CacheManager, CacheProvider, type CacheProviderProps, type ClickAction, CodeMirrorRenderer, CollaborationPanel, CollapsibleResourceNavigation, type CollapsibleResourceNavigationProps, type ColorToken, CommentEntry, CommentsPanel, ComposeLoadingState, type ComposeLoadingStateProps, type ContextCorrelationFlowConfig, type ContextCorrelationFlowState, type CreateAnnotationParams, type CreateConfig, type DeleteAnnotationParams, type DetectionConfig, type DevOpsFeature, type DrawingMode, EntityTagsPage, type EntityTagsPageProps, EntityTypeBadges, ErrorBoundary, Footer, type GenerationFlowState, type GenerationOptions, HOVER_DELAY_MS, HighlightEntry, HighlightPanel, HistoryEvent, type HoverEmitterProps, type HoverHandlers, ImageURLSchema, ImageViewer, JsonLdPanel, JsonLdView, type KeyboardShortcut, KeyboardShortcutsHelpModal, LeftSidebar, type LinkComponentProps, LiveRegionProvider, type Motivation$8 as Motivation, type NavigationItem, NavigationMenu, type NavigationMenuHelper, type NavigationProps, type OAuthProvider, type OAuthUser, OAuthUserSchema, ObservableLink, type ObservableLinkProps, type OpenResource, OpenResourcesManager, OpenResourcesProvider, type OverlayAnnotation, PageLayout, PanelHeader, type PanelNavigationState, PopupContainer, PopupHeader, ProposeEntitiesModal, QUERY_KEYS, RecentDocumentsPage, type RecentDocumentsPageProps, ReferenceEntry, ReferenceResolutionWidget, ReferencesPanel, ResizeHandle, type ResolutionFlowState, type ResolvedTheme, ResourceAnnotationsProvider, ResourceCard, type ResourceCardProps, ResourceComposePage, type ResourceComposePageProps, ResourceDiscoveryPage, type ResourceDiscoveryPageProps, ResourceErrorState, type ResourceErrorStateProps, ResourceInfoPanel, ResourceLoadingState, ResourceSearchModal, type ResourceSearchModalProps, ResourceTagsInline, ResourceViewer, ResourceViewerPage, type ResourceViewerPageProps, type RouteBuilder, type SaveResourceParams, SearchModal, type SearchModalProps, SelectedTextDisplay, type SelectionMotivation, type SelectorType, SemiontBranding, SemiontFavicon, type SemiontResource$4 as SemiontResource, SessionExpiryBanner, SessionManager, SessionProvider, SessionTimer, SettingsPanel, type ShadowToken, type ShapeType, SignInForm, type SignInFormProps, SignUpForm, type SignUpFormProps, SimpleNavigation, type SimpleNavigationItem, type SimpleNavigationProps, SkipLinks, SortableResourceTab, type SortableResourceTabProps, type SpacingToken, StatisticsPanel, StatusDisplay, type StreamStatus, SvgDrawingCanvas, TagEntry, TagSchemasPage, type TagSchemasPageProps, TaggingPanel, type TextSegment, type TextSelection, type Theme, ThemeProvider, ToastContainer, type ToastMessage, ToastProvider, type ToastType, Toolbar, type ToolbarPanelType, type TransitionToken, TranslationManager, TranslationProvider, type TranslationProviderProps, type TypographyToken, type UICreateAnnotationParams, UnifiedAnnotationsPanel, UnifiedHeader, type UseResourceContentResult, UserMenuSkeleton, WelcomePage, type WelcomePageProps, applyHighlights, buildSourceToRenderedMap, buildTextNodeIndex, buttonStyles, clearHighlights, createHoverHandlers, cssVariables, dispatch401Error, dispatch403Error, dispatchAuthEvent, faviconPaths, formatTime, generateCSSVariables, getResourceIcon, getSelectedShapeForSelectorType, getSelectorType, getShortcutDisplay, getSupportedShapes, isShapeSupported, jsonLightHighlightStyle, jsonLightTheme, onAuthEvent, resolveAnnotationRanges, sanitizeImageURL, saveSelectedShapeForSelectorType, supportsDetection, toOverlayAnnotations, tokens, useAdmin, useAnnotationFlow, useAnnotationManager, useAnnotations, useApiClient, useAttentionFlow, useAuthApi, useAuthToken, useCacheManager, useContextCorrelationFlow, useDebounce, useDebouncedCallback, useDocumentAnnouncements, useDoubleKeyPress, useDropdown, useEntityTypes, useEventSubscription, useEventSubscriptions, useFormAnnouncements, useGenerationFlow, useHealth, useHoverDelay, useHoverEmitter, useIsTyping, useKeyboardShortcuts, useLanguageChangeAnnouncements, useLineNumbers, useLiveRegion, useLoadingState, useLocalStorage, useObservableExternalNavigation, useObservableRouter, useOpenResources, usePanelNavigation, usePanelWidth, usePreloadTranslations, useResolutionFlow, useResourceAnnotations, useResourceContent, useResourceEvents, useResourceLoadingAnnouncements, useResources, useRovingTabIndex, useSearchAnnouncements, useSessionContext, useSessionExpiry, useTheme, useToast, useTranslations };