docrev 0.8.1 → 0.8.5

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 (306) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/PLAN-tables-and-postprocess.md +850 -0
  3. package/README.md +33 -0
  4. package/bin/rev.js +12 -131
  5. package/bin/rev.ts +145 -0
  6. package/dist/bin/rev.d.ts +9 -0
  7. package/dist/bin/rev.d.ts.map +1 -0
  8. package/dist/bin/rev.js +118 -0
  9. package/dist/bin/rev.js.map +1 -0
  10. package/dist/lib/annotations.d.ts +91 -0
  11. package/dist/lib/annotations.d.ts.map +1 -0
  12. package/dist/lib/annotations.js +554 -0
  13. package/dist/lib/annotations.js.map +1 -0
  14. package/dist/lib/build.d.ts +171 -0
  15. package/dist/lib/build.d.ts.map +1 -0
  16. package/dist/lib/build.js +755 -0
  17. package/dist/lib/build.js.map +1 -0
  18. package/dist/lib/citations.d.ts +34 -0
  19. package/dist/lib/citations.d.ts.map +1 -0
  20. package/dist/lib/citations.js +140 -0
  21. package/dist/lib/citations.js.map +1 -0
  22. package/dist/lib/commands/build.d.ts +13 -0
  23. package/dist/lib/commands/build.d.ts.map +1 -0
  24. package/dist/lib/commands/build.js +678 -0
  25. package/dist/lib/commands/build.js.map +1 -0
  26. package/dist/lib/commands/citations.d.ts +11 -0
  27. package/dist/lib/commands/citations.d.ts.map +1 -0
  28. package/dist/lib/commands/citations.js +428 -0
  29. package/dist/lib/commands/citations.js.map +1 -0
  30. package/dist/lib/commands/comments.d.ts +11 -0
  31. package/dist/lib/commands/comments.d.ts.map +1 -0
  32. package/dist/lib/commands/comments.js +883 -0
  33. package/dist/lib/commands/comments.js.map +1 -0
  34. package/dist/lib/commands/context.d.ts +35 -0
  35. package/dist/lib/commands/context.d.ts.map +1 -0
  36. package/dist/lib/commands/context.js +59 -0
  37. package/dist/lib/commands/context.js.map +1 -0
  38. package/dist/lib/commands/core.d.ts +11 -0
  39. package/dist/lib/commands/core.d.ts.map +1 -0
  40. package/dist/lib/commands/core.js +246 -0
  41. package/dist/lib/commands/core.js.map +1 -0
  42. package/dist/lib/commands/doi.d.ts +11 -0
  43. package/dist/lib/commands/doi.d.ts.map +1 -0
  44. package/dist/lib/commands/doi.js +373 -0
  45. package/dist/lib/commands/doi.js.map +1 -0
  46. package/dist/lib/commands/history.d.ts +11 -0
  47. package/dist/lib/commands/history.d.ts.map +1 -0
  48. package/dist/lib/commands/history.js +245 -0
  49. package/dist/lib/commands/history.js.map +1 -0
  50. package/dist/lib/commands/index.d.ts +28 -0
  51. package/dist/lib/commands/index.d.ts.map +1 -0
  52. package/dist/lib/commands/index.js +35 -0
  53. package/dist/lib/commands/index.js.map +1 -0
  54. package/dist/lib/commands/init.d.ts +11 -0
  55. package/dist/lib/commands/init.d.ts.map +1 -0
  56. package/dist/lib/commands/init.js +209 -0
  57. package/dist/lib/commands/init.js.map +1 -0
  58. package/dist/lib/commands/response.d.ts +11 -0
  59. package/dist/lib/commands/response.d.ts.map +1 -0
  60. package/dist/lib/commands/response.js +317 -0
  61. package/dist/lib/commands/response.js.map +1 -0
  62. package/dist/lib/commands/sections.d.ts +11 -0
  63. package/dist/lib/commands/sections.d.ts.map +1 -0
  64. package/dist/lib/commands/sections.js +1071 -0
  65. package/dist/lib/commands/sections.js.map +1 -0
  66. package/dist/lib/commands/utilities.d.ts +19 -0
  67. package/dist/lib/commands/utilities.d.ts.map +1 -0
  68. package/dist/lib/commands/utilities.js +2009 -0
  69. package/dist/lib/commands/utilities.js.map +1 -0
  70. package/dist/lib/comment-realign.d.ts +50 -0
  71. package/dist/lib/comment-realign.d.ts.map +1 -0
  72. package/dist/lib/comment-realign.js +372 -0
  73. package/dist/lib/comment-realign.js.map +1 -0
  74. package/dist/lib/config.d.ts +41 -0
  75. package/dist/lib/config.d.ts.map +1 -0
  76. package/dist/lib/config.js +76 -0
  77. package/dist/lib/config.js.map +1 -0
  78. package/dist/lib/crossref.d.ts +108 -0
  79. package/dist/lib/crossref.d.ts.map +1 -0
  80. package/dist/lib/crossref.js +597 -0
  81. package/dist/lib/crossref.js.map +1 -0
  82. package/dist/lib/dependencies.d.ts +30 -0
  83. package/dist/lib/dependencies.d.ts.map +1 -0
  84. package/dist/lib/dependencies.js +95 -0
  85. package/dist/lib/dependencies.js.map +1 -0
  86. package/dist/lib/doi-cache.d.ts +29 -0
  87. package/dist/lib/doi-cache.d.ts.map +1 -0
  88. package/dist/lib/doi-cache.js +104 -0
  89. package/dist/lib/doi-cache.js.map +1 -0
  90. package/dist/lib/doi.d.ts +65 -0
  91. package/dist/lib/doi.d.ts.map +1 -0
  92. package/dist/lib/doi.js +710 -0
  93. package/dist/lib/doi.js.map +1 -0
  94. package/dist/lib/equations.d.ts +61 -0
  95. package/dist/lib/equations.d.ts.map +1 -0
  96. package/dist/lib/equations.js +445 -0
  97. package/dist/lib/equations.js.map +1 -0
  98. package/dist/lib/errors.d.ts +60 -0
  99. package/dist/lib/errors.d.ts.map +1 -0
  100. package/dist/lib/errors.js +303 -0
  101. package/dist/lib/errors.js.map +1 -0
  102. package/dist/lib/format.d.ts +104 -0
  103. package/dist/lib/format.d.ts.map +1 -0
  104. package/dist/lib/format.js +416 -0
  105. package/dist/lib/format.js.map +1 -0
  106. package/dist/lib/git.d.ts +88 -0
  107. package/dist/lib/git.d.ts.map +1 -0
  108. package/dist/lib/git.js +304 -0
  109. package/dist/lib/git.js.map +1 -0
  110. package/dist/lib/grammar.d.ts +62 -0
  111. package/dist/lib/grammar.d.ts.map +1 -0
  112. package/dist/lib/grammar.js +244 -0
  113. package/dist/lib/grammar.js.map +1 -0
  114. package/dist/lib/image-registry.d.ts +68 -0
  115. package/dist/lib/image-registry.d.ts.map +1 -0
  116. package/dist/lib/image-registry.js +112 -0
  117. package/dist/lib/image-registry.js.map +1 -0
  118. package/dist/lib/import.d.ts +184 -0
  119. package/dist/lib/import.d.ts.map +1 -0
  120. package/dist/lib/import.js +1581 -0
  121. package/dist/lib/import.js.map +1 -0
  122. package/dist/lib/journals.d.ts +55 -0
  123. package/dist/lib/journals.d.ts.map +1 -0
  124. package/dist/lib/journals.js +417 -0
  125. package/dist/lib/journals.js.map +1 -0
  126. package/dist/lib/merge.d.ts +138 -0
  127. package/dist/lib/merge.d.ts.map +1 -0
  128. package/dist/lib/merge.js +603 -0
  129. package/dist/lib/merge.js.map +1 -0
  130. package/dist/lib/orcid.d.ts +36 -0
  131. package/dist/lib/orcid.d.ts.map +1 -0
  132. package/dist/lib/orcid.js +117 -0
  133. package/dist/lib/orcid.js.map +1 -0
  134. package/dist/lib/pdf-comments.d.ts +95 -0
  135. package/dist/lib/pdf-comments.d.ts.map +1 -0
  136. package/dist/lib/pdf-comments.js +192 -0
  137. package/dist/lib/pdf-comments.js.map +1 -0
  138. package/dist/lib/pdf-import.d.ts +118 -0
  139. package/dist/lib/pdf-import.d.ts.map +1 -0
  140. package/dist/lib/pdf-import.js +397 -0
  141. package/dist/lib/pdf-import.js.map +1 -0
  142. package/dist/lib/plugins.d.ts +76 -0
  143. package/dist/lib/plugins.d.ts.map +1 -0
  144. package/dist/lib/plugins.js +235 -0
  145. package/dist/lib/plugins.js.map +1 -0
  146. package/dist/lib/postprocess.d.ts +42 -0
  147. package/dist/lib/postprocess.d.ts.map +1 -0
  148. package/dist/lib/postprocess.js +138 -0
  149. package/dist/lib/postprocess.js.map +1 -0
  150. package/dist/lib/pptx-template.d.ts +59 -0
  151. package/dist/lib/pptx-template.d.ts.map +1 -0
  152. package/dist/lib/pptx-template.js +613 -0
  153. package/dist/lib/pptx-template.js.map +1 -0
  154. package/dist/lib/pptx-themes.d.ts +80 -0
  155. package/dist/lib/pptx-themes.d.ts.map +1 -0
  156. package/dist/lib/pptx-themes.js +818 -0
  157. package/dist/lib/pptx-themes.js.map +1 -0
  158. package/dist/lib/protect-restore.d.ts +137 -0
  159. package/dist/lib/protect-restore.d.ts.map +1 -0
  160. package/dist/lib/protect-restore.js +394 -0
  161. package/dist/lib/protect-restore.js.map +1 -0
  162. package/dist/lib/rate-limiter.d.ts +27 -0
  163. package/dist/lib/rate-limiter.d.ts.map +1 -0
  164. package/dist/lib/rate-limiter.js +79 -0
  165. package/dist/lib/rate-limiter.js.map +1 -0
  166. package/dist/lib/response.d.ts +41 -0
  167. package/dist/lib/response.d.ts.map +1 -0
  168. package/dist/lib/response.js +150 -0
  169. package/dist/lib/response.js.map +1 -0
  170. package/dist/lib/review.d.ts +35 -0
  171. package/dist/lib/review.d.ts.map +1 -0
  172. package/dist/lib/review.js +263 -0
  173. package/dist/lib/review.js.map +1 -0
  174. package/dist/lib/schema.d.ts +66 -0
  175. package/dist/lib/schema.d.ts.map +1 -0
  176. package/dist/lib/schema.js +339 -0
  177. package/dist/lib/schema.js.map +1 -0
  178. package/dist/lib/scientific-words.d.ts +6 -0
  179. package/dist/lib/scientific-words.d.ts.map +1 -0
  180. package/dist/lib/scientific-words.js +66 -0
  181. package/dist/lib/scientific-words.js.map +1 -0
  182. package/dist/lib/sections.d.ts +40 -0
  183. package/dist/lib/sections.d.ts.map +1 -0
  184. package/dist/lib/sections.js +288 -0
  185. package/dist/lib/sections.js.map +1 -0
  186. package/dist/lib/slides.d.ts +86 -0
  187. package/dist/lib/slides.d.ts.map +1 -0
  188. package/dist/lib/slides.js +676 -0
  189. package/dist/lib/slides.js.map +1 -0
  190. package/dist/lib/spelling.d.ts +76 -0
  191. package/dist/lib/spelling.d.ts.map +1 -0
  192. package/dist/lib/spelling.js +272 -0
  193. package/dist/lib/spelling.js.map +1 -0
  194. package/dist/lib/templates.d.ts +30 -0
  195. package/dist/lib/templates.d.ts.map +1 -0
  196. package/dist/lib/templates.js +504 -0
  197. package/dist/lib/templates.js.map +1 -0
  198. package/dist/lib/themes.d.ts +85 -0
  199. package/dist/lib/themes.d.ts.map +1 -0
  200. package/dist/lib/themes.js +652 -0
  201. package/dist/lib/themes.js.map +1 -0
  202. package/dist/lib/trackchanges.d.ts +51 -0
  203. package/dist/lib/trackchanges.d.ts.map +1 -0
  204. package/dist/lib/trackchanges.js +202 -0
  205. package/dist/lib/trackchanges.js.map +1 -0
  206. package/dist/lib/tui.d.ts +76 -0
  207. package/dist/lib/tui.d.ts.map +1 -0
  208. package/dist/lib/tui.js +377 -0
  209. package/dist/lib/tui.js.map +1 -0
  210. package/dist/lib/types.d.ts +447 -0
  211. package/dist/lib/types.d.ts.map +1 -0
  212. package/dist/lib/types.js +6 -0
  213. package/dist/lib/types.js.map +1 -0
  214. package/dist/lib/undo.d.ts +57 -0
  215. package/dist/lib/undo.d.ts.map +1 -0
  216. package/dist/lib/undo.js +185 -0
  217. package/dist/lib/undo.js.map +1 -0
  218. package/dist/lib/utils.d.ts +16 -0
  219. package/dist/lib/utils.d.ts.map +1 -0
  220. package/dist/lib/utils.js +40 -0
  221. package/dist/lib/utils.js.map +1 -0
  222. package/dist/lib/variables.d.ts +42 -0
  223. package/dist/lib/variables.d.ts.map +1 -0
  224. package/dist/lib/variables.js +141 -0
  225. package/dist/lib/variables.js.map +1 -0
  226. package/dist/lib/word.d.ts +80 -0
  227. package/dist/lib/word.d.ts.map +1 -0
  228. package/dist/lib/word.js +360 -0
  229. package/dist/lib/word.js.map +1 -0
  230. package/dist/lib/wordcomments.d.ts +51 -0
  231. package/dist/lib/wordcomments.d.ts.map +1 -0
  232. package/dist/lib/wordcomments.js +587 -0
  233. package/dist/lib/wordcomments.js.map +1 -0
  234. package/eslint.config.js +27 -0
  235. package/lib/annotations.ts +622 -0
  236. package/lib/apply-buildup-colors.py +88 -0
  237. package/lib/build.ts +1013 -0
  238. package/lib/{citations.js → citations.ts} +38 -27
  239. package/lib/commands/{build.js → build.ts} +80 -27
  240. package/lib/commands/{citations.js → citations.ts} +36 -18
  241. package/lib/commands/{comments.js → comments.ts} +187 -54
  242. package/lib/commands/{context.js → context.ts} +18 -8
  243. package/lib/commands/{core.js → core.ts} +34 -20
  244. package/lib/commands/{doi.js → doi.ts} +32 -16
  245. package/lib/commands/{history.js → history.ts} +25 -12
  246. package/lib/commands/{index.js → index.ts} +9 -5
  247. package/lib/commands/{init.js → init.ts} +20 -8
  248. package/lib/commands/{response.js → response.ts} +47 -20
  249. package/lib/commands/{sections.js → sections.ts} +273 -68
  250. package/lib/commands/{utilities.js → utilities.ts} +338 -158
  251. package/lib/{comment-realign.js → comment-realign.ts} +117 -45
  252. package/lib/config.ts +84 -0
  253. package/lib/{crossref.js → crossref.ts} +213 -138
  254. package/lib/dependencies.ts +106 -0
  255. package/lib/doi-cache.ts +115 -0
  256. package/lib/{doi.js → doi.ts} +115 -281
  257. package/lib/{equations.js → equations.ts} +60 -64
  258. package/lib/{errors.js → errors.ts} +56 -48
  259. package/lib/{format.js → format.ts} +137 -63
  260. package/lib/{git.js → git.ts} +66 -63
  261. package/lib/{grammar.js → grammar.ts} +45 -32
  262. package/lib/image-registry.ts +180 -0
  263. package/lib/import.ts +2060 -0
  264. package/lib/journals.ts +505 -0
  265. package/lib/{merge.js → merge.ts} +185 -135
  266. package/lib/{orcid.js → orcid.ts} +17 -22
  267. package/lib/{pdf-comments.js → pdf-comments.ts} +76 -18
  268. package/lib/{pdf-import.js → pdf-import.ts} +148 -70
  269. package/lib/{plugins.js → plugins.ts} +82 -39
  270. package/lib/postprocess.ts +188 -0
  271. package/lib/pptx-color-filter.lua +37 -0
  272. package/lib/pptx-template.ts +625 -0
  273. package/lib/pptx-themes/academic.pptx +0 -0
  274. package/lib/pptx-themes/corporate.pptx +0 -0
  275. package/lib/pptx-themes/dark.pptx +0 -0
  276. package/lib/pptx-themes/default.pptx +0 -0
  277. package/lib/pptx-themes/minimal.pptx +0 -0
  278. package/lib/pptx-themes/plant.pptx +0 -0
  279. package/lib/pptx-themes.ts +896 -0
  280. package/lib/protect-restore.ts +516 -0
  281. package/lib/rate-limiter.ts +94 -0
  282. package/lib/{response.js → response.ts} +36 -21
  283. package/lib/{review.js → review.ts} +53 -43
  284. package/lib/{schema.js → schema.ts} +70 -25
  285. package/lib/{sections.js → sections.ts} +71 -76
  286. package/lib/slides.ts +793 -0
  287. package/lib/{spelling.js → spelling.ts} +43 -59
  288. package/lib/{templates.js → templates.ts} +20 -17
  289. package/lib/themes.ts +742 -0
  290. package/lib/{trackchanges.js → trackchanges.ts} +52 -23
  291. package/lib/types.ts +509 -0
  292. package/lib/{undo.js → undo.ts} +75 -52
  293. package/lib/utils.ts +41 -0
  294. package/lib/{variables.js → variables.ts} +60 -54
  295. package/lib/word.ts +428 -0
  296. package/lib/{wordcomments.js → wordcomments.ts} +94 -40
  297. package/package.json +15 -5
  298. package/skill/REFERENCE.md +67 -0
  299. package/tsconfig.json +26 -0
  300. package/lib/annotations.js +0 -414
  301. package/lib/build.js +0 -639
  302. package/lib/config.js +0 -79
  303. package/lib/import.js +0 -1145
  304. package/lib/journals.js +0 -629
  305. package/lib/word.js +0 -225
  306. /package/lib/{scientific-words.js → scientific-words.ts} +0 -0
@@ -8,11 +8,31 @@ import * as fs from 'fs';
8
8
  import * as path from 'path';
9
9
  import { execSync } from 'child_process';
10
10
  import AdmZip from 'adm-zip';
11
+ import type { TrackChangeMarker } from './types.js';
12
+
13
+ interface PrepareOptions {
14
+ author?: string;
15
+ }
16
+
17
+ interface PrepareResult {
18
+ text: string;
19
+ markers: TrackChangeMarker[];
20
+ }
21
+
22
+ interface ApplyResult {
23
+ success: boolean;
24
+ message: string;
25
+ stats?: {
26
+ insertions: number;
27
+ deletions: number;
28
+ substitutions: number;
29
+ };
30
+ }
11
31
 
12
32
  /**
13
33
  * Escape XML special characters
14
34
  */
15
- function escapeXml(str) {
35
+ function escapeXml(str: string): string {
16
36
  return str
17
37
  .replace(/&/g, '&')
18
38
  .replace(/</g, '&lt;')
@@ -25,14 +45,13 @@ function escapeXml(str) {
25
45
  * Prepare text with CriticMarkup annotations for track changes
26
46
  * Replaces annotations with markers that can be processed in DOCX
27
47
  *
28
- * @param {string} text - Text with CriticMarkup annotations
29
- * @param {object} options - Options
30
- * @param {string} options.author - Default author for track changes
31
- * @returns {{text: string, markers: Array}} Processed text and marker info
48
+ * @param text - Text with CriticMarkup annotations
49
+ * @param options - Options
50
+ * @returns Processed text and marker info
32
51
  */
33
- export function prepareForTrackChanges(text, options = {}) {
52
+ export function prepareForTrackChanges(text: string, options: PrepareOptions = {}): PrepareResult {
34
53
  const { author = 'Reviewer' } = options;
35
- const markers = [];
54
+ const markers: TrackChangeMarker[] = [];
36
55
  let markerId = 0;
37
56
 
38
57
  let result = text;
@@ -100,21 +119,26 @@ export function prepareForTrackChanges(text, options = {}) {
100
119
  /**
101
120
  * Apply track changes markers to a Word document
102
121
  *
103
- * @param {string} docxPath - Path to input DOCX file
104
- * @param {Array} markers - Markers from prepareForTrackChanges
105
- * @param {string} outputPath - Path for output DOCX file
106
- * @returns {Promise<{success: boolean, message: string}>}
122
+ * @param docxPath - Path to input DOCX file
123
+ * @param markers - Markers from prepareForTrackChanges
124
+ * @param outputPath - Path for output DOCX file
125
+ * @returns Result with success status and message
107
126
  */
108
- export async function applyTrackChangesToDocx(docxPath, markers, outputPath) {
127
+ export async function applyTrackChangesToDocx(
128
+ docxPath: string,
129
+ markers: TrackChangeMarker[],
130
+ outputPath: string
131
+ ): Promise<ApplyResult> {
109
132
  if (!fs.existsSync(docxPath)) {
110
133
  return { success: false, message: `File not found: ${docxPath}` };
111
134
  }
112
135
 
113
- let zip;
136
+ let zip: AdmZip;
114
137
  try {
115
138
  zip = new AdmZip(docxPath);
116
139
  } catch (err) {
117
- return { success: false, message: `Invalid DOCX file: ${err.message}` };
140
+ const error = err as Error;
141
+ return { success: false, message: `Invalid DOCX file: ${error.message}` };
118
142
  }
119
143
 
120
144
  // Read document.xml
@@ -141,7 +165,7 @@ export async function applyTrackChangesToDocx(docxPath, markers, outputPath) {
141
165
  } else if (marker.type === 'delete') {
142
166
  replacement = `<w:del w:id="${marker.id}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:delText>${escapedContent}</w:delText></w:r></w:del>`;
143
167
  } else if (marker.type === 'substitute') {
144
- const escapedReplacement = escapeXml(marker.replacement);
168
+ const escapedReplacement = escapeXml(marker.replacement || '');
145
169
  replacement = `<w:del w:id="${marker.id}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:delText>${escapedContent}</w:delText></w:r></w:del><w:ins w:id="${marker.id + 1000}" w:author="${escapedAuthor}" w:date="${now}"><w:r><w:t>${escapedReplacement}</w:t></w:r></w:ins>`;
146
170
  }
147
171
 
@@ -173,13 +197,16 @@ export async function applyTrackChangesToDocx(docxPath, markers, outputPath) {
173
197
  /**
174
198
  * Build a Word document with track changes from annotated markdown
175
199
  *
176
- * @param {string} mdPath - Path to markdown file with CriticMarkup
177
- * @param {string} docxPath - Output path for Word document
178
- * @param {object} options - Options
179
- * @param {string} options.author - Author name for track changes
180
- * @returns {Promise<{success: boolean, message: string}>}
200
+ * @param mdPath - Path to markdown file with CriticMarkup
201
+ * @param docxPath - Output path for Word document
202
+ * @param options - Options
203
+ * @returns Result with success status and message
181
204
  */
182
- export async function buildWithTrackChanges(mdPath, docxPath, options = {}) {
205
+ export async function buildWithTrackChanges(
206
+ mdPath: string,
207
+ docxPath: string,
208
+ options: PrepareOptions = {}
209
+ ): Promise<ApplyResult> {
183
210
  const { author = 'Author' } = options;
184
211
 
185
212
  if (!fs.existsSync(mdPath)) {
@@ -197,7 +224,8 @@ export async function buildWithTrackChanges(mdPath, docxPath, options = {}) {
197
224
  execSync(`pandoc "${mdPath}" -o "${docxPath}"`, { encoding: 'utf-8' });
198
225
  return { success: true, message: `Created ${docxPath}` };
199
226
  } catch (err) {
200
- return { success: false, message: err.message };
227
+ const error = err as Error;
228
+ return { success: false, message: error.message };
201
229
  }
202
230
  }
203
231
 
@@ -224,6 +252,7 @@ export async function buildWithTrackChanges(mdPath, docxPath, options = {}) {
224
252
  // Clean up on error
225
253
  if (fs.existsSync(tempMd)) fs.unlinkSync(tempMd);
226
254
  if (fs.existsSync(tempDocx)) fs.unlinkSync(tempDocx);
227
- return { success: false, message: err.message };
255
+ const error = err as Error;
256
+ return { success: false, message: error.message };
228
257
  }
229
258
  }
package/lib/types.ts ADDED
@@ -0,0 +1,509 @@
1
+ /**
2
+ * Shared TypeScript type definitions for docrev
3
+ * Extracted from types/index.d.ts for internal use
4
+ */
5
+
6
+ // ============================================
7
+ // Annotations
8
+ // ============================================
9
+
10
+ export interface Annotation {
11
+ type: 'insert' | 'delete' | 'substitute' | 'comment' | 'highlight';
12
+ match: string;
13
+ content: string;
14
+ replacement?: string;
15
+ author?: string;
16
+ position: number;
17
+ line: number;
18
+ before?: string;
19
+ after?: string;
20
+ resolved?: boolean;
21
+ }
22
+
23
+ export interface Comment extends Annotation {
24
+ type: 'comment';
25
+ author: string;
26
+ resolved: boolean;
27
+ }
28
+
29
+ export interface AnnotationCounts {
30
+ inserts: number;
31
+ deletes: number;
32
+ substitutes: number;
33
+ comments: number;
34
+ total: number;
35
+ }
36
+
37
+ export interface StripOptions {
38
+ keepComments?: boolean;
39
+ }
40
+
41
+ export interface CommentFilterOptions {
42
+ pendingOnly?: boolean;
43
+ resolvedOnly?: boolean;
44
+ }
45
+
46
+ // ============================================
47
+ // Build
48
+ // ============================================
49
+
50
+ export interface Author {
51
+ name: string;
52
+ affiliation?: string;
53
+ email?: string;
54
+ orcid?: string;
55
+ }
56
+
57
+ export interface CrossrefConfig {
58
+ figureTitle?: string;
59
+ tableTitle?: string;
60
+ figPrefix?: string | string[];
61
+ tblPrefix?: string | string[];
62
+ }
63
+
64
+ export interface PdfConfig {
65
+ documentclass?: string;
66
+ fontsize?: string;
67
+ geometry?: string;
68
+ linestretch?: number;
69
+ toc?: boolean;
70
+ }
71
+
72
+ export interface DocxConfig {
73
+ reference?: string;
74
+ keepComments?: boolean;
75
+ toc?: boolean;
76
+ }
77
+
78
+ export interface BuildConfig {
79
+ title?: string;
80
+ authors?: Author[];
81
+ sections?: string[];
82
+ bibliography?: string;
83
+ csl?: string;
84
+ crossref?: CrossrefConfig;
85
+ pdf?: PdfConfig;
86
+ docx?: DocxConfig;
87
+ postprocess?: { [key: string]: string };
88
+ _configPath?: string;
89
+ [key: string]: unknown;
90
+ }
91
+
92
+ export interface BuildResult {
93
+ format: string;
94
+ output: string;
95
+ success: boolean;
96
+ error?: string;
97
+ }
98
+
99
+ // ============================================
100
+ // Citations
101
+ // ============================================
102
+
103
+ export interface Citation {
104
+ key: string;
105
+ line: number;
106
+ file: string;
107
+ }
108
+
109
+ export interface CitationValidation {
110
+ valid: Citation[];
111
+ missing: Citation[];
112
+ unused: string[];
113
+ duplicates: Array<{ key: string; count: number; locations: Citation[] }>;
114
+ }
115
+
116
+ export interface CitationStats {
117
+ totalCitations: number;
118
+ uniqueCited: number;
119
+ valid: number;
120
+ missing: number;
121
+ missingKeys: string[];
122
+ bibEntries: number;
123
+ unused: number;
124
+ unusedKeys: string[];
125
+ }
126
+
127
+ // ============================================
128
+ // Crossref
129
+ // ============================================
130
+
131
+ export interface RefNumber {
132
+ num: number;
133
+ isSupp: boolean;
134
+ suffix: string | null;
135
+ }
136
+
137
+ export interface HardcodedRef {
138
+ type: 'fig' | 'tbl' | 'eq';
139
+ match: string;
140
+ numbers: RefNumber[];
141
+ position: number;
142
+ }
143
+
144
+ export interface DynamicRef {
145
+ type: 'fig' | 'tbl' | 'eq';
146
+ label: string;
147
+ match: string;
148
+ position: number;
149
+ }
150
+
151
+ export interface FigureInfo {
152
+ label: string;
153
+ num: number;
154
+ isSupp: boolean;
155
+ file: string;
156
+ }
157
+
158
+ export interface Registry {
159
+ figures: Map<string, FigureInfo>;
160
+ tables: Map<string, FigureInfo>;
161
+ equations: Map<string, FigureInfo>;
162
+ byNumber: {
163
+ fig: Map<number, string>;
164
+ figS: Map<number, string>;
165
+ tbl: Map<number, string>;
166
+ tblS: Map<number, string>;
167
+ eq: Map<number, string>;
168
+ };
169
+ }
170
+
171
+ export interface RefStatus {
172
+ dynamic: DynamicRef[];
173
+ hardcoded: HardcodedRef[];
174
+ anchors: { figures: number; tables: number; equations: number };
175
+ }
176
+
177
+ export interface ConversionResult {
178
+ converted: string;
179
+ conversions: Array<{ from: string; to: string }>;
180
+ warnings: string[];
181
+ }
182
+
183
+ // ============================================
184
+ // DOI
185
+ // ============================================
186
+
187
+ export interface BibEntry {
188
+ key: string;
189
+ type: string;
190
+ doi: string | null;
191
+ title: string;
192
+ authorRaw: string;
193
+ year: number | null;
194
+ journal: string;
195
+ skip: boolean;
196
+ expectDoi: boolean;
197
+ noDoi: boolean;
198
+ line: number;
199
+ }
200
+
201
+ export interface DoiCheckResult {
202
+ valid: boolean;
203
+ source?: 'crossref' | 'datacite';
204
+ metadata?: {
205
+ title: string;
206
+ authors: string[];
207
+ year: number;
208
+ journal: string;
209
+ type?: string;
210
+ };
211
+ error?: string;
212
+ }
213
+
214
+ export interface BibtexFetchResult {
215
+ success: boolean;
216
+ bibtex?: string;
217
+ error?: string;
218
+ }
219
+
220
+ export interface DoiLookupResult {
221
+ found: boolean;
222
+ doi?: string;
223
+ confidence?: 'low' | 'medium' | 'high';
224
+ score?: number;
225
+ metadata?: {
226
+ title: string;
227
+ authors: string[];
228
+ year: number;
229
+ journal: string;
230
+ };
231
+ alternatives?: Array<{
232
+ doi: string;
233
+ title: string;
234
+ score: number;
235
+ }>;
236
+ error?: string;
237
+ }
238
+
239
+ export interface BibCheckResult {
240
+ entries: Array<BibEntry & { status: string; message?: string; metadata?: object }>;
241
+ valid: number;
242
+ invalid: number;
243
+ missing: number;
244
+ skipped: number;
245
+ }
246
+
247
+ // ============================================
248
+ // Equations
249
+ // ============================================
250
+
251
+ export interface Equation {
252
+ type: 'inline' | 'display';
253
+ content: string;
254
+ line: number;
255
+ file: string;
256
+ }
257
+
258
+ export interface EquationStats {
259
+ total: number;
260
+ display: number;
261
+ inline: number;
262
+ byFile: Array<{ file: string; display: number; inline: number }>;
263
+ }
264
+
265
+ export interface WordEquationResult {
266
+ success: boolean;
267
+ equations: Array<{
268
+ type: 'inline' | 'display' | 'unknown';
269
+ latex: string | null;
270
+ position: number;
271
+ line?: number;
272
+ raw?: string;
273
+ error?: string;
274
+ }>;
275
+ error?: string;
276
+ }
277
+
278
+ // ============================================
279
+ // Git
280
+ // ============================================
281
+
282
+ export interface FileChange {
283
+ added: number;
284
+ removed: number;
285
+ changes: Array<{ added?: boolean; removed?: boolean; value: string }>;
286
+ }
287
+
288
+ export interface CommitInfo {
289
+ hash: string;
290
+ date: string;
291
+ author: string;
292
+ message: string;
293
+ }
294
+
295
+ export interface ChangedFile {
296
+ file: string;
297
+ status: 'added' | 'deleted' | 'modified';
298
+ }
299
+
300
+ export interface BlameEntry {
301
+ line: number;
302
+ author: string;
303
+ date: string;
304
+ hash: string;
305
+ content: string;
306
+ }
307
+
308
+ export interface AuthorStats {
309
+ lines: number;
310
+ percentage: number;
311
+ }
312
+
313
+ export interface ContributorStats {
314
+ lines: number;
315
+ files: number;
316
+ }
317
+
318
+ // ============================================
319
+ // Journals
320
+ // ============================================
321
+
322
+ export interface JournalRequirements {
323
+ wordLimit?: { main?: number; abstract?: number };
324
+ references?: { max?: number; doiRequired?: boolean };
325
+ figures?: { max?: number };
326
+ tables?: { max?: number };
327
+ sections?: string[];
328
+ formatting?: object;
329
+ }
330
+
331
+ export interface JournalProfile {
332
+ name: string;
333
+ url: string;
334
+ requirements: JournalRequirements;
335
+ }
336
+
337
+ export interface ValidationResult {
338
+ journal: string;
339
+ valid: boolean;
340
+ wordCount: { main: number; abstract: number; limit: { main: number; abstract: number } };
341
+ figures: { count: number; max: number };
342
+ tables: { count: number; max: number };
343
+ references: { count: number; max: number };
344
+ sections: { found: string[]; missing: string[]; required: string[] };
345
+ errors: string[];
346
+ warnings: string[];
347
+ }
348
+
349
+ // ============================================
350
+ // Merge
351
+ // ============================================
352
+
353
+ export interface ReviewerChange {
354
+ reviewer: string;
355
+ type: 'insert' | 'delete' | 'replace';
356
+ start: number;
357
+ end: number;
358
+ oldText: string;
359
+ newText: string;
360
+ }
361
+
362
+ export interface Conflict {
363
+ id: string;
364
+ start: number;
365
+ end: number;
366
+ original: string;
367
+ changes: ReviewerChange[];
368
+ section?: string;
369
+ line?: number;
370
+ resolved: string | null;
371
+ }
372
+
373
+ export interface MergeResult {
374
+ merged: string;
375
+ conflicts: Conflict[];
376
+ stats: {
377
+ reviewers: number;
378
+ totalChanges: number;
379
+ nonConflicting: number;
380
+ conflicts: number;
381
+ comments: number;
382
+ };
383
+ originalText: string;
384
+ }
385
+
386
+ // ============================================
387
+ // Sections
388
+ // ============================================
389
+
390
+ export interface SectionConfig {
391
+ header: string;
392
+ aliases?: string[];
393
+ order?: number;
394
+ }
395
+
396
+ export interface SectionsConfig {
397
+ version: number;
398
+ description?: string;
399
+ sections: Record<string, SectionConfig>;
400
+ }
401
+
402
+ export interface ExtractedSection {
403
+ file: string;
404
+ header: string;
405
+ content: string;
406
+ matched: boolean;
407
+ }
408
+
409
+ // ============================================
410
+ // Word
411
+ // ============================================
412
+
413
+ export interface WordComment {
414
+ id: string;
415
+ author: string;
416
+ date?: string;
417
+ text: string;
418
+ }
419
+
420
+ export interface WordMetadata {
421
+ title?: string;
422
+ author?: string;
423
+ created?: string;
424
+ modified?: string;
425
+ }
426
+
427
+ export interface CommentAnchor {
428
+ text: string;
429
+ context: string;
430
+ }
431
+
432
+ export interface WordContent {
433
+ text: string;
434
+ html: string;
435
+ }
436
+
437
+ export interface TrackChangesResult {
438
+ hasTrackChanges: boolean;
439
+ content: string | null;
440
+ stats: { insertions: number; deletions: number };
441
+ }
442
+
443
+ // ============================================
444
+ // TrackChanges
445
+ // ============================================
446
+
447
+ export interface TrackChangeMarker {
448
+ id: number;
449
+ type: 'insert' | 'delete' | 'substitute' | 'comment';
450
+ content: string;
451
+ author: string;
452
+ replacement?: string;
453
+ }
454
+
455
+ // ============================================
456
+ // Spelling
457
+ // ============================================
458
+
459
+ export interface SpellingIssue {
460
+ word: string;
461
+ line: number;
462
+ column: number;
463
+ file?: string;
464
+ suggestions?: string[];
465
+ }
466
+
467
+ export interface SpellingResult {
468
+ misspelled: SpellingIssue[];
469
+ possibleNames: SpellingIssue[];
470
+ }
471
+
472
+ // ============================================
473
+ // Config
474
+ // ============================================
475
+
476
+ export interface UserConfig {
477
+ userName?: string;
478
+ defaultSections?: string[];
479
+ }
480
+
481
+ // ============================================
482
+ // DOI Cache
483
+ // ============================================
484
+
485
+ export interface DoiCacheEntry {
486
+ result: DoiCheckResult | DoiLookupResult;
487
+ timestamp: number;
488
+ }
489
+
490
+ export interface DoiCache {
491
+ entries: Record<string, DoiCacheEntry>;
492
+ version: number;
493
+ }
494
+
495
+ export interface DoiCacheStats {
496
+ size: number;
497
+ path: string;
498
+ }
499
+
500
+ // ============================================
501
+ // Errors
502
+ // ============================================
503
+
504
+ export interface ErrorInfo {
505
+ code: string;
506
+ message: string;
507
+ help?: string;
508
+ cause?: Error;
509
+ }