@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.
- package/LICENSE +168 -0
- package/NOTICE +31 -0
- package/README.md +79 -2
- package/dist/index.d.ts +96 -0
- package/dist/index.js +315 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.js +1 -0
- package/dist/wasm/f_office_wasm.d.ts +365 -0
- package/dist/wasm/f_office_wasm.js +1180 -0
- package/dist/wasm/f_office_wasm_bg.wasm +0 -0
- package/dist/wasm/f_office_wasm_bg.wasm.d.ts +56 -0
- package/dist/worker.d.ts +45 -0
- package/dist/worker.js +248 -0
- package/package.json +51 -4
|
@@ -0,0 +1,1180 @@
|
|
|
1
|
+
/* @ts-self-types="./f_office_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A document laid out into pages. Page indexes count from 0.
|
|
5
|
+
*/
|
|
6
|
+
export class Document {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(Document.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
DocumentFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
DocumentFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_document_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the fonts that the layout looked for and the renderer lacks, each once, with the
|
|
25
|
+
* families that the target tries for each. This includes fallback fonts looked up for
|
|
26
|
+
* characters that the primary fonts lack.
|
|
27
|
+
* @returns {FontNeed[]}
|
|
28
|
+
*/
|
|
29
|
+
fontNeeds() {
|
|
30
|
+
try {
|
|
31
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
32
|
+
wasm.document_fontNeeds(retptr, this.__wbg_ptr);
|
|
33
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
34
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
35
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
36
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
37
|
+
return v1;
|
|
38
|
+
} finally {
|
|
39
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the headings of the body in the order of the document.
|
|
44
|
+
* @returns {OutlineEntry[]}
|
|
45
|
+
*/
|
|
46
|
+
outline() {
|
|
47
|
+
try {
|
|
48
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
49
|
+
wasm.document_outline(retptr, this.__wbg_ptr);
|
|
50
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
51
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
52
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
53
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
54
|
+
return v1;
|
|
55
|
+
} finally {
|
|
56
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the number of pages.
|
|
61
|
+
* @returns {number}
|
|
62
|
+
*/
|
|
63
|
+
pageCount() {
|
|
64
|
+
const ret = wasm.document_pageCount(this.__wbg_ptr);
|
|
65
|
+
return ret >>> 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns the height in pixels of the image that `renderPage` draws at `dpi`.
|
|
69
|
+
*
|
|
70
|
+
* # Errors
|
|
71
|
+
*
|
|
72
|
+
* Throws when the page does not exist or cannot be drawn at this resolution.
|
|
73
|
+
* @param {number} index
|
|
74
|
+
* @param {number} dpi
|
|
75
|
+
* @returns {number}
|
|
76
|
+
*/
|
|
77
|
+
pageHeight(index, dpi) {
|
|
78
|
+
try {
|
|
79
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
80
|
+
wasm.document_pageHeight(retptr, this.__wbg_ptr, index, dpi);
|
|
81
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
82
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
83
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
84
|
+
if (r2) {
|
|
85
|
+
throw takeFromExternrefTable0(r1);
|
|
86
|
+
}
|
|
87
|
+
return r0 >>> 0;
|
|
88
|
+
} finally {
|
|
89
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns the width and the height in points of every page, in order: the width of page 0,
|
|
94
|
+
* its height, the width of page 1, and so on.
|
|
95
|
+
* @returns {Float64Array}
|
|
96
|
+
*/
|
|
97
|
+
pageSizes() {
|
|
98
|
+
try {
|
|
99
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
100
|
+
wasm.document_pageSizes(retptr, this.__wbg_ptr);
|
|
101
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
102
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
103
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
104
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
105
|
+
return v1;
|
|
106
|
+
} finally {
|
|
107
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns the width in pixels of the image that `renderPage` draws at `dpi`.
|
|
112
|
+
*
|
|
113
|
+
* # Errors
|
|
114
|
+
*
|
|
115
|
+
* Throws when the page does not exist or cannot be drawn at this resolution.
|
|
116
|
+
* @param {number} index
|
|
117
|
+
* @param {number} dpi
|
|
118
|
+
* @returns {number}
|
|
119
|
+
*/
|
|
120
|
+
pageWidth(index, dpi) {
|
|
121
|
+
try {
|
|
122
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
123
|
+
wasm.document_pageWidth(retptr, this.__wbg_ptr, index, dpi);
|
|
124
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
125
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
126
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
127
|
+
if (r2) {
|
|
128
|
+
throw takeFromExternrefTable0(r1);
|
|
129
|
+
}
|
|
130
|
+
return r0 >>> 0;
|
|
131
|
+
} finally {
|
|
132
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Draws one page at `dpi` pixels per inch on a white background. A CSS pixel is 1/96 inch,
|
|
137
|
+
* so a sharp image for the screen uses `96 * devicePixelRatio`.
|
|
138
|
+
*
|
|
139
|
+
* # Errors
|
|
140
|
+
*
|
|
141
|
+
* Throws when the page does not exist, or cannot be drawn at this resolution.
|
|
142
|
+
* @param {number} index
|
|
143
|
+
* @param {number} dpi
|
|
144
|
+
* @returns {PageImage}
|
|
145
|
+
*/
|
|
146
|
+
renderPage(index, dpi) {
|
|
147
|
+
try {
|
|
148
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
149
|
+
wasm.document_renderPage(retptr, this.__wbg_ptr, index, dpi);
|
|
150
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
151
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
152
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
153
|
+
if (r2) {
|
|
154
|
+
throw takeFromExternrefTable0(r1);
|
|
155
|
+
}
|
|
156
|
+
return PageImage.__wrap(r0);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Draws only the rectangular pixel tile `(x, y, width, height)` of page `index` at `dpi`
|
|
163
|
+
* pixels per inch on a white background, keeping memory proportional to the tile size.
|
|
164
|
+
*
|
|
165
|
+
* # Errors
|
|
166
|
+
*
|
|
167
|
+
* Throws when the page does not exist or the tile cannot be drawn at this resolution.
|
|
168
|
+
* @param {number} index
|
|
169
|
+
* @param {number} x
|
|
170
|
+
* @param {number} y
|
|
171
|
+
* @param {number} width
|
|
172
|
+
* @param {number} height
|
|
173
|
+
* @param {number} dpi
|
|
174
|
+
* @returns {PageImage}
|
|
175
|
+
*/
|
|
176
|
+
renderRegion(index, x, y, width, height, dpi) {
|
|
177
|
+
try {
|
|
178
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
179
|
+
wasm.document_renderRegion(retptr, this.__wbg_ptr, index, x, y, width, height, dpi);
|
|
180
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
181
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
182
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
183
|
+
if (r2) {
|
|
184
|
+
throw takeFromExternrefTable0(r1);
|
|
185
|
+
}
|
|
186
|
+
return PageImage.__wrap(r0);
|
|
187
|
+
} finally {
|
|
188
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the upright text runs of one page in painting order, for a text layer.
|
|
193
|
+
*
|
|
194
|
+
* # Errors
|
|
195
|
+
*
|
|
196
|
+
* Throws when the page does not exist.
|
|
197
|
+
* @param {number} index
|
|
198
|
+
* @returns {TextRun[]}
|
|
199
|
+
*/
|
|
200
|
+
textRuns(index) {
|
|
201
|
+
try {
|
|
202
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
203
|
+
wasm.document_textRuns(retptr, this.__wbg_ptr, index);
|
|
204
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
205
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
206
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
207
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
208
|
+
if (r3) {
|
|
209
|
+
throw takeFromExternrefTable0(r2);
|
|
210
|
+
}
|
|
211
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
212
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
213
|
+
return v1;
|
|
214
|
+
} finally {
|
|
215
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Returns the text of each distinct warning of the layout, such as a font that another font
|
|
220
|
+
* draws or a picture that the file lacks, once each.
|
|
221
|
+
* @returns {string[]}
|
|
222
|
+
*/
|
|
223
|
+
warnings() {
|
|
224
|
+
try {
|
|
225
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
226
|
+
wasm.document_warnings(retptr, this.__wbg_ptr);
|
|
227
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
228
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
229
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
230
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
231
|
+
return v1;
|
|
232
|
+
} finally {
|
|
233
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Writes the laid-out pages as a PDF file with the renderer's fonts subset and embedded.
|
|
238
|
+
*
|
|
239
|
+
* # Errors
|
|
240
|
+
*
|
|
241
|
+
* Throws when the pages cannot be written as PDF.
|
|
242
|
+
* @returns {Uint8Array}
|
|
243
|
+
*/
|
|
244
|
+
writePdf() {
|
|
245
|
+
try {
|
|
246
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
247
|
+
wasm.document_writePdf(retptr, this.__wbg_ptr);
|
|
248
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
249
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
250
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
251
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
252
|
+
if (r3) {
|
|
253
|
+
throw takeFromExternrefTable0(r2);
|
|
254
|
+
}
|
|
255
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
256
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
257
|
+
return v1;
|
|
258
|
+
} finally {
|
|
259
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (Symbol.dispose) Document.prototype[Symbol.dispose] = Document.prototype.free;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* A font that a document's text asks for and the families that the target tries for it.
|
|
267
|
+
*/
|
|
268
|
+
export class FontNeed {
|
|
269
|
+
static __wrap(ptr) {
|
|
270
|
+
const obj = Object.create(FontNeed.prototype);
|
|
271
|
+
obj.__wbg_ptr = ptr;
|
|
272
|
+
FontNeedFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
273
|
+
return obj;
|
|
274
|
+
}
|
|
275
|
+
__destroy_into_raw() {
|
|
276
|
+
const ptr = this.__wbg_ptr;
|
|
277
|
+
this.__wbg_ptr = 0;
|
|
278
|
+
FontNeedFinalization.unregister(this);
|
|
279
|
+
return ptr;
|
|
280
|
+
}
|
|
281
|
+
free() {
|
|
282
|
+
const ptr = this.__destroy_into_raw();
|
|
283
|
+
wasm.__wbg_fontneed_free(ptr, 0);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The family that the text asks for, or `undefined` for text that names no font.
|
|
287
|
+
* @returns {string | undefined}
|
|
288
|
+
*/
|
|
289
|
+
get family() {
|
|
290
|
+
try {
|
|
291
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
292
|
+
wasm.fontneed_family(retptr, this.__wbg_ptr);
|
|
293
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
294
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
295
|
+
let v1;
|
|
296
|
+
if (r0 !== 0) {
|
|
297
|
+
v1 = getStringFromWasm0(r0, r1);
|
|
298
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
299
|
+
}
|
|
300
|
+
return v1;
|
|
301
|
+
} finally {
|
|
302
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The families that the layout tries for the text, in order.
|
|
307
|
+
* @returns {string[]}
|
|
308
|
+
*/
|
|
309
|
+
get tried() {
|
|
310
|
+
try {
|
|
311
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
312
|
+
wasm.fontneed_tried(retptr, this.__wbg_ptr);
|
|
313
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
314
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
315
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
316
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
317
|
+
return v1;
|
|
318
|
+
} finally {
|
|
319
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (Symbol.dispose) FontNeed.prototype[Symbol.dispose] = FontNeed.prototype.free;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* A heading of the document's outline.
|
|
327
|
+
*/
|
|
328
|
+
export class OutlineEntry {
|
|
329
|
+
static __wrap(ptr) {
|
|
330
|
+
const obj = Object.create(OutlineEntry.prototype);
|
|
331
|
+
obj.__wbg_ptr = ptr;
|
|
332
|
+
OutlineEntryFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
333
|
+
return obj;
|
|
334
|
+
}
|
|
335
|
+
__destroy_into_raw() {
|
|
336
|
+
const ptr = this.__wbg_ptr;
|
|
337
|
+
this.__wbg_ptr = 0;
|
|
338
|
+
OutlineEntryFinalization.unregister(this);
|
|
339
|
+
return ptr;
|
|
340
|
+
}
|
|
341
|
+
free() {
|
|
342
|
+
const ptr = this.__destroy_into_raw();
|
|
343
|
+
wasm.__wbg_outlineentry_free(ptr, 0);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The address of its paragraph in the body, such as `p12`.
|
|
347
|
+
* @returns {string}
|
|
348
|
+
*/
|
|
349
|
+
get address() {
|
|
350
|
+
let deferred1_0;
|
|
351
|
+
let deferred1_1;
|
|
352
|
+
try {
|
|
353
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
354
|
+
wasm.outlineentry_address(retptr, this.__wbg_ptr);
|
|
355
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
356
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
357
|
+
deferred1_0 = r0;
|
|
358
|
+
deferred1_1 = r1;
|
|
359
|
+
return getStringFromWasm0(r0, r1);
|
|
360
|
+
} finally {
|
|
361
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
362
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* The heading's level, from 0 for the top level to 8: the level that the body's table of
|
|
367
|
+
* contents gives it when the outline follows that table, else its outline level.
|
|
368
|
+
* @returns {number}
|
|
369
|
+
*/
|
|
370
|
+
get level() {
|
|
371
|
+
const ret = wasm.outlineentry_level(this.__wbg_ptr);
|
|
372
|
+
return ret;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The index of the page of its first line, counted from 0.
|
|
376
|
+
* @returns {number}
|
|
377
|
+
*/
|
|
378
|
+
get page() {
|
|
379
|
+
const ret = wasm.outlineentry_page(this.__wbg_ptr);
|
|
380
|
+
return ret >>> 0;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* The heading's text on one line.
|
|
384
|
+
* @returns {string}
|
|
385
|
+
*/
|
|
386
|
+
get text() {
|
|
387
|
+
let deferred1_0;
|
|
388
|
+
let deferred1_1;
|
|
389
|
+
try {
|
|
390
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
391
|
+
wasm.outlineentry_text(retptr, this.__wbg_ptr);
|
|
392
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
393
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
394
|
+
deferred1_0 = r0;
|
|
395
|
+
deferred1_1 = r1;
|
|
396
|
+
return getStringFromWasm0(r0, r1);
|
|
397
|
+
} finally {
|
|
398
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
399
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (Symbol.dispose) OutlineEntry.prototype[Symbol.dispose] = OutlineEntry.prototype.free;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* One drawn page: RGBA pixels with their width and height, and the warnings of the drawing.
|
|
407
|
+
*/
|
|
408
|
+
export class PageImage {
|
|
409
|
+
static __wrap(ptr) {
|
|
410
|
+
const obj = Object.create(PageImage.prototype);
|
|
411
|
+
obj.__wbg_ptr = ptr;
|
|
412
|
+
PageImageFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
413
|
+
return obj;
|
|
414
|
+
}
|
|
415
|
+
__destroy_into_raw() {
|
|
416
|
+
const ptr = this.__wbg_ptr;
|
|
417
|
+
this.__wbg_ptr = 0;
|
|
418
|
+
PageImageFinalization.unregister(this);
|
|
419
|
+
return ptr;
|
|
420
|
+
}
|
|
421
|
+
free() {
|
|
422
|
+
const ptr = this.__destroy_into_raw();
|
|
423
|
+
wasm.__wbg_pageimage_free(ptr, 0);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* The pixels in gray, one byte each, row by row from the top left corner, as a comparison
|
|
427
|
+
* with a gray page image reads them: each pixel's luma, 0.299 red, 0.587 green and 0.114
|
|
428
|
+
* blue, rounded.
|
|
429
|
+
* @returns {Uint8Array}
|
|
430
|
+
*/
|
|
431
|
+
get gray() {
|
|
432
|
+
try {
|
|
433
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
434
|
+
wasm.pageimage_gray(retptr, this.__wbg_ptr);
|
|
435
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
436
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
437
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
438
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
439
|
+
return v1;
|
|
440
|
+
} finally {
|
|
441
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Height in pixels.
|
|
446
|
+
* @returns {number}
|
|
447
|
+
*/
|
|
448
|
+
get height() {
|
|
449
|
+
const ret = wasm.pageimage_height(this.__wbg_ptr);
|
|
450
|
+
return ret >>> 0;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* The pixels as RGBA bytes, row by row from the top left corner. Each read copies them
|
|
454
|
+
* once out of WebAssembly memory into a new array, which
|
|
455
|
+
* `new ImageData(pixels, width, height)` takes without another copy. Read it once, then
|
|
456
|
+
* call `free()`.
|
|
457
|
+
* @returns {Uint8ClampedArray}
|
|
458
|
+
*/
|
|
459
|
+
get pixels() {
|
|
460
|
+
const ret = wasm.pageimage_pixels(this.__wbg_ptr);
|
|
461
|
+
return ret;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Returns the text of each distinct warning of the drawing, such as an image that does not
|
|
465
|
+
* decode, once each.
|
|
466
|
+
* @returns {string[]}
|
|
467
|
+
*/
|
|
468
|
+
warnings() {
|
|
469
|
+
try {
|
|
470
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
471
|
+
wasm.pageimage_warnings(retptr, this.__wbg_ptr);
|
|
472
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
473
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
474
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
475
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
476
|
+
return v1;
|
|
477
|
+
} finally {
|
|
478
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Width in pixels.
|
|
483
|
+
* @returns {number}
|
|
484
|
+
*/
|
|
485
|
+
get width() {
|
|
486
|
+
const ret = wasm.pageimage_width(this.__wbg_ptr);
|
|
487
|
+
return ret >>> 0;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (Symbol.dispose) PageImage.prototype[Symbol.dispose] = PageImage.prototype.free;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Fonts for rendering. Add the fonts first, then open documents.
|
|
494
|
+
*/
|
|
495
|
+
export class Renderer {
|
|
496
|
+
__destroy_into_raw() {
|
|
497
|
+
const ptr = this.__wbg_ptr;
|
|
498
|
+
this.__wbg_ptr = 0;
|
|
499
|
+
RendererFinalization.unregister(this);
|
|
500
|
+
return ptr;
|
|
501
|
+
}
|
|
502
|
+
free() {
|
|
503
|
+
const ptr = this.__destroy_into_raw();
|
|
504
|
+
wasm.__wbg_renderer_free(ptr, 0);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Adds the pictures of the art page borders in a file of their form, and returns how many
|
|
508
|
+
* it added. Without them, a page border's side of an art style, such as `apples`, is not
|
|
509
|
+
* drawn, with a warning. A document that is already open keeps its layout.
|
|
510
|
+
*
|
|
511
|
+
* # Errors
|
|
512
|
+
*
|
|
513
|
+
* Throws when the data does not read as art pictures.
|
|
514
|
+
* @param {Uint8Array | number[]} data
|
|
515
|
+
* @returns {number}
|
|
516
|
+
*/
|
|
517
|
+
addArtPictures(data) {
|
|
518
|
+
try {
|
|
519
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
520
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
521
|
+
const len0 = WASM_VECTOR_LEN;
|
|
522
|
+
wasm.renderer_addArtPictures(retptr, this.__wbg_ptr, ptr0, len0);
|
|
523
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
524
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
525
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
526
|
+
if (r2) {
|
|
527
|
+
throw takeFromExternrefTable0(r1);
|
|
528
|
+
}
|
|
529
|
+
return r0 >>> 0;
|
|
530
|
+
} finally {
|
|
531
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Adds every face in an OpenType font or font collection (`.ttf`, `.otf`, `.ttc` or
|
|
536
|
+
* `.otc`), and returns the number of faces that it added. A document that is already open
|
|
537
|
+
* keeps its layout.
|
|
538
|
+
*
|
|
539
|
+
* # Errors
|
|
540
|
+
*
|
|
541
|
+
* Throws when the data is not a font that can be loaded.
|
|
542
|
+
* @param {Uint8Array | number[]} data
|
|
543
|
+
* @returns {number}
|
|
544
|
+
*/
|
|
545
|
+
addFont(data) {
|
|
546
|
+
try {
|
|
547
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
548
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
549
|
+
const len0 = WASM_VECTOR_LEN;
|
|
550
|
+
wasm.renderer_addFont(retptr, this.__wbg_ptr, ptr0, len0);
|
|
551
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
552
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
553
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
554
|
+
if (r2) {
|
|
555
|
+
throw takeFromExternrefTable0(r1);
|
|
556
|
+
}
|
|
557
|
+
return r0 >>> 0;
|
|
558
|
+
} finally {
|
|
559
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Returns the fonts that the text of a DOCX file asks for, for the target whose ID
|
|
564
|
+
* `target` gives or the base target, each with the families that the target tries for it.
|
|
565
|
+
* It needs no fonts: fetch the first family of each that you can, add it, then open the
|
|
566
|
+
* document.
|
|
567
|
+
*
|
|
568
|
+
* # Errors
|
|
569
|
+
*
|
|
570
|
+
* Throws when no target has the ID, or when the data is not a DOCX file that can be read.
|
|
571
|
+
* @param {Uint8Array | number[]} docx
|
|
572
|
+
* @param {string | null} [target]
|
|
573
|
+
* @returns {FontNeed[]}
|
|
574
|
+
*/
|
|
575
|
+
static fontsNeeded(docx, target) {
|
|
576
|
+
try {
|
|
577
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
578
|
+
let ptr0, len0, ptr1, len1;
|
|
579
|
+
try {
|
|
580
|
+
ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_export4);
|
|
581
|
+
len0 = WASM_VECTOR_LEN;
|
|
582
|
+
ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
583
|
+
len1 = WASM_VECTOR_LEN;
|
|
584
|
+
} catch (e) {
|
|
585
|
+
if (ptr1) { wasm.__wbindgen_export2(ptr1, len1 * 1, 1); }
|
|
586
|
+
if (ptr0) { wasm.__wbindgen_export2(ptr0, len0 * 1, 1); }
|
|
587
|
+
throw e;
|
|
588
|
+
}
|
|
589
|
+
wasm.renderer_fontsNeeded(retptr, ptr0, len0, ptr1, len1);
|
|
590
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
591
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
592
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
593
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
594
|
+
if (r3) {
|
|
595
|
+
throw takeFromExternrefTable0(r2);
|
|
596
|
+
}
|
|
597
|
+
var v3 = getArrayJsValueFromWasm0(r0, r1);
|
|
598
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
599
|
+
return v3;
|
|
600
|
+
} finally {
|
|
601
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Makes a renderer without fonts.
|
|
606
|
+
*/
|
|
607
|
+
constructor() {
|
|
608
|
+
const ret = wasm.renderer_new();
|
|
609
|
+
this.__wbg_ptr = ret;
|
|
610
|
+
RendererFinalization.register(this, this.__wbg_ptr, this);
|
|
611
|
+
return this;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Lays out a DOCX file into pages using constrained mobile/browser resource limits
|
|
615
|
+
* (`f_office::Limits::mobile()`) so oversized or hostile files fail cleanly instead of
|
|
616
|
+
* exhausting tab memory.
|
|
617
|
+
*
|
|
618
|
+
* # Errors
|
|
619
|
+
*
|
|
620
|
+
* Throws when no target has the ID, `now` is malformed, or the DOCX file breaks mobile
|
|
621
|
+
* limits or cannot be read.
|
|
622
|
+
* @param {Uint8Array | number[]} docx
|
|
623
|
+
* @param {string | null} [target]
|
|
624
|
+
* @param {string | null} [now]
|
|
625
|
+
* @returns {Document}
|
|
626
|
+
*/
|
|
627
|
+
openDocxMobile(docx, target, now) {
|
|
628
|
+
try {
|
|
629
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
630
|
+
let ptr0, len0, ptr1, len1, ptr2, len2;
|
|
631
|
+
try {
|
|
632
|
+
ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_export4);
|
|
633
|
+
len0 = WASM_VECTOR_LEN;
|
|
634
|
+
ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
635
|
+
len1 = WASM_VECTOR_LEN;
|
|
636
|
+
ptr2 = isLikeNone(now) ? 0 : passStringToWasm0(now, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
637
|
+
len2 = WASM_VECTOR_LEN;
|
|
638
|
+
} catch (e) {
|
|
639
|
+
if (ptr2) { wasm.__wbindgen_export2(ptr2, len2 * 1, 1); }
|
|
640
|
+
if (ptr1) { wasm.__wbindgen_export2(ptr1, len1 * 1, 1); }
|
|
641
|
+
if (ptr0) { wasm.__wbindgen_export2(ptr0, len0 * 1, 1); }
|
|
642
|
+
throw e;
|
|
643
|
+
}
|
|
644
|
+
wasm.renderer_openDocxMobile(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
645
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
646
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
647
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
648
|
+
if (r2) {
|
|
649
|
+
throw takeFromExternrefTable0(r1);
|
|
650
|
+
}
|
|
651
|
+
return Document.__wrap(r0);
|
|
652
|
+
} finally {
|
|
653
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Lays out a DOCX file into pages with the fonts added so far, for the Word product whose
|
|
658
|
+
* pages to reproduce: the target whose ID `target` gives, or the base target without one.
|
|
659
|
+
* `now`, written as `YYYY-MM-DDTHH:MM:SSZ` with the digits of the local clock, is the date
|
|
660
|
+
* and time that date fields show; without it they show the results stored in the file.
|
|
661
|
+
*
|
|
662
|
+
* # Errors
|
|
663
|
+
*
|
|
664
|
+
* Throws when no target has the ID, `now` is not written in that form, or the data is not
|
|
665
|
+
* a DOCX file that can be read.
|
|
666
|
+
* @param {Uint8Array | number[]} docx
|
|
667
|
+
* @param {string | null} [target]
|
|
668
|
+
* @param {string | null} [now]
|
|
669
|
+
* @returns {Document}
|
|
670
|
+
*/
|
|
671
|
+
openDocx(docx, target, now) {
|
|
672
|
+
try {
|
|
673
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
674
|
+
let ptr0, len0, ptr1, len1, ptr2, len2;
|
|
675
|
+
try {
|
|
676
|
+
ptr0 = passArray8ToWasm0(docx, wasm.__wbindgen_export4);
|
|
677
|
+
len0 = WASM_VECTOR_LEN;
|
|
678
|
+
ptr1 = isLikeNone(target) ? 0 : passStringToWasm0(target, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
679
|
+
len1 = WASM_VECTOR_LEN;
|
|
680
|
+
ptr2 = isLikeNone(now) ? 0 : passStringToWasm0(now, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
681
|
+
len2 = WASM_VECTOR_LEN;
|
|
682
|
+
} catch (e) {
|
|
683
|
+
if (ptr2) { wasm.__wbindgen_export2(ptr2, len2 * 1, 1); }
|
|
684
|
+
if (ptr1) { wasm.__wbindgen_export2(ptr1, len1 * 1, 1); }
|
|
685
|
+
if (ptr0) { wasm.__wbindgen_export2(ptr0, len0 * 1, 1); }
|
|
686
|
+
throw e;
|
|
687
|
+
}
|
|
688
|
+
wasm.renderer_openDocx(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
689
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
690
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
691
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
692
|
+
if (r2) {
|
|
693
|
+
throw takeFromExternrefTable0(r1);
|
|
694
|
+
}
|
|
695
|
+
return Document.__wrap(r0);
|
|
696
|
+
} finally {
|
|
697
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Returns the IDs of the targets that `openDocx` and `fontsNeeded` accept.
|
|
702
|
+
* @returns {string[]}
|
|
703
|
+
*/
|
|
704
|
+
static targets() {
|
|
705
|
+
try {
|
|
706
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
707
|
+
wasm.renderer_targets(retptr);
|
|
708
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
709
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
710
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1);
|
|
711
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
712
|
+
return v1;
|
|
713
|
+
} finally {
|
|
714
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (Symbol.dispose) Renderer.prototype[Symbol.dispose] = Renderer.prototype.free;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* A run of upright text on a page, in points from the page's top left corner: the box of its
|
|
722
|
+
* glyphs from its font's ascender to its descender, and its glyphs.
|
|
723
|
+
*/
|
|
724
|
+
export class TextRun {
|
|
725
|
+
static __wrap(ptr) {
|
|
726
|
+
const obj = Object.create(TextRun.prototype);
|
|
727
|
+
obj.__wbg_ptr = ptr;
|
|
728
|
+
TextRunFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
729
|
+
return obj;
|
|
730
|
+
}
|
|
731
|
+
__destroy_into_raw() {
|
|
732
|
+
const ptr = this.__wbg_ptr;
|
|
733
|
+
this.__wbg_ptr = 0;
|
|
734
|
+
TextRunFinalization.unregister(this);
|
|
735
|
+
return ptr;
|
|
736
|
+
}
|
|
737
|
+
free() {
|
|
738
|
+
const ptr = this.__destroy_into_raw();
|
|
739
|
+
wasm.__wbg_textrun_free(ptr, 0);
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* The baseline.
|
|
743
|
+
* @returns {number}
|
|
744
|
+
*/
|
|
745
|
+
get baseline() {
|
|
746
|
+
const ret = wasm.textrun_baseline(this.__wbg_ptr);
|
|
747
|
+
return ret;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* The end of each glyph's text in `text`, counted in UTF-16 code units as JavaScript
|
|
751
|
+
* counts a string's characters.
|
|
752
|
+
* @returns {Uint32Array}
|
|
753
|
+
*/
|
|
754
|
+
get glyphEnds() {
|
|
755
|
+
try {
|
|
756
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
757
|
+
wasm.textrun_glyphEnds(retptr, this.__wbg_ptr);
|
|
758
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
759
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
760
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
761
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
762
|
+
return v1;
|
|
763
|
+
} finally {
|
|
764
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* The left edge of each glyph's cell, in the order of the text.
|
|
769
|
+
* @returns {Float64Array}
|
|
770
|
+
*/
|
|
771
|
+
get glyphLefts() {
|
|
772
|
+
try {
|
|
773
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
774
|
+
wasm.textrun_glyphLefts(retptr, this.__wbg_ptr);
|
|
775
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
776
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
777
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
778
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
779
|
+
return v1;
|
|
780
|
+
} finally {
|
|
781
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* The advance of each glyph.
|
|
786
|
+
* @returns {Float64Array}
|
|
787
|
+
*/
|
|
788
|
+
get glyphWidths() {
|
|
789
|
+
try {
|
|
790
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
791
|
+
wasm.textrun_glyphWidths(retptr, this.__wbg_ptr);
|
|
792
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
793
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
794
|
+
var v1 = getArrayF64FromWasm0(r0, r1).slice();
|
|
795
|
+
wasm.__wbindgen_export2(r0, r1 * 8, 8);
|
|
796
|
+
return v1;
|
|
797
|
+
} finally {
|
|
798
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* The height of the box.
|
|
803
|
+
* @returns {number}
|
|
804
|
+
*/
|
|
805
|
+
get height() {
|
|
806
|
+
const ret = wasm.textrun_height(this.__wbg_ptr);
|
|
807
|
+
return ret;
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* The left edge of the box.
|
|
811
|
+
* @returns {number}
|
|
812
|
+
*/
|
|
813
|
+
get left() {
|
|
814
|
+
const ret = wasm.textrun_left(this.__wbg_ptr);
|
|
815
|
+
return ret;
|
|
816
|
+
}
|
|
817
|
+
/**
|
|
818
|
+
* The font size.
|
|
819
|
+
* @returns {number}
|
|
820
|
+
*/
|
|
821
|
+
get size() {
|
|
822
|
+
const ret = wasm.textrun_size(this.__wbg_ptr);
|
|
823
|
+
return ret;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* The text that the glyphs show.
|
|
827
|
+
* @returns {string}
|
|
828
|
+
*/
|
|
829
|
+
get text() {
|
|
830
|
+
let deferred1_0;
|
|
831
|
+
let deferred1_1;
|
|
832
|
+
try {
|
|
833
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
|
|
834
|
+
wasm.textrun_text(retptr, this.__wbg_ptr);
|
|
835
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
836
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
837
|
+
deferred1_0 = r0;
|
|
838
|
+
deferred1_1 = r1;
|
|
839
|
+
return getStringFromWasm0(r0, r1);
|
|
840
|
+
} finally {
|
|
841
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
842
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* The top edge of the box.
|
|
847
|
+
* @returns {number}
|
|
848
|
+
*/
|
|
849
|
+
get top() {
|
|
850
|
+
const ret = wasm.textrun_top(this.__wbg_ptr);
|
|
851
|
+
return ret;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* The width of the box.
|
|
855
|
+
* @returns {number}
|
|
856
|
+
*/
|
|
857
|
+
get width() {
|
|
858
|
+
const ret = wasm.textrun_width(this.__wbg_ptr);
|
|
859
|
+
return ret;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
if (Symbol.dispose) TextRun.prototype[Symbol.dispose] = TextRun.prototype.free;
|
|
863
|
+
function __wbg_get_imports() {
|
|
864
|
+
const import0 = {
|
|
865
|
+
__proto__: null,
|
|
866
|
+
__wbg_Error_208446807d0d1e30: function(arg0, arg1) {
|
|
867
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
868
|
+
return ret;
|
|
869
|
+
},
|
|
870
|
+
__wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
|
|
871
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
872
|
+
},
|
|
873
|
+
__wbg_fontneed_new: function(arg0) {
|
|
874
|
+
const ret = FontNeed.__wrap(arg0);
|
|
875
|
+
return ret;
|
|
876
|
+
},
|
|
877
|
+
__wbg_new_from_slice_c7cf3126a626653c: function(arg0, arg1) {
|
|
878
|
+
const ret = new Uint8ClampedArray(getArrayU8FromWasm0(arg0, arg1));
|
|
879
|
+
return ret;
|
|
880
|
+
},
|
|
881
|
+
__wbg_outlineentry_new: function(arg0) {
|
|
882
|
+
const ret = OutlineEntry.__wrap(arg0);
|
|
883
|
+
return ret;
|
|
884
|
+
},
|
|
885
|
+
__wbg_textrun_new: function(arg0) {
|
|
886
|
+
const ret = TextRun.__wrap(arg0);
|
|
887
|
+
return ret;
|
|
888
|
+
},
|
|
889
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
890
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
891
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
892
|
+
return ret;
|
|
893
|
+
},
|
|
894
|
+
__wbindgen_init_externref_table: function() {
|
|
895
|
+
const table = wasm.__wbindgen_externrefs;
|
|
896
|
+
table.set(0, undefined);
|
|
897
|
+
table.set(1024, undefined);
|
|
898
|
+
table.set(1025, null);
|
|
899
|
+
table.set(1026, true);
|
|
900
|
+
table.set(1027, false);
|
|
901
|
+
},
|
|
902
|
+
};
|
|
903
|
+
return {
|
|
904
|
+
__proto__: null,
|
|
905
|
+
"./f_office_wasm_bg.js": import0,
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
910
|
+
? { register: () => {}, unregister: () => {} }
|
|
911
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr, 1));
|
|
912
|
+
const FontNeedFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
913
|
+
? { register: () => {}, unregister: () => {} }
|
|
914
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fontneed_free(ptr, 1));
|
|
915
|
+
const OutlineEntryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
916
|
+
? { register: () => {}, unregister: () => {} }
|
|
917
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_outlineentry_free(ptr, 1));
|
|
918
|
+
const PageImageFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
919
|
+
? { register: () => {}, unregister: () => {} }
|
|
920
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pageimage_free(ptr, 1));
|
|
921
|
+
const RendererFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
922
|
+
? { register: () => {}, unregister: () => {} }
|
|
923
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_renderer_free(ptr, 1));
|
|
924
|
+
const TextRunFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
925
|
+
? { register: () => {}, unregister: () => {} }
|
|
926
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_textrun_free(ptr, 1));
|
|
927
|
+
|
|
928
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
929
|
+
ptr = ptr >>> 0;
|
|
930
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
934
|
+
ptr = ptr >>> 0;
|
|
935
|
+
const mem = getDataViewMemory0();
|
|
936
|
+
const result = [];
|
|
937
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
938
|
+
result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
|
|
939
|
+
}
|
|
940
|
+
wasm.__wbindgen_export(ptr, len);
|
|
941
|
+
return result;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
945
|
+
ptr = ptr >>> 0;
|
|
946
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
950
|
+
ptr = ptr >>> 0;
|
|
951
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
let cachedDataViewMemory0 = null;
|
|
955
|
+
function getDataViewMemory0() {
|
|
956
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
957
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
958
|
+
}
|
|
959
|
+
return cachedDataViewMemory0;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
963
|
+
function getFloat64ArrayMemory0() {
|
|
964
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
965
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
966
|
+
}
|
|
967
|
+
return cachedFloat64ArrayMemory0;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function getStringFromWasm0(ptr, len) {
|
|
971
|
+
ptr = ptr >>> 0;
|
|
972
|
+
return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
let cachedUint32ArrayMemory0 = null;
|
|
976
|
+
function getUint32ArrayMemory0() {
|
|
977
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
978
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
979
|
+
}
|
|
980
|
+
return cachedUint32ArrayMemory0;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
let cachedUint8ArrayMemory0 = null;
|
|
984
|
+
function getUint8ArrayMemory0() {
|
|
985
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
986
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
987
|
+
}
|
|
988
|
+
return cachedUint8ArrayMemory0;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function isLikeNone(x) {
|
|
992
|
+
return x === undefined || x === null;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
996
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
997
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
998
|
+
WASM_VECTOR_LEN = arg.length;
|
|
999
|
+
return ptr;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1003
|
+
if (realloc === undefined) {
|
|
1004
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1005
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1006
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1007
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1008
|
+
return ptr;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
let len = arg.length;
|
|
1012
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1013
|
+
|
|
1014
|
+
const mem = getUint8ArrayMemory0();
|
|
1015
|
+
|
|
1016
|
+
let offset = 0;
|
|
1017
|
+
|
|
1018
|
+
for (; offset < len; offset++) {
|
|
1019
|
+
const code = arg.charCodeAt(offset);
|
|
1020
|
+
if (code > 0x7F) break;
|
|
1021
|
+
mem[ptr + offset] = code;
|
|
1022
|
+
}
|
|
1023
|
+
if (offset !== len) {
|
|
1024
|
+
if (offset !== 0) {
|
|
1025
|
+
arg = arg.slice(offset);
|
|
1026
|
+
}
|
|
1027
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1028
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1029
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1030
|
+
|
|
1031
|
+
offset += ret.written;
|
|
1032
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
WASM_VECTOR_LEN = offset;
|
|
1036
|
+
return ptr;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
function takeFromExternrefTable0(idx) {
|
|
1040
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1041
|
+
wasm.__wbindgen_export3(idx);
|
|
1042
|
+
return value;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
1046
|
+
cachedTextDecoder.decode();
|
|
1047
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1048
|
+
let numBytesDecoded = 0;
|
|
1049
|
+
function decodeText(bytes) {
|
|
1050
|
+
numBytesDecoded += bytes.length;
|
|
1051
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1052
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
|
|
1053
|
+
cachedTextDecoder.decode();
|
|
1054
|
+
numBytesDecoded = bytes.length;
|
|
1055
|
+
}
|
|
1056
|
+
return cachedTextDecoder.decode(bytes);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1060
|
+
|
|
1061
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1062
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1063
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1064
|
+
view.set(buf);
|
|
1065
|
+
return {
|
|
1066
|
+
read: arg.length,
|
|
1067
|
+
written: buf.length
|
|
1068
|
+
};
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
let WASM_VECTOR_LEN = 0;
|
|
1073
|
+
|
|
1074
|
+
let wasmModule, wasmInstance, wasm;
|
|
1075
|
+
function __wbg_finalize_init(instance, module) {
|
|
1076
|
+
wasmInstance = instance;
|
|
1077
|
+
wasm = instance.exports;
|
|
1078
|
+
wasmModule = module;
|
|
1079
|
+
cachedDataViewMemory0 = null;
|
|
1080
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1081
|
+
cachedUint32ArrayMemory0 = null;
|
|
1082
|
+
cachedUint8ArrayMemory0 = null;
|
|
1083
|
+
wasm.__wbindgen_start();
|
|
1084
|
+
return wasm;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
async function __wbg_load(module, imports) {
|
|
1088
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1089
|
+
if (!module.ok) {
|
|
1090
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1094
|
+
try {
|
|
1095
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1096
|
+
} catch (e) {
|
|
1097
|
+
const validResponse = expectedResponseType(module.type);
|
|
1098
|
+
|
|
1099
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1100
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1101
|
+
|
|
1102
|
+
} else { throw e; }
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
const bytes = await module.arrayBuffer();
|
|
1107
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1108
|
+
} else {
|
|
1109
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1110
|
+
|
|
1111
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1112
|
+
return { instance, module };
|
|
1113
|
+
} else {
|
|
1114
|
+
return instance;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
function expectedResponseType(type) {
|
|
1119
|
+
switch (type) {
|
|
1120
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1121
|
+
}
|
|
1122
|
+
return false;
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function initSync(module) {
|
|
1127
|
+
if (wasm !== undefined) return wasm;
|
|
1128
|
+
|
|
1129
|
+
|
|
1130
|
+
if (module !== undefined) {
|
|
1131
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1132
|
+
({module} = module)
|
|
1133
|
+
} else {
|
|
1134
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
const imports = __wbg_get_imports();
|
|
1139
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1140
|
+
module = new WebAssembly.Module(module);
|
|
1141
|
+
}
|
|
1142
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1143
|
+
return __wbg_finalize_init(instance, module);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
let __wbg_init_promise;
|
|
1147
|
+
async function __wbg_init(module_or_path) {
|
|
1148
|
+
if (wasm !== undefined) return wasm;
|
|
1149
|
+
if (__wbg_init_promise === undefined) {
|
|
1150
|
+
__wbg_init_promise = __wbg_init_once(module_or_path);
|
|
1151
|
+
__wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
|
|
1152
|
+
}
|
|
1153
|
+
return __wbg_init_promise;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
async function __wbg_init_once(module_or_path) {
|
|
1157
|
+
|
|
1158
|
+
if (module_or_path !== undefined) {
|
|
1159
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1160
|
+
({module_or_path} = module_or_path)
|
|
1161
|
+
} else {
|
|
1162
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
if (module_or_path === undefined) {
|
|
1167
|
+
module_or_path = new URL('f_office_wasm_bg.wasm', import.meta.url);
|
|
1168
|
+
}
|
|
1169
|
+
const imports = __wbg_get_imports();
|
|
1170
|
+
|
|
1171
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1172
|
+
module_or_path = fetch(module_or_path);
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1176
|
+
|
|
1177
|
+
return __wbg_finalize_init(instance, module);
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
export { initSync, __wbg_init as default };
|