docxodus 12.6.4 → 13.0.0

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 (92) hide show
  1. package/README.md +8 -5
  2. package/dist/canonical.d.ts.map +1 -1
  3. package/dist/canonical.js +7 -3
  4. package/dist/canonical.js.map +1 -1
  5. package/dist/conversion-options.d.ts +16 -0
  6. package/dist/conversion-options.d.ts.map +1 -0
  7. package/dist/conversion-options.js +31 -0
  8. package/dist/conversion-options.js.map +1 -0
  9. package/dist/core.d.ts +17 -9
  10. package/dist/core.d.ts.map +1 -1
  11. package/dist/core.js +23 -24
  12. package/dist/core.js.map +1 -1
  13. package/dist/docxodus.worker.js +2 -1073
  14. package/dist/docxodus.worker.js.map +7 -1
  15. package/dist/editor.bundle.js +35 -14296
  16. package/dist/editor.bundle.js.map +7 -0
  17. package/dist/editor.d.ts +33 -2
  18. package/dist/editor.d.ts.map +1 -1
  19. package/dist/editor.js +6739 -4773
  20. package/dist/editor.js.map +7 -1
  21. package/dist/embed.bundle.js +159 -18703
  22. package/dist/embed.bundle.js.map +7 -0
  23. package/dist/embed.d.ts +1 -1
  24. package/dist/embed.iife.js +37 -18595
  25. package/dist/embed.iife.js.map +7 -0
  26. package/dist/embed.js +1 -1
  27. package/dist/export-assets.json +27 -27
  28. package/dist/export-browser.bundle.js +1388 -477
  29. package/dist/export-browser.d.ts +20 -0
  30. package/dist/export-browser.d.ts.map +1 -1
  31. package/dist/export-browser.js +132 -37
  32. package/dist/export-browser.js.map +1 -1
  33. package/dist/font-runtime.d.ts.map +1 -1
  34. package/dist/font-runtime.js +54 -0
  35. package/dist/font-runtime.js.map +1 -1
  36. package/dist/line-metrics.d.ts +60 -0
  37. package/dist/line-metrics.d.ts.map +1 -0
  38. package/dist/line-metrics.js +343 -0
  39. package/dist/line-metrics.js.map +1 -0
  40. package/dist/pagination.bundle.js +3 -3214
  41. package/dist/pagination.bundle.js.map +7 -0
  42. package/dist/pagination.d.ts +86 -9
  43. package/dist/pagination.d.ts.map +1 -1
  44. package/dist/pagination.js +358 -55
  45. package/dist/pagination.js.map +1 -1
  46. package/dist/react.d.ts.map +1 -1
  47. package/dist/react.js +63 -12
  48. package/dist/react.js.map +1 -1
  49. package/dist/render-report-v2.schema.json +29 -0
  50. package/dist/session.bundle.js +2 -2013
  51. package/dist/session.bundle.js.map +7 -0
  52. package/dist/session.d.ts +14 -5
  53. package/dist/session.d.ts.map +1 -1
  54. package/dist/session.js +62 -29
  55. package/dist/session.js.map +1 -1
  56. package/dist/types.d.ts +137 -21
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/types.js +14 -0
  59. package/dist/types.js.map +1 -1
  60. package/dist/wasm/_framework/Docxodus.wasm +0 -0
  61. package/dist/wasm/_framework/Docxodus.wasm.br +0 -0
  62. package/dist/wasm/_framework/DocxodusWasm.wasm +0 -0
  63. package/dist/wasm/_framework/DocxodusWasm.wasm.br +0 -0
  64. package/dist/wasm/_framework/System.Collections.wasm +0 -0
  65. package/dist/wasm/_framework/System.Collections.wasm.br +0 -0
  66. package/dist/wasm/_framework/System.IO.Compression.wasm +0 -0
  67. package/dist/wasm/_framework/System.IO.Compression.wasm.br +0 -0
  68. package/dist/wasm/_framework/System.Linq.wasm +0 -0
  69. package/dist/wasm/_framework/System.Linq.wasm.br +0 -0
  70. package/dist/wasm/_framework/System.Memory.wasm +0 -0
  71. package/dist/wasm/_framework/System.Memory.wasm.br +0 -0
  72. package/dist/wasm/_framework/System.Private.CoreLib.wasm +0 -0
  73. package/dist/wasm/_framework/System.Private.CoreLib.wasm.br +0 -0
  74. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm +0 -0
  75. package/dist/wasm/_framework/System.Private.Xml.Linq.wasm.br +0 -0
  76. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm +0 -0
  77. package/dist/wasm/_framework/System.Text.RegularExpressions.wasm.br +0 -0
  78. package/dist/wasm/_framework/dotnet.boot.js +11 -11
  79. package/dist/wasm/_framework/dotnet.boot.js.br +0 -0
  80. package/dist/wasm/_framework/dotnet.native.wasm +0 -0
  81. package/dist/wasm/_framework/dotnet.native.wasm.br +0 -0
  82. package/dist/word-text.d.ts +14 -0
  83. package/dist/word-text.d.ts.map +1 -0
  84. package/dist/word-text.js +377 -0
  85. package/dist/word-text.js.map +1 -0
  86. package/dist/worker-proxy.bundle.js +2 -536
  87. package/dist/worker-proxy.bundle.js.map +7 -0
  88. package/dist/worker-proxy.d.ts +14 -1
  89. package/dist/worker-proxy.d.ts.map +1 -1
  90. package/dist/worker-proxy.js +357 -339
  91. package/dist/worker-proxy.js.map +1 -1
  92. package/package.json +13 -12
@@ -1,1073 +1,2 @@
1
- // src/external-annotation-wire.ts
2
- function readPawlsPage(p) {
3
- return {
4
- page: {
5
- width: p.Page?.Width ?? p.page?.width,
6
- height: p.Page?.Height ?? p.page?.height,
7
- index: p.Page?.Index ?? p.page?.index
8
- },
9
- tokens: (p.Tokens || p.tokens || []).map((t) => ({
10
- x: t.X ?? t.x,
11
- y: t.Y ?? t.y,
12
- width: t.Width ?? t.width,
13
- height: t.Height ?? t.height,
14
- text: t.Text ?? t.text
15
- }))
16
- };
17
- }
18
- function readAnnotationJson(json) {
19
- if (!json) return void 0;
20
- if (json.Start !== void 0 || json.start !== void 0) {
21
- return {
22
- id: json.Id ?? json.id,
23
- start: json.Start ?? json.start,
24
- end: json.End ?? json.end,
25
- text: json.Text ?? json.text
26
- };
27
- }
28
- const result = {};
29
- for (const [key, value] of Object.entries(json)) {
30
- const v = value;
31
- result[key] = {
32
- bounds: {
33
- top: v.Bounds?.Top ?? v.bounds?.top,
34
- bottom: v.Bounds?.Bottom ?? v.bounds?.bottom,
35
- left: v.Bounds?.Left ?? v.bounds?.left,
36
- right: v.Bounds?.Right ?? v.bounds?.right
37
- },
38
- tokensJsons: (v.TokensJsons || v.tokensJsons || []).map((t) => ({
39
- pageIndex: t.PageIndex ?? t.pageIndex,
40
- tokenIndex: t.TokenIndex ?? t.tokenIndex
41
- })),
42
- rawText: v.RawText ?? v.rawText
43
- };
44
- }
45
- return result;
46
- }
47
- function readAnnotation(a) {
48
- return {
49
- id: a.Id ?? a.id,
50
- annotationLabel: a.AnnotationLabel ?? a.annotationLabel,
51
- rawText: a.RawText ?? a.rawText,
52
- page: a.Page ?? a.page,
53
- annotationJson: readAnnotationJson(a.AnnotationJson ?? a.annotationJson),
54
- parentId: a.ParentId ?? a.parentId,
55
- annotationType: a.AnnotationType ?? a.annotationType,
56
- structural: a.Structural ?? a.structural
57
- };
58
- }
59
- function readRelationship(r) {
60
- return {
61
- id: r.Id ?? r.id,
62
- relationshipLabel: r.RelationshipLabel ?? r.relationshipLabel,
63
- sourceAnnotationIds: r.SourceAnnotationIds ?? r.sourceAnnotationIds ?? [],
64
- targetAnnotationIds: r.TargetAnnotationIds ?? r.targetAnnotationIds ?? [],
65
- structural: r.Structural ?? r.structural
66
- };
67
- }
68
- function readLabel(l) {
69
- return {
70
- id: l.Id ?? l.id,
71
- color: l.Color ?? l.color,
72
- description: l.Description ?? l.description ?? "",
73
- icon: l.Icon ?? l.icon ?? "",
74
- text: l.Text ?? l.text,
75
- labelType: l.LabelType ?? l.labelType ?? "text"
76
- };
77
- }
78
- function readLabels(raw) {
79
- const labels = {};
80
- for (const [key, value] of Object.entries(raw || {})) labels[key] = readLabel(value);
81
- return labels;
82
- }
83
- function readOpenContractExport(parsed) {
84
- return {
85
- title: parsed.Title ?? parsed.title,
86
- content: parsed.Content ?? parsed.content,
87
- description: parsed.Description ?? parsed.description,
88
- pageCount: parsed.PageCount ?? parsed.pageCount,
89
- pawlsFileContent: (parsed.PawlsFileContent || parsed.pawlsFileContent || []).map(readPawlsPage),
90
- docLabels: parsed.DocLabels ?? parsed.docLabels ?? [],
91
- labelledText: (parsed.LabelledText || parsed.labelledText || []).map(readAnnotation),
92
- relationships: (parsed.Relationships || parsed.relationships)?.map(readRelationship)
93
- };
94
- }
95
- function readExternalAnnotationSet(parsed) {
96
- return {
97
- documentId: parsed.DocumentId ?? parsed.documentId,
98
- documentHash: parsed.DocumentHash ?? parsed.documentHash,
99
- createdAt: parsed.CreatedAt ?? parsed.createdAt,
100
- updatedAt: parsed.UpdatedAt ?? parsed.updatedAt,
101
- version: parsed.Version ?? parsed.version,
102
- ...readOpenContractExport(parsed),
103
- textLabels: readLabels(parsed.TextLabels || parsed.textLabels),
104
- docLabelDefinitions: readLabels(parsed.DocLabelDefinitions || parsed.docLabelDefinitions)
105
- };
106
- }
107
- function readExternalAnnotationValidation(parsed) {
108
- return {
109
- isValid: parsed.IsValid ?? parsed.isValid,
110
- hashMismatch: parsed.HashMismatch ?? parsed.hashMismatch,
111
- issues: (parsed.Issues || parsed.issues || []).map((i) => ({
112
- annotationId: i.AnnotationId ?? i.annotationId,
113
- issueType: i.IssueType ?? i.issueType,
114
- description: i.Description ?? i.description,
115
- expectedText: i.ExpectedText ?? i.expectedText,
116
- actualText: i.ActualText ?? i.actualText
117
- }))
118
- };
119
- }
120
- function readProjectedHtml(parsed) {
121
- return parsed.Html ?? parsed.html;
122
- }
123
-
124
- // src/docxodus.worker.ts
125
- var wasmExports = null;
126
- var initPromise = null;
127
- var sessionHandles = /* @__PURE__ */ new Set();
128
- async function initializeWasm(basePath) {
129
- if (wasmExports) {
130
- return;
131
- }
132
- if (initPromise) {
133
- return initPromise;
134
- }
135
- initPromise = (async () => {
136
- try {
137
- const normalizedPath = basePath.endsWith("/") ? basePath : basePath + "/";
138
- const dotnetModule = await import(
139
- /* webpackIgnore: true */
140
- `${normalizedPath}_framework/dotnet.js`
141
- );
142
- const { getAssemblyExports, getConfig } = await dotnetModule.dotnet.withDiagnosticTracing(false).create();
143
- const config = getConfig();
144
- const exports = await getAssemblyExports(config.mainAssemblyName);
145
- wasmExports = {
146
- DocumentConverter: exports.DocxodusWasm.DocumentConverter,
147
- DocumentComparer: exports.DocxodusWasm.DocumentComparer,
148
- DocxDiffBridge: exports.DocxodusWasm.DocxDiffBridge,
149
- DocxSessionBridge: exports.DocxodusWasm.DocxSessionBridge
150
- };
151
- } catch (error) {
152
- initPromise = null;
153
- throw error;
154
- }
155
- })();
156
- return initPromise;
157
- }
158
- function ensureInitialized() {
159
- if (!wasmExports) {
160
- throw new Error("Worker not initialized. Call init first.");
161
- }
162
- return wasmExports;
163
- }
164
- function isErrorResponse(result) {
165
- try {
166
- const parsed = JSON.parse(result);
167
- return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && "Error" in parsed;
168
- } catch {
169
- return false;
170
- }
171
- }
172
- function handleGeneratePackageManifest(request) {
173
- try {
174
- const json = request.limits ? ensureInitialized().DocumentConverter.GeneratePackageManifestWithOptions(
175
- request.documentBytes,
176
- request.limits.opcEntries,
177
- request.limits.expandedOpcBytes,
178
- request.limits.xmlPartBytes,
179
- request.limits.opcCompressionRatio,
180
- request.limits.opcUriCharacters
181
- ) : ensureInitialized().DocumentConverter.GeneratePackageManifest(
182
- request.documentBytes
183
- );
184
- const representation = request.representation ?? "both";
185
- return {
186
- manifest: representation === "json" ? void 0 : JSON.parse(json),
187
- manifestJson: representation === "object" ? void 0 : json
188
- };
189
- } catch (error) {
190
- return { error: String(error) };
191
- }
192
- }
193
- function handleProjectReviewProfile(request) {
194
- try {
195
- const result = request.profile === "final" ? ensureInitialized().DocxDiffBridge.AcceptRevisions(request.documentBytes) : ensureInitialized().DocxDiffBridge.RejectRevisions(request.documentBytes);
196
- if (!result || result.byteLength === 0) {
197
- return { error: `Failed to derive the ${request.profile} review profile` };
198
- }
199
- if (request.maximumOutputBytes !== void 0 && result.byteLength > request.maximumOutputBytes) {
200
- return {
201
- error: `Derived ${request.profile} package exceeds compressedDocxBytes (${result.byteLength} > ${request.maximumOutputBytes})`,
202
- errorCode: "resource_limit"
203
- };
204
- }
205
- return { documentBytes: result };
206
- } catch (error) {
207
- return { error: String(error) };
208
- }
209
- }
210
- function handleProveRedlineReversibility(request) {
211
- try {
212
- const json = ensureInitialized().DocumentConverter.ProveRedlineReversibility(
213
- request.baselineBytes,
214
- request.intendedFinalBytes,
215
- request.redlineBytes
216
- );
217
- return { proof: JSON.parse(json) };
218
- } catch (error) {
219
- return { error: String(error) };
220
- }
221
- }
222
- function handleVerifyDeliverable(request) {
223
- try {
224
- const converter = ensureInitialized().DocumentConverter;
225
- let json;
226
- if (request.requestJson !== void 0) {
227
- if (!converter.VerifyDeliverableWithRequest || !converter.VerifyDeliverableWithBaselineAndRequest) {
228
- throw new Error("This WASM bundle predates full verification requests; rebuild docxodus.");
229
- }
230
- json = request.baselineBytes === void 0 ? converter.VerifyDeliverableWithRequest(request.documentBytes, request.requestJson) : converter.VerifyDeliverableWithBaselineAndRequest(
231
- request.baselineBytes,
232
- request.documentBytes,
233
- request.requestJson
234
- );
235
- } else {
236
- json = request.baselineBytes === void 0 ? converter.VerifyDeliverable(request.documentBytes) : converter.VerifyDeliverableWithBaseline(
237
- request.baselineBytes,
238
- request.documentBytes
239
- );
240
- }
241
- return {
242
- verification: JSON.parse(json)
243
- };
244
- } catch (error) {
245
- return { error: String(error) };
246
- }
247
- }
248
- function handleGetSemanticChanges(request) {
249
- try {
250
- const json = ensureInitialized().DocxDiffBridge.GetSemanticChangesJson(
251
- request.leftBytes,
252
- request.rightBytes,
253
- request.settings ? JSON.stringify(request.settings) : ""
254
- );
255
- if (isErrorResponse(json)) return { error: parseError(json).error };
256
- return { semanticChanges: JSON.parse(json) };
257
- } catch (error) {
258
- return { error: String(error) };
259
- }
260
- }
261
- function handleCreateExternalAnnotationSet(request) {
262
- try {
263
- const json = ensureInitialized().DocumentConverter.CreateExternalAnnotationSet(
264
- request.documentBytes,
265
- request.documentId
266
- );
267
- if (isErrorResponse(json)) return { error: parseError(json).error };
268
- return { annotationSet: readExternalAnnotationSet(JSON.parse(json)) };
269
- } catch (error) {
270
- return { error: String(error) };
271
- }
272
- }
273
- function handleValidateExternalAnnotations(request) {
274
- try {
275
- const json = ensureInitialized().DocumentConverter.ValidateExternalAnnotations(
276
- request.documentBytes,
277
- JSON.stringify(request.annotationSet)
278
- );
279
- if (isErrorResponse(json)) return { error: parseError(json).error };
280
- return { validation: readExternalAnnotationValidation(JSON.parse(json)) };
281
- } catch (error) {
282
- return { error: String(error) };
283
- }
284
- }
285
- function handleProjectAnnotationsOntoHtml(request) {
286
- try {
287
- const json = ensureInitialized().DocumentConverter.ProjectAnnotationsOntoHtml(
288
- request.html,
289
- JSON.stringify(request.annotationSet),
290
- request.projectionOptions?.cssClassPrefix ?? "ext-annot-",
291
- request.projectionOptions?.labelMode ?? 0 /* Above */
292
- );
293
- if (isErrorResponse(json)) return { error: parseError(json).error };
294
- return { html: readProjectedHtml(JSON.parse(json)) };
295
- } catch (error) {
296
- return { error: String(error) };
297
- }
298
- }
299
- function handleConvertWithExternalAnnotations(request) {
300
- try {
301
- const options = request.conversionOptions;
302
- const json = ensureInitialized().DocumentConverter.ConvertDocxToHtmlWithExternalAnnotations(
303
- request.documentBytes,
304
- JSON.stringify(request.annotationSet),
305
- options?.pageTitle ?? "Document",
306
- options?.cssPrefix ?? "docx-",
307
- options?.fabricateClasses ?? true,
308
- options?.additionalCss ?? "",
309
- request.projectionOptions?.cssClassPrefix ?? "ext-annot-",
310
- request.projectionOptions?.labelMode ?? 0 /* Above */
311
- );
312
- if (isErrorResponse(json)) return { error: parseError(json).error };
313
- return { html: readProjectedHtml(JSON.parse(json)) };
314
- } catch (error) {
315
- return { error: String(error) };
316
- }
317
- }
318
- function handleExportToOpenContract(request) {
319
- try {
320
- const json = ensureInitialized().DocumentConverter.ExportToOpenContract(request.documentBytes);
321
- if (isErrorResponse(json)) return { error: parseError(json).error };
322
- return { export: readOpenContractExport(JSON.parse(json)) };
323
- } catch (error) {
324
- return { error: String(error) };
325
- }
326
- }
327
- function parseError(result) {
328
- try {
329
- const parsed = JSON.parse(result);
330
- return { error: parsed.Error || parsed.error || "Unknown error" };
331
- } catch {
332
- return { error: result };
333
- }
334
- }
335
- function handleConvert(request) {
336
- const exports = ensureInitialized();
337
- const options = request.options;
338
- try {
339
- let result;
340
- const needsCompleteMethod = options?.renderFootnotesAndEndnotes !== void 0 || options?.renderHeadersAndFooters !== void 0 || options?.renderTrackedChanges !== void 0 || options?.showDeletedContent !== void 0 || options?.renderMoveOperations !== void 0 || options?.renderUnsupportedContentPlaceholders !== void 0 || options?.documentLanguage !== void 0;
341
- if (needsCompleteMethod || options?.renderAnnotations) {
342
- result = exports.DocumentConverter.ConvertDocxToHtmlComplete(
343
- request.documentBytes,
344
- options?.pageTitle ?? "Document",
345
- options?.cssPrefix ?? "docx-",
346
- options?.fabricateClasses ?? true,
347
- options?.additionalCss ?? "",
348
- options?.commentRenderMode ?? -1,
349
- options?.commentCssClassPrefix ?? "comment-",
350
- options?.paginationMode ?? 0,
351
- options?.paginationScale ?? 1,
352
- options?.paginationCssClassPrefix ?? "page-",
353
- options?.renderAnnotations ?? false,
354
- options?.annotationLabelMode ?? 0,
355
- options?.annotationCssClassPrefix ?? "annot-",
356
- options?.renderFootnotesAndEndnotes ?? false,
357
- options?.renderHeadersAndFooters ?? false,
358
- options?.renderTrackedChanges ?? false,
359
- options?.showDeletedContent ?? true,
360
- options?.renderMoveOperations ?? true,
361
- options?.renderUnsupportedContentPlaceholders ?? false,
362
- options?.documentLanguage ?? null,
363
- options?.stampAnchors ?? false
364
- );
365
- } else if (options?.paginationMode !== void 0 && options.paginationMode !== 0) {
366
- result = exports.DocumentConverter.ConvertDocxToHtmlWithPagination(
367
- request.documentBytes,
368
- options.pageTitle ?? "Document",
369
- options.cssPrefix ?? "docx-",
370
- options.fabricateClasses ?? true,
371
- options.additionalCss ?? "",
372
- options.commentRenderMode ?? -1,
373
- options.commentCssClassPrefix ?? "comment-",
374
- options.paginationMode,
375
- options.paginationScale ?? 1,
376
- options.paginationCssClassPrefix ?? "page-"
377
- );
378
- } else if (options) {
379
- result = exports.DocumentConverter.ConvertDocxToHtmlWithOptions(
380
- request.documentBytes,
381
- options.pageTitle ?? "Document",
382
- options.cssPrefix ?? "docx-",
383
- options.fabricateClasses ?? true,
384
- options.additionalCss ?? "",
385
- options.commentRenderMode ?? -1,
386
- options.commentCssClassPrefix ?? "comment-"
387
- );
388
- } else {
389
- result = exports.DocumentConverter.ConvertDocxToHtml(
390
- request.documentBytes
391
- );
392
- }
393
- if (isErrorResponse(result)) {
394
- return parseError(result);
395
- }
396
- if (request.maximumOutputBytes !== void 0) {
397
- let byteLength = 0;
398
- for (let index = 0; index < result.length; index++) {
399
- const unit = result.charCodeAt(index);
400
- if (unit < 128) byteLength++;
401
- else if (unit < 2048) byteLength += 2;
402
- else if (unit >= 55296 && unit <= 56319 && result.charCodeAt(index + 1) >= 56320 && result.charCodeAt(index + 1) <= 57343) {
403
- byteLength += 4;
404
- index++;
405
- } else byteLength += 3;
406
- if (byteLength > request.maximumOutputBytes) {
407
- return {
408
- error: `Converted HTML exceeds htmlOutputBytes (${byteLength} > ${request.maximumOutputBytes})`,
409
- errorCode: "resource_limit"
410
- };
411
- }
412
- }
413
- }
414
- return { html: result };
415
- } catch (error) {
416
- return { error: String(error) };
417
- }
418
- }
419
- function handleCompare(request) {
420
- const exports = ensureInitialized();
421
- const options = request.options;
422
- try {
423
- let result;
424
- if (options?.caseInsensitive) {
425
- result = exports.DocumentComparer.CompareDocumentsWithOptions(
426
- request.originalBytes,
427
- request.modifiedBytes,
428
- options?.authorName ?? "Docxodus",
429
- options.caseInsensitive
430
- );
431
- } else {
432
- result = exports.DocumentComparer.CompareDocuments(
433
- request.originalBytes,
434
- request.modifiedBytes,
435
- options?.authorName ?? "Docxodus"
436
- );
437
- }
438
- if (result.length === 0) {
439
- return { error: "Comparison returned empty result" };
440
- }
441
- return { documentBytes: result };
442
- } catch (error) {
443
- return { error: String(error) };
444
- }
445
- }
446
- function handleCompareToHtml(request) {
447
- const exports = ensureInitialized();
448
- const options = request.options;
449
- try {
450
- const renderTrackedChanges = options?.renderTrackedChanges ?? true;
451
- const result = exports.DocumentComparer.CompareDocumentsToHtmlWithOptions(
452
- request.originalBytes,
453
- request.modifiedBytes,
454
- options?.authorName ?? "Docxodus",
455
- renderTrackedChanges
456
- );
457
- if (isErrorResponse(result)) {
458
- return parseError(result);
459
- }
460
- return { html: result };
461
- } catch (error) {
462
- return { error: String(error) };
463
- }
464
- }
465
- function handleGetRevisions(request) {
466
- const exports = ensureInitialized();
467
- try {
468
- const result = exports.DocumentComparer.GetRevisionsJson(request.documentBytes);
469
- if (isErrorResponse(result)) {
470
- return parseError(result);
471
- }
472
- const revisions = JSON.parse(result);
473
- return { revisions };
474
- } catch (error) {
475
- return { error: String(error) };
476
- }
477
- }
478
- function handleGetComments(request) {
479
- const exports = ensureInitialized();
480
- try {
481
- const result = exports.DocumentComparer.GetCommentsJson(request.documentBytes);
482
- if (isErrorResponse(result)) {
483
- return parseError(result);
484
- }
485
- return { comments: JSON.parse(result) };
486
- } catch (error) {
487
- return { error: String(error) };
488
- }
489
- }
490
- function handleGetDocumentMetadata(request) {
491
- const exports = ensureInitialized();
492
- try {
493
- const result = exports.DocumentConverter.GetDocumentMetadata(
494
- request.documentBytes
495
- );
496
- if (isErrorResponse(result)) {
497
- return parseError(result);
498
- }
499
- const parsed = JSON.parse(result);
500
- const convertSection = (s) => ({
501
- sectionIndex: s.SectionIndex ?? s.sectionIndex,
502
- pageWidthPt: s.PageWidthPt ?? s.pageWidthPt,
503
- pageHeightPt: s.PageHeightPt ?? s.pageHeightPt,
504
- marginTopPt: s.MarginTopPt ?? s.marginTopPt,
505
- marginRightPt: s.MarginRightPt ?? s.marginRightPt,
506
- marginBottomPt: s.MarginBottomPt ?? s.marginBottomPt,
507
- marginLeftPt: s.MarginLeftPt ?? s.marginLeftPt,
508
- contentWidthPt: s.ContentWidthPt ?? s.contentWidthPt,
509
- contentHeightPt: s.ContentHeightPt ?? s.contentHeightPt,
510
- headerPt: s.HeaderPt ?? s.headerPt,
511
- footerPt: s.FooterPt ?? s.footerPt,
512
- paragraphCount: s.ParagraphCount ?? s.paragraphCount,
513
- tableCount: s.TableCount ?? s.tableCount,
514
- hasHeader: s.HasHeader ?? s.hasHeader,
515
- hasFooter: s.HasFooter ?? s.hasFooter,
516
- hasFirstPageHeader: s.HasFirstPageHeader ?? s.hasFirstPageHeader,
517
- hasFirstPageFooter: s.HasFirstPageFooter ?? s.hasFirstPageFooter,
518
- hasEvenPageHeader: s.HasEvenPageHeader ?? s.hasEvenPageHeader,
519
- hasEvenPageFooter: s.HasEvenPageFooter ?? s.hasEvenPageFooter,
520
- startParagraphIndex: s.StartParagraphIndex ?? s.startParagraphIndex,
521
- endParagraphIndex: s.EndParagraphIndex ?? s.endParagraphIndex,
522
- startTableIndex: s.StartTableIndex ?? s.startTableIndex,
523
- endTableIndex: s.EndTableIndex ?? s.endTableIndex
524
- });
525
- const metadata = {
526
- sections: (parsed.Sections || parsed.sections || []).map(convertSection),
527
- totalParagraphs: parsed.TotalParagraphs ?? parsed.totalParagraphs,
528
- totalTables: parsed.TotalTables ?? parsed.totalTables,
529
- hasFootnotes: parsed.HasFootnotes ?? parsed.hasFootnotes,
530
- hasEndnotes: parsed.HasEndnotes ?? parsed.hasEndnotes,
531
- hasTrackedChanges: parsed.HasTrackedChanges ?? parsed.hasTrackedChanges,
532
- hasComments: parsed.HasComments ?? parsed.hasComments,
533
- estimatedPageCount: parsed.EstimatedPageCount ?? parsed.estimatedPageCount,
534
- estimatedPageCountSource: parsed.EstimatedPageCountSource ?? parsed.estimatedPageCountSource ?? "heuristic"
535
- };
536
- return { metadata };
537
- } catch (error) {
538
- return { error: String(error) };
539
- }
540
- }
541
- function handleSessionOpen(request) {
542
- const exports = ensureInitialized();
543
- try {
544
- const handle = exports.DocxSessionBridge.OpenSession(
545
- request.documentBytes,
546
- request.settingsJson ?? ""
547
- );
548
- sessionHandles.add(handle);
549
- return { handle };
550
- } catch (error) {
551
- return { error: String(error) };
552
- }
553
- }
554
- function handleSessionGetPackageManifest(request) {
555
- try {
556
- const json = ensureInitialized().DocxSessionBridge.GetPackageManifest(request.handle);
557
- return { manifest: JSON.parse(json) };
558
- } catch (error) {
559
- return { error: String(error) };
560
- }
561
- }
562
- function handleSessionGetSemanticChanges(request) {
563
- try {
564
- const json = ensureInitialized().DocxSessionBridge.GetSemanticChanges(request.handle);
565
- if (isErrorResponse(json)) return { error: parseError(json).error };
566
- return { semanticChanges: JSON.parse(json) };
567
- } catch (error) {
568
- return { error: String(error) };
569
- }
570
- }
571
- function handleSessionVerifyDeliverable(request) {
572
- try {
573
- const bridge = ensureInitialized().DocxSessionBridge;
574
- let json;
575
- if (request.requestJson !== void 0) {
576
- if (!bridge.VerifyDeliverableWithRequest) {
577
- throw new Error("This WASM bundle predates full verification requests; rebuild docxodus.");
578
- }
579
- json = bridge.VerifyDeliverableWithRequest(request.handle, request.requestJson);
580
- } else {
581
- json = bridge.VerifyDeliverable(request.handle);
582
- }
583
- return {
584
- verification: JSON.parse(json)
585
- };
586
- } catch (error) {
587
- return { error: String(error) };
588
- }
589
- }
590
- function handleSessionClose(request) {
591
- const exports = ensureInitialized();
592
- try {
593
- exports.DocxSessionBridge.CloseSession(request.handle);
594
- sessionHandles.delete(request.handle);
595
- return {};
596
- } catch (error) {
597
- return { error: String(error) };
598
- }
599
- }
600
- function handleSessionAddAnnotation(request) {
601
- const exports = ensureInitialized();
602
- try {
603
- const json = exports.DocxSessionBridge.AddAnnotation(
604
- request.handle,
605
- request.anchorId,
606
- request.spanJson,
607
- request.annotationJson
608
- );
609
- const result = JSON.parse(json);
610
- return { result };
611
- } catch (error) {
612
- return { error: String(error) };
613
- }
614
- }
615
- function handleSessionRemoveAnnotation(request) {
616
- const exports = ensureInitialized();
617
- try {
618
- const json = exports.DocxSessionBridge.SessionRemoveAnnotation(
619
- request.handle,
620
- request.annotationId
621
- );
622
- const result = JSON.parse(json);
623
- return { result };
624
- } catch (error) {
625
- return { error: String(error) };
626
- }
627
- }
628
- function handleSessionUpdateAnnotation(request) {
629
- const exports = ensureInitialized();
630
- try {
631
- const json = exports.DocxSessionBridge.UpdateAnnotation(
632
- request.handle,
633
- request.annotationId,
634
- request.updateJson
635
- );
636
- const result = JSON.parse(json);
637
- return { result };
638
- } catch (error) {
639
- return { error: String(error) };
640
- }
641
- }
642
- function handleSessionMoveAnnotation(request) {
643
- const exports = ensureInitialized();
644
- try {
645
- const json = exports.DocxSessionBridge.MoveAnnotation(
646
- request.handle,
647
- request.annotationId,
648
- request.newAnchorId,
649
- request.newSpanJson
650
- );
651
- const result = JSON.parse(json);
652
- return { result };
653
- } catch (error) {
654
- return { error: String(error) };
655
- }
656
- }
657
- function handlePrepare() {
658
- const exports = ensureInitialized();
659
- try {
660
- const result = exports.DocumentComparer.Warmup();
661
- if (isErrorResponse(result)) {
662
- return parseError(result);
663
- }
664
- return {};
665
- } catch (error) {
666
- return { error: String(error) };
667
- }
668
- }
669
- function handleGetVersion() {
670
- const exports = ensureInitialized();
671
- try {
672
- const result = exports.DocumentConverter.GetVersion();
673
- const parsed = JSON.parse(result);
674
- return {
675
- version: {
676
- library: parsed.Library || parsed.library,
677
- dotnetVersion: parsed.DotnetVersion || parsed.dotnetVersion,
678
- platform: parsed.Platform || parsed.platform
679
- }
680
- };
681
- } catch (error) {
682
- return { error: String(error) };
683
- }
684
- }
685
- self.addEventListener("message", async (event) => {
686
- const request = event.data;
687
- try {
688
- let response;
689
- switch (request.type) {
690
- case "init": {
691
- const initRequest = request;
692
- try {
693
- await initializeWasm(initRequest.wasmBasePath);
694
- response = {
695
- id: request.id,
696
- type: "init",
697
- success: true
698
- };
699
- } catch (error) {
700
- response = {
701
- id: request.id,
702
- type: "init",
703
- success: false,
704
- error: String(error)
705
- };
706
- }
707
- break;
708
- }
709
- case "generatePackageManifest": {
710
- const result = handleGeneratePackageManifest(
711
- request
712
- );
713
- response = {
714
- id: request.id,
715
- type: "generatePackageManifest",
716
- success: !result.error,
717
- manifest: result.manifest,
718
- manifestJson: result.manifestJson,
719
- error: result.error
720
- };
721
- break;
722
- }
723
- case "verifyDeliverable": {
724
- const result = handleVerifyDeliverable(
725
- request
726
- );
727
- response = {
728
- id: request.id,
729
- type: "verifyDeliverable",
730
- success: !result.error,
731
- verification: result.verification,
732
- error: result.error
733
- };
734
- break;
735
- }
736
- case "proveRedlineReversibility": {
737
- const result = handleProveRedlineReversibility(
738
- request
739
- );
740
- response = {
741
- id: request.id,
742
- type: "proveRedlineReversibility",
743
- success: !result.error,
744
- proof: result.proof,
745
- error: result.error
746
- };
747
- break;
748
- }
749
- case "projectReviewProfile": {
750
- const result = handleProjectReviewProfile(
751
- request
752
- );
753
- response = {
754
- id: request.id,
755
- type: "projectReviewProfile",
756
- success: !result.error,
757
- documentBytes: result.documentBytes,
758
- error: result.error,
759
- errorCode: result.errorCode
760
- };
761
- if (result.documentBytes) {
762
- self.postMessage(response, { transfer: [result.documentBytes.buffer] });
763
- return;
764
- }
765
- break;
766
- }
767
- case "convertDocxToHtml": {
768
- const convertRequest = request;
769
- const result = handleConvert(convertRequest);
770
- response = {
771
- id: request.id,
772
- type: "convertDocxToHtml",
773
- success: !result.error,
774
- html: result.html,
775
- error: result.error,
776
- errorCode: result.errorCode
777
- };
778
- break;
779
- }
780
- case "compareDocuments": {
781
- const compareRequest = request;
782
- const result = handleCompare(compareRequest);
783
- response = {
784
- id: request.id,
785
- type: "compareDocuments",
786
- success: !result.error,
787
- documentBytes: result.documentBytes,
788
- error: result.error
789
- };
790
- if (result.documentBytes) {
791
- self.postMessage(response, { transfer: [result.documentBytes.buffer] });
792
- return;
793
- }
794
- break;
795
- }
796
- case "compareDocumentsToHtml": {
797
- const compareToHtmlRequest = request;
798
- const result = handleCompareToHtml(compareToHtmlRequest);
799
- response = {
800
- id: request.id,
801
- type: "compareDocumentsToHtml",
802
- success: !result.error,
803
- html: result.html,
804
- error: result.error
805
- };
806
- break;
807
- }
808
- case "getSemanticChanges": {
809
- const result = handleGetSemanticChanges(
810
- request
811
- );
812
- response = {
813
- id: request.id,
814
- type: "getSemanticChanges",
815
- success: !result.error,
816
- semanticChanges: result.semanticChanges,
817
- error: result.error
818
- };
819
- break;
820
- }
821
- case "createExternalAnnotationSet": {
822
- const result = handleCreateExternalAnnotationSet(
823
- request
824
- );
825
- response = {
826
- id: request.id,
827
- type: "createExternalAnnotationSet",
828
- success: !result.error,
829
- annotationSet: result.annotationSet,
830
- error: result.error
831
- };
832
- break;
833
- }
834
- case "validateExternalAnnotations": {
835
- const result = handleValidateExternalAnnotations(
836
- request
837
- );
838
- response = {
839
- id: request.id,
840
- type: "validateExternalAnnotations",
841
- success: !result.error,
842
- validation: result.validation,
843
- error: result.error
844
- };
845
- break;
846
- }
847
- case "projectAnnotationsOntoHtml": {
848
- const result = handleProjectAnnotationsOntoHtml(
849
- request
850
- );
851
- response = {
852
- id: request.id,
853
- type: "projectAnnotationsOntoHtml",
854
- success: !result.error,
855
- html: result.html,
856
- error: result.error
857
- };
858
- break;
859
- }
860
- case "convertDocxToHtmlWithExternalAnnotations": {
861
- const result = handleConvertWithExternalAnnotations(
862
- request
863
- );
864
- response = {
865
- id: request.id,
866
- type: "convertDocxToHtmlWithExternalAnnotations",
867
- success: !result.error,
868
- html: result.html,
869
- error: result.error
870
- };
871
- break;
872
- }
873
- case "exportToOpenContract": {
874
- const result = handleExportToOpenContract(
875
- request
876
- );
877
- response = {
878
- id: request.id,
879
- type: "exportToOpenContract",
880
- success: !result.error,
881
- export: result.export,
882
- error: result.error
883
- };
884
- break;
885
- }
886
- case "getRevisions": {
887
- const getRevisionsRequest = request;
888
- const result = handleGetRevisions(getRevisionsRequest);
889
- response = {
890
- id: request.id,
891
- type: "getRevisions",
892
- success: !result.error,
893
- revisions: result.revisions,
894
- error: result.error
895
- };
896
- break;
897
- }
898
- case "getComments": {
899
- const result = handleGetComments(request);
900
- response = {
901
- id: request.id,
902
- type: "getComments",
903
- success: !result.error,
904
- comments: result.comments,
905
- error: result.error
906
- };
907
- break;
908
- }
909
- case "getDocumentMetadata": {
910
- const getMetadataRequest = request;
911
- const result = handleGetDocumentMetadata(getMetadataRequest);
912
- response = {
913
- id: request.id,
914
- type: "getDocumentMetadata",
915
- success: !result.error,
916
- metadata: result.metadata,
917
- error: result.error
918
- };
919
- break;
920
- }
921
- case "getVersion": {
922
- const result = handleGetVersion();
923
- response = {
924
- id: request.id,
925
- type: "getVersion",
926
- success: !result.error,
927
- version: result.version,
928
- error: result.error
929
- };
930
- break;
931
- }
932
- case "prepare": {
933
- const result = handlePrepare();
934
- response = {
935
- id: request.id,
936
- type: "prepare",
937
- success: !result.error,
938
- error: result.error
939
- };
940
- break;
941
- }
942
- case "sessionOpen": {
943
- const sessionOpenRequest = request;
944
- const result = handleSessionOpen(sessionOpenRequest);
945
- response = {
946
- id: request.id,
947
- type: "sessionOpen",
948
- success: !result.error,
949
- handle: result.handle,
950
- error: result.error
951
- };
952
- break;
953
- }
954
- case "sessionGetPackageManifest": {
955
- const result = handleSessionGetPackageManifest(
956
- request
957
- );
958
- response = {
959
- id: request.id,
960
- type: "sessionGetPackageManifest",
961
- success: !result.error,
962
- manifest: result.manifest,
963
- error: result.error
964
- };
965
- break;
966
- }
967
- case "sessionGetSemanticChanges": {
968
- const result = handleSessionGetSemanticChanges(
969
- request
970
- );
971
- response = {
972
- id: request.id,
973
- type: "sessionGetSemanticChanges",
974
- success: !result.error,
975
- semanticChanges: result.semanticChanges,
976
- error: result.error
977
- };
978
- break;
979
- }
980
- case "sessionVerifyDeliverable": {
981
- const result = handleSessionVerifyDeliverable(
982
- request
983
- );
984
- response = {
985
- id: request.id,
986
- type: "sessionVerifyDeliverable",
987
- success: !result.error,
988
- verification: result.verification,
989
- error: result.error
990
- };
991
- break;
992
- }
993
- case "sessionClose": {
994
- const sessionCloseRequest = request;
995
- const result = handleSessionClose(sessionCloseRequest);
996
- response = {
997
- id: request.id,
998
- type: "sessionClose",
999
- success: !result.error,
1000
- error: result.error
1001
- };
1002
- break;
1003
- }
1004
- case "sessionAddAnnotation": {
1005
- const addAnnotRequest = request;
1006
- const result = handleSessionAddAnnotation(addAnnotRequest);
1007
- response = {
1008
- id: request.id,
1009
- type: "sessionAddAnnotation",
1010
- success: !result.error,
1011
- result: result.result,
1012
- error: result.error
1013
- };
1014
- break;
1015
- }
1016
- case "sessionRemoveAnnotation": {
1017
- const removeAnnotRequest = request;
1018
- const result = handleSessionRemoveAnnotation(removeAnnotRequest);
1019
- response = {
1020
- id: request.id,
1021
- type: "sessionRemoveAnnotation",
1022
- success: !result.error,
1023
- result: result.result,
1024
- error: result.error
1025
- };
1026
- break;
1027
- }
1028
- case "sessionUpdateAnnotation": {
1029
- const updateAnnotRequest = request;
1030
- const result = handleSessionUpdateAnnotation(updateAnnotRequest);
1031
- response = {
1032
- id: request.id,
1033
- type: "sessionUpdateAnnotation",
1034
- success: !result.error,
1035
- result: result.result,
1036
- error: result.error
1037
- };
1038
- break;
1039
- }
1040
- case "sessionMoveAnnotation": {
1041
- const moveAnnotRequest = request;
1042
- const result = handleSessionMoveAnnotation(moveAnnotRequest);
1043
- response = {
1044
- id: request.id,
1045
- type: "sessionMoveAnnotation",
1046
- success: !result.error,
1047
- result: result.result,
1048
- error: result.error
1049
- };
1050
- break;
1051
- }
1052
- default: {
1053
- const unknownRequest = request;
1054
- self.postMessage({
1055
- id: unknownRequest.id,
1056
- type: unknownRequest.type,
1057
- success: false,
1058
- error: `Unknown request type: ${unknownRequest.type}`
1059
- });
1060
- return;
1061
- }
1062
- }
1063
- self.postMessage(response);
1064
- } catch (error) {
1065
- self.postMessage({
1066
- id: request.id,
1067
- type: request.type,
1068
- success: false,
1069
- error: String(error)
1070
- });
1071
- }
1072
- });
1073
- self.postMessage({ type: "ready" });
1
+ var y=["renderFootnotesAndEndnotes","renderHeadersAndFooters","renderTrackedChanges","showDeletedContent","renderMoveOperations","renderUnsupportedContentPlaceholders","documentLanguage","stampAnchors","revisionPresentation","semanticLists"];function p(e){return e?e.renderAnnotations===!0||y.some(n=>e[n]!==void 0):!1}function R(e){return{page:{width:e.Page?.Width??e.page?.width,height:e.Page?.Height??e.page?.height,index:e.Page?.Index??e.page?.index},tokens:(e.Tokens||e.tokens||[]).map(n=>({x:n.X??n.x,y:n.Y??n.y,width:n.Width??n.width,height:n.Height??n.height,text:n.Text??n.text}))}}function v(e){if(!e)return;if(e.Start!==void 0||e.start!==void 0)return{id:e.Id??e.id,start:e.Start??e.start,end:e.End??e.end,text:e.Text??e.text};let n={};for(let[t,r]of Object.entries(e)){let o=r;n[t]={bounds:{top:o.Bounds?.Top??o.bounds?.top,bottom:o.Bounds?.Bottom??o.bounds?.bottom,left:o.Bounds?.Left??o.bounds?.left,right:o.Bounds?.Right??o.bounds?.right},tokensJsons:(o.TokensJsons||o.tokensJsons||[]).map(s=>({pageIndex:s.PageIndex??s.pageIndex,tokenIndex:s.TokenIndex??s.tokenIndex})),rawText:o.RawText??o.rawText}}return n}function C(e){return{id:e.Id??e.id,annotationLabel:e.AnnotationLabel??e.annotationLabel,rawText:e.RawText??e.rawText,page:e.Page??e.page,annotationJson:v(e.AnnotationJson??e.annotationJson),parentId:e.ParentId??e.parentId,annotationType:e.AnnotationType??e.annotationType,structural:e.Structural??e.structural}}function k(e){return{id:e.Id??e.id,relationshipLabel:e.RelationshipLabel??e.relationshipLabel,sourceAnnotationIds:e.SourceAnnotationIds??e.sourceAnnotationIds??[],targetAnnotationIds:e.TargetAnnotationIds??e.targetAnnotationIds??[],structural:e.Structural??e.structural}}function A(e){return{id:e.Id??e.id,color:e.Color??e.color,description:e.Description??e.description??"",icon:e.Icon??e.icon??"",text:e.Text??e.text,labelType:e.LabelType??e.labelType??"text"}}function b(e){let n={};for(let[t,r]of Object.entries(e||{}))n[t]=A(r);return n}function u(e){return{title:e.Title??e.title,content:e.Content??e.content,description:e.Description??e.description,pageCount:e.PageCount??e.pageCount,pawlsFileContent:(e.PawlsFileContent||e.pawlsFileContent||[]).map(R),docLabels:e.DocLabels??e.docLabels??[],labelledText:(e.LabelledText||e.labelledText||[]).map(C),relationships:(e.Relationships||e.relationships)?.map(k)}}function h(e){return{documentId:e.DocumentId??e.documentId,documentHash:e.DocumentHash??e.documentHash,createdAt:e.CreatedAt??e.createdAt,updatedAt:e.UpdatedAt??e.updatedAt,version:e.Version??e.version,...u(e),textLabels:b(e.TextLabels||e.textLabels),docLabelDefinitions:b(e.DocLabelDefinitions||e.docLabelDefinitions)}}function f(e){return{isValid:e.IsValid??e.isValid,hashMismatch:e.HashMismatch??e.hashMismatch,issues:(e.Issues||e.issues||[]).map(n=>({annotationId:n.AnnotationId??n.annotationId,issueType:n.IssueType??n.issueType,description:n.Description??n.description,expectedText:n.ExpectedText??n.expectedText,actualText:n.ActualText??n.actualText}))}}function m(e){return e.Html??e.html}var d=null,g=null,x=new Set;async function P(e){if(!d)return g||(g=(async()=>{try{let t=await import(`${e.endsWith("/")?e:e+"/"}_framework/dotnet.js`),{getAssemblyExports:r,getConfig:o}=await t.dotnet.withDiagnosticTracing(!1).create(),s=o(),i=await r(s.mainAssemblyName);d={DocumentConverter:i.DocxodusWasm.DocumentConverter,DocumentComparer:i.DocxodusWasm.DocumentComparer,DocxDiffBridge:i.DocxodusWasm.DocxDiffBridge,DocxSessionBridge:i.DocxodusWasm.DocxSessionBridge}}catch(n){throw g=null,n}})(),g)}function a(){if(!d)throw new Error("Worker not initialized. Call init first.");return d}function l(e){try{let n=JSON.parse(e);return n!==null&&typeof n=="object"&&!Array.isArray(n)&&"Error"in n}catch{return!1}}function S(e){try{let n=e.limits?a().DocumentConverter.GeneratePackageManifestWithOptions(e.documentBytes,e.limits.opcEntries,e.limits.expandedOpcBytes,e.limits.xmlPartBytes,e.limits.opcCompressionRatio,e.limits.opcUriCharacters):a().DocumentConverter.GeneratePackageManifest(e.documentBytes),t=e.representation??"both";return{manifest:t==="json"?void 0:JSON.parse(n),manifestJson:t==="object"?void 0:n}}catch(n){return{error:String(n)}}}function I(e){try{let n=e.profile==="final"?a().DocxDiffBridge.AcceptRevisions(e.documentBytes):a().DocxDiffBridge.RejectRevisions(e.documentBytes);return!n||n.byteLength===0?{error:`Failed to derive the ${e.profile} review profile`}:e.maximumOutputBytes!==void 0&&n.byteLength>e.maximumOutputBytes?{error:`Derived ${e.profile} package exceeds compressedDocxBytes (${n.byteLength} > ${e.maximumOutputBytes})`,errorCode:"resource_limit"}:{documentBytes:n}}catch(n){return{error:String(n)}}}function D(e){try{let n=a().DocumentConverter.ProveRedlineReversibility(e.baselineBytes,e.intendedFinalBytes,e.redlineBytes);return{proof:JSON.parse(n)}}catch(n){return{error:String(n)}}}function T(e){try{let n=a().DocumentConverter,t;if(e.requestJson!==void 0){if(!n.VerifyDeliverableWithRequest||!n.VerifyDeliverableWithBaselineAndRequest)throw new Error("This WASM bundle predates full verification requests; rebuild docxodus.");t=e.baselineBytes===void 0?n.VerifyDeliverableWithRequest(e.documentBytes,e.requestJson):n.VerifyDeliverableWithBaselineAndRequest(e.baselineBytes,e.documentBytes,e.requestJson)}else t=e.baselineBytes===void 0?n.VerifyDeliverable(e.documentBytes):n.VerifyDeliverableWithBaseline(e.baselineBytes,e.documentBytes);return{verification:JSON.parse(t)}}catch(n){return{error:String(n)}}}function B(e){try{let n=a().DocxDiffBridge.GetSemanticChangesJson(e.leftBytes,e.rightBytes,e.settings?JSON.stringify(e.settings):"");return l(n)?{error:c(n).error}:{semanticChanges:JSON.parse(n)}}catch(n){return{error:String(n)}}}function W(e){try{let n=a().DocumentConverter.CreateExternalAnnotationSet(e.documentBytes,e.documentId);return l(n)?{error:c(n).error}:{annotationSet:h(JSON.parse(n))}}catch(n){return{error:String(n)}}}function E(e){try{let n=a().DocumentConverter.ValidateExternalAnnotations(e.documentBytes,JSON.stringify(e.annotationSet));return l(n)?{error:c(n).error}:{validation:f(JSON.parse(n))}}catch(n){return{error:String(n)}}}function w(e){try{let n=a().DocumentConverter.ProjectAnnotationsOntoHtml(e.html,JSON.stringify(e.annotationSet),e.projectionOptions?.cssClassPrefix??"ext-annot-",e.projectionOptions?.labelMode??0);return l(n)?{error:c(n).error}:{html:m(JSON.parse(n))}}catch(n){return{error:String(n)}}}function _(e){try{let n=e.conversionOptions,t=a().DocumentConverter.ConvertDocxToHtmlWithExternalAnnotations(e.documentBytes,JSON.stringify(e.annotationSet),n?.pageTitle??"Document",n?.cssPrefix??"docx-",n?.fabricateClasses??!0,n?.additionalCss??"",e.projectionOptions?.cssClassPrefix??"ext-annot-",e.projectionOptions?.labelMode??0);return l(t)?{error:c(t).error}:{html:m(JSON.parse(t))}}catch(n){return{error:String(n)}}}function M(e){try{let n=a().DocumentConverter.ExportToOpenContract(e.documentBytes);return l(n)?{error:c(n).error}:{export:u(JSON.parse(n))}}catch(n){return{error:String(n)}}}function c(e){try{let n=JSON.parse(e);return{error:n.Error||n.error||"Unknown error"}}catch{return{error:e}}}function O(e){let n=a(),t=e.options;try{let r;if(p(t)?r=n.DocumentConverter.ConvertDocxToHtmlComplete(e.documentBytes,t?.pageTitle??"Document",t?.cssPrefix??"docx-",t?.fabricateClasses??!0,t?.additionalCss??"",t?.commentRenderMode??-1,t?.commentCssClassPrefix??"comment-",t?.paginationMode??0,t?.paginationScale??1,t?.paginationCssClassPrefix??"page-",t?.renderAnnotations??!1,t?.annotationLabelMode??0,t?.annotationCssClassPrefix??"annot-",t?.renderFootnotesAndEndnotes??!1,t?.renderHeadersAndFooters??!1,t?.renderTrackedChanges??!1,t?.showDeletedContent??!0,t?.renderMoveOperations??!0,t?.renderUnsupportedContentPlaceholders??!1,t?.documentLanguage??null,t?.stampAnchors??!1,t?.revisionPresentation??0,t?.semanticLists??!1):t?.paginationMode!==void 0&&t.paginationMode!==0?r=n.DocumentConverter.ConvertDocxToHtmlWithPagination(e.documentBytes,t.pageTitle??"Document",t.cssPrefix??"docx-",t.fabricateClasses??!0,t.additionalCss??"",t.commentRenderMode??-1,t.commentCssClassPrefix??"comment-",t.paginationMode,t.paginationScale??1,t.paginationCssClassPrefix??"page-"):t?r=n.DocumentConverter.ConvertDocxToHtmlWithOptions(e.documentBytes,t.pageTitle??"Document",t.cssPrefix??"docx-",t.fabricateClasses??!0,t.additionalCss??"",t.commentRenderMode??-1,t.commentCssClassPrefix??"comment-"):r=n.DocumentConverter.ConvertDocxToHtml(e.documentBytes),l(r))return c(r);if(e.maximumOutputBytes!==void 0){let o=0;for(let s=0;s<r.length;s++){let i=r.charCodeAt(s);if(i<128?o++:i<2048?o+=2:i>=55296&&i<=56319&&r.charCodeAt(s+1)>=56320&&r.charCodeAt(s+1)<=57343?(o+=4,s++):o+=3,o>e.maximumOutputBytes)return{error:`Converted HTML exceeds htmlOutputBytes (${o} > ${e.maximumOutputBytes})`,errorCode:"resource_limit"}}}return{html:r}}catch(r){return{error:String(r)}}}function F(e){let n=a(),t=e.options;try{let r;return t?.caseInsensitive?r=n.DocumentComparer.CompareDocumentsWithOptions(e.originalBytes,e.modifiedBytes,t?.authorName??null,t.caseInsensitive):r=n.DocumentComparer.CompareDocuments(e.originalBytes,e.modifiedBytes,t?.authorName??null),r.length===0?{error:"Comparison returned empty result"}:{documentBytes:r}}catch(r){return{error:String(r)}}}function q(e){let n=a(),t=e.options;try{let r=t?.renderTrackedChanges??!0,o=n.DocumentComparer.CompareDocumentsToHtmlWithOptions(e.originalBytes,e.modifiedBytes,t?.authorName??null,r);return l(o)?c(o):{html:o}}catch(r){return{error:String(r)}}}function V(e){let n=a();try{let t=n.DocumentComparer.GetRevisionsJson(e.documentBytes);return l(t)?c(t):{revisions:JSON.parse(t)}}catch(t){return{error:String(t)}}}function H(e){let n=a();try{let t=n.DocumentComparer.GetCommentsJson(e.documentBytes);return l(t)?c(t):{comments:JSON.parse(t)}}catch(t){return{error:String(t)}}}function U(e){let n=a();try{let t=n.DocumentConverter.GetDocumentMetadata(e.documentBytes);if(l(t))return c(t);let r=JSON.parse(t),o=i=>({sectionIndex:i.SectionIndex??i.sectionIndex,pageWidthPt:i.PageWidthPt??i.pageWidthPt,pageHeightPt:i.PageHeightPt??i.pageHeightPt,marginTopPt:i.MarginTopPt??i.marginTopPt,marginRightPt:i.MarginRightPt??i.marginRightPt,marginBottomPt:i.MarginBottomPt??i.marginBottomPt,marginLeftPt:i.MarginLeftPt??i.marginLeftPt,contentWidthPt:i.ContentWidthPt??i.contentWidthPt,contentHeightPt:i.ContentHeightPt??i.contentHeightPt,headerPt:i.HeaderPt??i.headerPt,footerPt:i.FooterPt??i.footerPt,paragraphCount:i.ParagraphCount??i.paragraphCount,tableCount:i.TableCount??i.tableCount,hasHeader:i.HasHeader??i.hasHeader,hasFooter:i.HasFooter??i.hasFooter,hasFirstPageHeader:i.HasFirstPageHeader??i.hasFirstPageHeader,hasFirstPageFooter:i.HasFirstPageFooter??i.hasFirstPageFooter,hasEvenPageHeader:i.HasEvenPageHeader??i.hasEvenPageHeader,hasEvenPageFooter:i.HasEvenPageFooter??i.hasEvenPageFooter,startParagraphIndex:i.StartParagraphIndex??i.startParagraphIndex,endParagraphIndex:i.EndParagraphIndex??i.endParagraphIndex,startTableIndex:i.StartTableIndex??i.startTableIndex,endTableIndex:i.EndTableIndex??i.endTableIndex});return{metadata:{sections:(r.Sections||r.sections||[]).map(o),totalParagraphs:r.TotalParagraphs??r.totalParagraphs,totalTables:r.TotalTables??r.totalTables,hasFootnotes:r.HasFootnotes??r.hasFootnotes,hasEndnotes:r.HasEndnotes??r.hasEndnotes,hasTrackedChanges:r.HasTrackedChanges??r.hasTrackedChanges,hasComments:r.HasComments??r.hasComments,estimatedPageCount:r.EstimatedPageCount??r.estimatedPageCount,estimatedPageCountSource:r.EstimatedPageCountSource??r.estimatedPageCountSource??"heuristic"}}}catch(t){return{error:String(t)}}}function J(e){let n=a();try{let t=n.DocxSessionBridge.OpenSession(e.documentBytes,e.settingsJson??"");return x.add(t),{handle:t}}catch(t){return{error:String(t)}}}function L(e){try{let n=a().DocxSessionBridge.GetPackageManifest(e.handle);return{manifest:JSON.parse(n)}}catch(n){return{error:String(n)}}}function G(e){try{let n=a().DocxSessionBridge.GetSemanticChanges(e.handle);return l(n)?{error:c(n).error}:{semanticChanges:JSON.parse(n)}}catch(n){return{error:String(n)}}}function N(e){try{let n=a().DocxSessionBridge,t;if(e.requestJson!==void 0){if(!n.VerifyDeliverableWithRequest)throw new Error("This WASM bundle predates full verification requests; rebuild docxodus.");t=n.VerifyDeliverableWithRequest(e.handle,e.requestJson)}else t=n.VerifyDeliverable(e.handle);return{verification:JSON.parse(t)}}catch(n){return{error:String(n)}}}function j(e){let n=a();try{return n.DocxSessionBridge.CloseSession(e.handle),x.delete(e.handle),{}}catch(t){return{error:String(t)}}}function z(e){let n=a();try{let t=n.DocxSessionBridge.AddAnnotation(e.handle,e.anchorId,e.spanJson,e.annotationJson);return{result:JSON.parse(t)}}catch(t){return{error:String(t)}}}function K(e){let n=a();try{let t=n.DocxSessionBridge.SessionRemoveAnnotation(e.handle,e.annotationId);return{result:JSON.parse(t)}}catch(t){return{error:String(t)}}}function X(e){let n=a();try{let t=n.DocxSessionBridge.UpdateAnnotation(e.handle,e.annotationId,e.updateJson);return{result:JSON.parse(t)}}catch(t){return{error:String(t)}}}function $(e){let n=a();try{let t=n.DocxSessionBridge.MoveAnnotation(e.handle,e.annotationId,e.newAnchorId,e.newSpanJson);return{result:JSON.parse(t)}}catch(t){return{error:String(t)}}}function Y(){let e=a();try{let n=e.DocumentComparer.Warmup();return l(n)?c(n):{}}catch(n){return{error:String(n)}}}function Q(){let e=a();try{let n=e.DocumentConverter.GetVersion(),t=JSON.parse(n);return{version:{library:t.Library||t.library,dotnetVersion:t.DotnetVersion||t.dotnetVersion,platform:t.Platform||t.platform}}}catch(n){return{error:String(n)}}}self.addEventListener("message",async e=>{let n=e.data;try{let t;switch(n.type){case"init":{let r=n;try{await P(r.wasmBasePath),t={id:n.id,type:"init",success:!0}}catch(o){t={id:n.id,type:"init",success:!1,error:String(o),errorCode:"internal_error"}}break}case"generatePackageManifest":{let r=S(n);t={id:n.id,type:"generatePackageManifest",success:!r.error,manifest:r.manifest,manifestJson:r.manifestJson,error:r.error};break}case"verifyDeliverable":{let r=T(n);t={id:n.id,type:"verifyDeliverable",success:!r.error,verification:r.verification,error:r.error};break}case"proveRedlineReversibility":{let r=D(n);t={id:n.id,type:"proveRedlineReversibility",success:!r.error,proof:r.proof,error:r.error};break}case"projectReviewProfile":{let r=I(n);if(t={id:n.id,type:"projectReviewProfile",success:!r.error,documentBytes:r.documentBytes,error:r.error,errorCode:r.errorCode},r.documentBytes){self.postMessage(t,{transfer:[r.documentBytes.buffer]});return}break}case"convertDocxToHtml":{let o=O(n);t={id:n.id,type:"convertDocxToHtml",success:!o.error,html:o.html,error:o.error,errorCode:o.errorCode};break}case"compareDocuments":{let o=F(n);if(t={id:n.id,type:"compareDocuments",success:!o.error,documentBytes:o.documentBytes,error:o.error},o.documentBytes){self.postMessage(t,{transfer:[o.documentBytes.buffer]});return}break}case"compareDocumentsToHtml":{let o=q(n);t={id:n.id,type:"compareDocumentsToHtml",success:!o.error,html:o.html,error:o.error};break}case"getSemanticChanges":{let r=B(n);t={id:n.id,type:"getSemanticChanges",success:!r.error,semanticChanges:r.semanticChanges,error:r.error};break}case"createExternalAnnotationSet":{let r=W(n);t={id:n.id,type:"createExternalAnnotationSet",success:!r.error,annotationSet:r.annotationSet,error:r.error};break}case"validateExternalAnnotations":{let r=E(n);t={id:n.id,type:"validateExternalAnnotations",success:!r.error,validation:r.validation,error:r.error};break}case"projectAnnotationsOntoHtml":{let r=w(n);t={id:n.id,type:"projectAnnotationsOntoHtml",success:!r.error,html:r.html,error:r.error};break}case"convertDocxToHtmlWithExternalAnnotations":{let r=_(n);t={id:n.id,type:"convertDocxToHtmlWithExternalAnnotations",success:!r.error,html:r.html,error:r.error};break}case"exportToOpenContract":{let r=M(n);t={id:n.id,type:"exportToOpenContract",success:!r.error,export:r.export,error:r.error};break}case"getRevisions":{let o=V(n);t={id:n.id,type:"getRevisions",success:!o.error,revisions:o.revisions,error:o.error};break}case"getComments":{let r=H(n);t={id:n.id,type:"getComments",success:!r.error,comments:r.comments,error:r.error};break}case"getDocumentMetadata":{let o=U(n);t={id:n.id,type:"getDocumentMetadata",success:!o.error,metadata:o.metadata,error:o.error};break}case"getVersion":{let r=Q();t={id:n.id,type:"getVersion",success:!r.error,version:r.version,error:r.error};break}case"prepare":{let r=Y();t={id:n.id,type:"prepare",success:!r.error,error:r.error};break}case"sessionOpen":{let o=J(n);t={id:n.id,type:"sessionOpen",success:!o.error,handle:o.handle,error:o.error};break}case"sessionGetPackageManifest":{let r=L(n);t={id:n.id,type:"sessionGetPackageManifest",success:!r.error,manifest:r.manifest,error:r.error};break}case"sessionGetSemanticChanges":{let r=G(n);t={id:n.id,type:"sessionGetSemanticChanges",success:!r.error,semanticChanges:r.semanticChanges,error:r.error};break}case"sessionVerifyDeliverable":{let r=N(n);t={id:n.id,type:"sessionVerifyDeliverable",success:!r.error,verification:r.verification,error:r.error};break}case"sessionClose":{let o=j(n);t={id:n.id,type:"sessionClose",success:!o.error,error:o.error};break}case"sessionAddAnnotation":{let o=z(n);t={id:n.id,type:"sessionAddAnnotation",success:!o.error,result:o.result,error:o.error};break}case"sessionRemoveAnnotation":{let o=K(n);t={id:n.id,type:"sessionRemoveAnnotation",success:!o.error,result:o.result,error:o.error};break}case"sessionUpdateAnnotation":{let o=X(n);t={id:n.id,type:"sessionUpdateAnnotation",success:!o.error,result:o.result,error:o.error};break}case"sessionMoveAnnotation":{let o=$(n);t={id:n.id,type:"sessionMoveAnnotation",success:!o.error,result:o.result,error:o.error};break}default:{let r=n;self.postMessage({id:r.id,type:r.type,success:!1,error:`Unknown request type: ${r.type}`});return}}self.postMessage(t)}catch(t){self.postMessage({id:n.id,type:n.type,success:!1,error:String(t),errorCode:"internal_error"})}});self.postMessage({type:"ready"});
2
+ //# sourceMappingURL=docxodus.worker.js.map