js.documents 14.4.56 → 14.4.57

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 (163) hide show
  1. package/dist/codecs/read.cjs +2 -2
  2. package/dist/codecs/read.js +1 -1
  3. package/dist/composition-plan-CfvhXeOC.cjs +627 -0
  4. package/dist/composition-plan-DU9nPPN7.d.cts +102 -0
  5. package/dist/composition-plan-f0zaExUW.js +508 -0
  6. package/dist/composition-plan-l6QPO4FX.d.ts +102 -0
  7. package/dist/convert/composition-plan.cjs +7 -0
  8. package/dist/convert/composition-plan.d.cts +2 -0
  9. package/dist/convert/composition-plan.d.ts +2 -0
  10. package/dist/convert/composition-plan.js +2 -0
  11. package/dist/convert/composition-to-pdf.cjs +12 -12
  12. package/dist/convert/composition-to-pdf.d.cts +1 -1
  13. package/dist/convert/composition-to-pdf.d.ts +1 -1
  14. package/dist/convert/composition-to-pdf.js +2 -2
  15. package/dist/convert/composition.cjs +16 -511
  16. package/dist/convert/composition.d.cts +2 -85
  17. package/dist/convert/composition.d.ts +2 -85
  18. package/dist/convert/composition.js +2 -502
  19. package/dist/convert/convert.cjs +2 -2
  20. package/dist/convert/convert.js +1 -1
  21. package/dist/convert/from-package.cjs +3 -3
  22. package/dist/convert/from-package.js +2 -2
  23. package/dist/convert/from-pdf.cjs +18 -18
  24. package/dist/convert/from-pdf.js +2 -2
  25. package/dist/convert/local.cjs +3 -3
  26. package/dist/convert/local.js +1 -1
  27. package/dist/edit/odp/slide.cjs +4 -4
  28. package/dist/edit/odp/slide.d.cts +1 -1
  29. package/dist/edit/odp/slide.d.ts +1 -1
  30. package/dist/edit/odp/slide.js +1 -1
  31. package/dist/edit/odt/content.d.cts +1 -1
  32. package/dist/edit/odt/content.d.ts +1 -1
  33. package/dist/edit/odt/editor.cjs +4 -4
  34. package/dist/edit/odt/editor.d.cts +1 -1
  35. package/dist/edit/odt/editor.d.ts +1 -1
  36. package/dist/edit/odt/editor.js +1 -1
  37. package/dist/edit/odt/table-grid.cjs +23 -0
  38. package/dist/edit/odt/table-grid.d.cts +54 -0
  39. package/dist/edit/odt/table-grid.d.ts +54 -0
  40. package/dist/edit/odt/table-grid.js +2 -0
  41. package/dist/edit/odt/table.cjs +12 -653
  42. package/dist/edit/odt/table.d.cts +2 -2
  43. package/dist/edit/odt/table.d.ts +2 -2
  44. package/dist/edit/odt/table.js +2 -647
  45. package/dist/{evaluate-BbOsgdmN.d.cts → evaluate-BSEUxiUK.d.cts} +3 -1
  46. package/dist/evaluate-CEzsBx3w.cjs +564 -0
  47. package/dist/{evaluate-C7fmk69X.d.ts → evaluate-D8fG2ZeB.d.ts} +3 -1
  48. package/dist/evaluate-IK-3aMv5.js +445 -0
  49. package/dist/evaluate-columns-CyqKHkIW.d.cts +41 -0
  50. package/dist/evaluate-columns-cOo8fOfT.d.ts +41 -0
  51. package/dist/index.cjs +24 -24
  52. package/dist/index.d.cts +6 -5
  53. package/dist/index.d.ts +6 -5
  54. package/dist/index.js +8 -8
  55. package/dist/latex/lint.cjs +2 -2
  56. package/dist/latex/lint.js +1 -1
  57. package/dist/latex/lower-fold.cjs +6 -0
  58. package/dist/latex/lower-fold.d.cts +17 -0
  59. package/dist/latex/lower-fold.d.ts +17 -0
  60. package/dist/latex/lower-fold.js +2 -0
  61. package/dist/latex/lower.cjs +11 -617
  62. package/dist/latex/lower.d.cts +18 -1
  63. package/dist/latex/lower.d.ts +18 -1
  64. package/dist/latex/lower.js +2 -616
  65. package/dist/latex/symbols.d.cts +1 -15
  66. package/dist/latex/symbols.d.ts +1 -15
  67. package/dist/latex/temml.d.cts +1 -24
  68. package/dist/latex/temml.d.ts +1 -24
  69. package/dist/layout/engine.cjs +2 -2
  70. package/dist/layout/engine.js +1 -1
  71. package/dist/layout/reconstruct-lines.cjs +315 -0
  72. package/dist/layout/reconstruct-lines.d.cts +2 -0
  73. package/dist/layout/reconstruct-lines.d.ts +2 -0
  74. package/dist/layout/reconstruct-lines.js +297 -0
  75. package/dist/layout/reconstruct-presentations-prod.cjs +9 -0
  76. package/dist/layout/reconstruct-presentations-prod.d.cts +26 -0
  77. package/dist/layout/reconstruct-presentations-prod.d.ts +26 -0
  78. package/dist/layout/reconstruct-presentations-prod.js +2 -0
  79. package/dist/layout/reconstruct-tables.cjs +5 -0
  80. package/dist/layout/reconstruct-tables.d.cts +22 -0
  81. package/dist/layout/reconstruct-tables.d.ts +22 -0
  82. package/dist/layout/reconstruct-tables.js +2 -0
  83. package/dist/layout/reconstruct.cjs +11 -1545
  84. package/dist/layout/reconstruct.d.cts +2 -14
  85. package/dist/layout/reconstruct.d.ts +2 -14
  86. package/dist/layout/reconstruct.js +2 -1542
  87. package/dist/layout/shared.cjs +2 -2
  88. package/dist/layout/shared.js +1 -1
  89. package/dist/layout/sheets-render.cjs +19 -0
  90. package/dist/layout/sheets-render.d.cts +41 -0
  91. package/dist/layout/sheets-render.d.ts +41 -0
  92. package/dist/layout/sheets-render.js +2 -0
  93. package/dist/layout/sheets.cjs +10 -544
  94. package/dist/layout/sheets.d.cts +13 -2
  95. package/dist/layout/sheets.d.ts +13 -2
  96. package/dist/layout/sheets.js +2 -543
  97. package/dist/layout/slides.cjs +2 -2
  98. package/dist/layout/slides.js +1 -1
  99. package/dist/layout-DIJzJk4x.js +526 -0
  100. package/dist/layout-iuiyl_Fk.cjs +621 -0
  101. package/dist/layout-types-oSbHvZid.d.cts +13 -0
  102. package/dist/layout-types-oSbHvZid.d.ts +13 -0
  103. package/dist/lower-DCs3rWI7.js +618 -0
  104. package/dist/lower-DzOb13w4.cjs +701 -0
  105. package/dist/markdown/math.cjs +2 -2
  106. package/dist/markdown/math.js +1 -1
  107. package/dist/mathml/layout-stretch.cjs +16 -0
  108. package/dist/mathml/layout-stretch.d.cts +24 -0
  109. package/dist/mathml/layout-stretch.d.ts +24 -0
  110. package/dist/mathml/layout-stretch.js +2 -0
  111. package/dist/mathml/layout-types.d.cts +1 -12
  112. package/dist/mathml/layout-types.d.ts +1 -12
  113. package/dist/mathml/layout.cjs +3 -525
  114. package/dist/mathml/layout.d.cts +2 -2
  115. package/dist/mathml/layout.d.ts +2 -2
  116. package/dist/mathml/layout.js +1 -523
  117. package/dist/odb/formula/evaluate.d.cts +1 -1
  118. package/dist/odb/formula/evaluate.d.ts +1 -1
  119. package/dist/odb/report/render.d.cts +1 -1
  120. package/dist/odb/report/render.d.ts +1 -1
  121. package/dist/odb/report/source.cjs +2 -2
  122. package/dist/odb/report/source.d.cts +1 -1
  123. package/dist/odb/report/source.d.ts +1 -1
  124. package/dist/odb/report/source.js +1 -1
  125. package/dist/odb/sql/evaluate-columns.cjs +122 -0
  126. package/dist/odb/sql/evaluate-columns.d.cts +2 -0
  127. package/dist/odb/sql/evaluate-columns.d.ts +2 -0
  128. package/dist/odb/sql/evaluate-columns.js +114 -0
  129. package/dist/odb/sql/evaluate-predicates.cjs +16 -0
  130. package/dist/odb/sql/evaluate-predicates.d.cts +23 -0
  131. package/dist/odb/sql/evaluate-predicates.d.ts +23 -0
  132. package/dist/odb/sql/evaluate-predicates.js +2 -0
  133. package/dist/odb/sql/evaluate.cjs +7 -556
  134. package/dist/odb/sql/evaluate.d.cts +2 -2
  135. package/dist/odb/sql/evaluate.d.ts +2 -2
  136. package/dist/odb/sql/evaluate.js +2 -552
  137. package/dist/read-BSH--XB4.js +682 -0
  138. package/dist/read-CahCZMwG.cjs +759 -0
  139. package/dist/reconstruct-BKOCAedo.d.ts +29 -0
  140. package/dist/reconstruct-D4TEteZ6.d.cts +29 -0
  141. package/dist/reconstruct-lines-B7t66ICm.d.cts +33 -0
  142. package/dist/reconstruct-lines-B7t66ICm.d.ts +33 -0
  143. package/dist/reconstruct-presentations-prod-B5fkPiRZ.js +1256 -0
  144. package/dist/reconstruct-presentations-prod-X315aBmI.cjs +1375 -0
  145. package/dist/sheets-BQCpNXsE.cjs +700 -0
  146. package/dist/sheets-DWDvGN-g.js +545 -0
  147. package/dist/svg/read-geometry.cjs +10 -0
  148. package/dist/svg/read-geometry.d.cts +24 -0
  149. package/dist/svg/read-geometry.d.ts +24 -0
  150. package/dist/svg/read-geometry.js +2 -0
  151. package/dist/svg/read.cjs +6 -680
  152. package/dist/svg/read.d.cts +17 -2
  153. package/dist/svg/read.d.ts +17 -2
  154. package/dist/svg/read.js +2 -679
  155. package/dist/symbols-BlzXfLEe.d.cts +16 -0
  156. package/dist/symbols-CKm2r4D0.d.ts +16 -0
  157. package/dist/table-B5gSMY7w.js +649 -0
  158. package/dist/{table-DrE6jEWv.d.cts → table-BK_Ao-Y6.d.cts} +9 -1
  159. package/dist/{table-B5htMG3g.d.ts → table-CxY85YUj.d.ts} +9 -1
  160. package/dist/table-DqUIOSPV.cjs +840 -0
  161. package/dist/temml-1-I9N9DD.d.cts +25 -0
  162. package/dist/temml-1-I9N9DD.d.ts +25 -0
  163. package/package.json +1 -1
@@ -1,512 +1,17 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_svg_text = require("../svg/text.cjs");
3
- const require_model_bytes = require("../model/bytes.cjs");
4
- const require_edit_docx_content = require("../edit/docx/content.cjs");
5
- const require_edit_pptx_content = require("../edit/pptx/content.cjs");
6
- const require_edit_odt_content = require("../edit/odt/content.cjs");
7
- const require_edit_odp_content = require("../edit/odp/content.cjs");
8
- const require_edit_ods_content = require("../edit/ods/content.cjs");
9
- const require_edit_odg_content = require("../edit/odg/content.cjs");
10
- const require_markdown_write = require("../markdown/write.cjs");
11
- const require_markdown_read = require("../markdown/read.cjs");
12
- const require_read = require("../read-pPa9I8MO.cjs");
13
- const require_ppt_write = require("../ppt/write.cjs");
14
- const require_ooxml_docx_read = require("../ooxml/docx/read.cjs");
15
- const require_ooxml_pptx_read = require("../ooxml/pptx/read.cjs");
16
- const require_odf_odt_read = require("../odf/odt/read.cjs");
17
- const require_odf_odp_read = require("../odf/odp/read.cjs");
18
- const require_odf_ods_read = require("../odf/ods/read.cjs");
19
- const require_odf_odg_read = require("../odf/odg/read.cjs");
20
- const require_markdown_text = require("../markdown/text.cjs");
21
- const require_csv_text = require("../csv/text.cjs");
22
- const require_csv_read = require("../csv/read.cjs");
23
- const require_csv_write = require("../csv/write.cjs");
24
- const require_svg_read = require("../svg/read.cjs");
25
- const require_svg_write = require("../svg/write.cjs");
26
- const require_ports_abort = require("../ports/abort.cjs");
27
- const require_layout_reconstruct = require("../layout/reconstruct.cjs");
28
- const require_convert_pdf_package_tables = require("./pdf-package-tables.cjs");
29
- const require_convert_variant_bridges = require("./variant-bridges.cjs");
30
- const require_convert_capability = require("./capability.cjs");
31
- let ooxml_js = require("ooxml.js");
32
- let document_schema_js = require("document-schema.js");
33
- let odf_js = require("odf.js");
34
- let doc_codec = require("doc-codec");
35
- let xls_codec = require("xls-codec");
36
- let rtf_codec = require("rtf-codec");
37
- let epub_codec = require("epub-codec");
38
- require("markdown-codec");
39
- let wpd_codec = require("wpd-codec");
40
- let pdf_codec_read = require("pdf-codec/read");
41
- //#region src/convert/composition.ts
42
- const LATIN1_MAX_CODE = 255;
43
- const HEX_RADIX = 16;
44
- const UNICODE_HEX_DIGITS = 4;
45
- const THROUGH_PDF_EDGE_COST = 3;
46
- const MAX_CONVERSION_PATH_NODES = 4;
47
- const FORMAT_NODES = {
48
- docx: {
49
- variant: "wordprocessing",
50
- family: "ooxml",
51
- decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
52
- read: (pkg, options) => require_ooxml_docx_read.readDocxContent(pkg, { onMathDiagnostic: options?.onMathDiagnostic }),
53
- build: (content, options) => require_edit_docx_content.buildDocxPackage(content, { onMathDiagnostic: options?.onMathDiagnostic }),
54
- encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
55
- hasSourcePackage: true
56
- },
57
- pptx: {
58
- variant: "presentation",
59
- family: "ooxml",
60
- decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
61
- read: (pkg, options) => require_ooxml_pptx_read.readPptxContent(pkg, { onMathDiagnostic: options?.onMathDiagnostic }),
62
- build: (content, options) => require_edit_pptx_content.buildPptxPackage(content, { onMathDiagnostic: options?.onMathDiagnostic }),
63
- encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
64
- hasSourcePackage: true
65
- },
66
- xlsx: {
67
- variant: "spreadsheet",
68
- family: "ooxml",
69
- decode: (bytes) => (0, ooxml_js.decodePackage)(bytes),
70
- read: (pkg) => (0, ooxml_js.readXlsxContent)(pkg),
71
- build: (content) => (0, ooxml_js.buildXlsxPackageFromContent)(content),
72
- encode: (pkg) => (0, ooxml_js.encodePackage)(pkg),
73
- hasSourcePackage: true
74
- },
75
- odt: {
76
- variant: "wordprocessing",
77
- family: "odf",
78
- decode: (bytes) => (0, odf_js.decodePackage)(bytes),
79
- read: (pkg) => require_odf_odt_read.readOdtContent(pkg),
80
- build: (content) => require_edit_odt_content.buildOdtPackage(content),
81
- encode: (pkg) => (0, odf_js.encodePackage)(pkg),
82
- hasSourcePackage: true
83
- },
84
- odp: {
85
- variant: "presentation",
86
- family: "odf",
87
- decode: (bytes) => (0, odf_js.decodePackage)(bytes),
88
- read: (pkg) => require_odf_odp_read.readOdpContent(pkg),
89
- build: (content) => require_edit_odp_content.buildOdpPackage(content),
90
- encode: (pkg) => (0, odf_js.encodePackage)(pkg),
91
- hasSourcePackage: true
92
- },
93
- ods: {
94
- variant: "spreadsheet",
95
- family: "odf",
96
- decode: (bytes) => (0, odf_js.decodePackage)(bytes),
97
- read: (pkg) => require_odf_ods_read.readOdsContent(pkg),
98
- build: (content) => require_edit_ods_content.buildOdsPackage(content),
99
- encode: (pkg) => (0, odf_js.encodePackage)(pkg),
100
- hasSourcePackage: true
101
- },
102
- odg: {
103
- variant: "drawing",
104
- family: "odf",
105
- decode: (bytes) => (0, odf_js.decodePackage)(bytes),
106
- read: (pkg) => require_odf_odg_read.readOdgContent(pkg),
107
- build: (content) => require_edit_odg_content.buildOdgPackage(content),
108
- encode: (pkg) => (0, odf_js.encodePackage)(pkg),
109
- hasSourcePackage: true
110
- },
111
- svg: {
112
- variant: "drawing",
113
- family: "svg",
114
- decode: (bytes) => require_svg_text.decodeSvgText(bytes),
115
- read: (text, options) => require_svg_read.readSvgContent(text, { onSvgDiagnostic: options?.onSvgDiagnostic }),
116
- build: (content, options) => require_svg_write.buildSvgText(content, {
117
- page: options?.page,
118
- onSvgDiagnostic: options?.onSvgDiagnostic
119
- }),
120
- encode: (text) => require_svg_text.encodeSvgText(text),
121
- hasSourcePackage: false
122
- },
123
- markdown: {
124
- variant: "wordprocessing",
125
- family: "markdown",
126
- decode: (bytes) => require_markdown_text.decodeMarkdownText(bytes),
127
- read: (text, options) => require_markdown_read.readMarkdownContent(text, {
128
- signal: options?.signal,
129
- images: options?.images
130
- }),
131
- build: (content) => require_markdown_write.buildMarkdownText(content),
132
- encode: (text) => require_markdown_text.encodeMarkdownText(text),
133
- hasSourcePackage: false
134
- },
135
- csv: {
136
- variant: "spreadsheet",
137
- family: "csv",
138
- decode: (bytes) => require_csv_text.decodeCsvText(bytes),
139
- read: (text, options) => require_csv_read.readCsvContent(text, {
140
- delimiter: options?.delimiter,
141
- onCellTypeInference: options?.onCellTypeInference
142
- }),
143
- build: (content, options) => require_csv_write.buildCsvText(content, {
144
- delimiter: options?.delimiter,
145
- sheet: options?.sheet
146
- }),
147
- encode: (text) => require_csv_text.encodeCsvText(text),
148
- hasSourcePackage: false
149
- },
150
- rtf: {
151
- variant: "wordprocessing",
152
- family: "rtf",
153
- decode: (bytes) => bytesToLatin1(bytes),
154
- read: (text, options) => (0, rtf_codec.readRtfContent)(text, { signal: options?.signal }).document,
155
- build: (content) => bytesToLatin1((0, rtf_codec.writeRtfContent)(content)),
156
- encode: (text) => require_model_bytes.requireArrayBufferBytes((0, rtf_codec.rtfBytesFromLatin1)(text)),
157
- hasSourcePackage: false
158
- },
159
- doc: {
160
- variant: "wordprocessing",
161
- family: "doc",
162
- decode: (bytes) => bytesToLatin1(bytes),
163
- read: (text, options) => {
164
- require_ports_abort.throwIfAborted(options?.signal);
165
- return (0, doc_codec.readDocContent)(latin1ToBytes(text));
166
- },
167
- build: (content) => bytesToLatin1((0, doc_codec.writeDocContent)(content)),
168
- encode: (text) => latin1ToBytes(text),
169
- hasSourcePackage: false
170
- },
171
- epub: {
172
- variant: "wordprocessing",
173
- family: "epub",
174
- decode: (bytes) => bytesToLatin1(bytes),
175
- read: (text, options) => {
176
- require_ports_abort.throwIfAborted(options?.signal);
177
- return (0, epub_codec.readEpubContent)(latin1ToBytes(text));
178
- },
179
- build: (content) => bytesToLatin1((0, epub_codec.writeEpubContent)(content)),
180
- encode: (text) => latin1ToBytes(text),
181
- hasSourcePackage: false
182
- },
183
- xls: {
184
- variant: "spreadsheet",
185
- family: "xls",
186
- decode: (bytes) => bytesToLatin1(bytes),
187
- read: (text, options) => {
188
- require_ports_abort.throwIfAborted(options?.signal);
189
- return (0, xls_codec.readXlsContent)(latin1ToBytes(text));
190
- },
191
- build: (content) => {
192
- if (content.kind !== "spreadsheet") throw new Error("FORMAT_NODES.xls.build: expected a spreadsheet ContentDocument");
193
- return bytesToLatin1((0, xls_codec.writeXlsContent)(content));
194
- },
195
- encode: (text) => latin1ToBytes(text),
196
- hasSourcePackage: false
197
- },
198
- ppt: {
199
- variant: "presentation",
200
- family: "ppt",
201
- decode: (bytes) => bytesToLatin1(bytes),
202
- read: (text, options) => {
203
- require_ports_abort.throwIfAborted(options?.signal);
204
- return require_read.readPptContent(latin1ToBytes(text));
205
- },
206
- build: (content) => bytesToLatin1(require_ppt_write.writePptContent(content)),
207
- encode: (text) => latin1ToBytes(text),
208
- hasSourcePackage: false
209
- }
210
- };
211
- const CONTENT_FORMATS = [
212
- "docx",
213
- "pptx",
214
- "xlsx",
215
- "odt",
216
- "odp",
217
- "ods",
218
- "odg",
219
- "svg",
220
- "csv",
221
- "markdown",
222
- "rtf",
223
- "doc",
224
- "xls",
225
- "ppt",
226
- "epub"
227
- ];
228
- function isTextFormatNode(node) {
229
- return !node.hasSourcePackage;
230
- }
231
- const READ_ONLY_CONTENT_FORMATS = ["wpd"];
232
- const READ_ONLY_FORMAT_NODES = { wpd: {
233
- variant: "wordprocessing",
234
- read: (bytes) => (0, wpd_codec.readWpdContent)(bytes)
235
- } };
236
- function isReadOnlyContentFormat(format) {
237
- return READ_ONLY_CONTENT_FORMATS.includes(format);
238
- }
239
- function readSourceContent(format, bytes, options) {
240
- if (isReadOnlyContentFormat(format)) {
241
- const node = READ_ONLY_FORMAT_NODES[format];
242
- return {
243
- content: node.read(bytes, options),
244
- variant: node.variant
245
- };
246
- }
247
- const node = FORMAT_NODES[format];
248
- if (isTextFormatNode(node)) {
249
- const text = node.decode(bytes);
250
- return {
251
- content: node.read(text, options),
252
- variant: node.variant
253
- };
254
- }
255
- const pkg = node.decode(bytes);
256
- return {
257
- content: node.read(pkg, options),
258
- variant: node.variant
259
- };
260
- }
261
- const LATIN1_CHUNK_SIZE = 8192;
262
- function bytesToLatin1(bytes) {
263
- let text = "";
264
- for (let start = 0; start < bytes.length; start += LATIN1_CHUNK_SIZE) text += String.fromCharCode(...bytes.subarray(start, start + LATIN1_CHUNK_SIZE));
265
- return text;
266
- }
267
- function latin1ToBytes(text) {
268
- const bytes = new Uint8Array(text.length);
269
- for (let index = 0; index < text.length; index += 1) {
270
- const code = text.charCodeAt(index);
271
- if (code > LATIN1_MAX_CODE) throw new TypeError(`latin1ToBytes: character at index ${String(index)} is U+${code.toString(HEX_RADIX).toUpperCase().padStart(UNICODE_HEX_DIGITS, "0")}, above U+00FF — this string no longer holds the file's original bytes`);
272
- bytes[index] = code;
273
- }
274
- return bytes;
275
- }
276
- const LAYOUT_CAPABLE = /* @__PURE__ */ new Set([
277
- "docx",
278
- "pptx",
279
- "odt",
280
- "odp",
281
- "ods",
282
- "odg",
283
- "svg",
284
- "markdown",
285
- "wpd"
286
- ]);
287
- const TRANSFORMS = {
288
- "wordprocessing->presentation": (doc) => {
289
- if (doc.kind !== "wordprocessing") throw new Error("wordprocessingToPresentation: expected a wordprocessing ContentDocument");
290
- return require_convert_variant_bridges.wordprocessingToPresentation(doc);
291
- },
292
- "presentation->wordprocessing": (doc) => {
293
- if (doc.kind !== "presentation") throw new Error("presentationToWordprocessing: expected a presentation ContentDocument");
294
- return require_convert_variant_bridges.presentationToWordprocessing(doc);
295
- },
296
- "drawing->presentation": (doc) => {
297
- if (doc.kind !== "drawing") throw new Error("drawingToPresentation: expected a drawing ContentDocument");
298
- return require_convert_variant_bridges.drawingToPresentation(doc);
299
- },
300
- "presentation->drawing": (doc) => {
301
- if (doc.kind !== "presentation") throw new Error("presentationToDrawing: expected a presentation ContentDocument");
302
- return require_convert_variant_bridges.presentationToDrawing(doc);
303
- },
304
- "spreadsheet->wordprocessing": (doc) => {
305
- if (doc.kind !== "spreadsheet") throw new Error("spreadsheetToWordprocessing: expected a spreadsheet ContentDocument");
306
- return require_convert_variant_bridges.spreadsheetToWordprocessing(doc);
307
- }
308
- };
309
- const RECONSTRUCTORS = {
310
- wordprocessing: require_layout_reconstruct.reconstructWordprocessing,
311
- presentation: require_layout_reconstruct.reconstructPresentation,
312
- drawing: require_layout_reconstruct.reconstructDrawing,
313
- spreadsheet: require_layout_reconstruct.reconstructSpreadsheet
314
- };
315
- function executeBridge(source, target, bytes, options) {
316
- require_ports_abort.throwIfAborted(options?.signal);
317
- const targetNode = FORMAT_NODES[target];
318
- const { content, variant: sourceVariant } = readSourceContent(source, bytes, options);
319
- if (content.kind !== sourceVariant) throw new Error(`executeBridge: ${source} read returned a non-${sourceVariant} ContentDocument`);
320
- let buildContent = content;
321
- if (sourceVariant !== targetNode.variant) {
322
- const key = `${sourceVariant}->${targetNode.variant}`;
323
- const transform = TRANSFORMS[key];
324
- if (transform === void 0) throw new Error(`executeBridge: no transform registered for ${key}`);
325
- buildContent = transform(content);
326
- }
327
- require_ports_abort.throwIfAborted(options?.signal);
328
- let out;
329
- if (isTextFormatNode(targetNode)) {
330
- const text = targetNode.build(buildContent, options);
331
- out = targetNode.encode(text);
332
- } else {
333
- const pkg = targetNode.build(buildContent, options);
334
- out = targetNode.encode(pkg);
335
- }
336
- options?.onDocument?.((0, document_schema_js.assembleTree)(buildContent));
337
- return out;
338
- }
339
- function executeFromPdf(target, bytes, options) {
340
- const node = FORMAT_NODES[target];
341
- const layout = (0, pdf_codec_read.readPdf)(bytes, {
342
- signal: options?.signal,
343
- sink: options?.sink
344
- });
345
- const content = RECONSTRUCTORS[node.variant](layout, {
346
- signal: options?.signal,
347
- onCellTypeInference: options?.onCellTypeInference
348
- });
349
- const pages = layout.pages.map((page) => ({
350
- widthPt: page.widthPt,
351
- heightPt: page.heightPt
352
- }));
353
- let out;
354
- if (isTextFormatNode(node)) {
355
- const text = node.build(content, options);
356
- out = node.encode(text);
357
- } else {
358
- const pkg = node.build(content);
359
- out = node.encode(pkg);
360
- }
361
- const reported = (0, document_schema_js.assembleTree)(content, pages);
362
- require_convert_pdf_package_tables.stampPdfPackageTables(reported, layout);
363
- options?.onDocument?.(reported);
364
- return out;
365
- }
366
- function buildCompositionGraph() {
367
- const adj = /* @__PURE__ */ new Map();
368
- const addDirected = (from, to, cost) => {
369
- const list = adj.get(from);
370
- if (list === void 0) adj.set(from, [{
371
- to,
372
- cost
373
- }]);
374
- else list.push({
375
- to,
376
- cost
377
- });
378
- };
379
- const addEdge = (from, to, cost) => {
380
- addDirected(from, to, cost);
381
- addDirected(to, from, cost);
382
- };
383
- for (const a of CONTENT_FORMATS) for (const b of CONTENT_FORMATS) {
384
- if (a === b) continue;
385
- if (FORMAT_NODES[a].variant === FORMAT_NODES[b].variant) addEdge(a, b, 1);
386
- }
387
- for (const key of Object.keys(TRANSFORMS)) {
388
- const parts = key.split("->");
389
- const fromVariant = parts[0];
390
- const toVariant = parts[1];
391
- if (fromVariant === void 0 || toVariant === void 0) continue;
392
- for (const a of CONTENT_FORMATS) {
393
- if (FORMAT_NODES[a].variant !== fromVariant) continue;
394
- for (const b of CONTENT_FORMATS) {
395
- if (FORMAT_NODES[b].variant !== toVariant) continue;
396
- addDirected(a, b, 2);
397
- }
398
- }
399
- }
400
- for (const format of CONTENT_FORMATS) if (LAYOUT_CAPABLE.has(format)) addEdge(format, "pdf", THROUGH_PDF_EDGE_COST);
401
- for (const source of READ_ONLY_CONTENT_FORMATS) {
402
- const variant = READ_ONLY_FORMAT_NODES[source].variant;
403
- for (const target of CONTENT_FORMATS) {
404
- const targetVariant = FORMAT_NODES[target].variant;
405
- if (targetVariant === variant) addDirected(source, target, 1);
406
- else if (TRANSFORMS[`${variant}->${targetVariant}`] !== void 0) addDirected(source, target, 2);
407
- }
408
- if (LAYOUT_CAPABLE.has(source)) addDirected(source, "pdf", THROUGH_PDF_EDGE_COST);
409
- }
410
- return adj;
411
- }
412
- const COMPOSITION_GRAPH = buildCompositionGraph();
413
- function shortestPath(source, target) {
414
- if (source === target) return;
415
- const distances = /* @__PURE__ */ new Map([[source, 0]]);
416
- const previous = /* @__PURE__ */ new Map();
417
- const visited = /* @__PURE__ */ new Set();
418
- while (true) {
419
- let current = void 0;
420
- let currentDist = Infinity;
421
- for (const [node, dist] of distances) if (!visited.has(node) && dist < currentDist) {
422
- current = node;
423
- currentDist = dist;
424
- }
425
- if (current === void 0 || current === target) break;
426
- visited.add(current);
427
- for (const edge of COMPOSITION_GRAPH.get(current) ?? []) {
428
- if (visited.has(edge.to)) continue;
429
- const alt = currentDist + edge.cost;
430
- const known = distances.get(edge.to);
431
- if (known === void 0 || alt < known) {
432
- distances.set(edge.to, alt);
433
- previous.set(edge.to, current);
434
- }
435
- }
436
- }
437
- if (distances.get(target) === void 0) return;
438
- const path = [];
439
- let cursor = target;
440
- while (cursor !== void 0) {
441
- path.unshift(cursor);
442
- cursor = previous.get(cursor);
443
- }
444
- return path;
445
- }
446
- function resolveCompositionPlan(source, target) {
447
- const path = shortestPath(source, target);
448
- if (path === void 0) return;
449
- if (path.length > MAX_CONVERSION_PATH_NODES) return;
450
- const hops = [];
451
- for (let i = 0; i + 1 < path.length; i++) {
452
- const from = path[i];
453
- const to = path[i + 1];
454
- if (from === void 0 || to === void 0) return;
455
- const executor = to === "pdf" ? "toPdf" : from === "pdf" ? "fromPdf" : "bridge";
456
- hops.push({
457
- executor,
458
- from,
459
- to
460
- });
461
- }
462
- return { hops };
463
- }
464
- function isContentFormat(format) {
465
- return format !== "pdf" && format !== "odf" && !isReadOnlyContentFormat(format);
466
- }
467
- function isSourceContentFormat(format) {
468
- return isContentFormat(format) || isReadOnlyContentFormat(format);
469
- }
470
- function runCompositionPlan(plan, bytes, options, executors) {
471
- let current = bytes;
472
- for (let i = 0; i < plan.hops.length; i++) {
473
- const hop = plan.hops[i];
474
- if (hop === void 0) throw new Error("runCompositionPlan: resolveCompositionPlan returned a malformed hop");
475
- const hopOptions = i === plan.hops.length - 1 ? options : options === void 0 ? void 0 : {
476
- ...options,
477
- onDocument: void 0
478
- };
479
- if (hop.executor === "toPdf") {
480
- if (!isSourceContentFormat(hop.from)) throw new Error(`runCompositionPlan: toPdf source '${hop.from}' is not a content format`);
481
- const toPdf = executors.toPdf;
482
- if (toPdf === void 0) throw new Error(`runCompositionPlan: the plan's ${hop.from} -> ${hop.to} hop needs a toPdf executor, but this binding carries none (the read-only entry cannot render PDFs)`);
483
- current = toPdf(hop.from, current, hopOptions);
484
- } else if (hop.executor === "fromPdf") {
485
- if (!isContentFormat(hop.to)) throw new Error(`runCompositionPlan: fromPdf target '${hop.to}' is not a content format`);
486
- current = executors.fromPdf(hop.to, current, hopOptions);
487
- } else {
488
- if (!isSourceContentFormat(hop.from) || !isContentFormat(hop.to)) throw new Error(`runCompositionPlan: bridge endpoints '${hop.from}' -> '${hop.to}' are not both content formats`);
489
- current = executors.bridge(hop.from, hop.to, current, hopOptions);
490
- }
491
- }
492
- return current;
493
- }
494
- function convertDocumentFromPdf(target, bytes, options) {
495
- const plan = resolveCompositionPlan("pdf", target);
496
- if (plan === void 0) throw new require_convert_capability.UnsupportedConversionError("pdf", target);
497
- return runCompositionPlan(plan, bytes, options, {
498
- bridge: executeBridge,
499
- fromPdf: executeFromPdf
500
- });
501
- }
502
- //#endregion
503
- exports.FORMAT_NODES = FORMAT_NODES;
504
- exports.LAYOUT_CAPABLE = LAYOUT_CAPABLE;
505
- exports.READ_ONLY_FORMAT_NODES = READ_ONLY_FORMAT_NODES;
506
- exports.convertDocumentFromPdf = convertDocumentFromPdf;
507
- exports.executeBridge = executeBridge;
508
- exports.executeFromPdf = executeFromPdf;
509
- exports.isReadOnlyContentFormat = isReadOnlyContentFormat;
510
- exports.isTextFormatNode = isTextFormatNode;
511
- exports.resolveCompositionPlan = resolveCompositionPlan;
512
- exports.runCompositionPlan = runCompositionPlan;
2
+ const require_composition_plan = require("../composition-plan-CfvhXeOC.cjs");
3
+ exports.CONTENT_FORMATS = require_composition_plan.CONTENT_FORMATS;
4
+ exports.FORMAT_NODES = require_composition_plan.FORMAT_NODES;
5
+ exports.LAYOUT_CAPABLE = require_composition_plan.LAYOUT_CAPABLE;
6
+ exports.MAX_CONVERSION_PATH_NODES = require_composition_plan.MAX_CONVERSION_PATH_NODES;
7
+ exports.READ_ONLY_CONTENT_FORMATS = require_composition_plan.READ_ONLY_CONTENT_FORMATS;
8
+ exports.READ_ONLY_FORMAT_NODES = require_composition_plan.READ_ONLY_FORMAT_NODES;
9
+ exports.RECONSTRUCTORS = require_composition_plan.RECONSTRUCTORS;
10
+ exports.THROUGH_PDF_EDGE_COST = require_composition_plan.THROUGH_PDF_EDGE_COST;
11
+ exports.TRANSFORMS = require_composition_plan.TRANSFORMS;
12
+ exports.convertDocumentFromPdf = require_composition_plan.convertDocumentFromPdf;
13
+ exports.executeBridge = require_composition_plan.executeBridge;
14
+ exports.executeFromPdf = require_composition_plan.executeFromPdf;
15
+ exports.isReadOnlyContentFormat = require_composition_plan.isReadOnlyContentFormat;
16
+ exports.isTextFormatNode = require_composition_plan.isTextFormatNode;
17
+ exports.runCompositionPlan = require_composition_plan.runCompositionPlan;
@@ -1,85 +1,2 @@
1
- import { t as ClockPort } from "../clock-Cewekmhw.cjs";
2
- import { DocumentFormat } from "./port.cjs";
3
- import { t as ContentVariant } from "../capability-WJWAE-5Z.cjs";
4
- import { i as SvgDiagnosticSink } from "../diagnostics-DVAXKgcf.cjs";
5
- import { i as CellTypeInferenceSink } from "../cell-typing-BQ-xQ5X5.cjs";
6
- import { t as OmmlDiagnostic } from "../shared-c0Lp3_iY.cjs";
7
- import { ContentDocument, DocumentTree, FontSubstitution, ProvidedFont } from "document-schema.js";
8
- import { PdfDiagnosticSink, WinAnsiSubstitution } from "pdf-codec";
9
- import { MarkdownImageResolver } from "markdown-codec";
10
- import { Package } from "ooxml.js";
11
- //#region src/convert/composition.d.ts
12
- declare const FORMAT_NODES: Readonly<Record<ContentFormat, FormatNode>>;
13
- type SourcePackage = Package;
14
- interface UnifiedConversionOptions {
15
- readonly signal?: AbortSignal;
16
- readonly onDocument?: (pkg: DocumentTree) => void;
17
- readonly fonts?: readonly ProvidedFont[];
18
- readonly onFontSubstitution?: (substitution: FontSubstitution) => void;
19
- readonly onSubstitution?: (substitution: WinAnsiSubstitution, context: {
20
- readonly pageIndex: number;
21
- }) => void;
22
- readonly sink?: PdfDiagnosticSink;
23
- readonly onMathDiagnostic?: (diagnostic: OmmlDiagnostic, context: {
24
- readonly sourcePath?: string;
25
- }) => void;
26
- readonly images?: MarkdownImageResolver;
27
- readonly delimiter?: string;
28
- readonly sheet?: string;
29
- readonly onCellTypeInference?: CellTypeInferenceSink;
30
- readonly page?: number;
31
- readonly onSvgDiagnostic?: SvgDiagnosticSink;
32
- readonly clock?: ClockPort;
33
- }
34
- type ContentFormat = "docx" | "pptx" | "xlsx" | "odt" | "odp" | "ods" | "odg" | "svg" | "csv" | "markdown" | "rtf" | "doc" | "xls" | "ppt" | "epub";
35
- type LayoutVariant = Exclude<ContentVariant, "formula">;
36
- interface PackageFormatNode {
37
- readonly variant: LayoutVariant;
38
- readonly family: "ooxml" | "odf";
39
- readonly decode: (bytes: Uint8Array<ArrayBuffer>) => SourcePackage;
40
- readonly read: (pkg: SourcePackage, options?: UnifiedConversionOptions) => ContentDocument;
41
- readonly build: (content: ContentDocument, options?: UnifiedConversionOptions) => SourcePackage;
42
- readonly encode: (pkg: SourcePackage) => Uint8Array<ArrayBuffer>;
43
- readonly hasSourcePackage: true;
44
- }
45
- interface TextFormatNode {
46
- readonly variant: LayoutVariant;
47
- readonly family: "markdown" | "csv" | "svg" | "rtf" | "doc" | "xls" | "ppt" | "epub";
48
- readonly decode: (bytes: Uint8Array<ArrayBuffer>) => string;
49
- readonly read: (text: string, options?: UnifiedConversionOptions) => ContentDocument;
50
- readonly build: (content: ContentDocument, options?: UnifiedConversionOptions) => string;
51
- readonly encode: (text: string) => Uint8Array<ArrayBuffer>;
52
- readonly hasSourcePackage: false;
53
- }
54
- type FormatNode = PackageFormatNode | TextFormatNode;
55
- declare function isTextFormatNode(node: FormatNode): node is TextFormatNode;
56
- type ReadOnlyContentFormat = "wpd";
57
- interface ReadOnlyFormatNode {
58
- readonly variant: LayoutVariant;
59
- readonly read: (bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions) => ContentDocument;
60
- }
61
- declare const READ_ONLY_FORMAT_NODES: Readonly<Record<ReadOnlyContentFormat, ReadOnlyFormatNode>>;
62
- type SourceContentFormat = ContentFormat | ReadOnlyContentFormat;
63
- declare function isReadOnlyContentFormat(format: DocumentFormat): format is ReadOnlyContentFormat;
64
- declare const LAYOUT_CAPABLE: ReadonlySet<SourceContentFormat>;
65
- declare function executeBridge(source: SourceContentFormat, target: ContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions): Uint8Array<ArrayBuffer>;
66
- declare function executeFromPdf(target: ContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions): Uint8Array<ArrayBuffer>;
67
- type HopExecutor = "bridge" | "toPdf" | "fromPdf";
68
- interface CompositionHop {
69
- readonly executor: HopExecutor;
70
- readonly from: DocumentFormat;
71
- readonly to: DocumentFormat;
72
- }
73
- interface ConversionPlan {
74
- readonly hops: readonly CompositionHop[];
75
- }
76
- declare function resolveCompositionPlan(source: DocumentFormat, target: DocumentFormat): ConversionPlan | undefined;
77
- interface CompositionExecutorBinding {
78
- readonly bridge: (source: SourceContentFormat, target: ContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions) => Uint8Array<ArrayBuffer>;
79
- readonly fromPdf: (target: ContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions) => Uint8Array<ArrayBuffer>;
80
- readonly toPdf?: (source: SourceContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions) => Uint8Array<ArrayBuffer>;
81
- }
82
- declare function runCompositionPlan(plan: ConversionPlan, bytes: Uint8Array<ArrayBuffer>, options: UnifiedConversionOptions | undefined, executors: CompositionExecutorBinding): Uint8Array<ArrayBuffer>;
83
- declare function convertDocumentFromPdf(target: ContentFormat, bytes: Uint8Array<ArrayBuffer>, options?: UnifiedConversionOptions): Uint8Array<ArrayBuffer>;
84
- //#endregion
85
- export { CompositionExecutorBinding, CompositionHop, ContentFormat, ConversionPlan, FORMAT_NODES, FormatNode, HopExecutor, LAYOUT_CAPABLE, READ_ONLY_FORMAT_NODES, ReadOnlyContentFormat, ReadOnlyFormatNode, SourceContentFormat, UnifiedConversionOptions, convertDocumentFromPdf, executeBridge, executeFromPdf, isReadOnlyContentFormat, isTextFormatNode, resolveCompositionPlan, runCompositionPlan };
1
+ import { A as isTextFormatNode, C as THROUGH_PDF_EDGE_COST, D as executeBridge, E as convertDocumentFromPdf, O as executeFromPdf, S as SourceContentFormat, T as UnifiedConversionOptions, _ as READ_ONLY_CONTENT_FORMATS, b as ReadOnlyContentFormat, d as CompositionExecutorBinding, f as ContentFormat, g as MAX_CONVERSION_PATH_NODES, h as LAYOUT_CAPABLE, j as runCompositionPlan, k as isReadOnlyContentFormat, m as FormatNode, p as FORMAT_NODES, u as CONTENT_FORMATS, v as READ_ONLY_FORMAT_NODES, w as TRANSFORMS, x as ReadOnlyFormatNode, y as RECONSTRUCTORS } from "../composition-plan-DU9nPPN7.cjs";
2
+ export { CONTENT_FORMATS, CompositionExecutorBinding, ContentFormat, FORMAT_NODES, FormatNode, LAYOUT_CAPABLE, MAX_CONVERSION_PATH_NODES, READ_ONLY_CONTENT_FORMATS, READ_ONLY_FORMAT_NODES, RECONSTRUCTORS, ReadOnlyContentFormat, ReadOnlyFormatNode, SourceContentFormat, THROUGH_PDF_EDGE_COST, TRANSFORMS, UnifiedConversionOptions, convertDocumentFromPdf, executeBridge, executeFromPdf, isReadOnlyContentFormat, isTextFormatNode, runCompositionPlan };