@deepcitation/deepcitation-js 1.1.5 → 1.1.7

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.
@@ -55,7 +55,7 @@ export function getCitationStatus(verification) {
55
55
  const searchState = verification?.searchState;
56
56
  const isMiss = searchState?.status === "not_found";
57
57
  const isFullMatchWithMissedValue = searchState?.status === "found_phrase_missed_value";
58
- const isFoundValueMissedFullMatch = searchState?.status === "found_value_only";
58
+ const isFoundValueMissedFullMatch = searchState?.status === "found_key_span_only";
59
59
  const isPartialMatch = searchState?.status === "partial_text_found" ||
60
60
  searchState?.status === "found_on_other_page" ||
61
61
  searchState?.status === "found_on_other_line" ||
@@ -158,11 +158,10 @@ export const parseCitation = (fragment, mdAttachmentId, citationCounterRef, isVe
158
158
  pageNumber,
159
159
  startPageKey: `page_number_${pageNumber || 1}_index_${pageIndex || 0}`,
160
160
  fullPhrase,
161
- keySpan,
161
+ keySpan: keySpan || value,
162
162
  citationNumber,
163
163
  lineIds,
164
164
  beforeCite,
165
- value,
166
165
  timestamps,
167
166
  reasoning,
168
167
  };
@@ -221,9 +220,8 @@ const parseJsonCitation = (jsonCitation, citationNumber) => {
221
220
  fullPhrase,
222
221
  citationNumber,
223
222
  lineIds,
224
- keySpan,
223
+ keySpan: keySpan || value,
225
224
  reasoning,
226
- value,
227
225
  };
228
226
  return citation;
229
227
  };
@@ -94,7 +94,7 @@ const StatusTooltipContent = ({ citation, status, verification, isExpanded, onTo
94
94
  }
95
95
  // Fallback to citation text if no phrases recorded
96
96
  if (allPhrases.length === 0) {
97
- const searchedText = citation.fullPhrase || citation.value || "";
97
+ const searchedText = citation.fullPhrase || citation.keySpan?.toString() || "";
98
98
  if (searchedText) {
99
99
  allPhrases.push(searchedText);
100
100
  }
@@ -104,7 +104,7 @@ const StatusTooltipContent = ({ citation, status, verification, isExpanded, onTo
104
104
  return (_jsxs("span", { className: "dc-status-tooltip", role: "tooltip", children: [_jsxs("span", { className: "dc-status-header dc-status-header--miss", children: [_jsx(WarningIcon, {}), _jsx("span", { children: "Not found in source" })] }), allPhrases.length > 0 && (_jsxs("span", { className: "dc-search-phrases", children: [_jsxs("span", { className: "dc-search-phrases-header", children: [hiddenCount > 0 && (_jsx("button", { type: "button", className: "dc-search-phrases-toggle", onClick: onToggleExpand, children: isExpanded ? "collapse" : `+${hiddenCount} more` })), _jsxs("span", { className: "dc-status-label", children: ["Searched ", allPhrases.length, " phrase", allPhrases.length > 1 ? "s" : ""] })] }), _jsx("span", { className: "dc-search-phrases-list", children: (isExpanded ? allPhrases : allPhrases.slice(0, 1)).map((phrase, idx) => (_jsxs("span", { className: "dc-search-phrase-item", children: ["\"", phrase.length > 80 ? phrase.slice(0, 80) + "…" : phrase, "\""] }, idx))) })] }))] }));
105
105
  }
106
106
  if (isPartialMatch) {
107
- const expectedText = citation.fullPhrase || citation.value || "";
107
+ const expectedText = citation.fullPhrase || citation.keySpan?.toString() || "";
108
108
  const actualText = verification?.matchSnippet || "";
109
109
  const truncatedExpected = expectedText.length > 100
110
110
  ? expectedText.slice(0, 100) + "…"
@@ -68,7 +68,7 @@ export const ChipCitation = forwardRef(({ citation, children, className, display
68
68
  ? "citation-chip--pending"
69
69
  : "";
70
70
  return (_jsxs(_Fragment, { children: [children, _jsxs("span", { ref: ref, "data-citation-id": citationKey, "data-citation-instance": citationInstanceId, "data-variant": "chip", className: classNames("citation-chip", sizeClasses[size], statusClass, className), onMouseEnter: preventTooltips ? undefined : handleMouseEnter, onMouseLeave: preventTooltips ? undefined : handleMouseLeave, onMouseDown: handleClick, onClick: (e) => e.stopPropagation(), "aria-label": displayText ? `Citation: ${displayText}` : undefined, children: [showIcon &&
71
- (icon || _jsx("span", { className: "citation-chip__icon", children: "\uD83D\uDCC4" })), keySpanText && !displayKeySpan && (_jsx("span", { className: "citation-chip__keySpan", children: keySpanText })), _jsx("span", { className: "citation-chip__text", children: displayText }), isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && (_jsx("span", { className: "citation-chip__pending", children: pendingContent }))] })] }));
71
+ (icon || _jsx("span", { className: "citation-chip__icon", children: "\uD83D\uDCC4" })), _jsx("span", { className: "citation-chip__text", children: displayText }), isPartialMatch && renderPartialIndicator(status), isVerified && !isPartialMatch && renderVerifiedIndicator(status), isPending && (_jsx("span", { className: "citation-chip__pending", children: pendingContent }))] })] }));
72
72
  });
73
73
  ChipCitation.displayName = "ChipCitation";
74
74
  /**
@@ -101,7 +101,7 @@ export const CitationNumber = forwardRef(({ className, number, ...props }, ref)
101
101
  if (number !== undefined)
102
102
  return String(number);
103
103
  if (config.displayKeySpan) {
104
- return (citation.value ||
104
+ return (citation.keySpan?.toString() ||
105
105
  citation.citationNumber?.toString() ||
106
106
  config.fallbackDisplay ||
107
107
  "");
@@ -120,9 +120,9 @@ export const CitationValue = forwardRef(({ className, value, separator = " ", ..
120
120
  const displayValue = useMemo(() => {
121
121
  if (value !== undefined)
122
122
  return value;
123
- if (config.displayKeySpan)
123
+ if (!config.displayKeySpan)
124
124
  return "";
125
- return citation.value || "";
125
+ return citation.keySpan?.toString() || "";
126
126
  }, [value, citation, config]);
127
127
  if (!displayValue)
128
128
  return null;
@@ -20,7 +20,7 @@ export function generateCitationKey(citation) {
20
20
  * Combines the citation key with a random suffix for uniqueness.
21
21
  */
22
22
  export function generateCitationInstanceId(citationKey) {
23
- const randomSuffix = Math.random().toString(36).substr(2, 9);
23
+ const randomSuffix = Math.random().toString(36).slice(2, 11);
24
24
  return `${citationKey}-${randomSuffix}`;
25
25
  }
26
26
  /**
@@ -19,7 +19,6 @@ export interface Citation {
19
19
  fileId?: string;
20
20
  fullPhrase?: string | null;
21
21
  keySpan?: string | null;
22
- value?: string | null;
23
22
  startPageKey?: string | null;
24
23
  lineIds?: number[] | null;
25
24
  reasoning?: string | null;
@@ -1,4 +1,4 @@
1
- export type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_value_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
1
+ export type SearchStatus = "loading" | "pending" | "not_found" | "partial_text_found" | "found" | "found_key_span_only" | "found_phrase_missed_value" | "found_on_other_page" | "found_on_other_line" | "first_word_found" | "timestamp_wip";
2
2
  export type SearchMethod = "exact_line_match" | "line_with_buffer" | "current_page" | "keyspan_fallback" | "adjacent_pages" | "expanded_window" | "regex_search" | "bm25_search" | "fuzzy_regex" | "first_word_fallback";
3
3
  export interface SearchAttempt {
4
4
  method: SearchMethod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepcitation/deepcitation-js",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "DeepCitation JavaScript SDK for deterministic AI citation verification",
5
5
  "type": "module",
6
6
  "private": false,