@f-office/wasm 0.0.0-stage → 0.1.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.
@@ -0,0 +1,365 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * A document laid out into pages. Page indexes count from 0.
6
+ */
7
+ export class Document {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Returns the fonts that the layout looked for and the renderer lacks, each once, with the
13
+ * families that the target tries for each. This includes fallback fonts looked up for
14
+ * characters that the primary fonts lack.
15
+ */
16
+ fontNeeds(): FontNeed[];
17
+ /**
18
+ * Returns the headings of the body in the order of the document.
19
+ */
20
+ outline(): OutlineEntry[];
21
+ /**
22
+ * Returns the number of pages.
23
+ */
24
+ pageCount(): number;
25
+ /**
26
+ * Returns the height in pixels of the image that `renderPage` draws at `dpi`.
27
+ *
28
+ * # Errors
29
+ *
30
+ * Throws when the page does not exist or cannot be drawn at this resolution.
31
+ */
32
+ pageHeight(index: number, dpi: number): number;
33
+ /**
34
+ * Returns the width and the height in points of every page, in order: the width of page 0,
35
+ * its height, the width of page 1, and so on.
36
+ */
37
+ pageSizes(): Float64Array;
38
+ /**
39
+ * Returns the width in pixels of the image that `renderPage` draws at `dpi`.
40
+ *
41
+ * # Errors
42
+ *
43
+ * Throws when the page does not exist or cannot be drawn at this resolution.
44
+ */
45
+ pageWidth(index: number, dpi: number): number;
46
+ /**
47
+ * Draws one page at `dpi` pixels per inch on a white background. A CSS pixel is 1/96 inch,
48
+ * so a sharp image for the screen uses `96 * devicePixelRatio`.
49
+ *
50
+ * # Errors
51
+ *
52
+ * Throws when the page does not exist, or cannot be drawn at this resolution.
53
+ */
54
+ renderPage(index: number, dpi: number): PageImage;
55
+ /**
56
+ * Draws only the rectangular pixel tile `(x, y, width, height)` of page `index` at `dpi`
57
+ * pixels per inch on a white background, keeping memory proportional to the tile size.
58
+ *
59
+ * # Errors
60
+ *
61
+ * Throws when the page does not exist or the tile cannot be drawn at this resolution.
62
+ */
63
+ renderRegion(index: number, x: number, y: number, width: number, height: number, dpi: number): PageImage;
64
+ /**
65
+ * Returns the upright text runs of one page in painting order, for a text layer.
66
+ *
67
+ * # Errors
68
+ *
69
+ * Throws when the page does not exist.
70
+ */
71
+ textRuns(index: number): TextRun[];
72
+ /**
73
+ * Returns the text of each distinct warning of the layout, such as a font that another font
74
+ * draws or a picture that the file lacks, once each.
75
+ */
76
+ warnings(): string[];
77
+ /**
78
+ * Writes the laid-out pages as a PDF file with the renderer's fonts subset and embedded.
79
+ *
80
+ * # Errors
81
+ *
82
+ * Throws when the pages cannot be written as PDF.
83
+ */
84
+ writePdf(): Uint8Array;
85
+ }
86
+
87
+ /**
88
+ * A font that a document's text asks for and the families that the target tries for it.
89
+ */
90
+ export class FontNeed {
91
+ private constructor();
92
+ free(): void;
93
+ [Symbol.dispose](): void;
94
+ /**
95
+ * The family that the text asks for, or `undefined` for text that names no font.
96
+ */
97
+ readonly family: string | undefined;
98
+ /**
99
+ * The families that the layout tries for the text, in order.
100
+ */
101
+ readonly tried: string[];
102
+ }
103
+
104
+ /**
105
+ * A heading of the document's outline.
106
+ */
107
+ export class OutlineEntry {
108
+ private constructor();
109
+ free(): void;
110
+ [Symbol.dispose](): void;
111
+ /**
112
+ * The address of its paragraph in the body, such as `p12`.
113
+ */
114
+ readonly address: string;
115
+ /**
116
+ * The heading's level, from 0 for the top level to 8: the level that the body's table of
117
+ * contents gives it when the outline follows that table, else its outline level.
118
+ */
119
+ readonly level: number;
120
+ /**
121
+ * The index of the page of its first line, counted from 0.
122
+ */
123
+ readonly page: number;
124
+ /**
125
+ * The heading's text on one line.
126
+ */
127
+ readonly text: string;
128
+ }
129
+
130
+ /**
131
+ * One drawn page: RGBA pixels with their width and height, and the warnings of the drawing.
132
+ */
133
+ export class PageImage {
134
+ private constructor();
135
+ free(): void;
136
+ [Symbol.dispose](): void;
137
+ /**
138
+ * Returns the text of each distinct warning of the drawing, such as an image that does not
139
+ * decode, once each.
140
+ */
141
+ warnings(): string[];
142
+ /**
143
+ * The pixels in gray, one byte each, row by row from the top left corner, as a comparison
144
+ * with a gray page image reads them: each pixel's luma, 0.299 red, 0.587 green and 0.114
145
+ * blue, rounded.
146
+ */
147
+ readonly gray: Uint8Array;
148
+ /**
149
+ * Height in pixels.
150
+ */
151
+ readonly height: number;
152
+ /**
153
+ * The pixels as RGBA bytes, row by row from the top left corner. Each read copies them
154
+ * once out of WebAssembly memory into a new array, which
155
+ * `new ImageData(pixels, width, height)` takes without another copy. Read it once, then
156
+ * call `free()`.
157
+ */
158
+ readonly pixels: Uint8ClampedArray;
159
+ /**
160
+ * Width in pixels.
161
+ */
162
+ readonly width: number;
163
+ }
164
+
165
+ /**
166
+ * Fonts for rendering. Add the fonts first, then open documents.
167
+ */
168
+ export class Renderer {
169
+ free(): void;
170
+ [Symbol.dispose](): void;
171
+ /**
172
+ * Adds the pictures of the art page borders in a file of their form, and returns how many
173
+ * it added. Without them, a page border's side of an art style, such as `apples`, is not
174
+ * drawn, with a warning. A document that is already open keeps its layout.
175
+ *
176
+ * # Errors
177
+ *
178
+ * Throws when the data does not read as art pictures.
179
+ */
180
+ addArtPictures(data: Uint8Array | number[]): number;
181
+ /**
182
+ * Adds every face in an OpenType font or font collection (`.ttf`, `.otf`, `.ttc` or
183
+ * `.otc`), and returns the number of faces that it added. A document that is already open
184
+ * keeps its layout.
185
+ *
186
+ * # Errors
187
+ *
188
+ * Throws when the data is not a font that can be loaded.
189
+ */
190
+ addFont(data: Uint8Array | number[]): number;
191
+ /**
192
+ * Returns the fonts that the text of a DOCX file asks for, for the target whose ID
193
+ * `target` gives or the base target, each with the families that the target tries for it.
194
+ * It needs no fonts: fetch the first family of each that you can, add it, then open the
195
+ * document.
196
+ *
197
+ * # Errors
198
+ *
199
+ * Throws when no target has the ID, or when the data is not a DOCX file that can be read.
200
+ */
201
+ static fontsNeeded(docx: Uint8Array | number[], target?: string | null): FontNeed[];
202
+ /**
203
+ * Makes a renderer without fonts.
204
+ */
205
+ constructor();
206
+ /**
207
+ * Lays out a DOCX file into pages using constrained mobile/browser resource limits
208
+ * (`f_office::Limits::mobile()`) so oversized or hostile files fail cleanly instead of
209
+ * exhausting tab memory.
210
+ *
211
+ * # Errors
212
+ *
213
+ * Throws when no target has the ID, `now` is malformed, or the DOCX file breaks mobile
214
+ * limits or cannot be read.
215
+ */
216
+ openDocxMobile(docx: Uint8Array | number[], target?: string | null, now?: string | null): Document;
217
+ /**
218
+ * Lays out a DOCX file into pages with the fonts added so far, for the Word product whose
219
+ * pages to reproduce: the target whose ID `target` gives, or the base target without one.
220
+ * `now`, written as `YYYY-MM-DDTHH:MM:SSZ` with the digits of the local clock, is the date
221
+ * and time that date fields show; without it they show the results stored in the file.
222
+ *
223
+ * # Errors
224
+ *
225
+ * Throws when no target has the ID, `now` is not written in that form, or the data is not
226
+ * a DOCX file that can be read.
227
+ */
228
+ openDocx(docx: Uint8Array | number[], target?: string | null, now?: string | null): Document;
229
+ /**
230
+ * Returns the IDs of the targets that `openDocx` and `fontsNeeded` accept.
231
+ */
232
+ static targets(): string[];
233
+ }
234
+
235
+ /**
236
+ * A run of upright text on a page, in points from the page's top left corner: the box of its
237
+ * glyphs from its font's ascender to its descender, and its glyphs.
238
+ */
239
+ export class TextRun {
240
+ private constructor();
241
+ free(): void;
242
+ [Symbol.dispose](): void;
243
+ /**
244
+ * The baseline.
245
+ */
246
+ readonly baseline: number;
247
+ /**
248
+ * The end of each glyph's text in `text`, counted in UTF-16 code units as JavaScript
249
+ * counts a string's characters.
250
+ */
251
+ readonly glyphEnds: Uint32Array;
252
+ /**
253
+ * The left edge of each glyph's cell, in the order of the text.
254
+ */
255
+ readonly glyphLefts: Float64Array;
256
+ /**
257
+ * The advance of each glyph.
258
+ */
259
+ readonly glyphWidths: Float64Array;
260
+ /**
261
+ * The height of the box.
262
+ */
263
+ readonly height: number;
264
+ /**
265
+ * The left edge of the box.
266
+ */
267
+ readonly left: number;
268
+ /**
269
+ * The font size.
270
+ */
271
+ readonly size: number;
272
+ /**
273
+ * The text that the glyphs show.
274
+ */
275
+ readonly text: string;
276
+ /**
277
+ * The top edge of the box.
278
+ */
279
+ readonly top: number;
280
+ /**
281
+ * The width of the box.
282
+ */
283
+ readonly width: number;
284
+ }
285
+
286
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
287
+
288
+ export interface InitOutput {
289
+ readonly memory: WebAssembly.Memory;
290
+ readonly __wbg_document_free: (a: number, b: number) => void;
291
+ readonly __wbg_fontneed_free: (a: number, b: number) => void;
292
+ readonly __wbg_outlineentry_free: (a: number, b: number) => void;
293
+ readonly __wbg_pageimage_free: (a: number, b: number) => void;
294
+ readonly __wbg_renderer_free: (a: number, b: number) => void;
295
+ readonly __wbg_textrun_free: (a: number, b: number) => void;
296
+ readonly document_fontNeeds: (a: number, b: number) => void;
297
+ readonly document_outline: (a: number, b: number) => void;
298
+ readonly document_pageCount: (a: number) => number;
299
+ readonly document_pageHeight: (a: number, b: number, c: number, d: number) => void;
300
+ readonly document_pageSizes: (a: number, b: number) => void;
301
+ readonly document_pageWidth: (a: number, b: number, c: number, d: number) => void;
302
+ readonly document_renderPage: (a: number, b: number, c: number, d: number) => void;
303
+ readonly document_renderRegion: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
304
+ readonly document_textRuns: (a: number, b: number, c: number) => void;
305
+ readonly document_warnings: (a: number, b: number) => void;
306
+ readonly document_writePdf: (a: number, b: number) => void;
307
+ readonly fontneed_family: (a: number, b: number) => void;
308
+ readonly fontneed_tried: (a: number, b: number) => void;
309
+ readonly outlineentry_address: (a: number, b: number) => void;
310
+ readonly outlineentry_level: (a: number) => number;
311
+ readonly outlineentry_page: (a: number) => number;
312
+ readonly outlineentry_text: (a: number, b: number) => void;
313
+ readonly pageimage_gray: (a: number, b: number) => void;
314
+ readonly pageimage_height: (a: number) => number;
315
+ readonly pageimage_pixels: (a: number) => any;
316
+ readonly pageimage_warnings: (a: number, b: number) => void;
317
+ readonly pageimage_width: (a: number) => number;
318
+ readonly renderer_addArtPictures: (a: number, b: number, c: number, d: number) => void;
319
+ readonly renderer_addFont: (a: number, b: number, c: number, d: number) => void;
320
+ readonly renderer_fontsNeeded: (a: number, b: number, c: number, d: number, e: number) => void;
321
+ readonly renderer_new: () => number;
322
+ readonly renderer_openDocx: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
323
+ readonly renderer_openDocxMobile: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
324
+ readonly renderer_targets: (a: number) => void;
325
+ readonly textrun_baseline: (a: number) => number;
326
+ readonly textrun_glyphEnds: (a: number, b: number) => void;
327
+ readonly textrun_glyphLefts: (a: number, b: number) => void;
328
+ readonly textrun_glyphWidths: (a: number, b: number) => void;
329
+ readonly textrun_height: (a: number) => number;
330
+ readonly textrun_left: (a: number) => number;
331
+ readonly textrun_size: (a: number) => number;
332
+ readonly textrun_text: (a: number, b: number) => void;
333
+ readonly textrun_top: (a: number) => number;
334
+ readonly textrun_width: (a: number) => number;
335
+ readonly __wbindgen_externrefs: WebAssembly.Table;
336
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
337
+ readonly __wbindgen_export: (a: number, b: number) => void;
338
+ readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
339
+ readonly __wbindgen_export3: (a: number) => void;
340
+ readonly __wbindgen_export4: (a: number, b: number) => number;
341
+ readonly __wbindgen_export5: (a: number, b: number, c: number, d: number) => number;
342
+ readonly __wbindgen_start: () => void;
343
+ }
344
+
345
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
346
+
347
+ /**
348
+ * Instantiates the given `module`, which can either be bytes or
349
+ * a precompiled `WebAssembly.Module`.
350
+ *
351
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
352
+ *
353
+ * @returns {InitOutput}
354
+ */
355
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
356
+
357
+ /**
358
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
359
+ * for everything else, calls `WebAssembly.instantiate` directly.
360
+ *
361
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
362
+ *
363
+ * @returns {Promise<InitOutput>}
364
+ */
365
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;