@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,102 @@
|
|
|
1
|
+
export type FmdOutputFormat = "html" | "pdf";
|
|
2
|
+
export type FmdFont = "sans" | "serif";
|
|
3
|
+
export type FmdDarkMode = "auto" | "disabled";
|
|
4
|
+
|
|
5
|
+
export interface FmdDiagnostic {
|
|
6
|
+
severity: "warning" | "error";
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FmdPdfImageAsset {
|
|
13
|
+
/** Markdown image destination, for example `images/chart.png` from ``. */
|
|
14
|
+
destination: string;
|
|
15
|
+
/** Browser-supplied image bytes. PNG and SVG assets are supported in PDF output. */
|
|
16
|
+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type FmdFontAssetSlot =
|
|
20
|
+
| "body-regular"
|
|
21
|
+
| "body-bold"
|
|
22
|
+
| "body-italic"
|
|
23
|
+
| "body-bold-italic"
|
|
24
|
+
| "mono-regular";
|
|
25
|
+
|
|
26
|
+
export interface FmdFontAsset {
|
|
27
|
+
/** Renderer font slot to replace. Missing slots use bundled deterministic fallback fonts. */
|
|
28
|
+
slot: FmdFontAssetSlot;
|
|
29
|
+
/** Browser-supplied TrueType font bytes. */
|
|
30
|
+
bytes: Uint8Array | ArrayBuffer | ArrayBufferView;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface FmdRenderOptions {
|
|
34
|
+
font?: FmdFont;
|
|
35
|
+
darkMode?: FmdDarkMode;
|
|
36
|
+
title?: string;
|
|
37
|
+
customCss?: string;
|
|
38
|
+
allowRawHtml?: boolean;
|
|
39
|
+
author?: string;
|
|
40
|
+
/** Finite non-negative integer seconds, <= Number.MAX_SAFE_INTEGER. */
|
|
41
|
+
metadataEpochSeconds?: number;
|
|
42
|
+
codeLineNumbers?: boolean;
|
|
43
|
+
/** Host-supplied PDF image bytes; any number of assets may be supplied per render call. */
|
|
44
|
+
pdfImages?: FmdPdfImageAsset[];
|
|
45
|
+
/** Host-supplied TrueType font bytes by renderer slot. */
|
|
46
|
+
fontAssets?: FmdFontAsset[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface FmdRenderOutput {
|
|
50
|
+
format: FmdOutputFormat;
|
|
51
|
+
mimeType: string;
|
|
52
|
+
extension: "html" | "pdf";
|
|
53
|
+
sourceLength: number;
|
|
54
|
+
bytes: Uint8Array;
|
|
55
|
+
diagnostics: FmdDiagnostic[];
|
|
56
|
+
text(): string;
|
|
57
|
+
blob(): Blob;
|
|
58
|
+
filename(baseName?: string): string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface FmdCapabilities {
|
|
62
|
+
schema: "fmd-wasm-capabilities-v1";
|
|
63
|
+
outputs: FmdOutputFormat[];
|
|
64
|
+
input: "markdown_utf8";
|
|
65
|
+
html: {
|
|
66
|
+
mime_type: "text/html; charset=utf-8";
|
|
67
|
+
self_contained: boolean;
|
|
68
|
+
custom_css_utf8: boolean;
|
|
69
|
+
font_assets: "ttf_v0_host_supplied_bytes";
|
|
70
|
+
};
|
|
71
|
+
pdf: {
|
|
72
|
+
mime_type: "application/pdf";
|
|
73
|
+
deterministic_metadata_epoch: boolean;
|
|
74
|
+
image_assets: "png_svg_v0_host_supplied_bytes";
|
|
75
|
+
font_assets: "ttf_v0_host_supplied_bytes";
|
|
76
|
+
};
|
|
77
|
+
diagnostics: {
|
|
78
|
+
source_spans: "byte_offsets";
|
|
79
|
+
json: boolean;
|
|
80
|
+
};
|
|
81
|
+
runtime_assumptions: {
|
|
82
|
+
filesystem: false;
|
|
83
|
+
process: false;
|
|
84
|
+
network: false;
|
|
85
|
+
threads: false;
|
|
86
|
+
};
|
|
87
|
+
theme: unknown;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface FmdRenderer {
|
|
91
|
+
capabilities(): Promise<FmdCapabilities>;
|
|
92
|
+
renderHtml(markdown: string, options?: FmdRenderOptions): Promise<FmdRenderOutput>;
|
|
93
|
+
renderPdf(markdown: string, options?: FmdRenderOptions): Promise<FmdRenderOutput>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function init(input?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module): Promise<void>;
|
|
97
|
+
export function capabilities(): Promise<FmdCapabilities>;
|
|
98
|
+
export function renderHtml(markdown: string, options?: FmdRenderOptions): Promise<FmdRenderOutput>;
|
|
99
|
+
export function renderPdf(markdown: string, options?: FmdRenderOptions): Promise<FmdRenderOutput>;
|
|
100
|
+
export function createRenderer(
|
|
101
|
+
input?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module
|
|
102
|
+
): Promise<FmdRenderer>;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import initWasm, {
|
|
2
|
+
capabilities as wasmCapabilities,
|
|
3
|
+
renderHtmlConfigured,
|
|
4
|
+
renderHtmlConfiguredWithFonts,
|
|
5
|
+
renderPdfConfiguredMulti
|
|
6
|
+
} from "./pkg/franken_markdown.js";
|
|
7
|
+
|
|
8
|
+
let initPromise = null;
|
|
9
|
+
|
|
10
|
+
export async function init(input) {
|
|
11
|
+
if (initPromise === null) {
|
|
12
|
+
initPromise = input === undefined ? initWasm() : initWasm({ module_or_path: input });
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
await initPromise;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
initPromise = null;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function capabilities() {
|
|
23
|
+
await init();
|
|
24
|
+
return parseJson(wasmCapabilities(), "capabilities JSON");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function renderHtml(markdown, options = {}) {
|
|
28
|
+
await init();
|
|
29
|
+
const fontAssets = fontAssetsOption(options.fontAssets);
|
|
30
|
+
if (fontAssets.length > 0) {
|
|
31
|
+
return normalizeResult(
|
|
32
|
+
renderHtmlConfiguredWithFonts(
|
|
33
|
+
String(markdown),
|
|
34
|
+
stringOption(options.font),
|
|
35
|
+
darkModeOption(options.darkMode),
|
|
36
|
+
verbatimOption(options.title),
|
|
37
|
+
verbatimOption(options.customCss),
|
|
38
|
+
Boolean(options.allowRawHtml),
|
|
39
|
+
fontBytesForSlot(fontAssets, "body-regular"),
|
|
40
|
+
fontBytesForSlot(fontAssets, "body-bold"),
|
|
41
|
+
fontBytesForSlot(fontAssets, "body-italic"),
|
|
42
|
+
fontBytesForSlot(fontAssets, "body-bold-italic"),
|
|
43
|
+
fontBytesForSlot(fontAssets, "mono-regular")
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return normalizeResult(
|
|
48
|
+
renderHtmlConfigured(
|
|
49
|
+
String(markdown),
|
|
50
|
+
stringOption(options.font),
|
|
51
|
+
darkModeOption(options.darkMode),
|
|
52
|
+
verbatimOption(options.title),
|
|
53
|
+
verbatimOption(options.customCss),
|
|
54
|
+
Boolean(options.allowRawHtml)
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function renderPdf(markdown, options = {}) {
|
|
60
|
+
await init();
|
|
61
|
+
const pdfImages = pdfImagesOption(options.pdfImages);
|
|
62
|
+
const fontAssets = fontAssetsOption(options.fontAssets);
|
|
63
|
+
|
|
64
|
+
// Flatten any number of images into the three parallel arrays the core ABI
|
|
65
|
+
// accepts (wasm-bindgen cannot pass a Vec<Vec<u8>>): a destination per image,
|
|
66
|
+
// all image bytes concatenated, and each image's byte length.
|
|
67
|
+
const destinations = pdfImages.map((image) => image.destination);
|
|
68
|
+
const lengths = new Uint32Array(pdfImages.map((image) => image.bytes.length));
|
|
69
|
+
const totalBytes = pdfImages.reduce((sum, image) => sum + image.bytes.length, 0);
|
|
70
|
+
const flatBytes = new Uint8Array(totalBytes);
|
|
71
|
+
let offset = 0;
|
|
72
|
+
for (const image of pdfImages) {
|
|
73
|
+
flatBytes.set(image.bytes, offset);
|
|
74
|
+
offset += image.bytes.length;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return normalizeResult(
|
|
78
|
+
renderPdfConfiguredMulti(
|
|
79
|
+
String(markdown),
|
|
80
|
+
stringOption(options.font),
|
|
81
|
+
darkModeOption(options.darkMode),
|
|
82
|
+
verbatimOption(options.title),
|
|
83
|
+
verbatimOption(options.author),
|
|
84
|
+
epochOption(options.metadataEpochSeconds),
|
|
85
|
+
Boolean(options.allowRawHtml),
|
|
86
|
+
Boolean(options.codeLineNumbers),
|
|
87
|
+
destinations,
|
|
88
|
+
flatBytes,
|
|
89
|
+
lengths,
|
|
90
|
+
fontBytesForSlot(fontAssets, "body-regular"),
|
|
91
|
+
fontBytesForSlot(fontAssets, "body-bold"),
|
|
92
|
+
fontBytesForSlot(fontAssets, "body-italic"),
|
|
93
|
+
fontBytesForSlot(fontAssets, "body-bold-italic"),
|
|
94
|
+
fontBytesForSlot(fontAssets, "mono-regular")
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export async function createRenderer(input) {
|
|
100
|
+
await init(input);
|
|
101
|
+
return Object.freeze({
|
|
102
|
+
capabilities,
|
|
103
|
+
renderHtml,
|
|
104
|
+
renderPdf
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function normalizeResult(result) {
|
|
109
|
+
let bytes;
|
|
110
|
+
let diagnostics;
|
|
111
|
+
let format;
|
|
112
|
+
let mimeType;
|
|
113
|
+
let extension;
|
|
114
|
+
let sourceLength;
|
|
115
|
+
try {
|
|
116
|
+
bytes = result.bytes;
|
|
117
|
+
diagnostics = parseDiagnostics(result.diagnosticsJson());
|
|
118
|
+
format = result.format;
|
|
119
|
+
mimeType = result.mimeType;
|
|
120
|
+
extension = result.extension;
|
|
121
|
+
sourceLength = result.sourceLength;
|
|
122
|
+
} finally {
|
|
123
|
+
if (typeof result.free === "function") {
|
|
124
|
+
result.free();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const output = {
|
|
128
|
+
format,
|
|
129
|
+
mimeType,
|
|
130
|
+
extension,
|
|
131
|
+
sourceLength,
|
|
132
|
+
bytes,
|
|
133
|
+
diagnostics,
|
|
134
|
+
text() {
|
|
135
|
+
return new TextDecoder().decode(bytes);
|
|
136
|
+
},
|
|
137
|
+
blob() {
|
|
138
|
+
if (typeof Blob === "undefined") {
|
|
139
|
+
throw new Error("Blob is not available in this JavaScript runtime");
|
|
140
|
+
}
|
|
141
|
+
return new Blob([bytes], { type: output.mimeType });
|
|
142
|
+
},
|
|
143
|
+
filename(baseName = "document") {
|
|
144
|
+
const cleanBase = String(baseName).trim() || "document";
|
|
145
|
+
return `${cleanBase}.${output.extension}`;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return Object.freeze(output);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function parseDiagnostics(json) {
|
|
152
|
+
if (json === "") {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
return parseJson(json, "diagnostics JSON");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseJson(json, label) {
|
|
159
|
+
try {
|
|
160
|
+
return JSON.parse(json);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
throw new Error(`Invalid ${label} returned by franken_markdown wasm core: ${error.message}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function stringOption(value) {
|
|
167
|
+
if (value === undefined || value === null) {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
const text = String(value).trim();
|
|
171
|
+
return text === "" ? undefined : text;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Preserve a caller value VERBATIM (including surrounding whitespace), mapping
|
|
175
|
+
// only null/undefined/"" to `undefined`. Mirrors the Rust ABI's
|
|
176
|
+
// `nonempty_verbatim` so title/author/customCss reach the renderer byte-for-byte
|
|
177
|
+
// identical to the native CLI (native never trims them). `stringOption` (which
|
|
178
|
+
// trims) is kept only for the enum-like `font` value.
|
|
179
|
+
function verbatimOption(value) {
|
|
180
|
+
if (value === undefined || value === null) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const text = String(value);
|
|
184
|
+
return text === "" ? undefined : text;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function darkModeOption(value) {
|
|
188
|
+
if (value === undefined || value === null) {
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
const text = String(value).trim().toLowerCase();
|
|
192
|
+
if (text === "" || text === "auto" || text === "system") {
|
|
193
|
+
return text === "system" ? "auto" : text || undefined;
|
|
194
|
+
}
|
|
195
|
+
if (text === "disabled" || text === "disable" || text === "off" || text === "light") {
|
|
196
|
+
return "disabled";
|
|
197
|
+
}
|
|
198
|
+
throw new TypeError("darkMode must be 'auto' or 'disabled'");
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function epochOption(value) {
|
|
202
|
+
if (value === undefined || value === null) {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
const epoch = value;
|
|
206
|
+
if (typeof epoch !== "number") {
|
|
207
|
+
throw new TypeError("metadataEpochSeconds must be a number");
|
|
208
|
+
}
|
|
209
|
+
if (!Number.isSafeInteger(epoch) || epoch < 0) {
|
|
210
|
+
throw new TypeError(
|
|
211
|
+
"metadataEpochSeconds must be a finite non-negative integer <= Number.MAX_SAFE_INTEGER"
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
return epoch;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function pdfImagesOption(value) {
|
|
218
|
+
if (value === undefined || value === null) {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
if (!Array.isArray(value)) {
|
|
222
|
+
throw new TypeError("pdfImages must be an array of { destination, bytes } objects");
|
|
223
|
+
}
|
|
224
|
+
return value.map((asset, index) => {
|
|
225
|
+
if (asset === null || typeof asset !== "object") {
|
|
226
|
+
throw new TypeError(`pdfImages[${index}] must be an object`);
|
|
227
|
+
}
|
|
228
|
+
const destination = stringOption(asset.destination);
|
|
229
|
+
if (destination === undefined) {
|
|
230
|
+
throw new TypeError(`pdfImages[${index}].destination must be a non-empty string`);
|
|
231
|
+
}
|
|
232
|
+
const bytes = bytesOption(asset.bytes, `pdfImages[${index}].bytes`);
|
|
233
|
+
return Object.freeze({ destination, bytes });
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function fontAssetsOption(value) {
|
|
238
|
+
if (value === undefined || value === null) {
|
|
239
|
+
return [];
|
|
240
|
+
}
|
|
241
|
+
if (!Array.isArray(value)) {
|
|
242
|
+
throw new TypeError("fontAssets must be an array of { slot, bytes } objects");
|
|
243
|
+
}
|
|
244
|
+
const seen = new Set();
|
|
245
|
+
return value.map((asset, index) => {
|
|
246
|
+
if (asset === null || typeof asset !== "object") {
|
|
247
|
+
throw new TypeError(`fontAssets[${index}] must be an object`);
|
|
248
|
+
}
|
|
249
|
+
const slot = fontSlotOption(asset.slot, `fontAssets[${index}].slot`);
|
|
250
|
+
if (seen.has(slot)) {
|
|
251
|
+
throw new TypeError(`fontAssets contains duplicate slot ${slot}`);
|
|
252
|
+
}
|
|
253
|
+
seen.add(slot);
|
|
254
|
+
const bytes = bytesOption(asset.bytes, `fontAssets[${index}].bytes`);
|
|
255
|
+
if (bytes.byteLength === 0) {
|
|
256
|
+
throw new TypeError(`fontAssets[${index}].bytes must not be empty`);
|
|
257
|
+
}
|
|
258
|
+
return Object.freeze({ slot, bytes });
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function fontSlotOption(value, label) {
|
|
263
|
+
const slot = stringOption(value);
|
|
264
|
+
const allowed = new Set([
|
|
265
|
+
"body-regular",
|
|
266
|
+
"body-bold",
|
|
267
|
+
"body-italic",
|
|
268
|
+
"body-bold-italic",
|
|
269
|
+
"mono-regular"
|
|
270
|
+
]);
|
|
271
|
+
if (slot === undefined || !allowed.has(slot)) {
|
|
272
|
+
throw new TypeError(
|
|
273
|
+
`${label} must be one of body-regular, body-bold, body-italic, body-bold-italic, mono-regular`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return slot;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function fontBytesForSlot(assets, slot) {
|
|
280
|
+
const asset = assets.find((entry) => entry.slot === slot);
|
|
281
|
+
return asset === undefined ? new Uint8Array() : asset.bytes;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function bytesOption(value, label) {
|
|
285
|
+
if (value instanceof Uint8Array) {
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
if (value instanceof ArrayBuffer) {
|
|
289
|
+
return new Uint8Array(value);
|
|
290
|
+
}
|
|
291
|
+
if (ArrayBuffer.isView(value)) {
|
|
292
|
+
return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
293
|
+
}
|
|
294
|
+
throw new TypeError(`${label} must be a Uint8Array, ArrayBuffer, or typed-array view`);
|
|
295
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@franken-suite/franken-markdown",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Browser/WASM package for franken_markdown Markdown to HTML/PDF rendering.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"license": "LicenseRef-MIT-OpenAI-Anthropic-Rider",
|
|
8
|
+
"author": "Jeffrey Emanuel",
|
|
9
|
+
"homepage": "https://github.com/Dicklesworthstone/franken_markdown#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Dicklesworthstone/franken_markdown.git",
|
|
13
|
+
"directory": "wasm"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Dicklesworthstone/franken_markdown/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"markdown",
|
|
20
|
+
"pdf",
|
|
21
|
+
"html",
|
|
22
|
+
"renderer",
|
|
23
|
+
"wasm",
|
|
24
|
+
"webassembly",
|
|
25
|
+
"typesetting"
|
|
26
|
+
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public",
|
|
32
|
+
"provenance": true
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./franken_markdown.d.ts",
|
|
37
|
+
"import": "./franken_markdown.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"franken_markdown.js",
|
|
42
|
+
"franken_markdown.d.ts",
|
|
43
|
+
"demo/index.html",
|
|
44
|
+
"demo/demo.js",
|
|
45
|
+
"pkg/franken_markdown.js",
|
|
46
|
+
"pkg/franken_markdown_bg.wasm",
|
|
47
|
+
"pkg/franken_markdown_bg.wasm.d.ts",
|
|
48
|
+
"pkg/franken_markdown.d.ts"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Render output object exposed to JavaScript.
|
|
6
|
+
*/
|
|
7
|
+
export class FmdRenderResult {
|
|
8
|
+
private constructor();
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* Recoverable parser diagnostics as stable JSON.
|
|
13
|
+
*/
|
|
14
|
+
diagnosticsJson(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Rendered output bytes. HTML is UTF-8; PDF is binary.
|
|
17
|
+
*/
|
|
18
|
+
readonly bytes: Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Default file extension without a leading dot.
|
|
21
|
+
*/
|
|
22
|
+
readonly extension: string;
|
|
23
|
+
/**
|
|
24
|
+
* Stable output format: `html` or `pdf`.
|
|
25
|
+
*/
|
|
26
|
+
readonly format: string;
|
|
27
|
+
/**
|
|
28
|
+
* Browser MIME type for Blob construction.
|
|
29
|
+
*/
|
|
30
|
+
readonly mimeType: string;
|
|
31
|
+
/**
|
|
32
|
+
* Source size in bytes.
|
|
33
|
+
*/
|
|
34
|
+
readonly sourceLength: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Dependency-free capability contract as JSON.
|
|
39
|
+
*/
|
|
40
|
+
export function capabilities(): string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Render Markdown to self-contained HTML using default browser-safe options.
|
|
44
|
+
*
|
|
45
|
+
* # Errors
|
|
46
|
+
* Returns a JavaScript error when rendering fails.
|
|
47
|
+
*/
|
|
48
|
+
export function renderHtml(markdown: string): FmdRenderResult;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Render Markdown to self-contained HTML with browser package options.
|
|
52
|
+
*
|
|
53
|
+
* # Errors
|
|
54
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
55
|
+
*/
|
|
56
|
+
export function renderHtmlConfigured(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, custom_css: string | null | undefined, allow_raw_html: boolean): FmdRenderResult;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Render Markdown to self-contained HTML with browser package options and
|
|
60
|
+
* caller-supplied font bytes.
|
|
61
|
+
*
|
|
62
|
+
* Empty byte arrays mean "use bundled fallback" for that slot.
|
|
63
|
+
*
|
|
64
|
+
* # Errors
|
|
65
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
66
|
+
*/
|
|
67
|
+
export function renderHtmlConfiguredWithFonts(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, custom_css: string | null | undefined, allow_raw_html: boolean, body_regular: Uint8Array, body_bold: Uint8Array, body_italic: Uint8Array, body_bold_italic: Uint8Array, mono_regular: Uint8Array): FmdRenderResult;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Render Markdown to PDF using default browser-safe options.
|
|
71
|
+
*
|
|
72
|
+
* # Errors
|
|
73
|
+
* Returns a JavaScript error when rendering fails.
|
|
74
|
+
*/
|
|
75
|
+
export function renderPdf(markdown: string): FmdRenderResult;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Render Markdown to PDF with browser package options.
|
|
79
|
+
*
|
|
80
|
+
* # Errors
|
|
81
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
82
|
+
*/
|
|
83
|
+
export function renderPdfConfigured(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, author: string | null | undefined, metadata_epoch_seconds: number | null | undefined, allow_raw_html: boolean, code_line_numbers: boolean): FmdRenderResult;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Render Markdown to PDF with browser package options, ANY number of image
|
|
87
|
+
* assets, and caller-supplied font bytes. This is the general form the JS
|
|
88
|
+
* wrapper uses so multi-image documents reach native↔WASM parity (the
|
|
89
|
+
* single-image entry points above remain for a narrower ABI).
|
|
90
|
+
*
|
|
91
|
+
* Images arrive as three parallel arrays — a destination per image, all image
|
|
92
|
+
* bytes concatenated, and the byte length of each image — because wasm-bindgen
|
|
93
|
+
* cannot pass a `Vec<Vec<u8>>` directly. Empty font byte arrays mean "use
|
|
94
|
+
* bundled fallback" for that slot.
|
|
95
|
+
*
|
|
96
|
+
* # Errors
|
|
97
|
+
* Returns a JavaScript error when the image arrays are inconsistent, an option
|
|
98
|
+
* is invalid, or rendering fails.
|
|
99
|
+
*/
|
|
100
|
+
export function renderPdfConfiguredMulti(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, author: string | null | undefined, metadata_epoch_seconds: number | null | undefined, allow_raw_html: boolean, code_line_numbers: boolean, image_destinations: string[], image_bytes_flat: Uint8Array, image_bytes_lengths: Uint32Array, body_regular: Uint8Array, body_bold: Uint8Array, body_italic: Uint8Array, body_bold_italic: Uint8Array, mono_regular: Uint8Array): FmdRenderResult;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Render Markdown to PDF with browser package options, one optional image
|
|
104
|
+
* asset, and caller-supplied font bytes.
|
|
105
|
+
*
|
|
106
|
+
* Empty image destination/bytes means "no image asset"; empty font byte arrays
|
|
107
|
+
* mean "use bundled fallback" for that slot.
|
|
108
|
+
*
|
|
109
|
+
* # Errors
|
|
110
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
111
|
+
*/
|
|
112
|
+
export function renderPdfConfiguredWithAssets(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, author: string | null | undefined, metadata_epoch_seconds: number | null | undefined, allow_raw_html: boolean, code_line_numbers: boolean, image_destination: string, image_bytes: Uint8Array, body_regular: Uint8Array, body_bold: Uint8Array, body_italic: Uint8Array, body_bold_italic: Uint8Array, mono_regular: Uint8Array): FmdRenderResult;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Render Markdown to PDF with one browser-supplied image asset.
|
|
116
|
+
*
|
|
117
|
+
* This dependency-free adapter is intentionally narrow: callers pass bytes
|
|
118
|
+
* they already own (for example from a file picker or fetch handled outside
|
|
119
|
+
* the core). The renderer never touches the browser filesystem or network.
|
|
120
|
+
*
|
|
121
|
+
* # Errors
|
|
122
|
+
* Returns a JavaScript error when options are invalid or rendering fails.
|
|
123
|
+
*/
|
|
124
|
+
export function renderPdfConfiguredWithImage(markdown: string, font: string | null | undefined, dark_mode: string | null | undefined, title: string | null | undefined, author: string | null | undefined, metadata_epoch_seconds: number | null | undefined, allow_raw_html: boolean, code_line_numbers: boolean, image_destination: string, image_bytes: Uint8Array): FmdRenderResult;
|
|
125
|
+
|
|
126
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
127
|
+
|
|
128
|
+
export interface InitOutput {
|
|
129
|
+
readonly memory: WebAssembly.Memory;
|
|
130
|
+
readonly __wbg_fmdrenderresult_free: (a: number, b: number) => void;
|
|
131
|
+
readonly capabilities: (a: number) => void;
|
|
132
|
+
readonly fmdrenderresult_bytes: (a: number, b: number) => void;
|
|
133
|
+
readonly fmdrenderresult_diagnosticsJson: (a: number, b: number) => void;
|
|
134
|
+
readonly fmdrenderresult_extension: (a: number, b: number) => void;
|
|
135
|
+
readonly fmdrenderresult_format: (a: number, b: number) => void;
|
|
136
|
+
readonly fmdrenderresult_mimeType: (a: number, b: number) => void;
|
|
137
|
+
readonly fmdrenderresult_sourceLength: (a: number) => number;
|
|
138
|
+
readonly renderHtml: (a: number, b: number, c: number) => void;
|
|
139
|
+
readonly renderHtmlConfigured: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
|
|
140
|
+
readonly renderHtmlConfiguredWithFonts: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number) => void;
|
|
141
|
+
readonly renderPdf: (a: number, b: number, c: number) => void;
|
|
142
|
+
readonly renderPdfConfigured: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number) => void;
|
|
143
|
+
readonly renderPdfConfiguredMulti: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number, d1: number, e1: number) => void;
|
|
144
|
+
readonly renderPdfConfiguredWithAssets: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number, c1: number) => void;
|
|
145
|
+
readonly renderPdfConfiguredWithImage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number) => void;
|
|
146
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
147
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
148
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
149
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
156
|
+
* a precompiled `WebAssembly.Module`.
|
|
157
|
+
*
|
|
158
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
159
|
+
*
|
|
160
|
+
* @returns {InitOutput}
|
|
161
|
+
*/
|
|
162
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
166
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
167
|
+
*
|
|
168
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
169
|
+
*
|
|
170
|
+
* @returns {Promise<InitOutput>}
|
|
171
|
+
*/
|
|
172
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|