@franken-suite/franken-markdown 0.3.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/README.md +61 -0
- package/demo/demo.js +215 -0
- package/demo/index.html +395 -0
- package/franken_markdown.d.ts +102 -0
- package/franken_markdown.js +295 -0
- package/package.json +50 -0
- package/pkg/franken_markdown.d.ts +172 -0
- package/pkg/franken_markdown.js +811 -0
- package/pkg/franken_markdown_bg.wasm +0 -0
- package/pkg/franken_markdown_bg.wasm.d.ts +23 -0
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
/* @ts-self-types="./franken_markdown.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Render output object exposed to JavaScript.
|
|
5
|
+
*/
|
|
6
|
+
export class FmdRenderResult {
|
|
7
|
+
static __wrap(ptr) {
|
|
8
|
+
const obj = Object.create(FmdRenderResult.prototype);
|
|
9
|
+
obj.__wbg_ptr = ptr;
|
|
10
|
+
FmdRenderResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
11
|
+
return obj;
|
|
12
|
+
}
|
|
13
|
+
__destroy_into_raw() {
|
|
14
|
+
const ptr = this.__wbg_ptr;
|
|
15
|
+
this.__wbg_ptr = 0;
|
|
16
|
+
FmdRenderResultFinalization.unregister(this);
|
|
17
|
+
return ptr;
|
|
18
|
+
}
|
|
19
|
+
free() {
|
|
20
|
+
const ptr = this.__destroy_into_raw();
|
|
21
|
+
wasm.__wbg_fmdrenderresult_free(ptr, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Rendered output bytes. HTML is UTF-8; PDF is binary.
|
|
25
|
+
* @returns {Uint8Array}
|
|
26
|
+
*/
|
|
27
|
+
get bytes() {
|
|
28
|
+
try {
|
|
29
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
30
|
+
wasm.fmdrenderresult_bytes(retptr, this.__wbg_ptr);
|
|
31
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
32
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
33
|
+
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
34
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
35
|
+
return v1;
|
|
36
|
+
} finally {
|
|
37
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Recoverable parser diagnostics as stable JSON.
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
diagnosticsJson() {
|
|
45
|
+
let deferred1_0;
|
|
46
|
+
let deferred1_1;
|
|
47
|
+
try {
|
|
48
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
49
|
+
wasm.fmdrenderresult_diagnosticsJson(retptr, this.__wbg_ptr);
|
|
50
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
51
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
52
|
+
deferred1_0 = r0;
|
|
53
|
+
deferred1_1 = r1;
|
|
54
|
+
return getStringFromWasm0(r0, r1);
|
|
55
|
+
} finally {
|
|
56
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
57
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Default file extension without a leading dot.
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
get extension() {
|
|
65
|
+
let deferred1_0;
|
|
66
|
+
let deferred1_1;
|
|
67
|
+
try {
|
|
68
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
69
|
+
wasm.fmdrenderresult_extension(retptr, this.__wbg_ptr);
|
|
70
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
71
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
72
|
+
deferred1_0 = r0;
|
|
73
|
+
deferred1_1 = r1;
|
|
74
|
+
return getStringFromWasm0(r0, r1);
|
|
75
|
+
} finally {
|
|
76
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
77
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Stable output format: `html` or `pdf`.
|
|
82
|
+
* @returns {string}
|
|
83
|
+
*/
|
|
84
|
+
get format() {
|
|
85
|
+
let deferred1_0;
|
|
86
|
+
let deferred1_1;
|
|
87
|
+
try {
|
|
88
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
89
|
+
wasm.fmdrenderresult_format(retptr, this.__wbg_ptr);
|
|
90
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
91
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
92
|
+
deferred1_0 = r0;
|
|
93
|
+
deferred1_1 = r1;
|
|
94
|
+
return getStringFromWasm0(r0, r1);
|
|
95
|
+
} finally {
|
|
96
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
97
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Browser MIME type for Blob construction.
|
|
102
|
+
* @returns {string}
|
|
103
|
+
*/
|
|
104
|
+
get mimeType() {
|
|
105
|
+
let deferred1_0;
|
|
106
|
+
let deferred1_1;
|
|
107
|
+
try {
|
|
108
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
109
|
+
wasm.fmdrenderresult_mimeType(retptr, this.__wbg_ptr);
|
|
110
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
111
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
112
|
+
deferred1_0 = r0;
|
|
113
|
+
deferred1_1 = r1;
|
|
114
|
+
return getStringFromWasm0(r0, r1);
|
|
115
|
+
} finally {
|
|
116
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
117
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Source size in bytes.
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
get sourceLength() {
|
|
125
|
+
const ret = wasm.fmdrenderresult_sourceLength(this.__wbg_ptr);
|
|
126
|
+
return ret >>> 0;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (Symbol.dispose) FmdRenderResult.prototype[Symbol.dispose] = FmdRenderResult.prototype.free;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Dependency-free capability contract as JSON.
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
export function capabilities() {
|
|
136
|
+
let deferred1_0;
|
|
137
|
+
let deferred1_1;
|
|
138
|
+
try {
|
|
139
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
140
|
+
wasm.capabilities(retptr);
|
|
141
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
142
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
143
|
+
deferred1_0 = r0;
|
|
144
|
+
deferred1_1 = r1;
|
|
145
|
+
return getStringFromWasm0(r0, r1);
|
|
146
|
+
} finally {
|
|
147
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
148
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Render Markdown to self-contained HTML using default browser-safe options.
|
|
154
|
+
*
|
|
155
|
+
* # Errors
|
|
156
|
+
* Returns a JavaScript error when rendering fails.
|
|
157
|
+
* @param {string} markdown
|
|
158
|
+
* @returns {FmdRenderResult}
|
|
159
|
+
*/
|
|
160
|
+
export function renderHtml(markdown) {
|
|
161
|
+
try {
|
|
162
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
163
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
164
|
+
const len0 = WASM_VECTOR_LEN;
|
|
165
|
+
wasm.renderHtml(retptr, ptr0, len0);
|
|
166
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
167
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
168
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
169
|
+
if (r2) {
|
|
170
|
+
throw takeObject(r1);
|
|
171
|
+
}
|
|
172
|
+
return FmdRenderResult.__wrap(r0);
|
|
173
|
+
} finally {
|
|
174
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Render Markdown to self-contained HTML with browser package options.
|
|
180
|
+
*
|
|
181
|
+
* # Errors
|
|
182
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
183
|
+
* @param {string} markdown
|
|
184
|
+
* @param {string | null | undefined} font
|
|
185
|
+
* @param {string | null | undefined} dark_mode
|
|
186
|
+
* @param {string | null | undefined} title
|
|
187
|
+
* @param {string | null | undefined} custom_css
|
|
188
|
+
* @param {boolean} allow_raw_html
|
|
189
|
+
* @returns {FmdRenderResult}
|
|
190
|
+
*/
|
|
191
|
+
export function renderHtmlConfigured(markdown, font, dark_mode, title, custom_css, allow_raw_html) {
|
|
192
|
+
try {
|
|
193
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
194
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
195
|
+
const len0 = WASM_VECTOR_LEN;
|
|
196
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
197
|
+
var len1 = WASM_VECTOR_LEN;
|
|
198
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
199
|
+
var len2 = WASM_VECTOR_LEN;
|
|
200
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
201
|
+
var len3 = WASM_VECTOR_LEN;
|
|
202
|
+
var ptr4 = isLikeNone(custom_css) ? 0 : passStringToWasm0(custom_css, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
203
|
+
var len4 = WASM_VECTOR_LEN;
|
|
204
|
+
wasm.renderHtmlConfigured(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, allow_raw_html);
|
|
205
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
206
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
207
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
208
|
+
if (r2) {
|
|
209
|
+
throw takeObject(r1);
|
|
210
|
+
}
|
|
211
|
+
return FmdRenderResult.__wrap(r0);
|
|
212
|
+
} finally {
|
|
213
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Render Markdown to self-contained HTML with browser package options and
|
|
219
|
+
* caller-supplied font bytes.
|
|
220
|
+
*
|
|
221
|
+
* Empty byte arrays mean "use bundled fallback" for that slot.
|
|
222
|
+
*
|
|
223
|
+
* # Errors
|
|
224
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
225
|
+
* @param {string} markdown
|
|
226
|
+
* @param {string | null | undefined} font
|
|
227
|
+
* @param {string | null | undefined} dark_mode
|
|
228
|
+
* @param {string | null | undefined} title
|
|
229
|
+
* @param {string | null | undefined} custom_css
|
|
230
|
+
* @param {boolean} allow_raw_html
|
|
231
|
+
* @param {Uint8Array} body_regular
|
|
232
|
+
* @param {Uint8Array} body_bold
|
|
233
|
+
* @param {Uint8Array} body_italic
|
|
234
|
+
* @param {Uint8Array} body_bold_italic
|
|
235
|
+
* @param {Uint8Array} mono_regular
|
|
236
|
+
* @returns {FmdRenderResult}
|
|
237
|
+
*/
|
|
238
|
+
export function renderHtmlConfiguredWithFonts(markdown, font, dark_mode, title, custom_css, allow_raw_html, body_regular, body_bold, body_italic, body_bold_italic, mono_regular) {
|
|
239
|
+
try {
|
|
240
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
241
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
242
|
+
const len0 = WASM_VECTOR_LEN;
|
|
243
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
244
|
+
var len1 = WASM_VECTOR_LEN;
|
|
245
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
246
|
+
var len2 = WASM_VECTOR_LEN;
|
|
247
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
248
|
+
var len3 = WASM_VECTOR_LEN;
|
|
249
|
+
var ptr4 = isLikeNone(custom_css) ? 0 : passStringToWasm0(custom_css, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
250
|
+
var len4 = WASM_VECTOR_LEN;
|
|
251
|
+
const ptr5 = passArray8ToWasm0(body_regular, wasm.__wbindgen_export);
|
|
252
|
+
const len5 = WASM_VECTOR_LEN;
|
|
253
|
+
const ptr6 = passArray8ToWasm0(body_bold, wasm.__wbindgen_export);
|
|
254
|
+
const len6 = WASM_VECTOR_LEN;
|
|
255
|
+
const ptr7 = passArray8ToWasm0(body_italic, wasm.__wbindgen_export);
|
|
256
|
+
const len7 = WASM_VECTOR_LEN;
|
|
257
|
+
const ptr8 = passArray8ToWasm0(body_bold_italic, wasm.__wbindgen_export);
|
|
258
|
+
const len8 = WASM_VECTOR_LEN;
|
|
259
|
+
const ptr9 = passArray8ToWasm0(mono_regular, wasm.__wbindgen_export);
|
|
260
|
+
const len9 = WASM_VECTOR_LEN;
|
|
261
|
+
wasm.renderHtmlConfiguredWithFonts(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, allow_raw_html, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, ptr9, len9);
|
|
262
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
263
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
264
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
265
|
+
if (r2) {
|
|
266
|
+
throw takeObject(r1);
|
|
267
|
+
}
|
|
268
|
+
return FmdRenderResult.__wrap(r0);
|
|
269
|
+
} finally {
|
|
270
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Render Markdown to PDF using default browser-safe options.
|
|
276
|
+
*
|
|
277
|
+
* # Errors
|
|
278
|
+
* Returns a JavaScript error when rendering fails.
|
|
279
|
+
* @param {string} markdown
|
|
280
|
+
* @returns {FmdRenderResult}
|
|
281
|
+
*/
|
|
282
|
+
export function renderPdf(markdown) {
|
|
283
|
+
try {
|
|
284
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
285
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
286
|
+
const len0 = WASM_VECTOR_LEN;
|
|
287
|
+
wasm.renderPdf(retptr, ptr0, len0);
|
|
288
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
289
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
290
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
291
|
+
if (r2) {
|
|
292
|
+
throw takeObject(r1);
|
|
293
|
+
}
|
|
294
|
+
return FmdRenderResult.__wrap(r0);
|
|
295
|
+
} finally {
|
|
296
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Render Markdown to PDF with browser package options.
|
|
302
|
+
*
|
|
303
|
+
* # Errors
|
|
304
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
305
|
+
* @param {string} markdown
|
|
306
|
+
* @param {string | null | undefined} font
|
|
307
|
+
* @param {string | null | undefined} dark_mode
|
|
308
|
+
* @param {string | null | undefined} title
|
|
309
|
+
* @param {string | null | undefined} author
|
|
310
|
+
* @param {number | null | undefined} metadata_epoch_seconds
|
|
311
|
+
* @param {boolean} allow_raw_html
|
|
312
|
+
* @param {boolean} code_line_numbers
|
|
313
|
+
* @returns {FmdRenderResult}
|
|
314
|
+
*/
|
|
315
|
+
export function renderPdfConfigured(markdown, font, dark_mode, title, author, metadata_epoch_seconds, allow_raw_html, code_line_numbers) {
|
|
316
|
+
try {
|
|
317
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
318
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
320
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
321
|
+
var len1 = WASM_VECTOR_LEN;
|
|
322
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
323
|
+
var len2 = WASM_VECTOR_LEN;
|
|
324
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
325
|
+
var len3 = WASM_VECTOR_LEN;
|
|
326
|
+
var ptr4 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
327
|
+
var len4 = WASM_VECTOR_LEN;
|
|
328
|
+
wasm.renderPdfConfigured(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(metadata_epoch_seconds), isLikeNone(metadata_epoch_seconds) ? 0 : metadata_epoch_seconds, allow_raw_html, code_line_numbers);
|
|
329
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
330
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
331
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
332
|
+
if (r2) {
|
|
333
|
+
throw takeObject(r1);
|
|
334
|
+
}
|
|
335
|
+
return FmdRenderResult.__wrap(r0);
|
|
336
|
+
} finally {
|
|
337
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Render Markdown to PDF with browser package options, ANY number of image
|
|
343
|
+
* assets, and caller-supplied font bytes. This is the general form the JS
|
|
344
|
+
* wrapper uses so multi-image documents reach native↔WASM parity (the
|
|
345
|
+
* single-image entry points above remain for a narrower ABI).
|
|
346
|
+
*
|
|
347
|
+
* Images arrive as three parallel arrays — a destination per image, all image
|
|
348
|
+
* bytes concatenated, and the byte length of each image — because wasm-bindgen
|
|
349
|
+
* cannot pass a `Vec<Vec<u8>>` directly. Empty font byte arrays mean "use
|
|
350
|
+
* bundled fallback" for that slot.
|
|
351
|
+
*
|
|
352
|
+
* # Errors
|
|
353
|
+
* Returns a JavaScript error when the image arrays are inconsistent, an option
|
|
354
|
+
* is invalid, or rendering fails.
|
|
355
|
+
* @param {string} markdown
|
|
356
|
+
* @param {string | null | undefined} font
|
|
357
|
+
* @param {string | null | undefined} dark_mode
|
|
358
|
+
* @param {string | null | undefined} title
|
|
359
|
+
* @param {string | null | undefined} author
|
|
360
|
+
* @param {number | null | undefined} metadata_epoch_seconds
|
|
361
|
+
* @param {boolean} allow_raw_html
|
|
362
|
+
* @param {boolean} code_line_numbers
|
|
363
|
+
* @param {string[]} image_destinations
|
|
364
|
+
* @param {Uint8Array} image_bytes_flat
|
|
365
|
+
* @param {Uint32Array} image_bytes_lengths
|
|
366
|
+
* @param {Uint8Array} body_regular
|
|
367
|
+
* @param {Uint8Array} body_bold
|
|
368
|
+
* @param {Uint8Array} body_italic
|
|
369
|
+
* @param {Uint8Array} body_bold_italic
|
|
370
|
+
* @param {Uint8Array} mono_regular
|
|
371
|
+
* @returns {FmdRenderResult}
|
|
372
|
+
*/
|
|
373
|
+
export function renderPdfConfiguredMulti(markdown, font, dark_mode, title, author, metadata_epoch_seconds, allow_raw_html, code_line_numbers, image_destinations, image_bytes_flat, image_bytes_lengths, body_regular, body_bold, body_italic, body_bold_italic, mono_regular) {
|
|
374
|
+
try {
|
|
375
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
376
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
377
|
+
const len0 = WASM_VECTOR_LEN;
|
|
378
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
379
|
+
var len1 = WASM_VECTOR_LEN;
|
|
380
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
381
|
+
var len2 = WASM_VECTOR_LEN;
|
|
382
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
383
|
+
var len3 = WASM_VECTOR_LEN;
|
|
384
|
+
var ptr4 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
385
|
+
var len4 = WASM_VECTOR_LEN;
|
|
386
|
+
const ptr5 = passArrayJsValueToWasm0(image_destinations, wasm.__wbindgen_export);
|
|
387
|
+
const len5 = WASM_VECTOR_LEN;
|
|
388
|
+
const ptr6 = passArray8ToWasm0(image_bytes_flat, wasm.__wbindgen_export);
|
|
389
|
+
const len6 = WASM_VECTOR_LEN;
|
|
390
|
+
const ptr7 = passArray32ToWasm0(image_bytes_lengths, wasm.__wbindgen_export);
|
|
391
|
+
const len7 = WASM_VECTOR_LEN;
|
|
392
|
+
const ptr8 = passArray8ToWasm0(body_regular, wasm.__wbindgen_export);
|
|
393
|
+
const len8 = WASM_VECTOR_LEN;
|
|
394
|
+
const ptr9 = passArray8ToWasm0(body_bold, wasm.__wbindgen_export);
|
|
395
|
+
const len9 = WASM_VECTOR_LEN;
|
|
396
|
+
const ptr10 = passArray8ToWasm0(body_italic, wasm.__wbindgen_export);
|
|
397
|
+
const len10 = WASM_VECTOR_LEN;
|
|
398
|
+
const ptr11 = passArray8ToWasm0(body_bold_italic, wasm.__wbindgen_export);
|
|
399
|
+
const len11 = WASM_VECTOR_LEN;
|
|
400
|
+
const ptr12 = passArray8ToWasm0(mono_regular, wasm.__wbindgen_export);
|
|
401
|
+
const len12 = WASM_VECTOR_LEN;
|
|
402
|
+
wasm.renderPdfConfiguredMulti(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(metadata_epoch_seconds), isLikeNone(metadata_epoch_seconds) ? 0 : metadata_epoch_seconds, allow_raw_html, code_line_numbers, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, ptr9, len9, ptr10, len10, ptr11, len11, ptr12, len12);
|
|
403
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
404
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
405
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
406
|
+
if (r2) {
|
|
407
|
+
throw takeObject(r1);
|
|
408
|
+
}
|
|
409
|
+
return FmdRenderResult.__wrap(r0);
|
|
410
|
+
} finally {
|
|
411
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Render Markdown to PDF with browser package options, one optional image
|
|
417
|
+
* asset, and caller-supplied font bytes.
|
|
418
|
+
*
|
|
419
|
+
* Empty image destination/bytes means "no image asset"; empty font byte arrays
|
|
420
|
+
* mean "use bundled fallback" for that slot.
|
|
421
|
+
*
|
|
422
|
+
* # Errors
|
|
423
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
424
|
+
* @param {string} markdown
|
|
425
|
+
* @param {string | null | undefined} font
|
|
426
|
+
* @param {string | null | undefined} dark_mode
|
|
427
|
+
* @param {string | null | undefined} title
|
|
428
|
+
* @param {string | null | undefined} author
|
|
429
|
+
* @param {number | null | undefined} metadata_epoch_seconds
|
|
430
|
+
* @param {boolean} allow_raw_html
|
|
431
|
+
* @param {boolean} code_line_numbers
|
|
432
|
+
* @param {string} image_destination
|
|
433
|
+
* @param {Uint8Array} image_bytes
|
|
434
|
+
* @param {Uint8Array} body_regular
|
|
435
|
+
* @param {Uint8Array} body_bold
|
|
436
|
+
* @param {Uint8Array} body_italic
|
|
437
|
+
* @param {Uint8Array} body_bold_italic
|
|
438
|
+
* @param {Uint8Array} mono_regular
|
|
439
|
+
* @returns {FmdRenderResult}
|
|
440
|
+
*/
|
|
441
|
+
export function renderPdfConfiguredWithAssets(markdown, font, dark_mode, title, author, metadata_epoch_seconds, allow_raw_html, code_line_numbers, image_destination, image_bytes, body_regular, body_bold, body_italic, body_bold_italic, mono_regular) {
|
|
442
|
+
try {
|
|
443
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
444
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
445
|
+
const len0 = WASM_VECTOR_LEN;
|
|
446
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
447
|
+
var len1 = WASM_VECTOR_LEN;
|
|
448
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
449
|
+
var len2 = WASM_VECTOR_LEN;
|
|
450
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
451
|
+
var len3 = WASM_VECTOR_LEN;
|
|
452
|
+
var ptr4 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
453
|
+
var len4 = WASM_VECTOR_LEN;
|
|
454
|
+
const ptr5 = passStringToWasm0(image_destination, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
455
|
+
const len5 = WASM_VECTOR_LEN;
|
|
456
|
+
const ptr6 = passArray8ToWasm0(image_bytes, wasm.__wbindgen_export);
|
|
457
|
+
const len6 = WASM_VECTOR_LEN;
|
|
458
|
+
const ptr7 = passArray8ToWasm0(body_regular, wasm.__wbindgen_export);
|
|
459
|
+
const len7 = WASM_VECTOR_LEN;
|
|
460
|
+
const ptr8 = passArray8ToWasm0(body_bold, wasm.__wbindgen_export);
|
|
461
|
+
const len8 = WASM_VECTOR_LEN;
|
|
462
|
+
const ptr9 = passArray8ToWasm0(body_italic, wasm.__wbindgen_export);
|
|
463
|
+
const len9 = WASM_VECTOR_LEN;
|
|
464
|
+
const ptr10 = passArray8ToWasm0(body_bold_italic, wasm.__wbindgen_export);
|
|
465
|
+
const len10 = WASM_VECTOR_LEN;
|
|
466
|
+
const ptr11 = passArray8ToWasm0(mono_regular, wasm.__wbindgen_export);
|
|
467
|
+
const len11 = WASM_VECTOR_LEN;
|
|
468
|
+
wasm.renderPdfConfiguredWithAssets(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(metadata_epoch_seconds), isLikeNone(metadata_epoch_seconds) ? 0 : metadata_epoch_seconds, allow_raw_html, code_line_numbers, ptr5, len5, ptr6, len6, ptr7, len7, ptr8, len8, ptr9, len9, ptr10, len10, ptr11, len11);
|
|
469
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
470
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
471
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
472
|
+
if (r2) {
|
|
473
|
+
throw takeObject(r1);
|
|
474
|
+
}
|
|
475
|
+
return FmdRenderResult.__wrap(r0);
|
|
476
|
+
} finally {
|
|
477
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Render Markdown to PDF with one browser-supplied image asset.
|
|
483
|
+
*
|
|
484
|
+
* This dependency-free adapter is intentionally narrow: callers pass bytes
|
|
485
|
+
* they already own (for example from a file picker or fetch handled outside
|
|
486
|
+
* the core). The renderer never touches the browser filesystem or network.
|
|
487
|
+
*
|
|
488
|
+
* # Errors
|
|
489
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
490
|
+
* @param {string} markdown
|
|
491
|
+
* @param {string | null | undefined} font
|
|
492
|
+
* @param {string | null | undefined} dark_mode
|
|
493
|
+
* @param {string | null | undefined} title
|
|
494
|
+
* @param {string | null | undefined} author
|
|
495
|
+
* @param {number | null | undefined} metadata_epoch_seconds
|
|
496
|
+
* @param {boolean} allow_raw_html
|
|
497
|
+
* @param {boolean} code_line_numbers
|
|
498
|
+
* @param {string} image_destination
|
|
499
|
+
* @param {Uint8Array} image_bytes
|
|
500
|
+
* @returns {FmdRenderResult}
|
|
501
|
+
*/
|
|
502
|
+
export function renderPdfConfiguredWithImage(markdown, font, dark_mode, title, author, metadata_epoch_seconds, allow_raw_html, code_line_numbers, image_destination, image_bytes) {
|
|
503
|
+
try {
|
|
504
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
505
|
+
const ptr0 = passStringToWasm0(markdown, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
506
|
+
const len0 = WASM_VECTOR_LEN;
|
|
507
|
+
var ptr1 = isLikeNone(font) ? 0 : passStringToWasm0(font, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
508
|
+
var len1 = WASM_VECTOR_LEN;
|
|
509
|
+
var ptr2 = isLikeNone(dark_mode) ? 0 : passStringToWasm0(dark_mode, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
510
|
+
var len2 = WASM_VECTOR_LEN;
|
|
511
|
+
var ptr3 = isLikeNone(title) ? 0 : passStringToWasm0(title, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
512
|
+
var len3 = WASM_VECTOR_LEN;
|
|
513
|
+
var ptr4 = isLikeNone(author) ? 0 : passStringToWasm0(author, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
514
|
+
var len4 = WASM_VECTOR_LEN;
|
|
515
|
+
const ptr5 = passStringToWasm0(image_destination, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
516
|
+
const len5 = WASM_VECTOR_LEN;
|
|
517
|
+
const ptr6 = passArray8ToWasm0(image_bytes, wasm.__wbindgen_export);
|
|
518
|
+
const len6 = WASM_VECTOR_LEN;
|
|
519
|
+
wasm.renderPdfConfiguredWithImage(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, !isLikeNone(metadata_epoch_seconds), isLikeNone(metadata_epoch_seconds) ? 0 : metadata_epoch_seconds, allow_raw_html, code_line_numbers, ptr5, len5, ptr6, len6);
|
|
520
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
521
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
522
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
523
|
+
if (r2) {
|
|
524
|
+
throw takeObject(r1);
|
|
525
|
+
}
|
|
526
|
+
return FmdRenderResult.__wrap(r0);
|
|
527
|
+
} finally {
|
|
528
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function __wbg_get_imports() {
|
|
532
|
+
const import0 = {
|
|
533
|
+
__proto__: null,
|
|
534
|
+
__wbg___wbindgen_string_get_b0ca35b86a603356: function(arg0, arg1) {
|
|
535
|
+
const obj = getObject(arg1);
|
|
536
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
537
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
538
|
+
var len1 = WASM_VECTOR_LEN;
|
|
539
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
540
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
541
|
+
},
|
|
542
|
+
__wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
|
|
543
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
544
|
+
},
|
|
545
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
546
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
547
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
548
|
+
return addHeapObject(ret);
|
|
549
|
+
},
|
|
550
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
551
|
+
takeObject(arg0);
|
|
552
|
+
},
|
|
553
|
+
};
|
|
554
|
+
return {
|
|
555
|
+
__proto__: null,
|
|
556
|
+
"./franken_markdown_bg.js": import0,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const FmdRenderResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
561
|
+
? { register: () => {}, unregister: () => {} }
|
|
562
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_fmdrenderresult_free(ptr, 1));
|
|
563
|
+
|
|
564
|
+
function addHeapObject(obj) {
|
|
565
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
566
|
+
const idx = heap_next;
|
|
567
|
+
heap_next = heap[idx];
|
|
568
|
+
|
|
569
|
+
heap[idx] = obj;
|
|
570
|
+
return idx;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function dropObject(idx) {
|
|
574
|
+
if (idx < 1028) return;
|
|
575
|
+
heap[idx] = heap_next;
|
|
576
|
+
heap_next = idx;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
580
|
+
ptr = ptr >>> 0;
|
|
581
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
let cachedDataViewMemory0 = null;
|
|
585
|
+
function getDataViewMemory0() {
|
|
586
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
587
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
588
|
+
}
|
|
589
|
+
return cachedDataViewMemory0;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
function getStringFromWasm0(ptr, len) {
|
|
593
|
+
return decodeText(ptr >>> 0, len);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
let cachedUint32ArrayMemory0 = null;
|
|
597
|
+
function getUint32ArrayMemory0() {
|
|
598
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
599
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
600
|
+
}
|
|
601
|
+
return cachedUint32ArrayMemory0;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
let cachedUint8ArrayMemory0 = null;
|
|
605
|
+
function getUint8ArrayMemory0() {
|
|
606
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
607
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
608
|
+
}
|
|
609
|
+
return cachedUint8ArrayMemory0;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function getObject(idx) { return heap[idx]; }
|
|
613
|
+
|
|
614
|
+
let heap = new Array(1024).fill(undefined);
|
|
615
|
+
heap.push(undefined, null, true, false);
|
|
616
|
+
|
|
617
|
+
let heap_next = heap.length;
|
|
618
|
+
|
|
619
|
+
function isLikeNone(x) {
|
|
620
|
+
return x === undefined || x === null;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
624
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
625
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
626
|
+
WASM_VECTOR_LEN = arg.length;
|
|
627
|
+
return ptr;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
631
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
632
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
633
|
+
WASM_VECTOR_LEN = arg.length;
|
|
634
|
+
return ptr;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
638
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
639
|
+
const mem = getDataViewMemory0();
|
|
640
|
+
for (let i = 0; i < array.length; i++) {
|
|
641
|
+
mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
|
|
642
|
+
}
|
|
643
|
+
WASM_VECTOR_LEN = array.length;
|
|
644
|
+
return ptr;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
648
|
+
if (realloc === undefined) {
|
|
649
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
650
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
651
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
652
|
+
WASM_VECTOR_LEN = buf.length;
|
|
653
|
+
return ptr;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
let len = arg.length;
|
|
657
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
658
|
+
|
|
659
|
+
const mem = getUint8ArrayMemory0();
|
|
660
|
+
|
|
661
|
+
let offset = 0;
|
|
662
|
+
|
|
663
|
+
for (; offset < len; offset++) {
|
|
664
|
+
const code = arg.charCodeAt(offset);
|
|
665
|
+
if (code > 0x7F) break;
|
|
666
|
+
mem[ptr + offset] = code;
|
|
667
|
+
}
|
|
668
|
+
if (offset !== len) {
|
|
669
|
+
if (offset !== 0) {
|
|
670
|
+
arg = arg.slice(offset);
|
|
671
|
+
}
|
|
672
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
673
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
674
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
675
|
+
|
|
676
|
+
offset += ret.written;
|
|
677
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
WASM_VECTOR_LEN = offset;
|
|
681
|
+
return ptr;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
function takeObject(idx) {
|
|
685
|
+
const ret = getObject(idx);
|
|
686
|
+
dropObject(idx);
|
|
687
|
+
return ret;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
691
|
+
cachedTextDecoder.decode();
|
|
692
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
693
|
+
let numBytesDecoded = 0;
|
|
694
|
+
function decodeText(ptr, len) {
|
|
695
|
+
numBytesDecoded += len;
|
|
696
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
697
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
698
|
+
cachedTextDecoder.decode();
|
|
699
|
+
numBytesDecoded = len;
|
|
700
|
+
}
|
|
701
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
const cachedTextEncoder = new TextEncoder();
|
|
705
|
+
|
|
706
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
707
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
708
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
709
|
+
view.set(buf);
|
|
710
|
+
return {
|
|
711
|
+
read: arg.length,
|
|
712
|
+
written: buf.length
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
let WASM_VECTOR_LEN = 0;
|
|
718
|
+
|
|
719
|
+
let wasmModule, wasmInstance, wasm;
|
|
720
|
+
function __wbg_finalize_init(instance, module) {
|
|
721
|
+
wasmInstance = instance;
|
|
722
|
+
wasm = instance.exports;
|
|
723
|
+
wasmModule = module;
|
|
724
|
+
cachedDataViewMemory0 = null;
|
|
725
|
+
cachedUint32ArrayMemory0 = null;
|
|
726
|
+
cachedUint8ArrayMemory0 = null;
|
|
727
|
+
return wasm;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
async function __wbg_load(module, imports) {
|
|
731
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
732
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
733
|
+
try {
|
|
734
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
735
|
+
} catch (e) {
|
|
736
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
737
|
+
|
|
738
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
739
|
+
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);
|
|
740
|
+
|
|
741
|
+
} else { throw e; }
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
const bytes = await module.arrayBuffer();
|
|
746
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
747
|
+
} else {
|
|
748
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
749
|
+
|
|
750
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
751
|
+
return { instance, module };
|
|
752
|
+
} else {
|
|
753
|
+
return instance;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function expectedResponseType(type) {
|
|
758
|
+
switch (type) {
|
|
759
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
760
|
+
}
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function initSync(module) {
|
|
766
|
+
if (wasm !== undefined) return wasm;
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
if (module !== undefined) {
|
|
770
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
771
|
+
({module} = module)
|
|
772
|
+
} else {
|
|
773
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const imports = __wbg_get_imports();
|
|
778
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
779
|
+
module = new WebAssembly.Module(module);
|
|
780
|
+
}
|
|
781
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
782
|
+
return __wbg_finalize_init(instance, module);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
async function __wbg_init(module_or_path) {
|
|
786
|
+
if (wasm !== undefined) return wasm;
|
|
787
|
+
|
|
788
|
+
|
|
789
|
+
if (module_or_path !== undefined) {
|
|
790
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
791
|
+
({module_or_path} = module_or_path)
|
|
792
|
+
} else {
|
|
793
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if (module_or_path === undefined) {
|
|
798
|
+
module_or_path = new URL('franken_markdown_bg.wasm', import.meta.url);
|
|
799
|
+
}
|
|
800
|
+
const imports = __wbg_get_imports();
|
|
801
|
+
|
|
802
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
803
|
+
module_or_path = fetch(module_or_path);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
807
|
+
|
|
808
|
+
return __wbg_finalize_init(instance, module);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
export { initSync, __wbg_init as default };
|