@deepcitation/deepcitation-js 1.1.26 → 1.1.28

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.
Files changed (79) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +253 -253
  3. package/lib/chunk-2IZXUOQR.js +66 -0
  4. package/lib/chunk-4FGOHQFP.cjs +66 -0
  5. package/lib/chunk-CFXDRAJL.cjs +1 -0
  6. package/lib/chunk-DEUSSEFH.js +2 -0
  7. package/lib/chunk-F2MMVEVC.cjs +1 -0
  8. package/lib/chunk-J7U6YFOI.cjs +2 -0
  9. package/lib/chunk-O2XFH626.js +1 -0
  10. package/lib/chunk-RQPZSRID.js +1 -0
  11. package/lib/client/index.cjs +1 -0
  12. package/lib/client/{DeepCitation.d.ts → index.d.cts} +159 -3
  13. package/lib/client/index.d.ts +342 -2
  14. package/lib/client/index.js +1 -1
  15. package/lib/index.cjs +1 -0
  16. package/lib/index.d.cts +127 -0
  17. package/lib/index.d.ts +126 -23
  18. package/lib/index.js +1 -22
  19. package/lib/prompts/index.cjs +1 -0
  20. package/lib/prompts/index.d.cts +196 -0
  21. package/lib/prompts/index.d.ts +196 -3
  22. package/lib/prompts/index.js +1 -3
  23. package/lib/react/index.cjs +4 -0
  24. package/lib/react/index.js +4 -18
  25. package/lib/types/index.cjs +1 -0
  26. package/lib/types/index.d.cts +96 -0
  27. package/lib/types/index.d.ts +96 -11
  28. package/lib/types/index.js +1 -7
  29. package/package.json +62 -10
  30. package/lib/client/DeepCitation.js +0 -374
  31. package/lib/client/types.d.ts +0 -154
  32. package/lib/client/types.js +0 -1
  33. package/lib/parsing/normalizeCitation.d.ts +0 -5
  34. package/lib/parsing/normalizeCitation.js +0 -198
  35. package/lib/parsing/parseCitation.d.ts +0 -79
  36. package/lib/parsing/parseCitation.js +0 -431
  37. package/lib/parsing/parseWorkAround.d.ts +0 -2
  38. package/lib/parsing/parseWorkAround.js +0 -73
  39. package/lib/prompts/citationPrompts.d.ts +0 -138
  40. package/lib/prompts/citationPrompts.js +0 -168
  41. package/lib/prompts/promptCompression.d.ts +0 -14
  42. package/lib/prompts/promptCompression.js +0 -127
  43. package/lib/prompts/types.d.ts +0 -4
  44. package/lib/prompts/types.js +0 -1
  45. package/lib/react/CitationComponent.d.ts +0 -93
  46. package/lib/react/CitationComponent.js +0 -371
  47. package/lib/react/CitationVariants.d.ts +0 -132
  48. package/lib/react/CitationVariants.js +0 -284
  49. package/lib/react/DiffDisplay.d.ts +0 -10
  50. package/lib/react/DiffDisplay.js +0 -33
  51. package/lib/react/Popover.d.ts +0 -15
  52. package/lib/react/Popover.js +0 -20
  53. package/lib/react/UrlCitationComponent.d.ts +0 -83
  54. package/lib/react/UrlCitationComponent.js +0 -224
  55. package/lib/react/VerificationTabs.d.ts +0 -10
  56. package/lib/react/VerificationTabs.js +0 -36
  57. package/lib/react/icons.d.ts +0 -18
  58. package/lib/react/icons.js +0 -16
  59. package/lib/react/index.d.ts +0 -16
  60. package/lib/react/primitives.d.ts +0 -101
  61. package/lib/react/primitives.js +0 -193
  62. package/lib/react/types.d.ts +0 -283
  63. package/lib/react/types.js +0 -1
  64. package/lib/react/useSmartDiff.d.ts +0 -16
  65. package/lib/react/useSmartDiff.js +0 -64
  66. package/lib/react/utils.d.ts +0 -43
  67. package/lib/react/utils.js +0 -89
  68. package/lib/types/boxes.d.ts +0 -11
  69. package/lib/types/boxes.js +0 -1
  70. package/lib/types/citation.d.ts +0 -39
  71. package/lib/types/citation.js +0 -1
  72. package/lib/types/search.d.ts +0 -19
  73. package/lib/types/search.js +0 -1
  74. package/lib/types/verification.d.ts +0 -27
  75. package/lib/types/verification.js +0 -11
  76. package/lib/utils/diff.d.ts +0 -60
  77. package/lib/utils/diff.js +0 -414
  78. package/lib/utils/sha.d.ts +0 -10
  79. package/lib/utils/sha.js +0 -108
@@ -0,0 +1,96 @@
1
+ interface PdfSpaceItem extends ScreenBox {
2
+ text?: string;
3
+ }
4
+ type IVertex = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ interface ScreenBox extends IVertex {
9
+ width: number;
10
+ height: number;
11
+ }
12
+
13
+ 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";
14
+ 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";
15
+ interface SearchAttempt {
16
+ method: SearchMethod;
17
+ success: boolean;
18
+ searchPhrases: string[];
19
+ pageSearched?: number;
20
+ matchedPhrases?: string[];
21
+ matchedVariation?: string;
22
+ phraseVariations?: string[];
23
+ matchQuality?: string;
24
+ isPartialMatch?: boolean;
25
+ matchScore?: number;
26
+ matchSnippet?: string;
27
+ notes?: string;
28
+ startTime?: number;
29
+ endTime?: number;
30
+ durationMs?: number;
31
+ }
32
+
33
+ declare const NOT_FOUND_VERIFICATION_INDEX = -1;
34
+ declare const PENDING_VERIFICATION_INDEX = -2;
35
+ declare const BLANK_VERIFICATION: Verification;
36
+ interface Verification {
37
+ attachmentId?: string | null;
38
+ label?: string | null;
39
+ citation?: Citation;
40
+ status?: SearchStatus | null;
41
+ searchAttempts?: SearchAttempt[];
42
+ highlightColor?: string | null;
43
+ verifiedPageNumber?: number | null;
44
+ verifiedLineIds?: number[] | null;
45
+ verifiedTimestamps?: {
46
+ startTime?: string;
47
+ endTime?: string;
48
+ } | null;
49
+ verifiedFullPhrase?: string | null;
50
+ verifiedKeySpan?: string | null;
51
+ verifiedMatchSnippet?: string | null;
52
+ hitIndexWithinPage?: number | null;
53
+ pdfSpaceItem?: PdfSpaceItem;
54
+ verificationImageBase64?: string | null;
55
+ verifiedAt?: Date;
56
+ }
57
+
58
+ type OutputImageFormat = "jpeg" | "png" | "avif" | undefined | null;
59
+ declare const DEFAULT_OUTPUT_IMAGE_FORMAT: "avif";
60
+ interface VerifyCitationResponse {
61
+ verifications: {
62
+ [key: string]: Verification;
63
+ };
64
+ }
65
+ interface VerifyCitationRequest {
66
+ attachmentId: string;
67
+ citations: {
68
+ [key: string]: Citation;
69
+ };
70
+ outputImageFormat?: OutputImageFormat;
71
+ apiKey?: string;
72
+ }
73
+ interface Citation {
74
+ attachmentId?: string;
75
+ fullPhrase?: string | null;
76
+ keySpan?: string | null;
77
+ startPageKey?: string | null;
78
+ lineIds?: number[] | null;
79
+ reasoning?: string | null;
80
+ selection?: ScreenBox | null;
81
+ citationNumber?: number;
82
+ pageNumber?: number | null;
83
+ timestamps?: {
84
+ endTime?: string;
85
+ startTime?: string;
86
+ };
87
+ beforeCite?: string;
88
+ }
89
+ interface CitationStatus {
90
+ isVerified: boolean;
91
+ isMiss: boolean;
92
+ isPartialMatch: boolean;
93
+ isPending: boolean;
94
+ }
95
+
96
+ export { BLANK_VERIFICATION, type Citation, type CitationStatus, DEFAULT_OUTPUT_IMAGE_FORMAT, type IVertex, NOT_FOUND_VERIFICATION_INDEX, type OutputImageFormat, PENDING_VERIFICATION_INDEX, type PdfSpaceItem, type ScreenBox, type SearchAttempt, type SearchMethod, type SearchStatus, type Verification, type VerifyCitationRequest, type VerifyCitationResponse };
@@ -1,11 +1,96 @@
1
- /**
2
- * Type definitions for DeepCitation
3
- *
4
- * @packageDocumentation
5
- */
6
- export type { Citation, CitationStatus, VerifyCitationRequest, VerifyCitationResponse, OutputImageFormat, } from "./citation.js";
7
- export { DEFAULT_OUTPUT_IMAGE_FORMAT } from "./citation.js";
8
- export type { Verification } from "./verification.js";
9
- export { NOT_FOUND_VERIFICATION_INDEX, PENDING_VERIFICATION_INDEX, BLANK_VERIFICATION, } from "./verification.js";
10
- export type { SearchStatus, SearchMethod, SearchAttempt } from "./search.js";
11
- export type { ScreenBox, PdfSpaceItem, IVertex } from "./boxes.js";
1
+ interface PdfSpaceItem extends ScreenBox {
2
+ text?: string;
3
+ }
4
+ type IVertex = {
5
+ x: number;
6
+ y: number;
7
+ };
8
+ interface ScreenBox extends IVertex {
9
+ width: number;
10
+ height: number;
11
+ }
12
+
13
+ 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";
14
+ 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";
15
+ interface SearchAttempt {
16
+ method: SearchMethod;
17
+ success: boolean;
18
+ searchPhrases: string[];
19
+ pageSearched?: number;
20
+ matchedPhrases?: string[];
21
+ matchedVariation?: string;
22
+ phraseVariations?: string[];
23
+ matchQuality?: string;
24
+ isPartialMatch?: boolean;
25
+ matchScore?: number;
26
+ matchSnippet?: string;
27
+ notes?: string;
28
+ startTime?: number;
29
+ endTime?: number;
30
+ durationMs?: number;
31
+ }
32
+
33
+ declare const NOT_FOUND_VERIFICATION_INDEX = -1;
34
+ declare const PENDING_VERIFICATION_INDEX = -2;
35
+ declare const BLANK_VERIFICATION: Verification;
36
+ interface Verification {
37
+ attachmentId?: string | null;
38
+ label?: string | null;
39
+ citation?: Citation;
40
+ status?: SearchStatus | null;
41
+ searchAttempts?: SearchAttempt[];
42
+ highlightColor?: string | null;
43
+ verifiedPageNumber?: number | null;
44
+ verifiedLineIds?: number[] | null;
45
+ verifiedTimestamps?: {
46
+ startTime?: string;
47
+ endTime?: string;
48
+ } | null;
49
+ verifiedFullPhrase?: string | null;
50
+ verifiedKeySpan?: string | null;
51
+ verifiedMatchSnippet?: string | null;
52
+ hitIndexWithinPage?: number | null;
53
+ pdfSpaceItem?: PdfSpaceItem;
54
+ verificationImageBase64?: string | null;
55
+ verifiedAt?: Date;
56
+ }
57
+
58
+ type OutputImageFormat = "jpeg" | "png" | "avif" | undefined | null;
59
+ declare const DEFAULT_OUTPUT_IMAGE_FORMAT: "avif";
60
+ interface VerifyCitationResponse {
61
+ verifications: {
62
+ [key: string]: Verification;
63
+ };
64
+ }
65
+ interface VerifyCitationRequest {
66
+ attachmentId: string;
67
+ citations: {
68
+ [key: string]: Citation;
69
+ };
70
+ outputImageFormat?: OutputImageFormat;
71
+ apiKey?: string;
72
+ }
73
+ interface Citation {
74
+ attachmentId?: string;
75
+ fullPhrase?: string | null;
76
+ keySpan?: string | null;
77
+ startPageKey?: string | null;
78
+ lineIds?: number[] | null;
79
+ reasoning?: string | null;
80
+ selection?: ScreenBox | null;
81
+ citationNumber?: number;
82
+ pageNumber?: number | null;
83
+ timestamps?: {
84
+ endTime?: string;
85
+ startTime?: string;
86
+ };
87
+ beforeCite?: string;
88
+ }
89
+ interface CitationStatus {
90
+ isVerified: boolean;
91
+ isMiss: boolean;
92
+ isPartialMatch: boolean;
93
+ isPending: boolean;
94
+ }
95
+
96
+ export { BLANK_VERIFICATION, type Citation, type CitationStatus, DEFAULT_OUTPUT_IMAGE_FORMAT, type IVertex, NOT_FOUND_VERIFICATION_INDEX, type OutputImageFormat, PENDING_VERIFICATION_INDEX, type PdfSpaceItem, type ScreenBox, type SearchAttempt, type SearchMethod, type SearchStatus, type Verification, type VerifyCitationRequest, type VerifyCitationResponse };
@@ -1,7 +1 @@
1
- /**
2
- * Type definitions for DeepCitation
3
- *
4
- * @packageDocumentation
5
- */
6
- export { DEFAULT_OUTPUT_IMAGE_FORMAT } from "./citation.js";
7
- export { NOT_FOUND_VERIFICATION_INDEX, PENDING_VERIFICATION_INDEX, BLANK_VERIFICATION, } from "./verification.js";
1
+ export{d as BLANK_VERIFICATION,a as DEFAULT_OUTPUT_IMAGE_FORMAT,b as NOT_FOUND_VERIFICATION_INDEX,c as PENDING_VERIFICATION_INDEX}from'../chunk-RQPZSRID.js';import'../chunk-O2XFH626.js';
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@deepcitation/deepcitation-js",
3
- "version": "1.1.26",
3
+ "version": "1.1.28",
4
4
  "description": "DeepCitation JavaScript SDK for deterministic AI citation verification",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "license": "MIT",
8
8
  "author": "DeepCitation <opensource@deepcitation.com>",
9
+ "homepage": "https://deepcitation.com",
10
+ "bugs": {
11
+ "url": "https://github.com/deepcitation/deepcitation-js/issues"
12
+ },
9
13
  "repository": {
10
14
  "type": "git",
11
- "url": "git+https://github.com/deepcitation/deepcitation-js.git",
12
- "directory": "packages/deepcitation"
15
+ "url": "git+https://github.com/deepcitation/deepcitation-js.git"
13
16
  },
14
- "main": "./lib/index.js",
17
+ "main": "./lib/index.cjs",
18
+ "module": "./lib/index.js",
15
19
  "types": "./lib/index.d.ts",
16
20
  "sideEffects": false,
17
21
  "files": [
@@ -19,17 +23,20 @@
19
23
  "LICENSE"
20
24
  ],
21
25
  "scripts": {
22
- "build": "rimraf lib && tsc",
23
- "build:watch": "rimraf lib && tsc --watch",
26
+ "build": "tsup",
27
+ "build:watch": "tsup --watch",
28
+ "build:tsc": "rimraf lib && tsc",
24
29
  "test": "bun test ./src/__tests__/*.test.ts ./src/__tests__/*.test.tsx",
25
30
  "test:jest": "jest",
26
31
  "test:watch": "jest --watch",
27
32
  "test:ct": "playwright test -c playwright-ct.config.ts",
28
33
  "test:ct:ui": "playwright test -c playwright-ct.config.ts --ui",
34
+ "size": "size-limit",
35
+ "analyze": "size-limit --why",
29
36
  "prepublishOnly": "npm run build"
30
37
  },
31
38
  "engines": {
32
- "node": ">=22"
39
+ "node": ">=18"
33
40
  },
34
41
  "peerDependencies": {
35
42
  "react": ">=17.0.0",
@@ -48,6 +55,7 @@
48
55
  }
49
56
  },
50
57
  "devDependencies": {
58
+ "@size-limit/preset-small-lib": "^11.0.0",
51
59
  "@happy-dom/global-registrator": "^20.0.11",
52
60
  "@playwright/experimental-ct-react": "^1.57.0",
53
61
  "@playwright/test": "^1.57.0",
@@ -66,20 +74,55 @@
66
74
  "react": "19.2.3",
67
75
  "react-dom": "19.2.3",
68
76
  "rimraf": "^5.0.5",
77
+ "size-limit": "^11.0.0",
69
78
  "ts-jest": "^29.4.6",
79
+ "tsup": "^8.0.0",
70
80
  "typescript": "^5.9.3",
71
81
  "vite": "^7.3.0"
72
82
  },
83
+ "size-limit": [
84
+ {
85
+ "path": "lib/index.js",
86
+ "limit": "25 KB"
87
+ },
88
+ {
89
+ "path": "lib/client/index.js",
90
+ "limit": "10 KB"
91
+ },
92
+ {
93
+ "path": "lib/prompts/index.js",
94
+ "limit": "15 KB"
95
+ },
96
+ {
97
+ "path": "lib/react/index.js",
98
+ "limit": "15 KB"
99
+ }
100
+ ],
73
101
  "exports": {
74
102
  ".": {
75
103
  "types": "./lib/index.d.ts",
76
104
  "import": "./lib/index.js",
77
- "require": "./lib/index.js"
105
+ "require": "./lib/index.cjs"
106
+ },
107
+ "./client": {
108
+ "types": "./lib/client/index.d.ts",
109
+ "import": "./lib/client/index.js",
110
+ "require": "./lib/client/index.cjs"
111
+ },
112
+ "./prompts": {
113
+ "types": "./lib/prompts/index.d.ts",
114
+ "import": "./lib/prompts/index.js",
115
+ "require": "./lib/prompts/index.cjs"
78
116
  },
79
117
  "./react": {
80
118
  "types": "./lib/react/index.d.ts",
81
119
  "import": "./lib/react/index.js",
82
- "require": "./lib/react/index.js"
120
+ "require": "./lib/react/index.cjs"
121
+ },
122
+ "./types": {
123
+ "types": "./lib/types/index.d.ts",
124
+ "import": "./lib/types/index.js",
125
+ "require": "./lib/types/index.cjs"
83
126
  }
84
127
  },
85
128
  "keywords": [
@@ -89,6 +132,15 @@
89
132
  "llm",
90
133
  "hallucination",
91
134
  "react",
92
- "typescript"
135
+ "typescript",
136
+ "openai",
137
+ "anthropic",
138
+ "claude",
139
+ "gpt",
140
+ "rag",
141
+ "reference",
142
+ "source-verification",
143
+ "fact-checking",
144
+ "grounding"
93
145
  ]
94
146
  }