docling.rs-wasm 0.50.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 +21 -0
- package/README.md +77 -0
- package/bundler/docling_wasm.d.ts +132 -0
- package/bundler/docling_wasm.js +9 -0
- package/bundler/docling_wasm_bg.js +825 -0
- package/bundler/docling_wasm_bg.wasm +0 -0
- package/bundler/docling_wasm_bg.wasm.d.ts +33 -0
- package/package.json +50 -0
- package/web/docling_wasm.d.ts +190 -0
- package/web/docling_wasm.js +926 -0
- package/web/docling_wasm_bg.wasm +0 -0
- package/web/docling_wasm_bg.wasm.d.ts +33 -0
|
@@ -0,0 +1,926 @@
|
|
|
1
|
+
/* @ts-self-types="./docling_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A digital PDF being converted page by page. Construct it from the file's
|
|
5
|
+
* bytes (the text layer is parsed once, in Rust), then feed the rasterized
|
|
6
|
+
* pages in order.
|
|
7
|
+
*/
|
|
8
|
+
export class DigitalConverter {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
DigitalConverterFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_digitalconverter_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* [`add_page`](Self::add_page) with TableFormer for the table regions whose
|
|
21
|
+
* geometric reconstruction looks unreliable.
|
|
22
|
+
* @param {number} index
|
|
23
|
+
* @param {Uint8Array} rgba
|
|
24
|
+
* @param {number} px_w
|
|
25
|
+
* @param {number} px_h
|
|
26
|
+
* @param {number} scale
|
|
27
|
+
* @param {any} layout
|
|
28
|
+
* @param {any} tf
|
|
29
|
+
* @param {any | null} [rec]
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
addPageTf(index, rgba, px_w, px_h, scale, layout, tf, rec) {
|
|
33
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
34
|
+
const len0 = WASM_VECTOR_LEN;
|
|
35
|
+
const ret = wasm.digitalconverter_addPageTf(this.__wbg_ptr, index, ptr0, len0, px_w, px_h, scale, layout, tf, isLikeNone(rec) ? 0 : addToExternrefTable0(rec));
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Convert page `index` (0-based) given its rendered bitmap: layout
|
|
40
|
+
* detection plus geometric tables. `scale` is the raster's pixels per PDF
|
|
41
|
+
* point (2.0 for pdf.js `{scale: 2}`). With `rec` (and a dictionary at
|
|
42
|
+
* construction), embedded raster pictures that carry no text cells are
|
|
43
|
+
* OCR'd — the text a digital page's images hide from its text layer.
|
|
44
|
+
* @param {number} index
|
|
45
|
+
* @param {Uint8Array} rgba
|
|
46
|
+
* @param {number} px_w
|
|
47
|
+
* @param {number} px_h
|
|
48
|
+
* @param {number} scale
|
|
49
|
+
* @param {any} layout
|
|
50
|
+
* @param {any | null} [rec]
|
|
51
|
+
* @returns {Promise<void>}
|
|
52
|
+
*/
|
|
53
|
+
add_page(index, rgba, px_w, px_h, scale, layout, rec) {
|
|
54
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
55
|
+
const len0 = WASM_VECTOR_LEN;
|
|
56
|
+
const ret = wasm.digitalconverter_add_page(this.__wbg_ptr, index, ptr0, len0, px_w, px_h, scale, layout, isLikeNone(rec) ? 0 : addToExternrefTable0(rec));
|
|
57
|
+
return ret;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Assemble the converted pages into a document and render it as `"md"`
|
|
61
|
+
* (default), `"json"` or `"doclang"`, with `images` picking how pictures
|
|
62
|
+
* render in Markdown. Resets the converter.
|
|
63
|
+
* @param {string} name
|
|
64
|
+
* @param {string | null} [to]
|
|
65
|
+
* @param {string | null} [images]
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
68
|
+
finish(name, to, images) {
|
|
69
|
+
let deferred5_0;
|
|
70
|
+
let deferred5_1;
|
|
71
|
+
try {
|
|
72
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
73
|
+
const len0 = WASM_VECTOR_LEN;
|
|
74
|
+
var ptr1 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
75
|
+
var len1 = WASM_VECTOR_LEN;
|
|
76
|
+
var ptr2 = isLikeNone(images) ? 0 : passStringToWasm0(images, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
77
|
+
var len2 = WASM_VECTOR_LEN;
|
|
78
|
+
const ret = wasm.digitalconverter_finish(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
79
|
+
var ptr4 = ret[0];
|
|
80
|
+
var len4 = ret[1];
|
|
81
|
+
if (ret[3]) {
|
|
82
|
+
ptr4 = 0; len4 = 0;
|
|
83
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
84
|
+
}
|
|
85
|
+
deferred5_0 = ptr4;
|
|
86
|
+
deferred5_1 = len4;
|
|
87
|
+
return getStringFromWasm0(ptr4, len4);
|
|
88
|
+
} finally {
|
|
89
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Parse the PDF's text layer. Fails when there is none — the caller should
|
|
94
|
+
* fall back to the scanned pipeline, exactly as the demo page does.
|
|
95
|
+
* `dict` (optional) is the recognition dictionary text; with it and a
|
|
96
|
+
* `RecSession` on `add_page`, embedded raster pictures get OCR'd too.
|
|
97
|
+
* @param {Uint8Array} bytes
|
|
98
|
+
* @param {string | null} [dict]
|
|
99
|
+
*/
|
|
100
|
+
constructor(bytes, dict) {
|
|
101
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
var ptr1 = isLikeNone(dict) ? 0 : passStringToWasm0(dict, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
104
|
+
var len1 = WASM_VECTOR_LEN;
|
|
105
|
+
const ret = wasm.digitalconverter_new(ptr0, len0, ptr1, len1);
|
|
106
|
+
if (ret[2]) {
|
|
107
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
108
|
+
}
|
|
109
|
+
this.__wbg_ptr = ret[0];
|
|
110
|
+
DigitalConverterFinalization.register(this, this.__wbg_ptr, this);
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Pages the text parser found.
|
|
115
|
+
* @returns {number}
|
|
116
|
+
*/
|
|
117
|
+
page_count() {
|
|
118
|
+
const ret = wasm.digitalconverter_page_count(this.__wbg_ptr);
|
|
119
|
+
return ret >>> 0;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Install the recognition dictionary after construction — the host probes
|
|
123
|
+
* the text layer first (the constructor throws on a scan) and only then
|
|
124
|
+
* fetches the recognition model + dictionary.
|
|
125
|
+
* @param {string} dict
|
|
126
|
+
*/
|
|
127
|
+
setDict(dict) {
|
|
128
|
+
const ptr0 = passStringToWasm0(dict, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len0 = WASM_VECTOR_LEN;
|
|
130
|
+
wasm.digitalconverter_setDict(this.__wbg_ptr, ptr0, len0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (Symbol.dispose) DigitalConverter.prototype[Symbol.dispose] = DigitalConverter.prototype.free;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Multi-page scanned-document converter (lite profile). Feed pages in
|
|
137
|
+
* order, then [`finish`](Self::finish) — cross-page paragraph continuations
|
|
138
|
+
* merge exactly like the native pipeline.
|
|
139
|
+
*/
|
|
140
|
+
export class ScannedConverter {
|
|
141
|
+
__destroy_into_raw() {
|
|
142
|
+
const ptr = this.__wbg_ptr;
|
|
143
|
+
this.__wbg_ptr = 0;
|
|
144
|
+
ScannedConverterFinalization.unregister(this);
|
|
145
|
+
return ptr;
|
|
146
|
+
}
|
|
147
|
+
free() {
|
|
148
|
+
const ptr = this.__destroy_into_raw();
|
|
149
|
+
wasm.__wbg_scannedconverter_free(ptr, 0);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Convert one page with TableFormer (#157 stage 3): table regions get the
|
|
153
|
+
* ONNX table-structure model + docling's cell matcher instead of the
|
|
154
|
+
* geometric reconstruction. `tf` is the JS-side session over the encoder /
|
|
155
|
+
* decoder / bbox graphs.
|
|
156
|
+
* @param {Uint8Array} rgba
|
|
157
|
+
* @param {number} px_w
|
|
158
|
+
* @param {number} px_h
|
|
159
|
+
* @param {number} scale
|
|
160
|
+
* @param {any} layout
|
|
161
|
+
* @param {any} rec
|
|
162
|
+
* @param {any} tf
|
|
163
|
+
* @returns {Promise<void>}
|
|
164
|
+
*/
|
|
165
|
+
addPageTf(rgba, px_w, px_h, scale, layout, rec, tf) {
|
|
166
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
168
|
+
const ret = wasm.scannedconverter_addPageTf(this.__wbg_ptr, ptr0, len0, px_w, px_h, scale, layout, rec, tf);
|
|
169
|
+
return ret;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Convert one page (lite profile — geometric tables): `rgba` is the
|
|
173
|
+
* rendered bitmap (canvas ImageData), `scale` its pixels-per-PDF-point
|
|
174
|
+
* (2.0 for pdf.js `{scale: 2}`; 1.0 for a standalone image).
|
|
175
|
+
* @param {Uint8Array} rgba
|
|
176
|
+
* @param {number} px_w
|
|
177
|
+
* @param {number} px_h
|
|
178
|
+
* @param {number} scale
|
|
179
|
+
* @param {any} layout
|
|
180
|
+
* @param {any} rec
|
|
181
|
+
* @returns {Promise<void>}
|
|
182
|
+
*/
|
|
183
|
+
add_page(rgba, px_w, px_h, scale, layout, rec) {
|
|
184
|
+
const ptr0 = passArray8ToWasm0(rgba, wasm.__wbindgen_malloc);
|
|
185
|
+
const len0 = WASM_VECTOR_LEN;
|
|
186
|
+
const ret = wasm.scannedconverter_add_page(this.__wbg_ptr, ptr0, len0, px_w, px_h, scale, layout, rec);
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Assemble the accumulated pages into the final document and render it
|
|
191
|
+
* as `"md"` (default), `"json"` or `"doclang"` — the same three the
|
|
192
|
+
* declarative [`crate::convert`] entry point offers. `images` picks how
|
|
193
|
+
* cropped figures render in Markdown (`"placeholder"` | `"embedded"`),
|
|
194
|
+
* like [`crate::convert`]. Resets the converter.
|
|
195
|
+
* @param {string} name
|
|
196
|
+
* @param {string | null} [to]
|
|
197
|
+
* @param {string | null} [images]
|
|
198
|
+
* @returns {string}
|
|
199
|
+
*/
|
|
200
|
+
finish(name, to, images) {
|
|
201
|
+
let deferred5_0;
|
|
202
|
+
let deferred5_1;
|
|
203
|
+
try {
|
|
204
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
205
|
+
const len0 = WASM_VECTOR_LEN;
|
|
206
|
+
var ptr1 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
207
|
+
var len1 = WASM_VECTOR_LEN;
|
|
208
|
+
var ptr2 = isLikeNone(images) ? 0 : passStringToWasm0(images, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
209
|
+
var len2 = WASM_VECTOR_LEN;
|
|
210
|
+
const ret = wasm.scannedconverter_finish(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
211
|
+
var ptr4 = ret[0];
|
|
212
|
+
var len4 = ret[1];
|
|
213
|
+
if (ret[3]) {
|
|
214
|
+
ptr4 = 0; len4 = 0;
|
|
215
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
216
|
+
}
|
|
217
|
+
deferred5_0 = ptr4;
|
|
218
|
+
deferred5_1 = len4;
|
|
219
|
+
return getStringFromWasm0(ptr4, len4);
|
|
220
|
+
} finally {
|
|
221
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* `dict` is the recognition dictionary text (`en_dict.txt` for the
|
|
226
|
+
* default English model).
|
|
227
|
+
* @param {string} dict
|
|
228
|
+
*/
|
|
229
|
+
constructor(dict) {
|
|
230
|
+
const ptr0 = passStringToWasm0(dict, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
231
|
+
const len0 = WASM_VECTOR_LEN;
|
|
232
|
+
const ret = wasm.scannedconverter_new(ptr0, len0);
|
|
233
|
+
this.__wbg_ptr = ret;
|
|
234
|
+
ScannedConverterFinalization.register(this, this.__wbg_ptr, this);
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Number of pages converted so far (progress display).
|
|
239
|
+
* @returns {number}
|
|
240
|
+
*/
|
|
241
|
+
page_count() {
|
|
242
|
+
const ret = wasm.scannedconverter_page_count(this.__wbg_ptr);
|
|
243
|
+
return ret >>> 0;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (Symbol.dispose) ScannedConverter.prototype[Symbol.dispose] = ScannedConverter.prototype.free;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Convert a document (as bytes + filename, the extension drives format
|
|
250
|
+
* detection) to `to`: `"md"` (Markdown, default), `"json"` (docling-core's
|
|
251
|
+
* `DoclingDocument` wire format, schema 1.10.0) or `"doclang"` (docling's
|
|
252
|
+
* DocLang XML serialization).
|
|
253
|
+
*
|
|
254
|
+
* `images` controls how pictures render in Markdown — `"placeholder"`
|
|
255
|
+
* (default) or `"embedded"` (base64 data URIs), the same option
|
|
256
|
+
* docling-serve exposes. `max_pages` converts only a PDF's first N pages
|
|
257
|
+
* (issue #80's window, first pinned to 1); other formats ignore it.
|
|
258
|
+
* @param {Uint8Array} bytes
|
|
259
|
+
* @param {string} filename
|
|
260
|
+
* @param {string | null} [to]
|
|
261
|
+
* @param {string | null} [images]
|
|
262
|
+
* @param {number | null} [max_pages]
|
|
263
|
+
* @returns {string}
|
|
264
|
+
*/
|
|
265
|
+
export function convert(bytes, filename, to, images, max_pages) {
|
|
266
|
+
let deferred6_0;
|
|
267
|
+
let deferred6_1;
|
|
268
|
+
try {
|
|
269
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
270
|
+
const len0 = WASM_VECTOR_LEN;
|
|
271
|
+
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
272
|
+
const len1 = WASM_VECTOR_LEN;
|
|
273
|
+
var ptr2 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
274
|
+
var len2 = WASM_VECTOR_LEN;
|
|
275
|
+
var ptr3 = isLikeNone(images) ? 0 : passStringToWasm0(images, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
276
|
+
var len3 = WASM_VECTOR_LEN;
|
|
277
|
+
const ret = wasm.convert(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, isLikeNone(max_pages) ? Number.MAX_SAFE_INTEGER : (max_pages) >>> 0);
|
|
278
|
+
var ptr5 = ret[0];
|
|
279
|
+
var len5 = ret[1];
|
|
280
|
+
if (ret[3]) {
|
|
281
|
+
ptr5 = 0; len5 = 0;
|
|
282
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
283
|
+
}
|
|
284
|
+
deferred6_0 = ptr5;
|
|
285
|
+
deferred6_1 = len5;
|
|
286
|
+
return getStringFromWasm0(ptr5, len5);
|
|
287
|
+
} finally {
|
|
288
|
+
wasm.__wbindgen_free(deferred6_0, deferred6_1, 1);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* One-shot scanned-image conversion through the full lite profile (layout +
|
|
294
|
+
* OCR + assembly) — the browser counterpart of the native image path
|
|
295
|
+
* (a standalone image is its own page at scale 1).
|
|
296
|
+
* @param {Uint8Array} bytes
|
|
297
|
+
* @param {string} name
|
|
298
|
+
* @param {string} dict
|
|
299
|
+
* @param {any} layout
|
|
300
|
+
* @param {any} rec
|
|
301
|
+
* @param {string | null} [to]
|
|
302
|
+
* @param {string | null} [images]
|
|
303
|
+
* @returns {Promise<string>}
|
|
304
|
+
*/
|
|
305
|
+
export function convert_scanned_image(bytes, name, dict, layout, rec, to, images) {
|
|
306
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
307
|
+
const len0 = WASM_VECTOR_LEN;
|
|
308
|
+
const ptr1 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
309
|
+
const len1 = WASM_VECTOR_LEN;
|
|
310
|
+
const ptr2 = passStringToWasm0(dict, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
311
|
+
const len2 = WASM_VECTOR_LEN;
|
|
312
|
+
var ptr3 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
313
|
+
var len3 = WASM_VECTOR_LEN;
|
|
314
|
+
var ptr4 = isLikeNone(images) ? 0 : passStringToWasm0(images, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
315
|
+
var len4 = WASM_VECTOR_LEN;
|
|
316
|
+
const ret = wasm.convert_scanned_image(ptr0, len0, ptr1, len1, ptr2, len2, layout, rec, ptr3, len3, ptr4, len4);
|
|
317
|
+
return ret;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* OCR a scanned image entirely in the browser: `bytes` is the image file
|
|
322
|
+
* (PNG/JPEG/…), `dict` the recognition dictionary text (`en_dict.txt` for
|
|
323
|
+
* the default English model), `session` the JS inference wrapper. Returns
|
|
324
|
+
* Markdown (default) or docling JSON per `to`, one paragraph per recognized
|
|
325
|
+
* line.
|
|
326
|
+
* @param {Uint8Array} bytes
|
|
327
|
+
* @param {string} dict
|
|
328
|
+
* @param {any} session
|
|
329
|
+
* @param {string | null} [to]
|
|
330
|
+
* @returns {Promise<string>}
|
|
331
|
+
*/
|
|
332
|
+
export function ocr_image(bytes, dict, session, to) {
|
|
333
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
334
|
+
const len0 = WASM_VECTOR_LEN;
|
|
335
|
+
const ptr1 = passStringToWasm0(dict, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
336
|
+
const len1 = WASM_VECTOR_LEN;
|
|
337
|
+
var ptr2 = isLikeNone(to) ? 0 : passStringToWasm0(to, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
338
|
+
var len2 = WASM_VECTOR_LEN;
|
|
339
|
+
const ret = wasm.ocr_image(ptr0, len0, ptr1, len1, session, ptr2, len2);
|
|
340
|
+
return ret;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export function start() {
|
|
344
|
+
wasm.start();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The file extensions this build can convert, as a JSON string array —
|
|
349
|
+
* handy for an `<input accept=…>` filter. PDF converts via its embedded
|
|
350
|
+
* text layer (`pdf-text`); the remaining ML formats (images, audio, METS)
|
|
351
|
+
* are excluded: they are not compiled into the wasm build.
|
|
352
|
+
* @returns {string}
|
|
353
|
+
*/
|
|
354
|
+
export function supported_extensions() {
|
|
355
|
+
let deferred1_0;
|
|
356
|
+
let deferred1_1;
|
|
357
|
+
try {
|
|
358
|
+
const ret = wasm.supported_extensions();
|
|
359
|
+
deferred1_0 = ret[0];
|
|
360
|
+
deferred1_1 = ret[1];
|
|
361
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
362
|
+
} finally {
|
|
363
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* The docling.rs version this module was built from.
|
|
369
|
+
* @returns {string}
|
|
370
|
+
*/
|
|
371
|
+
export function version() {
|
|
372
|
+
let deferred1_0;
|
|
373
|
+
let deferred1_1;
|
|
374
|
+
try {
|
|
375
|
+
const ret = wasm.version();
|
|
376
|
+
deferred1_0 = ret[0];
|
|
377
|
+
deferred1_1 = ret[1];
|
|
378
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
379
|
+
} finally {
|
|
380
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function __wbg_get_imports() {
|
|
384
|
+
const import0 = {
|
|
385
|
+
__proto__: null,
|
|
386
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
387
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
388
|
+
return ret;
|
|
389
|
+
},
|
|
390
|
+
__wbg___wbindgen_debug_string_c25d447a39f5578f: function(arg0, arg1) {
|
|
391
|
+
const ret = debugString(arg1);
|
|
392
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
393
|
+
const len1 = WASM_VECTOR_LEN;
|
|
394
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
395
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
396
|
+
},
|
|
397
|
+
__wbg___wbindgen_is_function_1ff95bcc5517c252: function(arg0) {
|
|
398
|
+
const ret = typeof(arg0) === 'function';
|
|
399
|
+
return ret;
|
|
400
|
+
},
|
|
401
|
+
__wbg___wbindgen_is_undefined_c05833b95a3cf397: function(arg0) {
|
|
402
|
+
const ret = arg0 === undefined;
|
|
403
|
+
return ret;
|
|
404
|
+
},
|
|
405
|
+
__wbg___wbindgen_number_get_394265ed1e1b84ee: function(arg0, arg1) {
|
|
406
|
+
const obj = arg1;
|
|
407
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
408
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
409
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
410
|
+
},
|
|
411
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
412
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
413
|
+
},
|
|
414
|
+
__wbg__wbg_cb_unref_fffb441def202758: function(arg0) {
|
|
415
|
+
arg0._wbg_cb_unref();
|
|
416
|
+
},
|
|
417
|
+
__wbg_bbox_7b30625648740567: function() { return handleError(function (arg0, arg1, arg2) {
|
|
418
|
+
const ret = arg0.bbox(arg1, arg2 >>> 0);
|
|
419
|
+
return ret;
|
|
420
|
+
}, arguments); },
|
|
421
|
+
__wbg_call_a6e5c5dce5018821: function() { return handleError(function (arg0, arg1, arg2) {
|
|
422
|
+
const ret = arg0.call(arg1, arg2);
|
|
423
|
+
return ret;
|
|
424
|
+
}, arguments); },
|
|
425
|
+
__wbg_encode_d65d9f1985abdb0e: function() { return handleError(function (arg0, arg1) {
|
|
426
|
+
const ret = arg0.encode(arg1);
|
|
427
|
+
return ret;
|
|
428
|
+
}, arguments); },
|
|
429
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
430
|
+
let deferred0_0;
|
|
431
|
+
let deferred0_1;
|
|
432
|
+
try {
|
|
433
|
+
deferred0_0 = arg0;
|
|
434
|
+
deferred0_1 = arg1;
|
|
435
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
436
|
+
} finally {
|
|
437
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
__wbg_getRandomValues_cc7f052a444bb2ce: function() { return handleError(function (arg0, arg1) {
|
|
441
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
442
|
+
}, arguments); },
|
|
443
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
444
|
+
const ret = arg0[arg1 >>> 0];
|
|
445
|
+
return ret;
|
|
446
|
+
},
|
|
447
|
+
__wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
|
|
448
|
+
const ret = Reflect.get(arg0, arg1);
|
|
449
|
+
return ret;
|
|
450
|
+
}, arguments); },
|
|
451
|
+
__wbg_instanceof_Float32Array_0734a24e43081e98: function(arg0) {
|
|
452
|
+
let result;
|
|
453
|
+
try {
|
|
454
|
+
result = arg0 instanceof Float32Array;
|
|
455
|
+
} catch (_) {
|
|
456
|
+
result = false;
|
|
457
|
+
}
|
|
458
|
+
const ret = result;
|
|
459
|
+
return ret;
|
|
460
|
+
},
|
|
461
|
+
__wbg_isArray_0677c962b281d01a: function(arg0) {
|
|
462
|
+
const ret = Array.isArray(arg0);
|
|
463
|
+
return ret;
|
|
464
|
+
},
|
|
465
|
+
__wbg_length_370319915dc99107: function(arg0) {
|
|
466
|
+
const ret = arg0.length;
|
|
467
|
+
return ret;
|
|
468
|
+
},
|
|
469
|
+
__wbg_length_98f10d1e2f4ea968: function(arg0) {
|
|
470
|
+
const ret = arg0.length;
|
|
471
|
+
return ret;
|
|
472
|
+
},
|
|
473
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
474
|
+
const ret = new Error();
|
|
475
|
+
return ret;
|
|
476
|
+
},
|
|
477
|
+
__wbg_new_from_slice_ddf8b82c4d6af38e: function(arg0, arg1) {
|
|
478
|
+
const ret = new Float32Array(getArrayF32FromWasm0(arg0, arg1));
|
|
479
|
+
return ret;
|
|
480
|
+
},
|
|
481
|
+
__wbg_new_typed_1824d93f294193e5: function(arg0, arg1) {
|
|
482
|
+
try {
|
|
483
|
+
var state0 = {a: arg0, b: arg1};
|
|
484
|
+
var cb0 = (arg0, arg1) => {
|
|
485
|
+
const a = state0.a;
|
|
486
|
+
state0.a = 0;
|
|
487
|
+
try {
|
|
488
|
+
return wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined_______true_(a, state0.b, arg0, arg1);
|
|
489
|
+
} finally {
|
|
490
|
+
state0.a = a;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
const ret = new Promise(cb0);
|
|
494
|
+
return ret;
|
|
495
|
+
} finally {
|
|
496
|
+
state0.a = 0;
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
__wbg_prototypesetcall_ba9c9a7197c11933: function(arg0, arg1, arg2) {
|
|
500
|
+
Float32Array.prototype.set.call(getArrayF32FromWasm0(arg0, arg1), arg2);
|
|
501
|
+
},
|
|
502
|
+
__wbg_queueMicrotask_0ab5b2d2393e99b9: function(arg0) {
|
|
503
|
+
const ret = arg0.queueMicrotask;
|
|
504
|
+
return ret;
|
|
505
|
+
},
|
|
506
|
+
__wbg_queueMicrotask_6a09b7bc46549209: function(arg0) {
|
|
507
|
+
queueMicrotask(arg0);
|
|
508
|
+
},
|
|
509
|
+
__wbg_resolve_2191a4dfe481c25b: function(arg0) {
|
|
510
|
+
const ret = Promise.resolve(arg0);
|
|
511
|
+
return ret;
|
|
512
|
+
},
|
|
513
|
+
__wbg_run_6876dac5c80bce06: function() { return handleError(function (arg0, arg1) {
|
|
514
|
+
const ret = arg0.run(arg1);
|
|
515
|
+
return ret;
|
|
516
|
+
}, arguments); },
|
|
517
|
+
__wbg_run_d0e3da4a3c776751: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
518
|
+
const ret = arg0.run(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4);
|
|
519
|
+
return ret;
|
|
520
|
+
}, arguments); },
|
|
521
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
522
|
+
const ret = arg1.stack;
|
|
523
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
524
|
+
const len1 = WASM_VECTOR_LEN;
|
|
525
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
526
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
527
|
+
},
|
|
528
|
+
__wbg_static_accessor_GLOBAL_4ef717fb391d88b7: function() {
|
|
529
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
530
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
531
|
+
},
|
|
532
|
+
__wbg_static_accessor_GLOBAL_THIS_8d1badc68b5a74f4: function() {
|
|
533
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
534
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
535
|
+
},
|
|
536
|
+
__wbg_static_accessor_SELF_146583524fe1469b: function() {
|
|
537
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
538
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
539
|
+
},
|
|
540
|
+
__wbg_static_accessor_WINDOW_f2829a2234d7819e: function() {
|
|
541
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
542
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
543
|
+
},
|
|
544
|
+
__wbg_step_dbfdccc97b964fea: function() { return handleError(function (arg0, arg1) {
|
|
545
|
+
const ret = arg0.step(arg1);
|
|
546
|
+
return ret;
|
|
547
|
+
}, arguments); },
|
|
548
|
+
__wbg_then_16d107c451e9905d: function(arg0, arg1, arg2) {
|
|
549
|
+
const ret = arg0.then(arg1, arg2);
|
|
550
|
+
return ret;
|
|
551
|
+
},
|
|
552
|
+
__wbg_then_6ec10ae38b3e92f7: function(arg0, arg1) {
|
|
553
|
+
const ret = arg0.then(arg1);
|
|
554
|
+
return ret;
|
|
555
|
+
},
|
|
556
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
557
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 76, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
558
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___wasm_bindgen_c5dab95b9564c094___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_c5dab95b9564c094___JsError___true_);
|
|
559
|
+
return ret;
|
|
560
|
+
},
|
|
561
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
562
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
563
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
564
|
+
return ret;
|
|
565
|
+
},
|
|
566
|
+
__wbindgen_init_externref_table: function() {
|
|
567
|
+
const table = wasm.__wbindgen_externrefs;
|
|
568
|
+
const offset = table.grow(4);
|
|
569
|
+
table.set(0, undefined);
|
|
570
|
+
table.set(offset + 0, undefined);
|
|
571
|
+
table.set(offset + 1, null);
|
|
572
|
+
table.set(offset + 2, true);
|
|
573
|
+
table.set(offset + 3, false);
|
|
574
|
+
},
|
|
575
|
+
};
|
|
576
|
+
return {
|
|
577
|
+
__proto__: null,
|
|
578
|
+
"./docling_wasm_bg.js": import0,
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___wasm_bindgen_c5dab95b9564c094___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_c5dab95b9564c094___JsError___true_(arg0, arg1, arg2) {
|
|
583
|
+
const ret = wasm.wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___wasm_bindgen_c5dab95b9564c094___JsValue__core_9b3796e30d99ddb7___result__Result_____wasm_bindgen_c5dab95b9564c094___JsError___true_(arg0, arg1, arg2);
|
|
584
|
+
if (ret[1]) {
|
|
585
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined_______true_(arg0, arg1, arg2, arg3) {
|
|
590
|
+
wasm.wasm_bindgen_c5dab95b9564c094___convert__closures_____invoke___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined___js_sys_29633ec172849407___Function_fn_wasm_bindgen_c5dab95b9564c094___JsValue_____wasm_bindgen_c5dab95b9564c094___sys__Undefined_______true_(arg0, arg1, arg2, arg3);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
const DigitalConverterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
594
|
+
? { register: () => {}, unregister: () => {} }
|
|
595
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_digitalconverter_free(ptr, 1));
|
|
596
|
+
const ScannedConverterFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
597
|
+
? { register: () => {}, unregister: () => {} }
|
|
598
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_scannedconverter_free(ptr, 1));
|
|
599
|
+
|
|
600
|
+
function addToExternrefTable0(obj) {
|
|
601
|
+
const idx = wasm.__externref_table_alloc();
|
|
602
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
603
|
+
return idx;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
607
|
+
? { register: () => {}, unregister: () => {} }
|
|
608
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_destroy_closure(state.a, state.b));
|
|
609
|
+
|
|
610
|
+
function debugString(val) {
|
|
611
|
+
// primitive types
|
|
612
|
+
const type = typeof val;
|
|
613
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
614
|
+
return `${val}`;
|
|
615
|
+
}
|
|
616
|
+
if (type == 'string') {
|
|
617
|
+
return `"${val}"`;
|
|
618
|
+
}
|
|
619
|
+
if (type == 'symbol') {
|
|
620
|
+
const description = val.description;
|
|
621
|
+
if (description == null) {
|
|
622
|
+
return 'Symbol';
|
|
623
|
+
} else {
|
|
624
|
+
return `Symbol(${description})`;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (type == 'function') {
|
|
628
|
+
const name = val.name;
|
|
629
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
630
|
+
return `Function(${name})`;
|
|
631
|
+
} else {
|
|
632
|
+
return 'Function';
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// objects
|
|
636
|
+
if (Array.isArray(val)) {
|
|
637
|
+
const length = val.length;
|
|
638
|
+
let debug = '[';
|
|
639
|
+
if (length > 0) {
|
|
640
|
+
debug += debugString(val[0]);
|
|
641
|
+
}
|
|
642
|
+
for(let i = 1; i < length; i++) {
|
|
643
|
+
debug += ', ' + debugString(val[i]);
|
|
644
|
+
}
|
|
645
|
+
debug += ']';
|
|
646
|
+
return debug;
|
|
647
|
+
}
|
|
648
|
+
// Test for built-in
|
|
649
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
650
|
+
let className;
|
|
651
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
652
|
+
className = builtInMatches[1];
|
|
653
|
+
} else {
|
|
654
|
+
// Failed to match the standard '[object ClassName]'
|
|
655
|
+
return toString.call(val);
|
|
656
|
+
}
|
|
657
|
+
if (className == 'Object') {
|
|
658
|
+
// we're a user defined class or Object
|
|
659
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
660
|
+
// easier than looping through ownProperties of `val`.
|
|
661
|
+
try {
|
|
662
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
663
|
+
} catch (_) {
|
|
664
|
+
return 'Object';
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
// errors
|
|
668
|
+
if (val instanceof Error) {
|
|
669
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
670
|
+
}
|
|
671
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
672
|
+
return className;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
676
|
+
ptr = ptr >>> 0;
|
|
677
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
681
|
+
ptr = ptr >>> 0;
|
|
682
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
let cachedDataViewMemory0 = null;
|
|
686
|
+
function getDataViewMemory0() {
|
|
687
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
688
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
689
|
+
}
|
|
690
|
+
return cachedDataViewMemory0;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
694
|
+
function getFloat32ArrayMemory0() {
|
|
695
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
|
|
696
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
697
|
+
}
|
|
698
|
+
return cachedFloat32ArrayMemory0;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function getStringFromWasm0(ptr, len) {
|
|
702
|
+
return decodeText(ptr >>> 0, len);
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
let cachedUint8ArrayMemory0 = null;
|
|
706
|
+
function getUint8ArrayMemory0() {
|
|
707
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
708
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
709
|
+
}
|
|
710
|
+
return cachedUint8ArrayMemory0;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function handleError(f, args) {
|
|
714
|
+
try {
|
|
715
|
+
return f.apply(this, args);
|
|
716
|
+
} catch (e) {
|
|
717
|
+
const idx = addToExternrefTable0(e);
|
|
718
|
+
wasm.__wbindgen_exn_store(idx);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function isLikeNone(x) {
|
|
723
|
+
return x === undefined || x === null;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
727
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
728
|
+
const real = (...args) => {
|
|
729
|
+
|
|
730
|
+
// First up with a closure we increment the internal reference
|
|
731
|
+
// count. This ensures that the Rust closure environment won't
|
|
732
|
+
// be deallocated while we're invoking it.
|
|
733
|
+
state.cnt++;
|
|
734
|
+
const a = state.a;
|
|
735
|
+
state.a = 0;
|
|
736
|
+
try {
|
|
737
|
+
return f(a, state.b, ...args);
|
|
738
|
+
} finally {
|
|
739
|
+
state.a = a;
|
|
740
|
+
real._wbg_cb_unref();
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
real._wbg_cb_unref = () => {
|
|
744
|
+
if (--state.cnt === 0) {
|
|
745
|
+
wasm.__wbindgen_destroy_closure(state.a, state.b);
|
|
746
|
+
state.a = 0;
|
|
747
|
+
CLOSURE_DTORS.unregister(state);
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
751
|
+
return real;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
755
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
756
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
757
|
+
WASM_VECTOR_LEN = arg.length;
|
|
758
|
+
return ptr;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
762
|
+
if (realloc === undefined) {
|
|
763
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
764
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
765
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
766
|
+
WASM_VECTOR_LEN = buf.length;
|
|
767
|
+
return ptr;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
let len = arg.length;
|
|
771
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
772
|
+
|
|
773
|
+
const mem = getUint8ArrayMemory0();
|
|
774
|
+
|
|
775
|
+
let offset = 0;
|
|
776
|
+
|
|
777
|
+
for (; offset < len; offset++) {
|
|
778
|
+
const code = arg.charCodeAt(offset);
|
|
779
|
+
if (code > 0x7F) break;
|
|
780
|
+
mem[ptr + offset] = code;
|
|
781
|
+
}
|
|
782
|
+
if (offset !== len) {
|
|
783
|
+
if (offset !== 0) {
|
|
784
|
+
arg = arg.slice(offset);
|
|
785
|
+
}
|
|
786
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
787
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
788
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
789
|
+
|
|
790
|
+
offset += ret.written;
|
|
791
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
WASM_VECTOR_LEN = offset;
|
|
795
|
+
return ptr;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
function takeFromExternrefTable0(idx) {
|
|
799
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
800
|
+
wasm.__externref_table_dealloc(idx);
|
|
801
|
+
return value;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
805
|
+
cachedTextDecoder.decode();
|
|
806
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
807
|
+
let numBytesDecoded = 0;
|
|
808
|
+
function decodeText(ptr, len) {
|
|
809
|
+
numBytesDecoded += len;
|
|
810
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
811
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
812
|
+
cachedTextDecoder.decode();
|
|
813
|
+
numBytesDecoded = len;
|
|
814
|
+
}
|
|
815
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
const cachedTextEncoder = new TextEncoder();
|
|
819
|
+
|
|
820
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
821
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
822
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
823
|
+
view.set(buf);
|
|
824
|
+
return {
|
|
825
|
+
read: arg.length,
|
|
826
|
+
written: buf.length
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
let WASM_VECTOR_LEN = 0;
|
|
832
|
+
|
|
833
|
+
let wasmModule, wasmInstance, wasm;
|
|
834
|
+
function __wbg_finalize_init(instance, module) {
|
|
835
|
+
wasmInstance = instance;
|
|
836
|
+
wasm = instance.exports;
|
|
837
|
+
wasmModule = module;
|
|
838
|
+
cachedDataViewMemory0 = null;
|
|
839
|
+
cachedFloat32ArrayMemory0 = null;
|
|
840
|
+
cachedUint8ArrayMemory0 = null;
|
|
841
|
+
wasm.__wbindgen_start();
|
|
842
|
+
return wasm;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
async function __wbg_load(module, imports) {
|
|
846
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
847
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
848
|
+
try {
|
|
849
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
850
|
+
} catch (e) {
|
|
851
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
852
|
+
|
|
853
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
854
|
+
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);
|
|
855
|
+
|
|
856
|
+
} else { throw e; }
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
const bytes = await module.arrayBuffer();
|
|
861
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
862
|
+
} else {
|
|
863
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
864
|
+
|
|
865
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
866
|
+
return { instance, module };
|
|
867
|
+
} else {
|
|
868
|
+
return instance;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
function expectedResponseType(type) {
|
|
873
|
+
switch (type) {
|
|
874
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
875
|
+
}
|
|
876
|
+
return false;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
function initSync(module) {
|
|
881
|
+
if (wasm !== undefined) return wasm;
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
if (module !== undefined) {
|
|
885
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
886
|
+
({module} = module)
|
|
887
|
+
} else {
|
|
888
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
const imports = __wbg_get_imports();
|
|
893
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
894
|
+
module = new WebAssembly.Module(module);
|
|
895
|
+
}
|
|
896
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
897
|
+
return __wbg_finalize_init(instance, module);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
async function __wbg_init(module_or_path) {
|
|
901
|
+
if (wasm !== undefined) return wasm;
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
if (module_or_path !== undefined) {
|
|
905
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
906
|
+
({module_or_path} = module_or_path)
|
|
907
|
+
} else {
|
|
908
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
if (module_or_path === undefined) {
|
|
913
|
+
module_or_path = new URL('docling_wasm_bg.wasm', import.meta.url);
|
|
914
|
+
}
|
|
915
|
+
const imports = __wbg_get_imports();
|
|
916
|
+
|
|
917
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
918
|
+
module_or_path = fetch(module_or_path);
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
922
|
+
|
|
923
|
+
return __wbg_finalize_init(instance, module);
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
export { initSync, __wbg_init as default };
|