docxodus 3.9.0 → 4.0.1
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/dist/docxodus.worker.d.ts +11 -0
- package/dist/docxodus.worker.d.ts.map +1 -0
- package/dist/docxodus.worker.js +384 -0
- package/dist/docxodus.worker.js.map +1 -0
- package/dist/index.d.ts +36 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +289 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wasm/_framework/Docxodus.wasm +0 -0
- package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
- package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
- package/dist/wasm/_framework/System.Runtime.wasm +0 -0
- package/dist/wasm/_framework/System.Text.Json.wasm +0 -0
- package/dist/wasm/_framework/blazor.boot.json +7 -7
- package/dist/wasm/_framework/dotnet.native.wasm +0 -0
- package/dist/worker-proxy.bundle.js +170 -0
- package/dist/worker-proxy.d.ts +107 -0
- package/dist/worker-proxy.d.ts.map +1 -0
- package/dist/worker-proxy.js +229 -0
- package/dist/worker-proxy.js.map +1 -0
- package/package.json +8 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docxodus Web Worker
|
|
3
|
+
*
|
|
4
|
+
* This worker runs the WASM runtime in a separate thread, keeping the main
|
|
5
|
+
* thread free for UI updates and user interactions.
|
|
6
|
+
*
|
|
7
|
+
* Communication is via postMessage with structured request/response types.
|
|
8
|
+
* Document bytes are transferred (not copied) for efficiency.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=docxodus.worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docxodus.worker.d.ts","sourceRoot":"","sources":["../src/docxodus.worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
// src/docxodus.worker.ts
|
|
2
|
+
var wasmExports = null;
|
|
3
|
+
var initPromise = null;
|
|
4
|
+
async function initializeWasm(basePath) {
|
|
5
|
+
if (wasmExports) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (initPromise) {
|
|
9
|
+
return initPromise;
|
|
10
|
+
}
|
|
11
|
+
initPromise = (async () => {
|
|
12
|
+
try {
|
|
13
|
+
const normalizedPath = basePath.endsWith("/") ? basePath : basePath + "/";
|
|
14
|
+
const dotnetModule = await import(
|
|
15
|
+
/* webpackIgnore: true */
|
|
16
|
+
`${normalizedPath}_framework/dotnet.js`
|
|
17
|
+
);
|
|
18
|
+
const { getAssemblyExports, getConfig } = await dotnetModule.dotnet.withDiagnosticTracing(false).create();
|
|
19
|
+
const config = getConfig();
|
|
20
|
+
const exports = await getAssemblyExports(config.mainAssemblyName);
|
|
21
|
+
wasmExports = {
|
|
22
|
+
DocumentConverter: exports.DocxodusWasm.DocumentConverter,
|
|
23
|
+
DocumentComparer: exports.DocxodusWasm.DocumentComparer
|
|
24
|
+
};
|
|
25
|
+
} catch (error) {
|
|
26
|
+
initPromise = null;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
})();
|
|
30
|
+
return initPromise;
|
|
31
|
+
}
|
|
32
|
+
function ensureInitialized() {
|
|
33
|
+
if (!wasmExports) {
|
|
34
|
+
throw new Error("Worker not initialized. Call init first.");
|
|
35
|
+
}
|
|
36
|
+
return wasmExports;
|
|
37
|
+
}
|
|
38
|
+
function isErrorResponse(result) {
|
|
39
|
+
return result.startsWith("{") && result.includes('"Error"');
|
|
40
|
+
}
|
|
41
|
+
function parseError(result) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(result);
|
|
44
|
+
return { error: parsed.Error || parsed.error || "Unknown error" };
|
|
45
|
+
} catch {
|
|
46
|
+
return { error: result };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function handleConvert(request) {
|
|
50
|
+
const exports = ensureInitialized();
|
|
51
|
+
const options = request.options;
|
|
52
|
+
try {
|
|
53
|
+
let result;
|
|
54
|
+
const needsCompleteMethod = options?.renderFootnotesAndEndnotes !== void 0 || options?.renderHeadersAndFooters !== void 0 || options?.renderTrackedChanges !== void 0 || options?.showDeletedContent !== void 0 || options?.renderMoveOperations !== void 0;
|
|
55
|
+
if (needsCompleteMethod || options?.renderAnnotations) {
|
|
56
|
+
result = exports.DocumentConverter.ConvertDocxToHtmlComplete(
|
|
57
|
+
request.documentBytes,
|
|
58
|
+
options?.pageTitle ?? "Document",
|
|
59
|
+
options?.cssPrefix ?? "docx-",
|
|
60
|
+
options?.fabricateClasses ?? true,
|
|
61
|
+
options?.additionalCss ?? "",
|
|
62
|
+
options?.commentRenderMode ?? -1,
|
|
63
|
+
options?.commentCssClassPrefix ?? "comment-",
|
|
64
|
+
options?.paginationMode ?? 0,
|
|
65
|
+
options?.paginationScale ?? 1,
|
|
66
|
+
options?.paginationCssClassPrefix ?? "page-",
|
|
67
|
+
options?.renderAnnotations ?? false,
|
|
68
|
+
options?.annotationLabelMode ?? 0,
|
|
69
|
+
options?.annotationCssClassPrefix ?? "annot-",
|
|
70
|
+
options?.renderFootnotesAndEndnotes ?? false,
|
|
71
|
+
options?.renderHeadersAndFooters ?? false,
|
|
72
|
+
options?.renderTrackedChanges ?? false,
|
|
73
|
+
options?.showDeletedContent ?? true,
|
|
74
|
+
options?.renderMoveOperations ?? true
|
|
75
|
+
);
|
|
76
|
+
} else if (options?.paginationMode !== void 0 && options.paginationMode !== 0) {
|
|
77
|
+
result = exports.DocumentConverter.ConvertDocxToHtmlWithPagination(
|
|
78
|
+
request.documentBytes,
|
|
79
|
+
options.pageTitle ?? "Document",
|
|
80
|
+
options.cssPrefix ?? "docx-",
|
|
81
|
+
options.fabricateClasses ?? true,
|
|
82
|
+
options.additionalCss ?? "",
|
|
83
|
+
options.commentRenderMode ?? -1,
|
|
84
|
+
options.commentCssClassPrefix ?? "comment-",
|
|
85
|
+
options.paginationMode,
|
|
86
|
+
options.paginationScale ?? 1,
|
|
87
|
+
options.paginationCssClassPrefix ?? "page-"
|
|
88
|
+
);
|
|
89
|
+
} else if (options) {
|
|
90
|
+
result = exports.DocumentConverter.ConvertDocxToHtmlWithOptions(
|
|
91
|
+
request.documentBytes,
|
|
92
|
+
options.pageTitle ?? "Document",
|
|
93
|
+
options.cssPrefix ?? "docx-",
|
|
94
|
+
options.fabricateClasses ?? true,
|
|
95
|
+
options.additionalCss ?? "",
|
|
96
|
+
options.commentRenderMode ?? -1,
|
|
97
|
+
options.commentCssClassPrefix ?? "comment-"
|
|
98
|
+
);
|
|
99
|
+
} else {
|
|
100
|
+
result = exports.DocumentConverter.ConvertDocxToHtml(
|
|
101
|
+
request.documentBytes
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (isErrorResponse(result)) {
|
|
105
|
+
return parseError(result);
|
|
106
|
+
}
|
|
107
|
+
return { html: result };
|
|
108
|
+
} catch (error) {
|
|
109
|
+
return { error: String(error) };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function handleCompare(request) {
|
|
113
|
+
const exports = ensureInitialized();
|
|
114
|
+
const options = request.options;
|
|
115
|
+
try {
|
|
116
|
+
let result;
|
|
117
|
+
if (options?.detailThreshold !== void 0 || options?.caseInsensitive) {
|
|
118
|
+
result = exports.DocumentComparer.CompareDocumentsWithOptions(
|
|
119
|
+
request.originalBytes,
|
|
120
|
+
request.modifiedBytes,
|
|
121
|
+
options?.authorName ?? "Docxodus",
|
|
122
|
+
options?.detailThreshold ?? 0.15,
|
|
123
|
+
options?.caseInsensitive ?? false
|
|
124
|
+
);
|
|
125
|
+
} else {
|
|
126
|
+
result = exports.DocumentComparer.CompareDocuments(
|
|
127
|
+
request.originalBytes,
|
|
128
|
+
request.modifiedBytes,
|
|
129
|
+
options?.authorName ?? "Docxodus"
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
if (result.length === 0) {
|
|
133
|
+
return { error: "Comparison returned empty result" };
|
|
134
|
+
}
|
|
135
|
+
return { documentBytes: result };
|
|
136
|
+
} catch (error) {
|
|
137
|
+
return { error: String(error) };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function handleCompareToHtml(request) {
|
|
141
|
+
const exports = ensureInitialized();
|
|
142
|
+
const options = request.options;
|
|
143
|
+
try {
|
|
144
|
+
const renderTrackedChanges = options?.renderTrackedChanges ?? true;
|
|
145
|
+
const result = exports.DocumentComparer.CompareDocumentsToHtmlWithOptions(
|
|
146
|
+
request.originalBytes,
|
|
147
|
+
request.modifiedBytes,
|
|
148
|
+
options?.authorName ?? "Docxodus",
|
|
149
|
+
renderTrackedChanges
|
|
150
|
+
);
|
|
151
|
+
if (isErrorResponse(result)) {
|
|
152
|
+
return parseError(result);
|
|
153
|
+
}
|
|
154
|
+
return { html: result };
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return { error: String(error) };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function handleGetRevisions(request) {
|
|
160
|
+
const exports = ensureInitialized();
|
|
161
|
+
const options = request.options;
|
|
162
|
+
try {
|
|
163
|
+
const detectMoves = options?.detectMoves ?? true;
|
|
164
|
+
const moveSimilarityThreshold = options?.moveSimilarityThreshold ?? 0.8;
|
|
165
|
+
const moveMinimumWordCount = options?.moveMinimumWordCount ?? 3;
|
|
166
|
+
const caseInsensitive = options?.caseInsensitive ?? false;
|
|
167
|
+
const result = exports.DocumentComparer.GetRevisionsJsonWithOptions(
|
|
168
|
+
request.documentBytes,
|
|
169
|
+
detectMoves,
|
|
170
|
+
moveSimilarityThreshold,
|
|
171
|
+
moveMinimumWordCount,
|
|
172
|
+
caseInsensitive
|
|
173
|
+
);
|
|
174
|
+
if (isErrorResponse(result)) {
|
|
175
|
+
return parseError(result);
|
|
176
|
+
}
|
|
177
|
+
const parsed = JSON.parse(result);
|
|
178
|
+
const revisions = (parsed.Revisions || parsed.revisions || []).map(
|
|
179
|
+
(r) => ({
|
|
180
|
+
author: r.Author || r.author,
|
|
181
|
+
date: r.Date || r.date,
|
|
182
|
+
revisionType: r.RevisionType || r.revisionType,
|
|
183
|
+
text: r.Text || r.text,
|
|
184
|
+
moveGroupId: r.MoveGroupId ?? r.moveGroupId,
|
|
185
|
+
isMoveSource: r.IsMoveSource ?? r.isMoveSource,
|
|
186
|
+
formatChange: r.FormatChange || r.formatChange ? {
|
|
187
|
+
oldProperties: r.FormatChange?.OldProperties || r.formatChange?.oldProperties,
|
|
188
|
+
newProperties: r.FormatChange?.NewProperties || r.formatChange?.newProperties,
|
|
189
|
+
changedPropertyNames: r.FormatChange?.ChangedPropertyNames || r.formatChange?.changedPropertyNames
|
|
190
|
+
} : void 0
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
return { revisions };
|
|
194
|
+
} catch (error) {
|
|
195
|
+
return { error: String(error) };
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function handleGetDocumentMetadata(request) {
|
|
199
|
+
const exports = ensureInitialized();
|
|
200
|
+
try {
|
|
201
|
+
const result = exports.DocumentConverter.GetDocumentMetadata(
|
|
202
|
+
request.documentBytes
|
|
203
|
+
);
|
|
204
|
+
if (isErrorResponse(result)) {
|
|
205
|
+
return parseError(result);
|
|
206
|
+
}
|
|
207
|
+
const parsed = JSON.parse(result);
|
|
208
|
+
const convertSection = (s) => ({
|
|
209
|
+
sectionIndex: s.SectionIndex ?? s.sectionIndex,
|
|
210
|
+
pageWidthPt: s.PageWidthPt ?? s.pageWidthPt,
|
|
211
|
+
pageHeightPt: s.PageHeightPt ?? s.pageHeightPt,
|
|
212
|
+
marginTopPt: s.MarginTopPt ?? s.marginTopPt,
|
|
213
|
+
marginRightPt: s.MarginRightPt ?? s.marginRightPt,
|
|
214
|
+
marginBottomPt: s.MarginBottomPt ?? s.marginBottomPt,
|
|
215
|
+
marginLeftPt: s.MarginLeftPt ?? s.marginLeftPt,
|
|
216
|
+
contentWidthPt: s.ContentWidthPt ?? s.contentWidthPt,
|
|
217
|
+
contentHeightPt: s.ContentHeightPt ?? s.contentHeightPt,
|
|
218
|
+
headerPt: s.HeaderPt ?? s.headerPt,
|
|
219
|
+
footerPt: s.FooterPt ?? s.footerPt,
|
|
220
|
+
paragraphCount: s.ParagraphCount ?? s.paragraphCount,
|
|
221
|
+
tableCount: s.TableCount ?? s.tableCount,
|
|
222
|
+
hasHeader: s.HasHeader ?? s.hasHeader,
|
|
223
|
+
hasFooter: s.HasFooter ?? s.hasFooter,
|
|
224
|
+
hasFirstPageHeader: s.HasFirstPageHeader ?? s.hasFirstPageHeader,
|
|
225
|
+
hasFirstPageFooter: s.HasFirstPageFooter ?? s.hasFirstPageFooter,
|
|
226
|
+
hasEvenPageHeader: s.HasEvenPageHeader ?? s.hasEvenPageHeader,
|
|
227
|
+
hasEvenPageFooter: s.HasEvenPageFooter ?? s.hasEvenPageFooter,
|
|
228
|
+
startParagraphIndex: s.StartParagraphIndex ?? s.startParagraphIndex,
|
|
229
|
+
endParagraphIndex: s.EndParagraphIndex ?? s.endParagraphIndex,
|
|
230
|
+
startTableIndex: s.StartTableIndex ?? s.startTableIndex,
|
|
231
|
+
endTableIndex: s.EndTableIndex ?? s.endTableIndex
|
|
232
|
+
});
|
|
233
|
+
const metadata = {
|
|
234
|
+
sections: (parsed.Sections || parsed.sections || []).map(convertSection),
|
|
235
|
+
totalParagraphs: parsed.TotalParagraphs ?? parsed.totalParagraphs,
|
|
236
|
+
totalTables: parsed.TotalTables ?? parsed.totalTables,
|
|
237
|
+
hasFootnotes: parsed.HasFootnotes ?? parsed.hasFootnotes,
|
|
238
|
+
hasEndnotes: parsed.HasEndnotes ?? parsed.hasEndnotes,
|
|
239
|
+
hasTrackedChanges: parsed.HasTrackedChanges ?? parsed.hasTrackedChanges,
|
|
240
|
+
hasComments: parsed.HasComments ?? parsed.hasComments,
|
|
241
|
+
estimatedPageCount: parsed.EstimatedPageCount ?? parsed.estimatedPageCount
|
|
242
|
+
};
|
|
243
|
+
return { metadata };
|
|
244
|
+
} catch (error) {
|
|
245
|
+
return { error: String(error) };
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
function handleGetVersion() {
|
|
249
|
+
const exports = ensureInitialized();
|
|
250
|
+
try {
|
|
251
|
+
const result = exports.DocumentConverter.GetVersion();
|
|
252
|
+
const parsed = JSON.parse(result);
|
|
253
|
+
return {
|
|
254
|
+
version: {
|
|
255
|
+
library: parsed.Library || parsed.library,
|
|
256
|
+
dotnetVersion: parsed.DotnetVersion || parsed.dotnetVersion,
|
|
257
|
+
platform: parsed.Platform || parsed.platform
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
} catch (error) {
|
|
261
|
+
return { error: String(error) };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
self.onmessage = async (event) => {
|
|
265
|
+
const request = event.data;
|
|
266
|
+
try {
|
|
267
|
+
let response;
|
|
268
|
+
switch (request.type) {
|
|
269
|
+
case "init": {
|
|
270
|
+
const initRequest = request;
|
|
271
|
+
try {
|
|
272
|
+
await initializeWasm(initRequest.wasmBasePath);
|
|
273
|
+
response = {
|
|
274
|
+
id: request.id,
|
|
275
|
+
type: "init",
|
|
276
|
+
success: true
|
|
277
|
+
};
|
|
278
|
+
} catch (error) {
|
|
279
|
+
response = {
|
|
280
|
+
id: request.id,
|
|
281
|
+
type: "init",
|
|
282
|
+
success: false,
|
|
283
|
+
error: String(error)
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case "convertDocxToHtml": {
|
|
289
|
+
const convertRequest = request;
|
|
290
|
+
const result = handleConvert(convertRequest);
|
|
291
|
+
response = {
|
|
292
|
+
id: request.id,
|
|
293
|
+
type: "convertDocxToHtml",
|
|
294
|
+
success: !result.error,
|
|
295
|
+
html: result.html,
|
|
296
|
+
error: result.error
|
|
297
|
+
};
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
300
|
+
case "compareDocuments": {
|
|
301
|
+
const compareRequest = request;
|
|
302
|
+
const result = handleCompare(compareRequest);
|
|
303
|
+
response = {
|
|
304
|
+
id: request.id,
|
|
305
|
+
type: "compareDocuments",
|
|
306
|
+
success: !result.error,
|
|
307
|
+
documentBytes: result.documentBytes,
|
|
308
|
+
error: result.error
|
|
309
|
+
};
|
|
310
|
+
if (result.documentBytes) {
|
|
311
|
+
self.postMessage(response, { transfer: [result.documentBytes.buffer] });
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
case "compareDocumentsToHtml": {
|
|
317
|
+
const compareToHtmlRequest = request;
|
|
318
|
+
const result = handleCompareToHtml(compareToHtmlRequest);
|
|
319
|
+
response = {
|
|
320
|
+
id: request.id,
|
|
321
|
+
type: "compareDocumentsToHtml",
|
|
322
|
+
success: !result.error,
|
|
323
|
+
html: result.html,
|
|
324
|
+
error: result.error
|
|
325
|
+
};
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "getRevisions": {
|
|
329
|
+
const getRevisionsRequest = request;
|
|
330
|
+
const result = handleGetRevisions(getRevisionsRequest);
|
|
331
|
+
response = {
|
|
332
|
+
id: request.id,
|
|
333
|
+
type: "getRevisions",
|
|
334
|
+
success: !result.error,
|
|
335
|
+
revisions: result.revisions,
|
|
336
|
+
error: result.error
|
|
337
|
+
};
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
case "getDocumentMetadata": {
|
|
341
|
+
const getMetadataRequest = request;
|
|
342
|
+
const result = handleGetDocumentMetadata(getMetadataRequest);
|
|
343
|
+
response = {
|
|
344
|
+
id: request.id,
|
|
345
|
+
type: "getDocumentMetadata",
|
|
346
|
+
success: !result.error,
|
|
347
|
+
metadata: result.metadata,
|
|
348
|
+
error: result.error
|
|
349
|
+
};
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case "getVersion": {
|
|
353
|
+
const result = handleGetVersion();
|
|
354
|
+
response = {
|
|
355
|
+
id: request.id,
|
|
356
|
+
type: "getVersion",
|
|
357
|
+
success: !result.error,
|
|
358
|
+
version: result.version,
|
|
359
|
+
error: result.error
|
|
360
|
+
};
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
default: {
|
|
364
|
+
const unknownRequest = request;
|
|
365
|
+
self.postMessage({
|
|
366
|
+
id: unknownRequest.id,
|
|
367
|
+
type: unknownRequest.type,
|
|
368
|
+
success: false,
|
|
369
|
+
error: `Unknown request type: ${unknownRequest.type}`
|
|
370
|
+
});
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
self.postMessage(response);
|
|
375
|
+
} catch (error) {
|
|
376
|
+
self.postMessage({
|
|
377
|
+
id: request.id,
|
|
378
|
+
type: request.type,
|
|
379
|
+
success: false,
|
|
380
|
+
error: String(error)
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
self.postMessage({ type: "ready" });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docxodus.worker.js","sourceRoot":"","sources":["../src/docxodus.worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAqBH,qBAAqB;AACrB,IAAI,WAAW,GAA+B,IAAI,CAAC;AACnD,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C;;GAEG;AACH,KAAK,UAAU,cAAc,CAAC,QAAgB;IAC5C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,sBAAsB;IAChC,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,CAAC,6BAA6B;IACnD,CAAC;IAED,WAAW,GAAG,CAAC,KAAK,IAAI,EAAE;QACxB,IAAI,CAAC;YACH,sBAAsB;YACtB,MAAM,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAA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,MAAM,CAAC,KAAK;oBACtB,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAC;gBACF,MAAM;YACR,CAAC;YAED,OAAO,CAAC,CAAC,CAAC;gBACR,wEAAwE;gBACxE,MAAM,cAAc,GAAG,OAAuC,CAAC;gBAC/D,IAAI,CAAC,WAAW,CAAC;oBACf,EAAE,EAAE,cAAc,CAAC,EAAE;oBACrB,IAAI,EAAE,cAAc,CAAC,IAAI;oBACzB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,yBAAyB,cAAc,CAAC,IAAI,EAAE;iBACtD,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;QACH,CAAC;QAED,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kCAAkC;QAClC,IAAI,CAAC,WAAW,CAAC;YACf,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;SACH,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAEF,kCAAkC;AAClC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ConversionOptions, CompareOptions, Revision, VersionInfo, ErrorResponse, CompareResult, GetRevisionsOptions, FormatChangeDetails, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest } from "./types.js";
|
|
1
|
+
import type { ConversionOptions, CompareOptions, Revision, VersionInfo, ErrorResponse, CompareResult, GetRevisionsOptions, FormatChangeDetails, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest, DocumentMetadata, SectionMetadata } from "./types.js";
|
|
2
2
|
import { CommentRenderMode, PaginationMode, AnnotationLabelMode, RevisionType, DocumentElementType, isInsertion, isDeletion, isMove, isMoveSource, isMoveDestination, findMovePair, isFormatChange, findElementById, findElementsByType, getParagraphs, getTables, getTableColumns, targetElement, targetParagraph, targetParagraphRange, targetRun, targetTable, targetTableRow, targetTableCell, targetTableColumn, targetSearch, targetSearchInElement } from "./types.js";
|
|
3
3
|
export type { PageDimensions, MeasuredBlock, PageInfo, PaginationResult, PaginationOptions, } from "./pagination.js";
|
|
4
4
|
export { PaginationEngine, paginateHtml } from "./pagination.js";
|
|
5
|
-
export type { ConversionOptions, CompareOptions, Revision, VersionInfo, ErrorResponse, CompareResult, GetRevisionsOptions, FormatChangeDetails, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest, };
|
|
5
|
+
export type { ConversionOptions, CompareOptions, Revision, VersionInfo, ErrorResponse, CompareResult, GetRevisionsOptions, FormatChangeDetails, Annotation, AddAnnotationRequest, AddAnnotationResponse, RemoveAnnotationResponse, AnnotationOptions, DocumentStructure, DocumentElement, TableColumnInfo, AnnotationTarget, AddAnnotationWithTargetRequest, DocumentMetadata, SectionMetadata, };
|
|
6
6
|
export { CommentRenderMode, PaginationMode, AnnotationLabelMode, RevisionType, DocumentElementType, isInsertion, isDeletion, isMove, isMoveSource, isMoveDestination, findMovePair, isFormatChange, findElementById, findElementsByType, getParagraphs, getTables, getTableColumns, targetElement, targetParagraph, targetParagraphRange, targetRun, targetTable, targetTableRow, targetTableCell, targetTableColumn, targetSearch, targetSearchInElement, };
|
|
7
7
|
/**
|
|
8
8
|
* Current base path for WASM files.
|
|
@@ -241,6 +241,40 @@ export declare function hasAnnotations(document: File | Uint8Array): Promise<boo
|
|
|
241
241
|
* ```
|
|
242
242
|
*/
|
|
243
243
|
export declare function getDocumentStructure(document: File | Uint8Array): Promise<DocumentStructure>;
|
|
244
|
+
/**
|
|
245
|
+
* Get document metadata for lazy loading pagination.
|
|
246
|
+
* This is a fast operation that extracts structure information without full HTML rendering.
|
|
247
|
+
*
|
|
248
|
+
* @param document - DOCX file as File object or Uint8Array
|
|
249
|
+
* @returns Document metadata including sections, dimensions, and content counts
|
|
250
|
+
* @throws Error if operation fails
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const metadata = await getDocumentMetadata(docxFile);
|
|
255
|
+
*
|
|
256
|
+
* // Check document overview
|
|
257
|
+
* console.log(`Document has ${metadata.totalParagraphs} paragraphs`);
|
|
258
|
+
* console.log(`Document has ${metadata.sections.length} sections`);
|
|
259
|
+
* console.log(`Estimated ${metadata.estimatedPageCount} pages`);
|
|
260
|
+
*
|
|
261
|
+
* // Check section properties
|
|
262
|
+
* for (const section of metadata.sections) {
|
|
263
|
+
* console.log(`Section ${section.sectionIndex}: ${section.pageWidthPt}x${section.pageHeightPt}pt`);
|
|
264
|
+
* console.log(` Paragraphs: ${section.paragraphCount}, Tables: ${section.tableCount}`);
|
|
265
|
+
* console.log(` Has header: ${section.hasHeader}, Has footer: ${section.hasFooter}`);
|
|
266
|
+
* }
|
|
267
|
+
*
|
|
268
|
+
* // Check document features
|
|
269
|
+
* if (metadata.hasTrackedChanges) {
|
|
270
|
+
* console.log("Document has tracked changes");
|
|
271
|
+
* }
|
|
272
|
+
* if (metadata.hasFootnotes) {
|
|
273
|
+
* console.log("Document has footnotes");
|
|
274
|
+
* }
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export declare function getDocumentMetadata(document: File | Uint8Array): Promise<DocumentMetadata>;
|
|
244
278
|
/**
|
|
245
279
|
* Add an annotation using flexible targeting (element ID, indices, or text search).
|
|
246
280
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EAEb,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,8BAA8B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,WAAW,EACX,aAAa,EACb,aAAa,EAEb,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,8BAA8B,EAC9B,gBAAgB,EAChB,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,eAAe,EACf,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,cAAc,EACd,aAAa,EACb,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB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BAAiB,CAAC,CAyD5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,IAAI,GAAG,UAAU,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAqD3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,IAAI,GAAG,UAAU,EAC3B,OAAO,EAAE,8BAA8B,GACtC,OAAO,CAAC,qBAAqB,CAAC,CAoDhC"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,32 @@ findElementById, findElementsByType, getParagraphs, getTables, getTableColumns,
|
|
|
7
7
|
targetElement, targetParagraph, targetParagraphRange, targetRun, targetTable, targetTableRow, targetTableCell, targetTableColumn, targetSearch, targetSearchInElement, };
|
|
8
8
|
let wasmExports = null;
|
|
9
9
|
let initPromise = null;
|
|
10
|
+
/**
|
|
11
|
+
* Yields to the browser's main thread, allowing pending UI updates to render.
|
|
12
|
+
*
|
|
13
|
+
* This is critical for WASM operations: since WASM runs synchronously on the
|
|
14
|
+
* main thread, React state updates (like loading spinners) won't paint unless
|
|
15
|
+
* we yield before the blocking work begins.
|
|
16
|
+
*
|
|
17
|
+
* Uses requestAnimationFrame which fires just before the next paint, ensuring
|
|
18
|
+
* any queued state updates are committed to the DOM.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
async function yieldToMain() {
|
|
23
|
+
// In non-browser environments (SSR, tests), skip yielding
|
|
24
|
+
if (typeof requestAnimationFrame === "undefined") {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Double-rAF ensures the browser has fully painted before we continue
|
|
28
|
+
// First rAF: scheduled for next frame
|
|
29
|
+
// Second rAF: ensures first frame actually painted
|
|
30
|
+
await new Promise((resolve) => {
|
|
31
|
+
requestAnimationFrame(() => {
|
|
32
|
+
requestAnimationFrame(() => resolve());
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
}
|
|
10
36
|
/**
|
|
11
37
|
* Derive the WASM base path from this module's URL.
|
|
12
38
|
* Works whether loaded from node_modules, CDN, or bundled.
|
|
@@ -188,6 +214,8 @@ async function toBytes(input) {
|
|
|
188
214
|
export async function convertDocxToHtml(document, options) {
|
|
189
215
|
const exports = ensureInitialized();
|
|
190
216
|
const bytes = await toBytes(document);
|
|
217
|
+
// Yield to browser before heavy WASM work - allows loading states to render
|
|
218
|
+
await yieldToMain();
|
|
191
219
|
let result;
|
|
192
220
|
// Check if any of the new complete options are specified
|
|
193
221
|
const needsCompleteMethod = options?.renderFootnotesAndEndnotes !== undefined ||
|
|
@@ -228,6 +256,8 @@ export async function compareDocuments(original, modified, options) {
|
|
|
228
256
|
const exports = ensureInitialized();
|
|
229
257
|
const originalBytes = await toBytes(original);
|
|
230
258
|
const modifiedBytes = await toBytes(modified);
|
|
259
|
+
// Yield to browser before heavy WASM work - allows loading states to render
|
|
260
|
+
await yieldToMain();
|
|
231
261
|
let result;
|
|
232
262
|
if (options?.detailThreshold !== undefined || options?.caseInsensitive) {
|
|
233
263
|
result = exports.DocumentComparer.CompareDocumentsWithOptions(originalBytes, modifiedBytes, options?.authorName ?? "Docxodus", options?.detailThreshold ?? 0.15, options?.caseInsensitive ?? false);
|
|
@@ -253,6 +283,8 @@ export async function compareDocumentsToHtml(original, modified, options) {
|
|
|
253
283
|
const exports = ensureInitialized();
|
|
254
284
|
const originalBytes = await toBytes(original);
|
|
255
285
|
const modifiedBytes = await toBytes(modified);
|
|
286
|
+
// Yield to browser before heavy WASM work - allows loading states to render
|
|
287
|
+
await yieldToMain();
|
|
256
288
|
// Use the new options method if renderTrackedChanges is explicitly set
|
|
257
289
|
const renderTrackedChanges = options?.renderTrackedChanges ?? true;
|
|
258
290
|
const result = exports.DocumentComparer.CompareDocumentsToHtmlWithOptions(originalBytes, modifiedBytes, options?.authorName ?? "Docxodus", renderTrackedChanges);
|
|
@@ -290,6 +322,8 @@ export async function compareDocumentsToHtml(original, modified, options) {
|
|
|
290
322
|
export async function getRevisions(document, options) {
|
|
291
323
|
const exports = ensureInitialized();
|
|
292
324
|
const bytes = await toBytes(document);
|
|
325
|
+
// Yield to browser before WASM work - allows loading states to render
|
|
326
|
+
await yieldToMain();
|
|
293
327
|
// Apply defaults for move detection options
|
|
294
328
|
const detectMoves = options?.detectMoves ?? true;
|
|
295
329
|
const moveSimilarityThreshold = options?.moveSimilarityThreshold ?? 0.8;
|
|
@@ -409,6 +443,8 @@ export async function getAnnotations(document) {
|
|
|
409
443
|
export async function addAnnotation(document, request) {
|
|
410
444
|
const exports = ensureInitialized();
|
|
411
445
|
const bytes = await toBytes(document);
|
|
446
|
+
// Yield to browser before WASM work - allows loading states to render
|
|
447
|
+
await yieldToMain();
|
|
412
448
|
const requestJson = JSON.stringify({
|
|
413
449
|
Id: request.id,
|
|
414
450
|
LabelId: request.labelId,
|
|
@@ -532,6 +568,8 @@ export async function hasAnnotations(document) {
|
|
|
532
568
|
export async function getDocumentStructure(document) {
|
|
533
569
|
const exports = ensureInitialized();
|
|
534
570
|
const bytes = await toBytes(document);
|
|
571
|
+
// Yield to browser before WASM work - allows loading states to render
|
|
572
|
+
await yieldToMain();
|
|
535
573
|
const result = exports.DocumentConverter.GetDocumentStructure(bytes);
|
|
536
574
|
if (isErrorResponse(result)) {
|
|
537
575
|
const error = parseError(result);
|
|
@@ -575,6 +613,87 @@ export async function getDocumentStructure(document) {
|
|
|
575
613
|
tableColumns,
|
|
576
614
|
};
|
|
577
615
|
}
|
|
616
|
+
/**
|
|
617
|
+
* Get document metadata for lazy loading pagination.
|
|
618
|
+
* This is a fast operation that extracts structure information without full HTML rendering.
|
|
619
|
+
*
|
|
620
|
+
* @param document - DOCX file as File object or Uint8Array
|
|
621
|
+
* @returns Document metadata including sections, dimensions, and content counts
|
|
622
|
+
* @throws Error if operation fails
|
|
623
|
+
*
|
|
624
|
+
* @example
|
|
625
|
+
* ```typescript
|
|
626
|
+
* const metadata = await getDocumentMetadata(docxFile);
|
|
627
|
+
*
|
|
628
|
+
* // Check document overview
|
|
629
|
+
* console.log(`Document has ${metadata.totalParagraphs} paragraphs`);
|
|
630
|
+
* console.log(`Document has ${metadata.sections.length} sections`);
|
|
631
|
+
* console.log(`Estimated ${metadata.estimatedPageCount} pages`);
|
|
632
|
+
*
|
|
633
|
+
* // Check section properties
|
|
634
|
+
* for (const section of metadata.sections) {
|
|
635
|
+
* console.log(`Section ${section.sectionIndex}: ${section.pageWidthPt}x${section.pageHeightPt}pt`);
|
|
636
|
+
* console.log(` Paragraphs: ${section.paragraphCount}, Tables: ${section.tableCount}`);
|
|
637
|
+
* console.log(` Has header: ${section.hasHeader}, Has footer: ${section.hasFooter}`);
|
|
638
|
+
* }
|
|
639
|
+
*
|
|
640
|
+
* // Check document features
|
|
641
|
+
* if (metadata.hasTrackedChanges) {
|
|
642
|
+
* console.log("Document has tracked changes");
|
|
643
|
+
* }
|
|
644
|
+
* if (metadata.hasFootnotes) {
|
|
645
|
+
* console.log("Document has footnotes");
|
|
646
|
+
* }
|
|
647
|
+
* ```
|
|
648
|
+
*/
|
|
649
|
+
export async function getDocumentMetadata(document) {
|
|
650
|
+
const exports = ensureInitialized();
|
|
651
|
+
const bytes = await toBytes(document);
|
|
652
|
+
// Yield to browser before WASM work - allows loading states to render
|
|
653
|
+
await yieldToMain();
|
|
654
|
+
const result = exports.DocumentConverter.GetDocumentMetadata(bytes);
|
|
655
|
+
if (isErrorResponse(result)) {
|
|
656
|
+
const error = parseError(result);
|
|
657
|
+
throw new Error(`Failed to get document metadata: ${error.error}`);
|
|
658
|
+
}
|
|
659
|
+
const parsed = JSON.parse(result);
|
|
660
|
+
// Convert from PascalCase to camelCase
|
|
661
|
+
const convertSection = (s) => ({
|
|
662
|
+
sectionIndex: s.SectionIndex ?? s.sectionIndex,
|
|
663
|
+
pageWidthPt: s.PageWidthPt ?? s.pageWidthPt,
|
|
664
|
+
pageHeightPt: s.PageHeightPt ?? s.pageHeightPt,
|
|
665
|
+
marginTopPt: s.MarginTopPt ?? s.marginTopPt,
|
|
666
|
+
marginRightPt: s.MarginRightPt ?? s.marginRightPt,
|
|
667
|
+
marginBottomPt: s.MarginBottomPt ?? s.marginBottomPt,
|
|
668
|
+
marginLeftPt: s.MarginLeftPt ?? s.marginLeftPt,
|
|
669
|
+
contentWidthPt: s.ContentWidthPt ?? s.contentWidthPt,
|
|
670
|
+
contentHeightPt: s.ContentHeightPt ?? s.contentHeightPt,
|
|
671
|
+
headerPt: s.HeaderPt ?? s.headerPt,
|
|
672
|
+
footerPt: s.FooterPt ?? s.footerPt,
|
|
673
|
+
paragraphCount: s.ParagraphCount ?? s.paragraphCount,
|
|
674
|
+
tableCount: s.TableCount ?? s.tableCount,
|
|
675
|
+
hasHeader: s.HasHeader ?? s.hasHeader,
|
|
676
|
+
hasFooter: s.HasFooter ?? s.hasFooter,
|
|
677
|
+
hasFirstPageHeader: s.HasFirstPageHeader ?? s.hasFirstPageHeader,
|
|
678
|
+
hasFirstPageFooter: s.HasFirstPageFooter ?? s.hasFirstPageFooter,
|
|
679
|
+
hasEvenPageHeader: s.HasEvenPageHeader ?? s.hasEvenPageHeader,
|
|
680
|
+
hasEvenPageFooter: s.HasEvenPageFooter ?? s.hasEvenPageFooter,
|
|
681
|
+
startParagraphIndex: s.StartParagraphIndex ?? s.startParagraphIndex,
|
|
682
|
+
endParagraphIndex: s.EndParagraphIndex ?? s.endParagraphIndex,
|
|
683
|
+
startTableIndex: s.StartTableIndex ?? s.startTableIndex,
|
|
684
|
+
endTableIndex: s.EndTableIndex ?? s.endTableIndex,
|
|
685
|
+
});
|
|
686
|
+
return {
|
|
687
|
+
sections: (parsed.Sections || parsed.sections || []).map(convertSection),
|
|
688
|
+
totalParagraphs: parsed.TotalParagraphs ?? parsed.totalParagraphs,
|
|
689
|
+
totalTables: parsed.TotalTables ?? parsed.totalTables,
|
|
690
|
+
hasFootnotes: parsed.HasFootnotes ?? parsed.hasFootnotes,
|
|
691
|
+
hasEndnotes: parsed.HasEndnotes ?? parsed.hasEndnotes,
|
|
692
|
+
hasTrackedChanges: parsed.HasTrackedChanges ?? parsed.hasTrackedChanges,
|
|
693
|
+
hasComments: parsed.HasComments ?? parsed.hasComments,
|
|
694
|
+
estimatedPageCount: parsed.EstimatedPageCount ?? parsed.estimatedPageCount,
|
|
695
|
+
};
|
|
696
|
+
}
|
|
578
697
|
/**
|
|
579
698
|
* Add an annotation using flexible targeting (element ID, indices, or text search).
|
|
580
699
|
*
|
|
@@ -628,6 +747,8 @@ export async function getDocumentStructure(document) {
|
|
|
628
747
|
export async function addAnnotationWithTarget(document, request) {
|
|
629
748
|
const exports = ensureInitialized();
|
|
630
749
|
const bytes = await toBytes(document);
|
|
750
|
+
// Yield to browser before WASM work - allows loading states to render
|
|
751
|
+
await yieldToMain();
|
|
631
752
|
const requestJson = JSON.stringify({
|
|
632
753
|
Id: request.id,
|
|
633
754
|
LabelId: request.labelId,
|