officetopdf-wasm 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # officetopdf-wasm
2
+
3
+ `office2pdf` v0.6.8 compiled to WebAssembly from https://github.com/developer0hye/office2pdf.
4
+
5
+ Installed automatically as an optional dependency of [`officetopdf`](https://www.npmjs.com/package/officetopdf). Use that package rather than importing this one directly.
package/office2pdf.js ADDED
@@ -0,0 +1,742 @@
1
+ /* @ts-self-types="./office2pdf.d.ts" */
2
+
3
+ /**
4
+ * PDF bytes and non-fatal warnings from a WASM conversion.
5
+ */
6
+ export class ConversionResult {
7
+ static __wrap(ptr) {
8
+ ptr = ptr >>> 0;
9
+ const obj = Object.create(ConversionResult.prototype);
10
+ obj.__wbg_ptr = ptr;
11
+ ConversionResultFinalization.register(obj, obj.__wbg_ptr, obj);
12
+ return obj;
13
+ }
14
+ __destroy_into_raw() {
15
+ const ptr = this.__wbg_ptr;
16
+ this.__wbg_ptr = 0;
17
+ ConversionResultFinalization.unregister(this);
18
+ return ptr;
19
+ }
20
+ free() {
21
+ const ptr = this.__destroy_into_raw();
22
+ wasm.__wbg_conversionresult_free(ptr, 0);
23
+ }
24
+ /**
25
+ * @returns {Uint8Array}
26
+ */
27
+ get pdf() {
28
+ const ret = wasm.conversionresult_pdf(this.__wbg_ptr);
29
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
30
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
31
+ return v1;
32
+ }
33
+ /**
34
+ * @param {number} index
35
+ * @returns {ConversionWarning | undefined}
36
+ */
37
+ warningAt(index) {
38
+ const ret = wasm.conversionresult_warningAt(this.__wbg_ptr, index);
39
+ return ret === 0 ? undefined : ConversionWarning.__wrap(ret);
40
+ }
41
+ /**
42
+ * @returns {number}
43
+ */
44
+ get warningCount() {
45
+ const ret = wasm.conversionresult_warningCount(this.__wbg_ptr);
46
+ return ret >>> 0;
47
+ }
48
+ }
49
+ if (Symbol.dispose) ConversionResult.prototype[Symbol.dispose] = ConversionResult.prototype.free;
50
+
51
+ /**
52
+ * Structured warning returned by the result-bearing WASM API.
53
+ */
54
+ export class ConversionWarning {
55
+ static __wrap(ptr) {
56
+ ptr = ptr >>> 0;
57
+ const obj = Object.create(ConversionWarning.prototype);
58
+ obj.__wbg_ptr = ptr;
59
+ ConversionWarningFinalization.register(obj, obj.__wbg_ptr, obj);
60
+ return obj;
61
+ }
62
+ __destroy_into_raw() {
63
+ const ptr = this.__wbg_ptr;
64
+ this.__wbg_ptr = 0;
65
+ ConversionWarningFinalization.unregister(this);
66
+ return ptr;
67
+ }
68
+ free() {
69
+ const ptr = this.__destroy_into_raw();
70
+ wasm.__wbg_conversionwarning_free(ptr, 0);
71
+ }
72
+ /**
73
+ * @returns {string | undefined}
74
+ */
75
+ get detail() {
76
+ const ret = wasm.conversionwarning_detail(this.__wbg_ptr);
77
+ let v1;
78
+ if (ret[0] !== 0) {
79
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
80
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
81
+ }
82
+ return v1;
83
+ }
84
+ /**
85
+ * @returns {string | undefined}
86
+ */
87
+ get element() {
88
+ const ret = wasm.conversionwarning_element(this.__wbg_ptr);
89
+ let v1;
90
+ if (ret[0] !== 0) {
91
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
92
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
93
+ }
94
+ return v1;
95
+ }
96
+ /**
97
+ * @returns {string}
98
+ */
99
+ get format() {
100
+ let deferred1_0;
101
+ let deferred1_1;
102
+ try {
103
+ const ret = wasm.conversionwarning_format(this.__wbg_ptr);
104
+ deferred1_0 = ret[0];
105
+ deferred1_1 = ret[1];
106
+ return getStringFromWasm0(ret[0], ret[1]);
107
+ } finally {
108
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
109
+ }
110
+ }
111
+ /**
112
+ * @returns {string | undefined}
113
+ */
114
+ get from() {
115
+ const ret = wasm.conversionwarning_from(this.__wbg_ptr);
116
+ let v1;
117
+ if (ret[0] !== 0) {
118
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
119
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
120
+ }
121
+ return v1;
122
+ }
123
+ /**
124
+ * @returns {string}
125
+ */
126
+ get kind() {
127
+ let deferred1_0;
128
+ let deferred1_1;
129
+ try {
130
+ const ret = wasm.conversionwarning_kind(this.__wbg_ptr);
131
+ deferred1_0 = ret[0];
132
+ deferred1_1 = ret[1];
133
+ return getStringFromWasm0(ret[0], ret[1]);
134
+ } finally {
135
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
136
+ }
137
+ }
138
+ /**
139
+ * @returns {string}
140
+ */
141
+ get message() {
142
+ let deferred1_0;
143
+ let deferred1_1;
144
+ try {
145
+ const ret = wasm.conversionwarning_message(this.__wbg_ptr);
146
+ deferred1_0 = ret[0];
147
+ deferred1_1 = ret[1];
148
+ return getStringFromWasm0(ret[0], ret[1]);
149
+ } finally {
150
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
151
+ }
152
+ }
153
+ /**
154
+ * @returns {string | undefined}
155
+ */
156
+ get reason() {
157
+ const ret = wasm.conversionwarning_reason(this.__wbg_ptr);
158
+ let v1;
159
+ if (ret[0] !== 0) {
160
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
161
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
162
+ }
163
+ return v1;
164
+ }
165
+ /**
166
+ * @returns {string | undefined}
167
+ */
168
+ get to() {
169
+ const ret = wasm.conversionwarning_to(this.__wbg_ptr);
170
+ let v1;
171
+ if (ret[0] !== 0) {
172
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
173
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
174
+ }
175
+ return v1;
176
+ }
177
+ }
178
+ if (Symbol.dispose) ConversionWarning.prototype[Symbol.dispose] = ConversionWarning.prototype.free;
179
+
180
+ /**
181
+ * Per-instance WASM converter with caller-provided in-memory fonts.
182
+ */
183
+ export class Office2PdfConverter {
184
+ __destroy_into_raw() {
185
+ const ptr = this.__wbg_ptr;
186
+ this.__wbg_ptr = 0;
187
+ Office2PdfConverterFinalization.unregister(this);
188
+ return ptr;
189
+ }
190
+ free() {
191
+ const ptr = this.__destroy_into_raw();
192
+ wasm.__wbg_office2pdfconverter_free(ptr, 0);
193
+ }
194
+ /**
195
+ * Remove all caller-registered font buffers from this converter.
196
+ */
197
+ clearFonts() {
198
+ wasm.office2pdfconverter_clearFonts(this.__wbg_ptr);
199
+ }
200
+ /**
201
+ * Remove the configured last-resort family.
202
+ */
203
+ clearLastResortFontFamily() {
204
+ wasm.office2pdfconverter_clearLastResortFontFamily(this.__wbg_ptr);
205
+ }
206
+ /**
207
+ * @param {Uint8Array} data
208
+ * @returns {ConversionResult}
209
+ */
210
+ convertDocxToPdf(data) {
211
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
212
+ const len0 = WASM_VECTOR_LEN;
213
+ const ret = wasm.office2pdfconverter_convertDocxToPdf(this.__wbg_ptr, ptr0, len0);
214
+ if (ret[2]) {
215
+ throw takeFromExternrefTable0(ret[1]);
216
+ }
217
+ return ConversionResult.__wrap(ret[0]);
218
+ }
219
+ /**
220
+ * @param {Uint8Array} data
221
+ * @returns {ConversionResult}
222
+ */
223
+ convertPptxToPdf(data) {
224
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ const ret = wasm.office2pdfconverter_convertPptxToPdf(this.__wbg_ptr, ptr0, len0);
227
+ if (ret[2]) {
228
+ throw takeFromExternrefTable0(ret[1]);
229
+ }
230
+ return ConversionResult.__wrap(ret[0]);
231
+ }
232
+ /**
233
+ * @param {Uint8Array} data
234
+ * @param {string} format
235
+ * @returns {ConversionResult}
236
+ */
237
+ convertToPdf(data, format) {
238
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
239
+ const len0 = WASM_VECTOR_LEN;
240
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
241
+ const len1 = WASM_VECTOR_LEN;
242
+ const ret = wasm.office2pdfconverter_convertToPdf(this.__wbg_ptr, ptr0, len0, ptr1, len1);
243
+ if (ret[2]) {
244
+ throw takeFromExternrefTable0(ret[1]);
245
+ }
246
+ return ConversionResult.__wrap(ret[0]);
247
+ }
248
+ /**
249
+ * @param {Uint8Array} data
250
+ * @returns {ConversionResult}
251
+ */
252
+ convertXlsxToPdf(data) {
253
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
254
+ const len0 = WASM_VECTOR_LEN;
255
+ const ret = wasm.office2pdfconverter_convertXlsxToPdf(this.__wbg_ptr, ptr0, len0);
256
+ if (ret[2]) {
257
+ throw takeFromExternrefTable0(ret[1]);
258
+ }
259
+ return ConversionResult.__wrap(ret[0]);
260
+ }
261
+ constructor() {
262
+ const ret = wasm.office2pdfconverter_new();
263
+ this.__wbg_ptr = ret >>> 0;
264
+ Office2PdfConverterFinalization.register(this, this.__wbg_ptr, this);
265
+ return this;
266
+ }
267
+ /**
268
+ * Register a standalone font or font collection for later conversions.
269
+ * @param {Uint8Array} data
270
+ */
271
+ registerFont(data) {
272
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ const ret = wasm.office2pdfconverter_registerFont(this.__wbg_ptr, ptr0, len0);
275
+ if (ret[1]) {
276
+ throw takeFromExternrefTable0(ret[0]);
277
+ }
278
+ }
279
+ /**
280
+ * Set the family appended to every generated font chain.
281
+ * @param {string} family
282
+ */
283
+ setLastResortFontFamily(family) {
284
+ const ptr0 = passStringToWasm0(family, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
285
+ const len0 = WASM_VECTOR_LEN;
286
+ const ret = wasm.office2pdfconverter_setLastResortFontFamily(this.__wbg_ptr, ptr0, len0);
287
+ if (ret[1]) {
288
+ throw takeFromExternrefTable0(ret[0]);
289
+ }
290
+ }
291
+ }
292
+ if (Symbol.dispose)
293
+ Office2PdfConverter.prototype[Symbol.dispose] = Office2PdfConverter.prototype.free;
294
+
295
+ /**
296
+ * Convert a DOCX document to PDF.
297
+ *
298
+ * `data` is the raw bytes of a `.docx` file.
299
+ *
300
+ * Returns the PDF bytes on success, or throws a JS error string on failure.
301
+ * @param {Uint8Array} data
302
+ * @returns {Uint8Array}
303
+ */
304
+ export function convertDocxToPdf(data) {
305
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
306
+ const len0 = WASM_VECTOR_LEN;
307
+ const ret = wasm.convertDocxToPdf(ptr0, len0);
308
+ if (ret[3]) {
309
+ throw takeFromExternrefTable0(ret[2]);
310
+ }
311
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
312
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
313
+ return v2;
314
+ }
315
+
316
+ /**
317
+ * Convert a DOCX with default options and return PDF bytes plus warnings.
318
+ * @param {Uint8Array} data
319
+ * @returns {ConversionResult}
320
+ */
321
+ export function convertDocxToPdfWithResult(data) {
322
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
323
+ const len0 = WASM_VECTOR_LEN;
324
+ const ret = wasm.convertDocxToPdfWithResult(ptr0, len0);
325
+ if (ret[2]) {
326
+ throw takeFromExternrefTable0(ret[1]);
327
+ }
328
+ return ConversionResult.__wrap(ret[0]);
329
+ }
330
+
331
+ /**
332
+ * Convert a PPTX document to PDF.
333
+ *
334
+ * `data` is the raw bytes of a `.pptx` file.
335
+ *
336
+ * Returns the PDF bytes on success, or throws a JS error string on failure.
337
+ * @param {Uint8Array} data
338
+ * @returns {Uint8Array}
339
+ */
340
+ export function convertPptxToPdf(data) {
341
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
342
+ const len0 = WASM_VECTOR_LEN;
343
+ const ret = wasm.convertPptxToPdf(ptr0, len0);
344
+ if (ret[3]) {
345
+ throw takeFromExternrefTable0(ret[2]);
346
+ }
347
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
348
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
349
+ return v2;
350
+ }
351
+
352
+ /**
353
+ * Convert a PPTX with default options and return PDF bytes plus warnings.
354
+ * @param {Uint8Array} data
355
+ * @returns {ConversionResult}
356
+ */
357
+ export function convertPptxToPdfWithResult(data) {
358
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.convertPptxToPdfWithResult(ptr0, len0);
361
+ if (ret[2]) {
362
+ throw takeFromExternrefTable0(ret[1]);
363
+ }
364
+ return ConversionResult.__wrap(ret[0]);
365
+ }
366
+
367
+ /**
368
+ * Convert an Office document to PDF.
369
+ *
370
+ * `data` is the raw bytes of the input document (DOCX, PPTX, or XLSX).
371
+ * `format` is one of `"docx"`, `"pptx"`, or `"xlsx"` (case-insensitive).
372
+ *
373
+ * Returns the PDF bytes on success, or throws a JS error string on failure.
374
+ * @param {Uint8Array} data
375
+ * @param {string} format
376
+ * @returns {Uint8Array}
377
+ */
378
+ export function convertToPdf(data, format) {
379
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
380
+ const len0 = WASM_VECTOR_LEN;
381
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
382
+ const len1 = WASM_VECTOR_LEN;
383
+ const ret = wasm.convertToPdf(ptr0, len0, ptr1, len1);
384
+ if (ret[3]) {
385
+ throw takeFromExternrefTable0(ret[2]);
386
+ }
387
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
388
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
389
+ return v3;
390
+ }
391
+
392
+ /**
393
+ * Convert a document with default options and return PDF bytes plus warnings.
394
+ * @param {Uint8Array} data
395
+ * @param {string} format
396
+ * @returns {ConversionResult}
397
+ */
398
+ export function convertToPdfWithResult(data, format) {
399
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
400
+ const len0 = WASM_VECTOR_LEN;
401
+ const ptr1 = passStringToWasm0(format, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
402
+ const len1 = WASM_VECTOR_LEN;
403
+ const ret = wasm.convertToPdfWithResult(ptr0, len0, ptr1, len1);
404
+ if (ret[2]) {
405
+ throw takeFromExternrefTable0(ret[1]);
406
+ }
407
+ return ConversionResult.__wrap(ret[0]);
408
+ }
409
+
410
+ /**
411
+ * Convert an XLSX document to PDF.
412
+ *
413
+ * `data` is the raw bytes of a `.xlsx` file.
414
+ *
415
+ * Returns the PDF bytes on success, or throws a JS error string on failure.
416
+ * @param {Uint8Array} data
417
+ * @returns {Uint8Array}
418
+ */
419
+ export function convertXlsxToPdf(data) {
420
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
421
+ const len0 = WASM_VECTOR_LEN;
422
+ const ret = wasm.convertXlsxToPdf(ptr0, len0);
423
+ if (ret[3]) {
424
+ throw takeFromExternrefTable0(ret[2]);
425
+ }
426
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
427
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
428
+ return v2;
429
+ }
430
+
431
+ /**
432
+ * Convert an XLSX with default options and return PDF bytes plus warnings.
433
+ * @param {Uint8Array} data
434
+ * @returns {ConversionResult}
435
+ */
436
+ export function convertXlsxToPdfWithResult(data) {
437
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
438
+ const len0 = WASM_VECTOR_LEN;
439
+ const ret = wasm.convertXlsxToPdfWithResult(ptr0, len0);
440
+ if (ret[2]) {
441
+ throw takeFromExternrefTable0(ret[1]);
442
+ }
443
+ return ConversionResult.__wrap(ret[0]);
444
+ }
445
+
446
+ function __wbg_get_imports() {
447
+ const import0 = {
448
+ __proto__: null,
449
+ __wbg___wbindgen_is_undefined_87a3a837f331fef5: function (arg0) {
450
+ const ret = arg0 === undefined;
451
+ return ret;
452
+ },
453
+ __wbg___wbindgen_throw_5549492daedad139: function (arg0, arg1) {
454
+ throw new Error(getStringFromWasm0(arg0, arg1));
455
+ },
456
+ __wbg_getRandomValues_3f44b700395062e5: function () {
457
+ return handleError(function (arg0, arg1) {
458
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
459
+ }, arguments);
460
+ },
461
+ __wbg_now_46736a527d2e74e7: function () {
462
+ const ret = Date.now();
463
+ return ret;
464
+ },
465
+ __wbg_now_e7c6795a7f81e10f: function (arg0) {
466
+ const ret = arg0.now();
467
+ return ret;
468
+ },
469
+ __wbg_performance_3fcf6e32a7e1ed0a: function (arg0) {
470
+ const ret = arg0.performance;
471
+ return ret;
472
+ },
473
+ __wbg_static_accessor_GLOBAL_8dfb7f5e26ebe523: function () {
474
+ const ret = typeof global === "undefined" ? null : global;
475
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
476
+ },
477
+ __wbg_static_accessor_GLOBAL_THIS_941154efc8395cdd: function () {
478
+ const ret = typeof globalThis === "undefined" ? null : globalThis;
479
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
480
+ },
481
+ __wbg_static_accessor_SELF_58dac9af822f561f: function () {
482
+ const ret = typeof self === "undefined" ? null : self;
483
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
484
+ },
485
+ __wbg_static_accessor_WINDOW_ee64f0b3d8354c0b: function () {
486
+ const ret = typeof window === "undefined" ? null : window;
487
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
488
+ },
489
+ __wbindgen_cast_0000000000000001: function (arg0, arg1) {
490
+ // Cast intrinsic for `Ref(String) -> Externref`.
491
+ const ret = getStringFromWasm0(arg0, arg1);
492
+ return ret;
493
+ },
494
+ __wbindgen_init_externref_table: function () {
495
+ const table = wasm.__wbindgen_externrefs;
496
+ const offset = table.grow(4);
497
+ table.set(0, undefined);
498
+ table.set(offset + 0, undefined);
499
+ table.set(offset + 1, null);
500
+ table.set(offset + 2, true);
501
+ table.set(offset + 3, false);
502
+ },
503
+ };
504
+ return {
505
+ __proto__: null,
506
+ "./office2pdf_bg.js": import0,
507
+ };
508
+ }
509
+
510
+ const ConversionResultFinalization =
511
+ typeof FinalizationRegistry === "undefined"
512
+ ? { register: () => {}, unregister: () => {} }
513
+ : new FinalizationRegistry((ptr) => wasm.__wbg_conversionresult_free(ptr >>> 0, 1));
514
+ const ConversionWarningFinalization =
515
+ typeof FinalizationRegistry === "undefined"
516
+ ? { register: () => {}, unregister: () => {} }
517
+ : new FinalizationRegistry((ptr) => wasm.__wbg_conversionwarning_free(ptr >>> 0, 1));
518
+ const Office2PdfConverterFinalization =
519
+ typeof FinalizationRegistry === "undefined"
520
+ ? { register: () => {}, unregister: () => {} }
521
+ : new FinalizationRegistry((ptr) => wasm.__wbg_office2pdfconverter_free(ptr >>> 0, 1));
522
+
523
+ function addToExternrefTable0(obj) {
524
+ const idx = wasm.__externref_table_alloc();
525
+ wasm.__wbindgen_externrefs.set(idx, obj);
526
+ return idx;
527
+ }
528
+
529
+ function getArrayU8FromWasm0(ptr, len) {
530
+ ptr = ptr >>> 0;
531
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
532
+ }
533
+
534
+ function getStringFromWasm0(ptr, len) {
535
+ ptr = ptr >>> 0;
536
+ return decodeText(ptr, len);
537
+ }
538
+
539
+ let cachedUint8ArrayMemory0 = null;
540
+ function getUint8ArrayMemory0() {
541
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
542
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
543
+ }
544
+ return cachedUint8ArrayMemory0;
545
+ }
546
+
547
+ function handleError(f, args) {
548
+ try {
549
+ return f.apply(this, args);
550
+ } catch (e) {
551
+ const idx = addToExternrefTable0(e);
552
+ wasm.__wbindgen_exn_store(idx);
553
+ }
554
+ }
555
+
556
+ function isLikeNone(x) {
557
+ return x === undefined || x === null;
558
+ }
559
+
560
+ function passArray8ToWasm0(arg, malloc) {
561
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
562
+ getUint8ArrayMemory0().set(arg, ptr / 1);
563
+ WASM_VECTOR_LEN = arg.length;
564
+ return ptr;
565
+ }
566
+
567
+ function passStringToWasm0(arg, malloc, realloc) {
568
+ if (realloc === undefined) {
569
+ const buf = cachedTextEncoder.encode(arg);
570
+ const ptr = malloc(buf.length, 1) >>> 0;
571
+ getUint8ArrayMemory0()
572
+ .subarray(ptr, ptr + buf.length)
573
+ .set(buf);
574
+ WASM_VECTOR_LEN = buf.length;
575
+ return ptr;
576
+ }
577
+
578
+ let len = arg.length;
579
+ let ptr = malloc(len, 1) >>> 0;
580
+
581
+ const mem = getUint8ArrayMemory0();
582
+
583
+ let offset = 0;
584
+
585
+ for (; offset < len; offset++) {
586
+ const code = arg.charCodeAt(offset);
587
+ if (code > 0x7f) break;
588
+ mem[ptr + offset] = code;
589
+ }
590
+ if (offset !== len) {
591
+ if (offset !== 0) {
592
+ arg = arg.slice(offset);
593
+ }
594
+ ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
595
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
596
+ const ret = cachedTextEncoder.encodeInto(arg, view);
597
+
598
+ offset += ret.written;
599
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
600
+ }
601
+
602
+ WASM_VECTOR_LEN = offset;
603
+ return ptr;
604
+ }
605
+
606
+ function takeFromExternrefTable0(idx) {
607
+ const value = wasm.__wbindgen_externrefs.get(idx);
608
+ wasm.__externref_table_dealloc(idx);
609
+ return value;
610
+ }
611
+
612
+ let cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
613
+ cachedTextDecoder.decode();
614
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
615
+ let numBytesDecoded = 0;
616
+ function decodeText(ptr, len) {
617
+ numBytesDecoded += len;
618
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
619
+ cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
620
+ cachedTextDecoder.decode();
621
+ numBytesDecoded = len;
622
+ }
623
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
624
+ }
625
+
626
+ const cachedTextEncoder = new TextEncoder();
627
+
628
+ if (!("encodeInto" in cachedTextEncoder)) {
629
+ cachedTextEncoder.encodeInto = function (arg, view) {
630
+ const buf = cachedTextEncoder.encode(arg);
631
+ view.set(buf);
632
+ return {
633
+ read: arg.length,
634
+ written: buf.length,
635
+ };
636
+ };
637
+ }
638
+
639
+ let WASM_VECTOR_LEN = 0;
640
+
641
+ let wasmModule, wasm;
642
+ function __wbg_finalize_init(instance, module) {
643
+ wasm = instance.exports;
644
+ wasmModule = module;
645
+ cachedUint8ArrayMemory0 = null;
646
+ wasm.__wbindgen_start();
647
+ return wasm;
648
+ }
649
+
650
+ async function __wbg_load(module, imports) {
651
+ if (typeof Response === "function" && module instanceof Response) {
652
+ if (typeof WebAssembly.instantiateStreaming === "function") {
653
+ try {
654
+ return await WebAssembly.instantiateStreaming(module, imports);
655
+ } catch (e) {
656
+ const validResponse = module.ok && expectedResponseType(module.type);
657
+
658
+ if (validResponse && module.headers.get("Content-Type") !== "application/wasm") {
659
+ console.warn(
660
+ "`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",
661
+ e,
662
+ );
663
+ } else {
664
+ throw e;
665
+ }
666
+ }
667
+ }
668
+
669
+ const bytes = await module.arrayBuffer();
670
+ return await WebAssembly.instantiate(bytes, imports);
671
+ } else {
672
+ const instance = await WebAssembly.instantiate(module, imports);
673
+
674
+ if (instance instanceof WebAssembly.Instance) {
675
+ return { instance, module };
676
+ } else {
677
+ return instance;
678
+ }
679
+ }
680
+
681
+ function expectedResponseType(type) {
682
+ switch (type) {
683
+ case "basic":
684
+ case "cors":
685
+ case "default":
686
+ return true;
687
+ }
688
+ return false;
689
+ }
690
+ }
691
+
692
+ function initSync(module) {
693
+ if (wasm !== undefined) return wasm;
694
+
695
+ if (module !== undefined) {
696
+ if (Object.getPrototypeOf(module) === Object.prototype) {
697
+ ({ module } = module);
698
+ } else {
699
+ console.warn("using deprecated parameters for `initSync()`; pass a single object instead");
700
+ }
701
+ }
702
+
703
+ const imports = __wbg_get_imports();
704
+ if (!(module instanceof WebAssembly.Module)) {
705
+ module = new WebAssembly.Module(module);
706
+ }
707
+ const instance = new WebAssembly.Instance(module, imports);
708
+ return __wbg_finalize_init(instance, module);
709
+ }
710
+
711
+ async function __wbg_init(module_or_path) {
712
+ if (wasm !== undefined) return wasm;
713
+
714
+ if (module_or_path !== undefined) {
715
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
716
+ ({ module_or_path } = module_or_path);
717
+ } else {
718
+ console.warn(
719
+ "using deprecated parameters for the initialization function; pass a single object instead",
720
+ );
721
+ }
722
+ }
723
+
724
+ if (module_or_path === undefined) {
725
+ module_or_path = new URL("office2pdf_bg.wasm", import.meta.url);
726
+ }
727
+ const imports = __wbg_get_imports();
728
+
729
+ if (
730
+ typeof module_or_path === "string" ||
731
+ (typeof Request === "function" && module_or_path instanceof Request) ||
732
+ (typeof URL === "function" && module_or_path instanceof URL)
733
+ ) {
734
+ module_or_path = fetch(module_or_path);
735
+ }
736
+
737
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
738
+
739
+ return __wbg_finalize_init(instance, module);
740
+ }
741
+
742
+ export { initSync, __wbg_init as default };
Binary file
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "officetopdf-wasm",
3
+ "version": "0.0.1",
4
+ "description": "office2pdf v0.6.8 compiled to WebAssembly.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Nilesh9106/officetopdf.git"
10
+ },
11
+ "main": "./office2pdf.js",
12
+ "module": "./office2pdf.js",
13
+ "exports": {
14
+ ".": "./office2pdf.js",
15
+ "./office2pdf_bg.wasm": "./office2pdf_bg.wasm",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "sideEffects": [
19
+ "./office2pdf.js"
20
+ ],
21
+ "files": [
22
+ "office2pdf.js",
23
+ "office2pdf_bg.wasm"
24
+ ]
25
+ }