@zonks/wasm 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +205 -2
- package/THIRD_PARTY_NOTICES.md +156 -0
- package/fonts/GPL-2 +339 -0
- package/fonts/LICENSE +102 -0
- package/fonts/LiberationMono-Bold.ttf +0 -0
- package/fonts/LiberationMono-BoldItalic.ttf +0 -0
- package/fonts/LiberationMono-Italic.ttf +0 -0
- package/fonts/LiberationMono.ttf +0 -0
- package/fonts/LiberationSans-Bold.ttf +0 -0
- package/fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/fonts/LiberationSans-Italic.ttf +0 -0
- package/fonts/LiberationSans.ttf +0 -0
- package/fonts/LiberationSerif-Bold.ttf +0 -0
- package/fonts/LiberationSerif-BoldItalic.ttf +0 -0
- package/fonts/LiberationSerif-Italic.ttf +0 -0
- package/fonts/LiberationSerif-Regular.COPYRIGHT +73 -0
- package/fonts/LiberationSerif.ttf +0 -0
- package/fonts/NotoEmoji-Regular.ttf +0 -0
- package/fonts/NotoSans-Regular.ttf +0 -0
- package/fonts/NotoSansCJKsc-Regular.otf +0 -0
- package/fonts/NotoSansMath-Regular.ttf +0 -0
- package/fonts/NotoSansSymbols-Regular.ttf +0 -0
- package/fonts/NotoSansSymbols2-Regular.ttf +0 -0
- package/fonts/OFL-NotoEmoji.txt +93 -0
- package/fonts/OFL-NotoSans.txt +93 -0
- package/fonts/OFL-NotoSansCJK.txt +94 -0
- package/fonts/OFL-NotoSansMath.txt +93 -0
- package/fonts/OFL-NotoSansSymbols.txt +93 -0
- package/fonts/OFL-NotoSansSymbols2.txt +93 -0
- package/fonts/fonts.json +128 -0
- package/node.d.ts +24 -0
- package/node.js +38 -0
- package/package.json +19 -4
- package/zonks_wasm.d.ts +163 -0
- package/zonks_wasm.js +660 -0
- package/zonks_wasm_bg.wasm +0 -0
- package/zonks_wasm_bg.wasm.d.ts +29 -0
package/package.json
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zonks/wasm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "zonks as WebAssembly: render, detect and version for JavaScript hosts",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://derzonk.de",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/LinkeTh/zonks.git", "directory": "crates/zonks-wasm" },
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"node": { "types": "./node.d.ts", "default": "./node.js" },
|
|
12
|
+
"default": { "types": "./zonks_wasm.d.ts", "default": "./zonks_wasm.js" }
|
|
13
|
+
},
|
|
14
|
+
"./zonks_wasm_bg.wasm": "./zonks_wasm_bg.wasm",
|
|
15
|
+
"./fonts/*": "./fonts/*",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"types": "./zonks_wasm.d.ts",
|
|
19
|
+
"files": ["zonks_wasm_bg.wasm", "zonks_wasm_bg.wasm.d.ts", "zonks_wasm.js", "zonks_wasm.d.ts", "node.js", "node.d.ts", "THIRD_PARTY_NOTICES.md", "fonts/"],
|
|
20
|
+
"sideEffects": false
|
|
21
|
+
}
|
package/zonks_wasm.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One long-lived engine session: fonts and icon packs are set once, and
|
|
6
|
+
* its caches make repeated renders (an editor's keystrokes) faster. Every
|
|
7
|
+
* render equals the free [`render`] in a fresh session with the same
|
|
8
|
+
* fonts, packs and options. `free()` releases it. Called from inside one
|
|
9
|
+
* of the renderer's own calls (a host getter), `free()` throws
|
|
10
|
+
* wasm-bindgen's "attempted to take ownership of Rust value while it was
|
|
11
|
+
* borrowed" but still releases it when that call returns; later calls
|
|
12
|
+
* throw "null pointer passed to rust", as for any freed object (the
|
|
13
|
+
* instance stays usable).
|
|
14
|
+
*/
|
|
15
|
+
export class Renderer {
|
|
16
|
+
free(): void;
|
|
17
|
+
[Symbol.dispose](): void;
|
|
18
|
+
/**
|
|
19
|
+
* The estimated bytes the caches hold.
|
|
20
|
+
*/
|
|
21
|
+
cacheBytes(): number;
|
|
22
|
+
/**
|
|
23
|
+
* Empties the caches.
|
|
24
|
+
*/
|
|
25
|
+
clearCaches(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Unregisters every icon pack.
|
|
28
|
+
*/
|
|
29
|
+
clearIconPacks(): void;
|
|
30
|
+
/**
|
|
31
|
+
* The work units the last render spent (to size `workBudget`).
|
|
32
|
+
*/
|
|
33
|
+
lastRenderWork(): number;
|
|
34
|
+
/**
|
|
35
|
+
* A renderer with the build's default fonts (the bundled Liberation
|
|
36
|
+
* set, or none without `bundled-fonts`: call `setFonts`) and no icon
|
|
37
|
+
* packs.
|
|
38
|
+
*/
|
|
39
|
+
constructor();
|
|
40
|
+
/**
|
|
41
|
+
* Registers a resolved pack (`{name, data}`, as `iconPackFromIconify`
|
|
42
|
+
* returns it, as a JSON string), replacing one of that name; returns
|
|
43
|
+
* its number of icons. An invalid pack throws and changes nothing.
|
|
44
|
+
*/
|
|
45
|
+
registerIconPack(pack: string): number;
|
|
46
|
+
/**
|
|
47
|
+
* Registers an Iconify JSON icon set (text) under `name` without the
|
|
48
|
+
* resolved pack crossing to JavaScript; returns its number of icons.
|
|
49
|
+
*/
|
|
50
|
+
registerIconifyPack(name: string, iconify_json: string): number;
|
|
51
|
+
/**
|
|
52
|
+
* Unregisters the pack named `name`; whether there was one.
|
|
53
|
+
*/
|
|
54
|
+
removeIconPack(name: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Renders Mermaid `source` to SVG: `options` as for the free `render`,
|
|
57
|
+
* without `iconPacks` (they throw: register packs once instead).
|
|
58
|
+
*/
|
|
59
|
+
render(source: string, options?: string): string;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the caches' byte budget (a whole number; 0 keeps nothing;
|
|
62
|
+
* 16 MiB by default) and empties them; anything else throws.
|
|
63
|
+
*/
|
|
64
|
+
setCacheBudget(bytes: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Replaces the renderer's fonts (as the free `setFonts`); returns the
|
|
67
|
+
* number of faces. Empties the caches and keeps the icon packs.
|
|
68
|
+
* Invalid data throws and keeps the previous set.
|
|
69
|
+
*/
|
|
70
|
+
setFonts(files: Uint8Array[]): number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The diagram type (`{keyword, family}`) or `null`; a source that is not a
|
|
75
|
+
* string (or longer than [`api::MAX_TEXT_BYTES`]) throws.
|
|
76
|
+
*/
|
|
77
|
+
export function detect(source: string): any;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An Iconify JSON icon set (text) as a resolved pack for `iconPacks` (or
|
|
81
|
+
* `Renderer.registerIconPack`, stringified).
|
|
82
|
+
*/
|
|
83
|
+
export function iconPackFromIconify(name: string, iconify_json: string): any;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Renders Mermaid `source` to SVG in a fresh engine session with the
|
|
87
|
+
* instance's fonts. `options` is a JSON object (`id`, `config`,
|
|
88
|
+
* `background`, `width`, `nowUnixMs`, `embedFonts`, `iconPacks`) as a
|
|
89
|
+
* string, empty or absent; without `nowUnixMs` the host clock
|
|
90
|
+
* (`Date.now()`) is used.
|
|
91
|
+
*/
|
|
92
|
+
export function render(source: string, options?: string): string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Replaces the instance's fonts for the free [`render`] with these font
|
|
96
|
+
* files (TrueType/OpenType bytes, in fallback order); returns the number of
|
|
97
|
+
* faces. Invalid data throws and keeps the previous set.
|
|
98
|
+
*/
|
|
99
|
+
export function setFonts(files: Uint8Array[]): number;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Runs when the module is instantiated.
|
|
103
|
+
*/
|
|
104
|
+
export function start(): void;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* `{zonks, mermaidSyntax, bundledFonts, noto}`.
|
|
108
|
+
*/
|
|
109
|
+
export function version(): any;
|
|
110
|
+
|
|
111
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
112
|
+
|
|
113
|
+
export interface InitOutput {
|
|
114
|
+
readonly memory: WebAssembly.Memory;
|
|
115
|
+
readonly __wbg_renderer_free: (a: number, b: number) => void;
|
|
116
|
+
readonly detect: (a: any) => [number, number, number];
|
|
117
|
+
readonly iconPackFromIconify: (a: any, b: any) => [number, number, number];
|
|
118
|
+
readonly render: (a: any, b: any) => [number, number, number, number];
|
|
119
|
+
readonly renderer_cacheBytes: (a: number) => number;
|
|
120
|
+
readonly renderer_clearCaches: (a: number) => void;
|
|
121
|
+
readonly renderer_clearIconPacks: (a: number) => void;
|
|
122
|
+
readonly renderer_lastRenderWork: (a: number) => number;
|
|
123
|
+
readonly renderer_new: () => number;
|
|
124
|
+
readonly renderer_registerIconPack: (a: number, b: any) => [number, number, number];
|
|
125
|
+
readonly renderer_registerIconifyPack: (a: number, b: any, c: any) => [number, number, number];
|
|
126
|
+
readonly renderer_removeIconPack: (a: number, b: any) => [number, number, number];
|
|
127
|
+
readonly renderer_render: (a: number, b: any, c: any) => [number, number, number, number];
|
|
128
|
+
readonly renderer_setCacheBudget: (a: number, b: any) => [number, number];
|
|
129
|
+
readonly renderer_setFonts: (a: number, b: any) => [number, number, number];
|
|
130
|
+
readonly setFonts: (a: any) => [number, number, number];
|
|
131
|
+
readonly start: () => void;
|
|
132
|
+
readonly version: () => any;
|
|
133
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
134
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
135
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
136
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
137
|
+
readonly __externref_table_alloc: () => number;
|
|
138
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
139
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
140
|
+
readonly __wbindgen_start: () => void;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
147
|
+
* a precompiled `WebAssembly.Module`.
|
|
148
|
+
*
|
|
149
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
150
|
+
*
|
|
151
|
+
* @returns {InitOutput}
|
|
152
|
+
*/
|
|
153
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
157
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
158
|
+
*
|
|
159
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
160
|
+
*
|
|
161
|
+
* @returns {Promise<InitOutput>}
|
|
162
|
+
*/
|
|
163
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|