@deepcitation/deepcitation-js 1.1.27 → 1.1.29
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/LICENSE +21 -21
- package/README.md +253 -253
- package/lib/chunk-2IZXUOQR.js +66 -0
- package/lib/chunk-3GR7VKUJ.cjs +1 -0
- package/lib/chunk-4FGOHQFP.cjs +66 -0
- package/lib/chunk-CFXDRAJL.cjs +1 -0
- package/lib/chunk-F2MMVEVC.cjs +1 -0
- package/lib/chunk-LSKISWWH.cjs +2 -0
- package/lib/chunk-O2XFH626.js +1 -0
- package/lib/chunk-QGXCOW3E.js +1 -0
- package/lib/chunk-RCHWBA6D.js +2 -0
- package/lib/chunk-RQPZSRID.js +1 -0
- package/lib/client/index.cjs +1 -0
- package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
- package/lib/client/index.d.ts +342 -2
- package/lib/client/index.js +1 -1
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +105 -0
- package/lib/index.d.ts +103 -21
- package/lib/index.js +1 -20
- package/lib/prompts/index.cjs +1 -0
- package/lib/prompts/index.d.cts +196 -0
- package/lib/prompts/index.d.ts +196 -3
- package/lib/prompts/index.js +1 -3
- package/lib/react/index.cjs +4 -0
- package/lib/react/{types.d.ts → index.d.cts} +173 -22
- package/lib/react/index.d.ts +461 -12
- package/lib/react/index.js +4 -20
- package/lib/types/index.cjs +1 -0
- package/lib/types/index.d.cts +96 -0
- package/lib/types/index.d.ts +96 -11
- package/lib/types/index.js +1 -7
- package/lib/utils-CSqRI6NU.d.cts +45 -0
- package/lib/{react/utils.d.ts → utils-D_wxy_ni.d.ts} +13 -12
- package/package.json +46 -11
- package/lib/client/DeepCitation.js +0 -374
- package/lib/client/types.d.ts +0 -154
- package/lib/client/types.js +0 -1
- package/lib/parsing/normalizeCitation.d.ts +0 -5
- package/lib/parsing/normalizeCitation.js +0 -198
- package/lib/parsing/parseCitation.d.ts +0 -79
- package/lib/parsing/parseCitation.js +0 -431
- package/lib/parsing/parseWorkAround.d.ts +0 -2
- package/lib/parsing/parseWorkAround.js +0 -73
- package/lib/prompts/citationPrompts.d.ts +0 -138
- package/lib/prompts/citationPrompts.js +0 -168
- package/lib/prompts/promptCompression.d.ts +0 -14
- package/lib/prompts/promptCompression.js +0 -127
- package/lib/prompts/types.d.ts +0 -4
- package/lib/prompts/types.js +0 -1
- package/lib/react/CitationComponent.d.ts +0 -106
- package/lib/react/CitationComponent.js +0 -419
- package/lib/react/CitationVariants.d.ts +0 -132
- package/lib/react/CitationVariants.js +0 -277
- package/lib/react/DiffDisplay.d.ts +0 -10
- package/lib/react/DiffDisplay.js +0 -33
- package/lib/react/Popover.d.ts +0 -15
- package/lib/react/Popover.js +0 -20
- package/lib/react/UrlCitationComponent.d.ts +0 -83
- package/lib/react/UrlCitationComponent.js +0 -224
- package/lib/react/VerificationTabs.d.ts +0 -10
- package/lib/react/VerificationTabs.js +0 -36
- package/lib/react/icons.d.ts +0 -22
- package/lib/react/icons.js +0 -16
- package/lib/react/primitives.d.ts +0 -99
- package/lib/react/primitives.js +0 -187
- package/lib/react/types.js +0 -1
- package/lib/react/useSmartDiff.d.ts +0 -16
- package/lib/react/useSmartDiff.js +0 -64
- package/lib/react/utils.js +0 -88
- package/lib/types/boxes.d.ts +0 -11
- package/lib/types/boxes.js +0 -1
- package/lib/types/citation.d.ts +0 -39
- package/lib/types/citation.js +0 -1
- package/lib/types/search.d.ts +0 -19
- package/lib/types/search.js +0 -1
- package/lib/types/verification.d.ts +0 -27
- package/lib/types/verification.js +0 -11
- package/lib/utils/diff.d.ts +0 -60
- package/lib/utils/diff.js +0 -414
- package/lib/utils/sha.d.ts +0 -10
- package/lib/utils/sha.js +0 -108
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import { Citation, Verification, SearchStatus, CitationStatus } from '../types/index.cjs';
|
|
2
|
+
export { C as CITATION_X_PADDING, c as CITATION_Y_PADDING, h as classNames, b as generateCitationInstanceId, g as generateCitationKey, d as getCitationDisplayText, f as getCitationKeySpanText, e as getCitationNumber } from '../utils-CSqRI6NU.cjs';
|
|
3
|
+
import React$1 from 'react';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Visual style variants for citations.
|
|
6
8
|
*
|
|
@@ -12,7 +14,7 @@ import type { SearchStatus } from "../types/search.js";
|
|
|
12
14
|
* | `superscript` | Small raised text like footnotes¹ |
|
|
13
15
|
* | `minimal` | Compact text with indicator, truncated |
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "minimal";
|
|
16
18
|
/**
|
|
17
19
|
* Content to display in the citation.
|
|
18
20
|
*
|
|
@@ -29,15 +31,15 @@ export type CitationVariant = "chip" | "brackets" | "text" | "superscript" | "mi
|
|
|
29
31
|
* - `superscript` → `number`
|
|
30
32
|
* - `minimal` → `number`
|
|
31
33
|
*/
|
|
32
|
-
|
|
34
|
+
type CitationContent = "keySpan" | "number" | "indicator";
|
|
33
35
|
/**
|
|
34
36
|
* URL fetch status for URL citations.
|
|
35
37
|
*/
|
|
36
|
-
|
|
38
|
+
type UrlFetchStatus = "verified" | "partial" | "pending" | "blocked_antibot" | "blocked_login" | "blocked_paywall" | "blocked_geo" | "blocked_rate_limit" | "error_timeout" | "error_not_found" | "error_server" | "error_network" | "unknown";
|
|
37
39
|
/**
|
|
38
40
|
* URL citation metadata.
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
interface UrlCitationMeta {
|
|
41
43
|
/** The full URL */
|
|
42
44
|
url: string;
|
|
43
45
|
/** Display domain (e.g., "example.com") */
|
|
@@ -59,7 +61,7 @@ export interface UrlCitationMeta {
|
|
|
59
61
|
* Style configuration for the citation component.
|
|
60
62
|
* All properties are optional class name strings.
|
|
61
63
|
*/
|
|
62
|
-
|
|
64
|
+
interface CitationStyles {
|
|
63
65
|
/** Container wrapper class */
|
|
64
66
|
container?: string;
|
|
65
67
|
/** Citation number bracket wrapper */
|
|
@@ -78,7 +80,7 @@ export interface CitationStyles {
|
|
|
78
80
|
/**
|
|
79
81
|
* State classes applied based on citation verification status
|
|
80
82
|
*/
|
|
81
|
-
|
|
83
|
+
interface CitationStateClasses {
|
|
82
84
|
/** Applied when citation is verified (found in document) */
|
|
83
85
|
verified?: string;
|
|
84
86
|
/** Applied when citation is a miss (not found) */
|
|
@@ -91,7 +93,7 @@ export interface CitationStateClasses {
|
|
|
91
93
|
/**
|
|
92
94
|
* Cursor classes for different zoom states
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
interface CitationCursorClasses {
|
|
95
97
|
zoomIn?: string;
|
|
96
98
|
zoomOut?: string;
|
|
97
99
|
pointer?: string;
|
|
@@ -99,7 +101,7 @@ export interface CitationCursorClasses {
|
|
|
99
101
|
/**
|
|
100
102
|
* Props for the base CitationComponent
|
|
101
103
|
*/
|
|
102
|
-
|
|
104
|
+
interface BaseCitationProps {
|
|
103
105
|
/** The citation data to display */
|
|
104
106
|
citation: Citation;
|
|
105
107
|
/** Child content to render before the citation bracket */
|
|
@@ -129,11 +131,11 @@ export interface BaseCitationProps {
|
|
|
129
131
|
/**
|
|
130
132
|
* Visual style variants for URL citations.
|
|
131
133
|
*/
|
|
132
|
-
|
|
134
|
+
type UrlCitationVariant = "chip" | "inline" | "bracket";
|
|
133
135
|
/**
|
|
134
136
|
* Props for URL citation component
|
|
135
137
|
*/
|
|
136
|
-
|
|
138
|
+
interface UrlCitationProps extends Omit<BaseCitationProps, "citation" | "variant"> {
|
|
137
139
|
/** Visual style variant for the URL citation */
|
|
138
140
|
variant?: UrlCitationVariant;
|
|
139
141
|
/** URL metadata including fetch status */
|
|
@@ -160,7 +162,7 @@ export interface UrlCitationProps extends Omit<BaseCitationProps, "citation" | "
|
|
|
160
162
|
/**
|
|
161
163
|
* Extended props for the citation content renderer
|
|
162
164
|
*/
|
|
163
|
-
|
|
165
|
+
interface CitationContentProps extends BaseCitationProps {
|
|
164
166
|
/** Unique key for this citation */
|
|
165
167
|
citationKey: string;
|
|
166
168
|
/** Unique instance ID for this citation render */
|
|
@@ -191,7 +193,7 @@ export interface CitationContentProps extends BaseCitationProps {
|
|
|
191
193
|
/**
|
|
192
194
|
* Render props for custom citation rendering
|
|
193
195
|
*/
|
|
194
|
-
|
|
196
|
+
interface CitationRenderProps {
|
|
195
197
|
/** The citation data */
|
|
196
198
|
citation: Citation;
|
|
197
199
|
/** Citation verification status */
|
|
@@ -206,7 +208,7 @@ export interface CitationRenderProps {
|
|
|
206
208
|
/**
|
|
207
209
|
* Event handlers for citation interactions
|
|
208
210
|
*/
|
|
209
|
-
|
|
211
|
+
interface CitationEventHandlers {
|
|
210
212
|
/** Called when mouse enters citation */
|
|
211
213
|
onMouseEnter?: (citation: Citation, citationKey: string) => void;
|
|
212
214
|
/** Called when mouse leaves citation */
|
|
@@ -219,7 +221,7 @@ export interface CitationEventHandlers {
|
|
|
219
221
|
/**
|
|
220
222
|
* Context provided to behavior handlers for making decisions.
|
|
221
223
|
*/
|
|
222
|
-
|
|
224
|
+
interface CitationBehaviorContext {
|
|
223
225
|
/** The citation data */
|
|
224
226
|
citation: Citation;
|
|
225
227
|
/** Unique key for this citation */
|
|
@@ -237,7 +239,7 @@ export interface CitationBehaviorContext {
|
|
|
237
239
|
* Actions that can be performed by the citation component.
|
|
238
240
|
* These are returned by behavior handlers to control component state.
|
|
239
241
|
*/
|
|
240
|
-
|
|
242
|
+
interface CitationBehaviorActions {
|
|
241
243
|
/** Pin or unpin the popover (keeps it visible without hover) */
|
|
242
244
|
setTooltipExpanded?: boolean;
|
|
243
245
|
/** Open or close the full-size image overlay */
|
|
@@ -249,11 +251,11 @@ export interface CitationBehaviorActions {
|
|
|
249
251
|
* Configuration for click behavior.
|
|
250
252
|
* Return actions to perform, or `false` to prevent default behavior.
|
|
251
253
|
*/
|
|
252
|
-
|
|
254
|
+
type CitationClickBehavior = (context: CitationBehaviorContext, event: React.MouseEvent | React.TouchEvent) => CitationBehaviorActions | false | void;
|
|
253
255
|
/**
|
|
254
256
|
* Configuration for hover behavior.
|
|
255
257
|
*/
|
|
256
|
-
|
|
258
|
+
interface CitationHoverBehavior {
|
|
257
259
|
/** Called when mouse enters the citation */
|
|
258
260
|
onEnter?: (context: CitationBehaviorContext) => void;
|
|
259
261
|
/** Called when mouse leaves the citation */
|
|
@@ -289,7 +291,7 @@ export interface CitationHoverBehavior {
|
|
|
289
291
|
* />
|
|
290
292
|
* ```
|
|
291
293
|
*/
|
|
292
|
-
|
|
294
|
+
interface CitationBehaviorConfig {
|
|
293
295
|
/**
|
|
294
296
|
* Custom click behavior handler. When provided, REPLACES the default click behavior.
|
|
295
297
|
*
|
|
@@ -307,9 +309,158 @@ export interface CitationBehaviorConfig {
|
|
|
307
309
|
/**
|
|
308
310
|
* Props for the tooltip wrapper component
|
|
309
311
|
*/
|
|
310
|
-
|
|
312
|
+
interface CitationTooltipProps {
|
|
311
313
|
children: React.ReactNode;
|
|
312
314
|
citation: Citation;
|
|
313
315
|
verification?: Verification | null;
|
|
314
316
|
shouldShowTooltip: boolean;
|
|
315
317
|
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Extracts domain from URL for compact display.
|
|
321
|
+
*/
|
|
322
|
+
declare function extractDomain(url: string): string;
|
|
323
|
+
/**
|
|
324
|
+
* Checks if status is a blocked status.
|
|
325
|
+
*/
|
|
326
|
+
declare function isBlockedStatus(status: UrlFetchStatus): boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Checks if status is an error status.
|
|
329
|
+
*/
|
|
330
|
+
declare function isErrorStatus(status: UrlFetchStatus): boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Checks if URL was successfully verified.
|
|
333
|
+
*/
|
|
334
|
+
declare function isVerifiedStatus(status: UrlFetchStatus): boolean;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Props for the CitationComponent.
|
|
338
|
+
*
|
|
339
|
+
* ## Behavior
|
|
340
|
+
*
|
|
341
|
+
* Default interaction pattern:
|
|
342
|
+
* - **Hover**: Shows popover with verification image/details
|
|
343
|
+
* - **Click**: Opens full-size image overlay (zoom)
|
|
344
|
+
* - **Escape / Click outside / Click overlay**: Closes image overlay
|
|
345
|
+
*
|
|
346
|
+
* Custom behavior:
|
|
347
|
+
* - Use `behaviorConfig.onClick` to replace the default click behavior
|
|
348
|
+
* - Use `eventHandlers.onClick` to add side effects (disables default)
|
|
349
|
+
*
|
|
350
|
+
* @example Default usage
|
|
351
|
+
* ```tsx
|
|
352
|
+
* <CitationComponent
|
|
353
|
+
* citation={citation}
|
|
354
|
+
* verification={verification}
|
|
355
|
+
* />
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @example Custom click behavior
|
|
359
|
+
* ```tsx
|
|
360
|
+
* <CitationComponent
|
|
361
|
+
* citation={citation}
|
|
362
|
+
* verification={verification}
|
|
363
|
+
* behaviorConfig={{
|
|
364
|
+
* onClick: (context) => {
|
|
365
|
+
* // Custom action
|
|
366
|
+
* console.log('Clicked:', context.citationKey);
|
|
367
|
+
* return { setImageExpanded: true };
|
|
368
|
+
* }
|
|
369
|
+
* }}
|
|
370
|
+
* />
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
interface CitationComponentProps extends BaseCitationProps {
|
|
374
|
+
/** Verification result from the DeepCitation API */
|
|
375
|
+
verification?: Verification | null;
|
|
376
|
+
/**
|
|
377
|
+
* Explicitly show loading spinner. When true, displays spinner regardless
|
|
378
|
+
* of verification status. Use this when verification is in-flight.
|
|
379
|
+
*/
|
|
380
|
+
isLoading?: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Visual style variant for the citation.
|
|
383
|
+
* - `chip`: Pill/badge style with background color
|
|
384
|
+
* - `brackets`: [text✓] with square brackets (default)
|
|
385
|
+
* - `text`: Plain text, inherits parent styling
|
|
386
|
+
* - `superscript`: Small raised text like footnotes¹
|
|
387
|
+
* - `minimal`: Compact text with indicator, truncated
|
|
388
|
+
*/
|
|
389
|
+
variant?: CitationVariant;
|
|
390
|
+
/**
|
|
391
|
+
* What content to display in the citation.
|
|
392
|
+
* - `keySpan`: Descriptive text (e.g., "Revenue Growth")
|
|
393
|
+
* - `number`: Citation number (e.g., "1", "2", "3")
|
|
394
|
+
* - `indicator`: Only the status icon, no text
|
|
395
|
+
*
|
|
396
|
+
* Defaults based on variant:
|
|
397
|
+
* - `chip` → `keySpan`
|
|
398
|
+
* - `brackets` → `keySpan`
|
|
399
|
+
* - `text` → `keySpan`
|
|
400
|
+
* - `superscript` → `number`
|
|
401
|
+
* - `minimal` → `number`
|
|
402
|
+
*/
|
|
403
|
+
content?: CitationContent;
|
|
404
|
+
/** Event handlers for citation interactions */
|
|
405
|
+
eventHandlers?: CitationEventHandlers;
|
|
406
|
+
/**
|
|
407
|
+
* Configuration for customizing default click/hover behaviors.
|
|
408
|
+
* Providing onClick REPLACES the default click behavior.
|
|
409
|
+
*/
|
|
410
|
+
behaviorConfig?: CitationBehaviorConfig;
|
|
411
|
+
/** Enable mobile touch handlers */
|
|
412
|
+
isMobile?: boolean;
|
|
413
|
+
/** Custom render function for the status indicator */
|
|
414
|
+
renderIndicator?: (status: CitationStatus) => React$1.ReactNode;
|
|
415
|
+
/** Custom render function for entire citation content */
|
|
416
|
+
renderContent?: (props: CitationRenderProps) => React$1.ReactNode;
|
|
417
|
+
/** Position of popover. Use "hidden" to disable. */
|
|
418
|
+
popoverPosition?: "top" | "bottom" | "hidden";
|
|
419
|
+
/** Custom render function for popover content */
|
|
420
|
+
renderPopoverContent?: (props: {
|
|
421
|
+
citation: BaseCitationProps["citation"];
|
|
422
|
+
verification: Verification | null;
|
|
423
|
+
status: CitationStatus;
|
|
424
|
+
}) => React$1.ReactNode;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* CitationComponent displays a citation with verification status.
|
|
428
|
+
*
|
|
429
|
+
* ## Interaction Pattern
|
|
430
|
+
*
|
|
431
|
+
* - **Hover**: Shows popover with verification image or details
|
|
432
|
+
* - **Click**: Opens full-size image overlay (if image available)
|
|
433
|
+
* - **Escape / Click overlay**: Closes the image overlay
|
|
434
|
+
*
|
|
435
|
+
* ## Customization
|
|
436
|
+
*
|
|
437
|
+
* Use `behaviorConfig.onClick` to completely replace the click behavior,
|
|
438
|
+
* or `eventHandlers.onClick` to add side effects (which disables defaults).
|
|
439
|
+
*/
|
|
440
|
+
declare const CitationComponent: React$1.ForwardRefExoticComponent<CitationComponentProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
441
|
+
declare const MemoizedCitationComponent: React$1.NamedExoticComponent<CitationComponentProps & React$1.RefAttributes<HTMLSpanElement>>;
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* DeepCitation icon SVG (no dependencies)
|
|
445
|
+
*/
|
|
446
|
+
declare const DeepCitationIcon: ({ className }: {
|
|
447
|
+
className?: string;
|
|
448
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
449
|
+
/**
|
|
450
|
+
* Check icon SVG (no dependencies)
|
|
451
|
+
*/
|
|
452
|
+
declare const CheckIcon: ({ className }: {
|
|
453
|
+
className?: string;
|
|
454
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
455
|
+
/**
|
|
456
|
+
* Warning icon SVG (no dependencies)
|
|
457
|
+
*/
|
|
458
|
+
declare const WarningIcon: ({ className }: {
|
|
459
|
+
className?: string;
|
|
460
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
461
|
+
/** Spinner component for loading/pending state */
|
|
462
|
+
declare const SpinnerIcon: ({ className }: {
|
|
463
|
+
className?: string;
|
|
464
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
465
|
+
|
|
466
|
+
export { CheckIcon, type CitationBehaviorActions, type CitationBehaviorConfig, type CitationBehaviorContext, type CitationClickBehavior, CitationComponent, type CitationComponentProps, type CitationContent, type CitationContentProps, type CitationCursorClasses, type CitationEventHandlers, type CitationHoverBehavior, type CitationRenderProps, type CitationStateClasses, type CitationStyles, type CitationTooltipProps, type CitationVariant, type CitationVariant as CitationVariantType, DeepCitationIcon, MemoizedCitationComponent, SpinnerIcon, type UrlCitationMeta, type UrlCitationProps, type UrlCitationVariant, type UrlFetchStatus, WarningIcon, extractDomain, isBlockedStatus, isErrorStatus, isVerifiedStatus };
|