@docmux/wasm 0.3.0 → 0.4.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/bundler/docmux_wasm.d.ts +15 -0
- package/bundler/docmux_wasm.js +1 -1
- package/bundler/docmux_wasm_bg.js +165 -0
- package/bundler/docmux_wasm_bg.wasm +0 -0
- package/bundler/docmux_wasm_bg.wasm.d.ts +5 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/node/docmux_wasm.d.ts +15 -0
- package/node/docmux_wasm.js +169 -1
- package/node/docmux_wasm_bg.wasm +0 -0
- package/node/docmux_wasm_bg.wasm.d.ts +5 -1
- package/package.json +6 -1
- package/web/docmux_wasm.d.ts +117 -0
- package/web/docmux_wasm.js +708 -0
- package/web/docmux_wasm_bg.wasm +0 -0
- package/web/docmux_wasm_bg.wasm.d.ts +20 -0
package/bundler/docmux_wasm.d.ts
CHANGED
|
@@ -26,11 +26,26 @@ export function convertBytes(input: Uint8Array, from: string, to: string): strin
|
|
|
26
26
|
*/
|
|
27
27
|
export function convertBytesStandalone(input: Uint8Array, from: string, to: string): string;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Convert binary input to binary output (e.g. DOCX → DOCX), with additional resources.
|
|
31
|
+
*/
|
|
32
|
+
export function convertBytesToBytes(input: Uint8Array, from: string, to: string, resources: Map<any, any>): Uint8Array;
|
|
33
|
+
|
|
29
34
|
/**
|
|
30
35
|
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
31
36
|
*/
|
|
32
37
|
export function convertStandalone(input: string, from: string, to: string): string;
|
|
33
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Convert text input to binary output (e.g. markdown → DOCX), with image resources.
|
|
41
|
+
*/
|
|
42
|
+
export function convertToBytes(input: string, from: string, to: string, resources: Map<any, any>): Uint8Array;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Convert text input to string output, with image resources for embedding.
|
|
46
|
+
*/
|
|
47
|
+
export function convertWithResources(input: string, from: string, to: string, resources: Map<any, any>): string;
|
|
48
|
+
|
|
34
49
|
/**
|
|
35
50
|
* Return a list of supported input format names.
|
|
36
51
|
*/
|
package/bundler/docmux_wasm.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./docmux_wasm_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
|
|
7
7
|
export {
|
|
8
|
-
convert, convertBytes, convertBytesStandalone, convertStandalone, inputFormats, markdownToHtml, outputFormats, parseBytesToJson, parseToJson
|
|
8
|
+
convert, convertBytes, convertBytesStandalone, convertBytesToBytes, convertStandalone, convertToBytes, convertWithResources, inputFormats, markdownToHtml, outputFormats, parseBytesToJson, parseToJson
|
|
9
9
|
} from "./docmux_wasm_bg.js";
|
|
@@ -122,6 +122,37 @@ export function convertBytesStandalone(input, from, to) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Convert binary input to binary output (e.g. DOCX → DOCX), with additional resources.
|
|
127
|
+
* @param {Uint8Array} input
|
|
128
|
+
* @param {string} from
|
|
129
|
+
* @param {string} to
|
|
130
|
+
* @param {Map<any, any>} resources
|
|
131
|
+
* @returns {Uint8Array}
|
|
132
|
+
*/
|
|
133
|
+
export function convertBytesToBytes(input, from, to, resources) {
|
|
134
|
+
try {
|
|
135
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
136
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
137
|
+
const len0 = WASM_VECTOR_LEN;
|
|
138
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
139
|
+
const len1 = WASM_VECTOR_LEN;
|
|
140
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
141
|
+
const len2 = WASM_VECTOR_LEN;
|
|
142
|
+
wasm.convertBytesToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
143
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
144
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
145
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
146
|
+
if (r2) {
|
|
147
|
+
throw takeObject(r1);
|
|
148
|
+
}
|
|
149
|
+
return takeObject(r0);
|
|
150
|
+
} finally {
|
|
151
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
152
|
+
heap[stack_pointer++] = undefined;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
125
156
|
/**
|
|
126
157
|
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
127
158
|
* @param {string} input
|
|
@@ -160,6 +191,77 @@ export function convertStandalone(input, from, to) {
|
|
|
160
191
|
}
|
|
161
192
|
}
|
|
162
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Convert text input to binary output (e.g. markdown → DOCX), with image resources.
|
|
196
|
+
* @param {string} input
|
|
197
|
+
* @param {string} from
|
|
198
|
+
* @param {string} to
|
|
199
|
+
* @param {Map<any, any>} resources
|
|
200
|
+
* @returns {Uint8Array}
|
|
201
|
+
*/
|
|
202
|
+
export function convertToBytes(input, from, to, resources) {
|
|
203
|
+
try {
|
|
204
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
205
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
206
|
+
const len0 = WASM_VECTOR_LEN;
|
|
207
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
208
|
+
const len1 = WASM_VECTOR_LEN;
|
|
209
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
210
|
+
const len2 = WASM_VECTOR_LEN;
|
|
211
|
+
wasm.convertToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
212
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
213
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
214
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
215
|
+
if (r2) {
|
|
216
|
+
throw takeObject(r1);
|
|
217
|
+
}
|
|
218
|
+
return takeObject(r0);
|
|
219
|
+
} finally {
|
|
220
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
221
|
+
heap[stack_pointer++] = undefined;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Convert text input to string output, with image resources for embedding.
|
|
227
|
+
* @param {string} input
|
|
228
|
+
* @param {string} from
|
|
229
|
+
* @param {string} to
|
|
230
|
+
* @param {Map<any, any>} resources
|
|
231
|
+
* @returns {string}
|
|
232
|
+
*/
|
|
233
|
+
export function convertWithResources(input, from, to, resources) {
|
|
234
|
+
let deferred5_0;
|
|
235
|
+
let deferred5_1;
|
|
236
|
+
try {
|
|
237
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
238
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
239
|
+
const len0 = WASM_VECTOR_LEN;
|
|
240
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
241
|
+
const len1 = WASM_VECTOR_LEN;
|
|
242
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
243
|
+
const len2 = WASM_VECTOR_LEN;
|
|
244
|
+
wasm.convertWithResources(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
245
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
246
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
247
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
248
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
249
|
+
var ptr4 = r0;
|
|
250
|
+
var len4 = r1;
|
|
251
|
+
if (r3) {
|
|
252
|
+
ptr4 = 0; len4 = 0;
|
|
253
|
+
throw takeObject(r2);
|
|
254
|
+
}
|
|
255
|
+
deferred5_0 = ptr4;
|
|
256
|
+
deferred5_1 = len4;
|
|
257
|
+
return getStringFromWasm0(ptr4, len4);
|
|
258
|
+
} finally {
|
|
259
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
260
|
+
heap[stack_pointer++] = undefined;
|
|
261
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
163
265
|
/**
|
|
164
266
|
* Return a list of supported input format names.
|
|
165
267
|
* @returns {string[]}
|
|
@@ -301,11 +403,57 @@ export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
|
301
403
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
302
404
|
return addHeapObject(ret);
|
|
303
405
|
}
|
|
406
|
+
export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
|
|
407
|
+
const obj = getObject(arg1);
|
|
408
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
409
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
410
|
+
var len1 = WASM_VECTOR_LEN;
|
|
411
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
412
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
413
|
+
}
|
|
414
|
+
export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
|
|
415
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
416
|
+
}
|
|
417
|
+
export function __wbg_forEach_5bdeef2ab2f0b065(arg0, arg1, arg2) {
|
|
418
|
+
try {
|
|
419
|
+
var state0 = {a: arg1, b: arg2};
|
|
420
|
+
var cb0 = (arg0, arg1) => {
|
|
421
|
+
const a = state0.a;
|
|
422
|
+
state0.a = 0;
|
|
423
|
+
try {
|
|
424
|
+
return __wasm_bindgen_func_elem_332(a, state0.b, arg0, arg1);
|
|
425
|
+
} finally {
|
|
426
|
+
state0.a = a;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
getObject(arg0).forEach(cb0);
|
|
430
|
+
} finally {
|
|
431
|
+
state0.a = 0;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
export function __wbg_length_9f1775224cf1d815(arg0) {
|
|
435
|
+
const ret = getObject(arg0).length;
|
|
436
|
+
return ret;
|
|
437
|
+
}
|
|
438
|
+
export function __wbg_new_from_slice_b5ea43e23f6008c0(arg0, arg1) {
|
|
439
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
440
|
+
return addHeapObject(ret);
|
|
441
|
+
}
|
|
442
|
+
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
443
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
444
|
+
}
|
|
304
445
|
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
305
446
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
306
447
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
307
448
|
return addHeapObject(ret);
|
|
308
449
|
}
|
|
450
|
+
export function __wbindgen_object_drop_ref(arg0) {
|
|
451
|
+
takeObject(arg0);
|
|
452
|
+
}
|
|
453
|
+
function __wasm_bindgen_func_elem_332(arg0, arg1, arg2, arg3) {
|
|
454
|
+
wasm.__wasm_bindgen_func_elem_332(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
455
|
+
}
|
|
456
|
+
|
|
309
457
|
function addHeapObject(obj) {
|
|
310
458
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
311
459
|
const idx = heap_next;
|
|
@@ -315,6 +463,12 @@ function addHeapObject(obj) {
|
|
|
315
463
|
return idx;
|
|
316
464
|
}
|
|
317
465
|
|
|
466
|
+
function addBorrowedObject(obj) {
|
|
467
|
+
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
468
|
+
heap[--stack_pointer] = obj;
|
|
469
|
+
return stack_pointer;
|
|
470
|
+
}
|
|
471
|
+
|
|
318
472
|
function dropObject(idx) {
|
|
319
473
|
if (idx < 1028) return;
|
|
320
474
|
heap[idx] = heap_next;
|
|
@@ -331,6 +485,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
331
485
|
return result;
|
|
332
486
|
}
|
|
333
487
|
|
|
488
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
489
|
+
ptr = ptr >>> 0;
|
|
490
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
491
|
+
}
|
|
492
|
+
|
|
334
493
|
let cachedDataViewMemory0 = null;
|
|
335
494
|
function getDataViewMemory0() {
|
|
336
495
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -359,6 +518,10 @@ heap.push(undefined, null, true, false);
|
|
|
359
518
|
|
|
360
519
|
let heap_next = heap.length;
|
|
361
520
|
|
|
521
|
+
function isLikeNone(x) {
|
|
522
|
+
return x === undefined || x === null;
|
|
523
|
+
}
|
|
524
|
+
|
|
362
525
|
function passArray8ToWasm0(arg, malloc) {
|
|
363
526
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
364
527
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -403,6 +566,8 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
403
566
|
return ptr;
|
|
404
567
|
}
|
|
405
568
|
|
|
569
|
+
let stack_pointer = 1024;
|
|
570
|
+
|
|
406
571
|
function takeObject(idx) {
|
|
407
572
|
const ret = getObject(idx);
|
|
408
573
|
dropObject(idx);
|
|
Binary file
|
|
@@ -4,13 +4,17 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
5
5
|
export const convertBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
6
6
|
export const convertBytesStandalone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
7
|
+
export const convertBytesToBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
7
8
|
export const convertStandalone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
9
|
+
export const convertToBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
10
|
+
export const convertWithResources: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
8
11
|
export const inputFormats: (a: number) => void;
|
|
9
12
|
export const markdownToHtml: (a: number, b: number, c: number) => void;
|
|
10
13
|
export const outputFormats: (a: number) => void;
|
|
11
14
|
export const parseBytesToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
15
|
export const parseToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
13
|
-
export const
|
|
16
|
+
export const __wasm_bindgen_func_elem_332: (a: number, b: number, c: number, d: number) => void;
|
|
14
17
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
18
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
19
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
16
20
|
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,9 @@ export declare function convertBytes(input: Uint8Array, from: string, to: string
|
|
|
14
14
|
export declare function convertBytesStandalone(input: Uint8Array, from: string, to: string): Promise<ConvertOutcome>;
|
|
15
15
|
export declare function parseBytesToJson(input: Uint8Array, from: string): Promise<ConvertOutcome>;
|
|
16
16
|
export declare function markdownToHtml(input: string): Promise<ConvertOutcome>;
|
|
17
|
+
export declare function convertWithResources(input: string, from: string, to: string, resources: Map<string, Uint8Array>): Promise<ConvertOutcome>;
|
|
18
|
+
export declare function convertToBytes(input: string, from: string, to: string, resources: Map<string, Uint8Array>): Promise<Uint8Array>;
|
|
19
|
+
export declare function convertBytesToBytes(input: Uint8Array, from: string, to: string, resources: Map<string, Uint8Array>): Promise<Uint8Array>;
|
|
17
20
|
export declare function getInputFormats(): Promise<string[]>;
|
|
18
21
|
export declare function getOutputFormats(): Promise<string[]>;
|
|
19
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,eAAe,CAAC;AAiBhE,wBAAgB,OAAO,CACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAErE;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GACjC,OAAO,CAAC,cAAc,CAAC,CAEzB;AAED,wBAAsB,cAAc,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GACjC,OAAO,CAAC,UAAU,CAAC,CAErB;AAED,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GACjC,OAAO,CAAC,UAAU,CAAC,CAErB;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAEzD;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAE1D"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { convert as wasmConvert, convertStandalone as wasmConvertStandalone, convertBytes as wasmConvertBytes, convertBytesStandalone as wasmConvertBytesStandalone, parseToJson as wasmParseToJson, parseBytesToJson as wasmParseBytesToJson, markdownToHtml as wasmMarkdownToHtml, inputFormats as wasmInputFormats, outputFormats as wasmOutputFormats, } from "../bundler/docmux_wasm.js";
|
|
1
|
+
import { convert as wasmConvert, convertStandalone as wasmConvertStandalone, convertBytes as wasmConvertBytes, convertBytesStandalone as wasmConvertBytesStandalone, convertWithResources as wasmConvertWithResources, convertToBytes as wasmConvertToBytes, convertBytesToBytes as wasmConvertBytesToBytes, parseToJson as wasmParseToJson, parseBytesToJson as wasmParseBytesToJson, markdownToHtml as wasmMarkdownToHtml, inputFormats as wasmInputFormats, outputFormats as wasmOutputFormats, } from "../bundler/docmux_wasm.js";
|
|
2
2
|
// ── Internal helper ────────────────────────────────────────────────────
|
|
3
3
|
async function callWasm(fn, ...args) {
|
|
4
4
|
try {
|
|
@@ -30,6 +30,15 @@ export function parseBytesToJson(input, from) {
|
|
|
30
30
|
export function markdownToHtml(input) {
|
|
31
31
|
return callWasm(wasmMarkdownToHtml, input);
|
|
32
32
|
}
|
|
33
|
+
export function convertWithResources(input, from, to, resources) {
|
|
34
|
+
return callWasm(wasmConvertWithResources, input, from, to, resources);
|
|
35
|
+
}
|
|
36
|
+
export async function convertToBytes(input, from, to, resources) {
|
|
37
|
+
return wasmConvertToBytes(input, from, to, resources);
|
|
38
|
+
}
|
|
39
|
+
export async function convertBytesToBytes(input, from, to, resources) {
|
|
40
|
+
return wasmConvertBytesToBytes(input, from, to, resources);
|
|
41
|
+
}
|
|
33
42
|
export async function getInputFormats() {
|
|
34
43
|
return wasmInputFormats();
|
|
35
44
|
}
|
package/node/docmux_wasm.d.ts
CHANGED
|
@@ -26,11 +26,26 @@ export function convertBytes(input: Uint8Array, from: string, to: string): strin
|
|
|
26
26
|
*/
|
|
27
27
|
export function convertBytesStandalone(input: Uint8Array, from: string, to: string): string;
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Convert binary input to binary output (e.g. DOCX → DOCX), with additional resources.
|
|
31
|
+
*/
|
|
32
|
+
export function convertBytesToBytes(input: Uint8Array, from: string, to: string, resources: Map<any, any>): Uint8Array;
|
|
33
|
+
|
|
29
34
|
/**
|
|
30
35
|
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
31
36
|
*/
|
|
32
37
|
export function convertStandalone(input: string, from: string, to: string): string;
|
|
33
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Convert text input to binary output (e.g. markdown → DOCX), with image resources.
|
|
41
|
+
*/
|
|
42
|
+
export function convertToBytes(input: string, from: string, to: string, resources: Map<any, any>): Uint8Array;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Convert text input to string output, with image resources for embedding.
|
|
46
|
+
*/
|
|
47
|
+
export function convertWithResources(input: string, from: string, to: string, resources: Map<any, any>): string;
|
|
48
|
+
|
|
34
49
|
/**
|
|
35
50
|
* Return a list of supported input format names.
|
|
36
51
|
*/
|
package/node/docmux_wasm.js
CHANGED
|
@@ -129,6 +129,38 @@ function convertBytesStandalone(input, from, to) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Convert binary input to binary output (e.g. DOCX → DOCX), with additional resources.
|
|
134
|
+
* @param {Uint8Array} input
|
|
135
|
+
* @param {string} from
|
|
136
|
+
* @param {string} to
|
|
137
|
+
* @param {Map<any, any>} resources
|
|
138
|
+
* @returns {Uint8Array}
|
|
139
|
+
*/
|
|
140
|
+
function convertBytesToBytes(input, from, to, resources) {
|
|
141
|
+
try {
|
|
142
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
143
|
+
const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
148
|
+
const len2 = WASM_VECTOR_LEN;
|
|
149
|
+
wasm.convertBytesToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
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 takeObject(r1);
|
|
155
|
+
}
|
|
156
|
+
return takeObject(r0);
|
|
157
|
+
} finally {
|
|
158
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
159
|
+
heap[stack_pointer++] = undefined;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
|
|
132
164
|
/**
|
|
133
165
|
* Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
|
|
134
166
|
* @param {string} input
|
|
@@ -168,6 +200,79 @@ function convertStandalone(input, from, to) {
|
|
|
168
200
|
}
|
|
169
201
|
|
|
170
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Convert text input to binary output (e.g. markdown → DOCX), with image resources.
|
|
205
|
+
* @param {string} input
|
|
206
|
+
* @param {string} from
|
|
207
|
+
* @param {string} to
|
|
208
|
+
* @param {Map<any, any>} resources
|
|
209
|
+
* @returns {Uint8Array}
|
|
210
|
+
*/
|
|
211
|
+
function convertToBytes(input, from, to, resources) {
|
|
212
|
+
try {
|
|
213
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
214
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
215
|
+
const len0 = WASM_VECTOR_LEN;
|
|
216
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
217
|
+
const len1 = WASM_VECTOR_LEN;
|
|
218
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
219
|
+
const len2 = WASM_VECTOR_LEN;
|
|
220
|
+
wasm.convertToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
221
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
222
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
223
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
224
|
+
if (r2) {
|
|
225
|
+
throw takeObject(r1);
|
|
226
|
+
}
|
|
227
|
+
return takeObject(r0);
|
|
228
|
+
} finally {
|
|
229
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
230
|
+
heap[stack_pointer++] = undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Convert text input to string output, with image resources for embedding.
|
|
237
|
+
* @param {string} input
|
|
238
|
+
* @param {string} from
|
|
239
|
+
* @param {string} to
|
|
240
|
+
* @param {Map<any, any>} resources
|
|
241
|
+
* @returns {string}
|
|
242
|
+
*/
|
|
243
|
+
function convertWithResources(input, from, to, resources) {
|
|
244
|
+
let deferred5_0;
|
|
245
|
+
let deferred5_1;
|
|
246
|
+
try {
|
|
247
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
248
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
249
|
+
const len0 = WASM_VECTOR_LEN;
|
|
250
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
251
|
+
const len1 = WASM_VECTOR_LEN;
|
|
252
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
253
|
+
const len2 = WASM_VECTOR_LEN;
|
|
254
|
+
wasm.convertWithResources(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
|
|
255
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
256
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
257
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
258
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
259
|
+
var ptr4 = r0;
|
|
260
|
+
var len4 = r1;
|
|
261
|
+
if (r3) {
|
|
262
|
+
ptr4 = 0; len4 = 0;
|
|
263
|
+
throw takeObject(r2);
|
|
264
|
+
}
|
|
265
|
+
deferred5_0 = ptr4;
|
|
266
|
+
deferred5_1 = len4;
|
|
267
|
+
return getStringFromWasm0(ptr4, len4);
|
|
268
|
+
} finally {
|
|
269
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
270
|
+
heap[stack_pointer++] = undefined;
|
|
271
|
+
wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
171
276
|
/**
|
|
172
277
|
* Return a list of supported input format names.
|
|
173
278
|
* @returns {string[]}
|
|
@@ -317,11 +422,53 @@ function __wbg_get_imports() {
|
|
|
317
422
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
318
423
|
return addHeapObject(ret);
|
|
319
424
|
},
|
|
425
|
+
__wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
|
|
426
|
+
const obj = getObject(arg1);
|
|
427
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
428
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
429
|
+
var len1 = WASM_VECTOR_LEN;
|
|
430
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
431
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
432
|
+
},
|
|
433
|
+
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
|
|
434
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
435
|
+
},
|
|
436
|
+
__wbg_forEach_5bdeef2ab2f0b065: function(arg0, arg1, arg2) {
|
|
437
|
+
try {
|
|
438
|
+
var state0 = {a: arg1, b: arg2};
|
|
439
|
+
var cb0 = (arg0, arg1) => {
|
|
440
|
+
const a = state0.a;
|
|
441
|
+
state0.a = 0;
|
|
442
|
+
try {
|
|
443
|
+
return __wasm_bindgen_func_elem_332(a, state0.b, arg0, arg1);
|
|
444
|
+
} finally {
|
|
445
|
+
state0.a = a;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
getObject(arg0).forEach(cb0);
|
|
449
|
+
} finally {
|
|
450
|
+
state0.a = 0;
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
__wbg_length_9f1775224cf1d815: function(arg0) {
|
|
454
|
+
const ret = getObject(arg0).length;
|
|
455
|
+
return ret;
|
|
456
|
+
},
|
|
457
|
+
__wbg_new_from_slice_b5ea43e23f6008c0: function(arg0, arg1) {
|
|
458
|
+
const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
|
|
459
|
+
return addHeapObject(ret);
|
|
460
|
+
},
|
|
461
|
+
__wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
|
|
462
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
463
|
+
},
|
|
320
464
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
321
465
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
322
466
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
323
467
|
return addHeapObject(ret);
|
|
324
468
|
},
|
|
469
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
470
|
+
takeObject(arg0);
|
|
471
|
+
},
|
|
325
472
|
};
|
|
326
473
|
return {
|
|
327
474
|
__proto__: null,
|
|
@@ -329,6 +476,10 @@ function __wbg_get_imports() {
|
|
|
329
476
|
};
|
|
330
477
|
}
|
|
331
478
|
|
|
479
|
+
function __wasm_bindgen_func_elem_332(arg0, arg1, arg2, arg3) {
|
|
480
|
+
wasm.__wasm_bindgen_func_elem_332(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
481
|
+
}
|
|
482
|
+
|
|
332
483
|
function addHeapObject(obj) {
|
|
333
484
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
334
485
|
const idx = heap_next;
|
|
@@ -338,6 +489,12 @@ function addHeapObject(obj) {
|
|
|
338
489
|
return idx;
|
|
339
490
|
}
|
|
340
491
|
|
|
492
|
+
function addBorrowedObject(obj) {
|
|
493
|
+
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
494
|
+
heap[--stack_pointer] = obj;
|
|
495
|
+
return stack_pointer;
|
|
496
|
+
}
|
|
497
|
+
|
|
341
498
|
function dropObject(idx) {
|
|
342
499
|
if (idx < 1028) return;
|
|
343
500
|
heap[idx] = heap_next;
|
|
@@ -354,6 +511,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
|
|
|
354
511
|
return result;
|
|
355
512
|
}
|
|
356
513
|
|
|
514
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
515
|
+
ptr = ptr >>> 0;
|
|
516
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
517
|
+
}
|
|
518
|
+
|
|
357
519
|
let cachedDataViewMemory0 = null;
|
|
358
520
|
function getDataViewMemory0() {
|
|
359
521
|
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
@@ -382,6 +544,10 @@ heap.push(undefined, null, true, false);
|
|
|
382
544
|
|
|
383
545
|
let heap_next = heap.length;
|
|
384
546
|
|
|
547
|
+
function isLikeNone(x) {
|
|
548
|
+
return x === undefined || x === null;
|
|
549
|
+
}
|
|
550
|
+
|
|
385
551
|
function passArray8ToWasm0(arg, malloc) {
|
|
386
552
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
387
553
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
@@ -426,6 +592,8 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
426
592
|
return ptr;
|
|
427
593
|
}
|
|
428
594
|
|
|
595
|
+
let stack_pointer = 1024;
|
|
596
|
+
|
|
429
597
|
function takeObject(idx) {
|
|
430
598
|
const ret = getObject(idx);
|
|
431
599
|
dropObject(idx);
|
|
@@ -459,4 +627,4 @@ const wasmBytes = readFileSync(wasmPath);
|
|
|
459
627
|
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
460
628
|
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
461
629
|
|
|
462
|
-
export { convert, convertBytes, convertBytesStandalone, convertStandalone, inputFormats, markdownToHtml, outputFormats, parseBytesToJson, parseToJson };
|
|
630
|
+
export { convert, convertBytes, convertBytesStandalone, convertBytesToBytes, convertStandalone, convertToBytes, convertWithResources, inputFormats, markdownToHtml, outputFormats, parseBytesToJson, parseToJson };
|
package/node/docmux_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -4,13 +4,17 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const convert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
5
5
|
export const convertBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
6
6
|
export const convertBytesStandalone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
7
|
+
export const convertBytesToBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
7
8
|
export const convertStandalone: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
9
|
+
export const convertToBytes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
10
|
+
export const convertWithResources: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
8
11
|
export const inputFormats: (a: number) => void;
|
|
9
12
|
export const markdownToHtml: (a: number, b: number, c: number) => void;
|
|
10
13
|
export const outputFormats: (a: number) => void;
|
|
11
14
|
export const parseBytesToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
12
15
|
export const parseToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
13
|
-
export const
|
|
16
|
+
export const __wasm_bindgen_func_elem_332: (a: number, b: number, c: number, d: number) => void;
|
|
14
17
|
export const __wbindgen_export: (a: number, b: number) => number;
|
|
15
18
|
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
19
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
16
20
|
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docmux/wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Universal document converter — WASM bindings for docmux",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,11 +29,16 @@
|
|
|
29
29
|
"import": "./bundler/docmux_wasm.js",
|
|
30
30
|
"types": "./bundler/docmux_wasm.d.ts"
|
|
31
31
|
}
|
|
32
|
+
},
|
|
33
|
+
"./web": {
|
|
34
|
+
"import": "./web/docmux_wasm.js",
|
|
35
|
+
"types": "./web/docmux_wasm.d.ts"
|
|
32
36
|
}
|
|
33
37
|
},
|
|
34
38
|
"files": [
|
|
35
39
|
"dist/",
|
|
36
40
|
"bundler/",
|
|
41
|
+
"web/",
|
|
37
42
|
"node/",
|
|
38
43
|
"README.md",
|
|
39
44
|
"LICENSE"
|