@kakemono/wasm 0.0.0-stage → 0.22.3
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 +34 -2
- package/package.json +47 -4
- package/pkg/node/index.d.mts +171 -0
- package/pkg/node/index.mjs +4 -0
- package/pkg/node/kakemono_wasm.d.ts +169 -0
- package/pkg/node/kakemono_wasm.js +509 -0
- package/pkg/node/kakemono_wasm_bg.wasm +0 -0
- package/pkg/node/kakemono_wasm_bg.wasm.d.ts +31 -0
- package/pkg/node/package.json +1 -0
- package/pkg/web/kakemono_wasm.d.ts +225 -0
- package/pkg/web/kakemono_wasm.js +612 -0
- package/pkg/web/kakemono_wasm_bg.wasm +0 -0
- package/pkg/web/kakemono_wasm_bg.wasm.d.ts +31 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/** Options of reading and analysing a document, kept for every output. */
|
|
5
|
+
export interface OpenOptions {
|
|
6
|
+
/** The name recorded as the document's source (nothing by default). */
|
|
7
|
+
sourceName?: string
|
|
8
|
+
/** Rebuild tables as real tables when their grid is clear (default true). */
|
|
9
|
+
tables?: boolean
|
|
10
|
+
/** How hard PNG pictures are compressed; the pixels are the same. */
|
|
11
|
+
pngCompression?: 'fast' | 'balanced' | 'high'
|
|
12
|
+
/** An edited copy of the output of `toJson()` (its text, or the parsed object): every output shows its text. */
|
|
13
|
+
content?: string | object
|
|
14
|
+
/** The header rows of every table of an Excel workbook, given instead of found. */
|
|
15
|
+
headerRows?: number
|
|
16
|
+
}
|
|
17
|
+
type Equations = 'mathml' | 'image'
|
|
18
|
+
/** Options of the HTML output. */
|
|
19
|
+
export interface HtmlOptions {
|
|
20
|
+
mode?: 'hard' | 'hard-95' | 'medium' | 'friendly'
|
|
21
|
+
equations?: Equations
|
|
22
|
+
/** Pixels per PDF point of the pictures, above 0.2 and at most 8 (default 3). */
|
|
23
|
+
scale?: number
|
|
24
|
+
pageImage?: 'svg' | 'svg-only' | 'png'
|
|
25
|
+
embedFonts?: boolean
|
|
26
|
+
/** Pictures as data URIs in the page (default true); otherwise as `files`. */
|
|
27
|
+
inlineImages?: boolean
|
|
28
|
+
imageDir?: string
|
|
29
|
+
}
|
|
30
|
+
/** Options of the Markdown output. */
|
|
31
|
+
export interface MarkdownOptions {
|
|
32
|
+
mode?: 'medium' | 'friendly'
|
|
33
|
+
equations?: Equations
|
|
34
|
+
scale?: number
|
|
35
|
+
/** The folder of the picture files, relative (default 'images'). */
|
|
36
|
+
imageDir?: string
|
|
37
|
+
inlineImages?: boolean
|
|
38
|
+
}
|
|
39
|
+
/** Options of the editable JSON output. */
|
|
40
|
+
export interface JsonOptions { equations?: Equations; scale?: number; imageDir?: string; inlineImages?: boolean }
|
|
41
|
+
/** Options of the LaTeX output. */
|
|
42
|
+
export interface LatexOptions { equations?: Equations; scale?: number; imageDir?: string }
|
|
43
|
+
/** Options of the Typst output. */
|
|
44
|
+
export interface TypstOptions { equations?: Equations; scale?: number; imageDir?: string; layout?: 'auto' | 'article' | 'book' }
|
|
45
|
+
/** Options of the Word output: with `imageDir`, its pictures are files too. */
|
|
46
|
+
export interface DocxOptions { equations?: Equations; scale?: number; imageDir?: string }
|
|
47
|
+
/** Options of the EPUB output. */
|
|
48
|
+
export interface EpubOptions {
|
|
49
|
+
equations?: Equations
|
|
50
|
+
scale?: number
|
|
51
|
+
maxMathWidthEm?: number
|
|
52
|
+
cover?: boolean
|
|
53
|
+
/** The book's date, `CCYY-MM-DDThh:mm:ssZ` (default: a fixed date). */
|
|
54
|
+
modified?: string
|
|
55
|
+
}
|
|
56
|
+
/** Options of the chunks for retrieval (tokens are estimated). */
|
|
57
|
+
export interface ChunkOptions { maxTokens?: number }
|
|
58
|
+
/** A picture file of an output, at a path relative to the output's folder. */
|
|
59
|
+
export interface OutputFile { path: string; data: Uint8Array }
|
|
60
|
+
/** A text output and its picture files. */
|
|
61
|
+
export interface TextOutput { text: string; files: OutputFile[] }
|
|
62
|
+
/** A binary output (Word document, EPUB book, PDF) and its picture files. */
|
|
63
|
+
export interface BinaryOutput { data: Uint8Array; files: OutputFile[] }
|
|
64
|
+
/** A chunk for retrieval. */
|
|
65
|
+
export interface Chunk {
|
|
66
|
+
id: number
|
|
67
|
+
/** The text to embed: the section path, a blank line, then the text. */
|
|
68
|
+
text: string
|
|
69
|
+
tokens: number
|
|
70
|
+
title?: string
|
|
71
|
+
section: string[]
|
|
72
|
+
blocks: number[]
|
|
73
|
+
/** The pages it comes from, from 0 (`[0]` for documents without pages). */
|
|
74
|
+
pages: number[]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A PDF, Word document, Excel workbook, EPUB book or web page, read and
|
|
81
|
+
* analysed once: every output written from it shares that analysis.
|
|
82
|
+
*/
|
|
83
|
+
export class Document {
|
|
84
|
+
private constructor();
|
|
85
|
+
free(): void;
|
|
86
|
+
[Symbol.dispose](): void;
|
|
87
|
+
/**
|
|
88
|
+
* The structure of the document (its blocks in reading order), as the
|
|
89
|
+
* command line's `--json` writes it.
|
|
90
|
+
*/
|
|
91
|
+
analyze(): any;
|
|
92
|
+
/**
|
|
93
|
+
* Reads and analyses the bytes of a document (a PDF, a Word document,
|
|
94
|
+
* an Excel workbook, an EPUB book or a web page).
|
|
95
|
+
*/
|
|
96
|
+
static fromBytes(data: Uint8Array | number[], opts: OpenOptions): Document;
|
|
97
|
+
/**
|
|
98
|
+
* Chunks for retrieval (RAG), cut at sentence ends and headed by their
|
|
99
|
+
* section.
|
|
100
|
+
*/
|
|
101
|
+
toChunks(opts: ChunkOptions): Chunk[];
|
|
102
|
+
/**
|
|
103
|
+
* A Word document (`.docx`).
|
|
104
|
+
*/
|
|
105
|
+
toDocx(opts: DocxOptions): BinaryOutput;
|
|
106
|
+
/**
|
|
107
|
+
* An EPUB 3 book.
|
|
108
|
+
*/
|
|
109
|
+
toEpub(opts: EpubOptions): BinaryOutput;
|
|
110
|
+
/**
|
|
111
|
+
* An HTML page; its pictures are inline unless `inlineImages` is false.
|
|
112
|
+
*/
|
|
113
|
+
toHtml(opts: HtmlOptions): TextOutput;
|
|
114
|
+
/**
|
|
115
|
+
* The editable JSON and its picture files.
|
|
116
|
+
*/
|
|
117
|
+
toJson(opts: JsonOptions): TextOutput;
|
|
118
|
+
/**
|
|
119
|
+
* LaTeX source and its picture files.
|
|
120
|
+
*/
|
|
121
|
+
toLatex(opts: LatexOptions): TextOutput;
|
|
122
|
+
/**
|
|
123
|
+
* Markdown and its picture files.
|
|
124
|
+
*/
|
|
125
|
+
toMarkdown(opts: MarkdownOptions): TextOutput;
|
|
126
|
+
/**
|
|
127
|
+
* A Word document, workbook or EPUB book laid out in pages, as a PDF.
|
|
128
|
+
*/
|
|
129
|
+
toPdf(): BinaryOutput;
|
|
130
|
+
/**
|
|
131
|
+
* Typst source and its picture files.
|
|
132
|
+
*/
|
|
133
|
+
toTypst(opts: TypstOptions): TextOutput;
|
|
134
|
+
/**
|
|
135
|
+
* The input format: `'pdf'`, `'docx'`, `'doc'`, `'xlsx'`, `'epub'` or
|
|
136
|
+
* `'html'`.
|
|
137
|
+
*/
|
|
138
|
+
readonly format: string;
|
|
139
|
+
/**
|
|
140
|
+
* The number of pages of a PDF (0 for the formats that have none).
|
|
141
|
+
*/
|
|
142
|
+
readonly pageCount: number;
|
|
143
|
+
/**
|
|
144
|
+
* The title of the document, when it has one.
|
|
145
|
+
*/
|
|
146
|
+
readonly title: string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* The warnings of applying `content`: blocks that kept their own text.
|
|
149
|
+
*/
|
|
150
|
+
readonly warnings: string[];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Adds a TrueType or OpenType font (or a collection) to those documents
|
|
155
|
+
* are laid out and SVG text drawn with: WebAssembly has no installed
|
|
156
|
+
* fonts, and laying out a Word document or a workbook as a PDF needs one.
|
|
157
|
+
* Returns its number of faces.
|
|
158
|
+
*/
|
|
159
|
+
export function addFont(data: Uint8Array | number[]): number;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Logs a panic's message to `console.error` before the module aborts.
|
|
163
|
+
*/
|
|
164
|
+
export function start(): void;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The version of kakemono.
|
|
168
|
+
*/
|
|
169
|
+
export function version(): string;
|
|
170
|
+
|
|
171
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
172
|
+
|
|
173
|
+
export interface InitOutput {
|
|
174
|
+
readonly memory: WebAssembly.Memory;
|
|
175
|
+
readonly __wbg_document_free: (a: number, b: number) => void;
|
|
176
|
+
readonly addFont: (a: number, b: number) => [number, number, number];
|
|
177
|
+
readonly document_analyze: (a: number) => [number, number, number];
|
|
178
|
+
readonly document_format: (a: number) => [number, number];
|
|
179
|
+
readonly document_fromBytes: (a: number, b: number, c: any) => [number, number, number];
|
|
180
|
+
readonly document_pageCount: (a: number) => number;
|
|
181
|
+
readonly document_title: (a: number) => [number, number];
|
|
182
|
+
readonly document_toChunks: (a: number, b: any) => [number, number, number];
|
|
183
|
+
readonly document_toDocx: (a: number, b: any) => [number, number, number];
|
|
184
|
+
readonly document_toEpub: (a: number, b: any) => [number, number, number];
|
|
185
|
+
readonly document_toHtml: (a: number, b: any) => [number, number, number];
|
|
186
|
+
readonly document_toJson: (a: number, b: any) => [number, number, number];
|
|
187
|
+
readonly document_toLatex: (a: number, b: any) => [number, number, number];
|
|
188
|
+
readonly document_toMarkdown: (a: number, b: any) => [number, number, number];
|
|
189
|
+
readonly document_toPdf: (a: number) => [number, number, number];
|
|
190
|
+
readonly document_toTypst: (a: number, b: any) => [number, number, number];
|
|
191
|
+
readonly document_warnings: (a: number) => [number, number];
|
|
192
|
+
readonly start: () => void;
|
|
193
|
+
readonly version: () => [number, number];
|
|
194
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
195
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
196
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
197
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
198
|
+
readonly __externref_table_alloc: () => number;
|
|
199
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
200
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
201
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
202
|
+
readonly __wbindgen_start: () => void;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
209
|
+
* a precompiled `WebAssembly.Module`.
|
|
210
|
+
*
|
|
211
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
212
|
+
*
|
|
213
|
+
* @returns {InitOutput}
|
|
214
|
+
*/
|
|
215
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
219
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
220
|
+
*
|
|
221
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
222
|
+
*
|
|
223
|
+
* @returns {Promise<InitOutput>}
|
|
224
|
+
*/
|
|
225
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|