@adeu/core 1.6.2

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.
@@ -0,0 +1,247 @@
1
+ import JSZip from 'jszip';
2
+
3
+ declare class Relationship {
4
+ id: string;
5
+ type: string;
6
+ target: string;
7
+ isExternal: boolean;
8
+ constructor(id: string, type: string, target: string, isExternal: boolean);
9
+ }
10
+ declare class Part {
11
+ partname: string;
12
+ blob: string;
13
+ contentType: string;
14
+ rels: Map<string, Relationship>;
15
+ _element: Element;
16
+ constructor(partname: string, blob: string, element: Element, contentType: string);
17
+ addRelationship(id: string, type: string, target: string, isExternal?: boolean): void;
18
+ }
19
+ declare class DocxPackage {
20
+ zip: JSZip;
21
+ parts: Part[];
22
+ mainDocumentPart: Part;
23
+ constructor(zip: JSZip);
24
+ getPartByPath(path: string): Part | undefined;
25
+ nextPartname(pattern: string): string;
26
+ addPart(partname: string, contentType: string, xmlString: string): Part;
27
+ getOrCreateRelsPart(sourcePartname: string): Part;
28
+ }
29
+ declare class DocumentObject {
30
+ pkg: DocxPackage;
31
+ part: Part;
32
+ settings: {
33
+ oddAndEvenPagesHeaderFooter: boolean;
34
+ };
35
+ sections: any[];
36
+ constructor(pkg: DocxPackage, part: Part);
37
+ get element(): Element;
38
+ /**
39
+ * Main entrypoint for loading a DOCX buffer into the DOM wrapper.
40
+ */
41
+ static load(buffer: Buffer | ArrayBuffer): Promise<DocumentObject>;
42
+ relateTo(part: Part, relType: string): void;
43
+ save(): Promise<Buffer>;
44
+ }
45
+
46
+ declare class Paragraph {
47
+ _element: Element;
48
+ _parent: any;
49
+ constructor(_element: Element, _parent: any);
50
+ get text(): string;
51
+ }
52
+ declare class Run {
53
+ _element: Element;
54
+ _parent: any;
55
+ constructor(_element: Element, _parent: any);
56
+ }
57
+
58
+ declare function extractTextFromBuffer(buffer: Buffer, cleanView?: boolean): Promise<string>;
59
+
60
+ interface TextSpan {
61
+ start: number;
62
+ end: number;
63
+ text: string;
64
+ run: Run | null;
65
+ paragraph: Paragraph | null;
66
+ ins_id?: string | null;
67
+ del_id?: string | null;
68
+ hyperlink_id?: string | null;
69
+ }
70
+ declare class DocumentMapper {
71
+ doc: DocumentObject;
72
+ clean_view: boolean;
73
+ comments_map: Record<string, any>;
74
+ full_text: string;
75
+ spans: TextSpan[];
76
+ appendix_start_index: number;
77
+ private _text_chunks;
78
+ constructor(doc: DocumentObject, clean_view?: boolean);
79
+ private _build_map;
80
+ private _map_blocks;
81
+ private _map_table;
82
+ private _strip_markdown_formatting;
83
+ private _map_paragraph_content;
84
+ private _get_wrappers;
85
+ private _build_merged_meta_block;
86
+ private _add_virtual_text;
87
+ private _replace_smart_quotes;
88
+ private _make_fuzzy_regex;
89
+ find_match_index(target_text: string): [number, number];
90
+ find_all_match_indices(target_text: string): [number, number][];
91
+ find_target_runs(target_text: string): Run[];
92
+ find_target_runs_by_index(start_index: number, length: number, rebuild_map?: boolean): Run[];
93
+ get_virtual_spans_in_range(start_index: number, length: number): TextSpan[];
94
+ private _resolve_runs_at_range;
95
+ get_insertion_anchor(index: number, rebuild_map?: boolean): [Run | null, Paragraph | null];
96
+ private _split_run_at_index;
97
+ private _set_run_text_elements;
98
+ get_context_at_range(start_idx: number, end_idx: number): TextSpan | null;
99
+ }
100
+
101
+ declare class CommentsManager {
102
+ doc: DocumentObject;
103
+ private _commentsPart;
104
+ private _extendedPart;
105
+ private _idsPart;
106
+ private _extensiblePart;
107
+ private _nextId;
108
+ constructor(doc: DocumentObject);
109
+ get commentsPart(): Part;
110
+ get extendedPart(): Part;
111
+ get idsPart(): Part;
112
+ get extensiblePart(): Part;
113
+ get nextId(): number;
114
+ set nextId(value: number);
115
+ private _getExistingPartByType;
116
+ private _linkPart;
117
+ private _getOrCreateCommentsPart;
118
+ private _getOrCreateExtendedPart;
119
+ private _getOrCreateIdsPart;
120
+ private _getOrCreateExtensiblePart;
121
+ private _ensureNamespaces;
122
+ private _getNextCommentId;
123
+ private _generateHexId;
124
+ private _getInitials;
125
+ private _findParaIdForComment;
126
+ private _findThreadRootParaId;
127
+ addComment(author: string, text: string, parentId?: string | null): string;
128
+ deleteComment(commentId: string): void;
129
+ }
130
+
131
+ interface ModifyText {
132
+ type: 'modify';
133
+ target_text: string;
134
+ new_text: string;
135
+ comment?: string | null;
136
+ _match_start_index?: number | null;
137
+ _internal_op?: string | null;
138
+ _active_mapper_ref?: any | null;
139
+ _original_target_text?: string;
140
+ _is_table_edit?: boolean;
141
+ }
142
+ interface AcceptChange {
143
+ type: 'accept';
144
+ target_id: string;
145
+ comment?: string | null;
146
+ }
147
+ interface RejectChange {
148
+ type: 'reject';
149
+ target_id: string;
150
+ comment?: string | null;
151
+ }
152
+ interface ReplyComment {
153
+ type: 'reply';
154
+ target_id: string;
155
+ text: string;
156
+ }
157
+ interface InsertTableRow {
158
+ type: 'insert_row';
159
+ target_text: string;
160
+ position: 'above' | 'below';
161
+ cells: string[];
162
+ _match_start_index?: number | null;
163
+ }
164
+ interface DeleteTableRow {
165
+ type: 'delete_row';
166
+ target_text: string;
167
+ _match_start_index?: number | null;
168
+ }
169
+ type DocumentChange = ModifyText | AcceptChange | RejectChange | ReplyComment | InsertTableRow | DeleteTableRow;
170
+
171
+ declare class BatchValidationError extends Error {
172
+ errors: string[];
173
+ constructor(errors: string[]);
174
+ }
175
+ declare class RedlineEngine {
176
+ doc: DocumentObject;
177
+ author: string;
178
+ timestamp: string;
179
+ current_id: number;
180
+ mapper: DocumentMapper;
181
+ comments_manager: CommentsManager;
182
+ clean_mapper: DocumentMapper | null;
183
+ skipped_details: string[];
184
+ constructor(doc: DocumentObject, author?: string);
185
+ private _scan_existing_ids;
186
+ accept_all_revisions(): void;
187
+ private _getNextId;
188
+ private _create_track_change_tag;
189
+ private _set_text_content;
190
+ private _parse_markdown_style;
191
+ private _parse_inline_markdown;
192
+ private _apply_run_props;
193
+ validate_edits(edits: any[]): string[];
194
+ process_batch(changes: DocumentChange[]): any;
195
+ apply_edits(edits: any[]): [number, number];
196
+ apply_review_actions(actions: any[]): [number, number];
197
+ private _apply_table_edit;
198
+ private _pre_resolve_heuristic_edit;
199
+ private _apply_single_edit_indexed;
200
+ }
201
+
202
+ declare function trim_common_context(target: string, new_val: string): [number, number];
203
+ declare function generate_edits_from_text(original_text: string, modified_text: string): ModifyText[];
204
+
205
+ declare function apply_edits_to_markdown(markdown_text: string, edits: ModifyText[], include_index?: boolean, highlight_only?: boolean): string;
206
+
207
+ /**
208
+ * Stateless paginator for projected DOCX Markdown.
209
+ */
210
+ interface PageInfo {
211
+ page: number;
212
+ total_pages: number;
213
+ has_next: boolean;
214
+ has_prev: boolean;
215
+ tracked_change_count: number;
216
+ page_content: string;
217
+ }
218
+ interface PaginationResult {
219
+ pages: PageInfo[];
220
+ total_pages: number;
221
+ body_pages: string[];
222
+ body_page_offsets: number[];
223
+ }
224
+ declare function split_structural_appendix(markdown: string): [string, string];
225
+ declare function paginate(markdown_body: string, structural_appendix?: string): PaginationResult;
226
+
227
+ /**
228
+ * Structural outline extractor.
229
+ */
230
+
231
+ interface OutlineNode {
232
+ level: number;
233
+ text: string;
234
+ page: number;
235
+ style: string;
236
+ has_table: boolean;
237
+ footnote_ids: string[];
238
+ }
239
+ declare function extract_outline(doc: DocumentObject, projected_body: string, body_pages: string[], body_page_offsets: number[], paragraph_offsets?: Record<string, [number, number]> | null): OutlineNode[];
240
+
241
+ /**
242
+ * @adeu/core
243
+ * Cross-platform XML Redlining Engine
244
+ */
245
+ declare const identifyEngine: () => string;
246
+
247
+ export { BatchValidationError, DocumentMapper, DocumentObject, type OutlineNode, type PageInfo, type PaginationResult, RedlineEngine, type TextSpan, apply_edits_to_markdown, extractTextFromBuffer, extract_outline, generate_edits_from_text, identifyEngine, paginate, split_structural_appendix, trim_common_context };
@@ -0,0 +1,247 @@
1
+ import JSZip from 'jszip';
2
+
3
+ declare class Relationship {
4
+ id: string;
5
+ type: string;
6
+ target: string;
7
+ isExternal: boolean;
8
+ constructor(id: string, type: string, target: string, isExternal: boolean);
9
+ }
10
+ declare class Part {
11
+ partname: string;
12
+ blob: string;
13
+ contentType: string;
14
+ rels: Map<string, Relationship>;
15
+ _element: Element;
16
+ constructor(partname: string, blob: string, element: Element, contentType: string);
17
+ addRelationship(id: string, type: string, target: string, isExternal?: boolean): void;
18
+ }
19
+ declare class DocxPackage {
20
+ zip: JSZip;
21
+ parts: Part[];
22
+ mainDocumentPart: Part;
23
+ constructor(zip: JSZip);
24
+ getPartByPath(path: string): Part | undefined;
25
+ nextPartname(pattern: string): string;
26
+ addPart(partname: string, contentType: string, xmlString: string): Part;
27
+ getOrCreateRelsPart(sourcePartname: string): Part;
28
+ }
29
+ declare class DocumentObject {
30
+ pkg: DocxPackage;
31
+ part: Part;
32
+ settings: {
33
+ oddAndEvenPagesHeaderFooter: boolean;
34
+ };
35
+ sections: any[];
36
+ constructor(pkg: DocxPackage, part: Part);
37
+ get element(): Element;
38
+ /**
39
+ * Main entrypoint for loading a DOCX buffer into the DOM wrapper.
40
+ */
41
+ static load(buffer: Buffer | ArrayBuffer): Promise<DocumentObject>;
42
+ relateTo(part: Part, relType: string): void;
43
+ save(): Promise<Buffer>;
44
+ }
45
+
46
+ declare class Paragraph {
47
+ _element: Element;
48
+ _parent: any;
49
+ constructor(_element: Element, _parent: any);
50
+ get text(): string;
51
+ }
52
+ declare class Run {
53
+ _element: Element;
54
+ _parent: any;
55
+ constructor(_element: Element, _parent: any);
56
+ }
57
+
58
+ declare function extractTextFromBuffer(buffer: Buffer, cleanView?: boolean): Promise<string>;
59
+
60
+ interface TextSpan {
61
+ start: number;
62
+ end: number;
63
+ text: string;
64
+ run: Run | null;
65
+ paragraph: Paragraph | null;
66
+ ins_id?: string | null;
67
+ del_id?: string | null;
68
+ hyperlink_id?: string | null;
69
+ }
70
+ declare class DocumentMapper {
71
+ doc: DocumentObject;
72
+ clean_view: boolean;
73
+ comments_map: Record<string, any>;
74
+ full_text: string;
75
+ spans: TextSpan[];
76
+ appendix_start_index: number;
77
+ private _text_chunks;
78
+ constructor(doc: DocumentObject, clean_view?: boolean);
79
+ private _build_map;
80
+ private _map_blocks;
81
+ private _map_table;
82
+ private _strip_markdown_formatting;
83
+ private _map_paragraph_content;
84
+ private _get_wrappers;
85
+ private _build_merged_meta_block;
86
+ private _add_virtual_text;
87
+ private _replace_smart_quotes;
88
+ private _make_fuzzy_regex;
89
+ find_match_index(target_text: string): [number, number];
90
+ find_all_match_indices(target_text: string): [number, number][];
91
+ find_target_runs(target_text: string): Run[];
92
+ find_target_runs_by_index(start_index: number, length: number, rebuild_map?: boolean): Run[];
93
+ get_virtual_spans_in_range(start_index: number, length: number): TextSpan[];
94
+ private _resolve_runs_at_range;
95
+ get_insertion_anchor(index: number, rebuild_map?: boolean): [Run | null, Paragraph | null];
96
+ private _split_run_at_index;
97
+ private _set_run_text_elements;
98
+ get_context_at_range(start_idx: number, end_idx: number): TextSpan | null;
99
+ }
100
+
101
+ declare class CommentsManager {
102
+ doc: DocumentObject;
103
+ private _commentsPart;
104
+ private _extendedPart;
105
+ private _idsPart;
106
+ private _extensiblePart;
107
+ private _nextId;
108
+ constructor(doc: DocumentObject);
109
+ get commentsPart(): Part;
110
+ get extendedPart(): Part;
111
+ get idsPart(): Part;
112
+ get extensiblePart(): Part;
113
+ get nextId(): number;
114
+ set nextId(value: number);
115
+ private _getExistingPartByType;
116
+ private _linkPart;
117
+ private _getOrCreateCommentsPart;
118
+ private _getOrCreateExtendedPart;
119
+ private _getOrCreateIdsPart;
120
+ private _getOrCreateExtensiblePart;
121
+ private _ensureNamespaces;
122
+ private _getNextCommentId;
123
+ private _generateHexId;
124
+ private _getInitials;
125
+ private _findParaIdForComment;
126
+ private _findThreadRootParaId;
127
+ addComment(author: string, text: string, parentId?: string | null): string;
128
+ deleteComment(commentId: string): void;
129
+ }
130
+
131
+ interface ModifyText {
132
+ type: 'modify';
133
+ target_text: string;
134
+ new_text: string;
135
+ comment?: string | null;
136
+ _match_start_index?: number | null;
137
+ _internal_op?: string | null;
138
+ _active_mapper_ref?: any | null;
139
+ _original_target_text?: string;
140
+ _is_table_edit?: boolean;
141
+ }
142
+ interface AcceptChange {
143
+ type: 'accept';
144
+ target_id: string;
145
+ comment?: string | null;
146
+ }
147
+ interface RejectChange {
148
+ type: 'reject';
149
+ target_id: string;
150
+ comment?: string | null;
151
+ }
152
+ interface ReplyComment {
153
+ type: 'reply';
154
+ target_id: string;
155
+ text: string;
156
+ }
157
+ interface InsertTableRow {
158
+ type: 'insert_row';
159
+ target_text: string;
160
+ position: 'above' | 'below';
161
+ cells: string[];
162
+ _match_start_index?: number | null;
163
+ }
164
+ interface DeleteTableRow {
165
+ type: 'delete_row';
166
+ target_text: string;
167
+ _match_start_index?: number | null;
168
+ }
169
+ type DocumentChange = ModifyText | AcceptChange | RejectChange | ReplyComment | InsertTableRow | DeleteTableRow;
170
+
171
+ declare class BatchValidationError extends Error {
172
+ errors: string[];
173
+ constructor(errors: string[]);
174
+ }
175
+ declare class RedlineEngine {
176
+ doc: DocumentObject;
177
+ author: string;
178
+ timestamp: string;
179
+ current_id: number;
180
+ mapper: DocumentMapper;
181
+ comments_manager: CommentsManager;
182
+ clean_mapper: DocumentMapper | null;
183
+ skipped_details: string[];
184
+ constructor(doc: DocumentObject, author?: string);
185
+ private _scan_existing_ids;
186
+ accept_all_revisions(): void;
187
+ private _getNextId;
188
+ private _create_track_change_tag;
189
+ private _set_text_content;
190
+ private _parse_markdown_style;
191
+ private _parse_inline_markdown;
192
+ private _apply_run_props;
193
+ validate_edits(edits: any[]): string[];
194
+ process_batch(changes: DocumentChange[]): any;
195
+ apply_edits(edits: any[]): [number, number];
196
+ apply_review_actions(actions: any[]): [number, number];
197
+ private _apply_table_edit;
198
+ private _pre_resolve_heuristic_edit;
199
+ private _apply_single_edit_indexed;
200
+ }
201
+
202
+ declare function trim_common_context(target: string, new_val: string): [number, number];
203
+ declare function generate_edits_from_text(original_text: string, modified_text: string): ModifyText[];
204
+
205
+ declare function apply_edits_to_markdown(markdown_text: string, edits: ModifyText[], include_index?: boolean, highlight_only?: boolean): string;
206
+
207
+ /**
208
+ * Stateless paginator for projected DOCX Markdown.
209
+ */
210
+ interface PageInfo {
211
+ page: number;
212
+ total_pages: number;
213
+ has_next: boolean;
214
+ has_prev: boolean;
215
+ tracked_change_count: number;
216
+ page_content: string;
217
+ }
218
+ interface PaginationResult {
219
+ pages: PageInfo[];
220
+ total_pages: number;
221
+ body_pages: string[];
222
+ body_page_offsets: number[];
223
+ }
224
+ declare function split_structural_appendix(markdown: string): [string, string];
225
+ declare function paginate(markdown_body: string, structural_appendix?: string): PaginationResult;
226
+
227
+ /**
228
+ * Structural outline extractor.
229
+ */
230
+
231
+ interface OutlineNode {
232
+ level: number;
233
+ text: string;
234
+ page: number;
235
+ style: string;
236
+ has_table: boolean;
237
+ footnote_ids: string[];
238
+ }
239
+ declare function extract_outline(doc: DocumentObject, projected_body: string, body_pages: string[], body_page_offsets: number[], paragraph_offsets?: Record<string, [number, number]> | null): OutlineNode[];
240
+
241
+ /**
242
+ * @adeu/core
243
+ * Cross-platform XML Redlining Engine
244
+ */
245
+ declare const identifyEngine: () => string;
246
+
247
+ export { BatchValidationError, DocumentMapper, DocumentObject, type OutlineNode, type PageInfo, type PaginationResult, RedlineEngine, type TextSpan, apply_edits_to_markdown, extractTextFromBuffer, extract_outline, generate_edits_from_text, identifyEngine, paginate, split_structural_appendix, trim_common_context };