@ameyanagi/reshiki 0.0.0-stage → 0.12.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 +218 -2
- package/dist/editor/reshiki.d.ts +93 -0
- package/dist/editor/reshiki.js +3317 -0
- package/dist/editor/reshiki_bg.wasm +0 -0
- package/dist/editor/reshiki_bg.wasm.d.ts +29 -0
- package/dist/licenses/LICENSE +20 -0
- package/dist/licenses/LICENSE-APACHE +202 -0
- package/dist/licenses/LICENSE-MIT +21 -0
- package/dist/licenses/NOTICE +38 -0
- package/dist/licenses/THIRD-PARTY-NOTICES.txt +114672 -0
- package/dist/wasm/reshiki_web.d.ts +91 -0
- package/dist/wasm/reshiki_web.js +537 -0
- package/dist/wasm/reshiki_web_bg.wasm +0 -0
- package/dist/wasm/reshiki_web_bg.wasm.d.ts +20 -0
- package/package.json +49 -4
- package/src/editor.d.ts +58 -0
- package/src/editor.js +57 -0
- package/src/element.d.ts +19 -0
- package/src/element.js +68 -0
- package/src/embed.d.ts +29 -0
- package/src/embed.js +83 -0
- package/src/fonts.d.ts +30 -0
- package/src/fonts.js +95 -0
- package/src/frame.html +53 -0
- package/src/index.d.ts +70 -0
- package/src/index.js +56 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add a TrueType or OpenType font (or collection) for figures and previews.
|
|
6
|
+
* Text whose own font lacks a glyph, such as Japanese, falls back to it.
|
|
7
|
+
* Returns how many faces it holds.
|
|
8
|
+
*/
|
|
9
|
+
export function addFont(bytes: Uint8Array): number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Convert `data` read as `from` into the format `to`. The formats are those of
|
|
13
|
+
* [`reshiki_io::formats`].
|
|
14
|
+
*/
|
|
15
|
+
export function convert(data: Uint8Array, from: string, to: string): Promise<Uint8Array>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The standard InChI of `data` read as `format`.
|
|
19
|
+
*/
|
|
20
|
+
export function inchi(data: Uint8Array, format: string): Promise<string>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The editor's PNG preview of `data` read as `format`, within
|
|
24
|
+
* `max_width` × `max_height` (1600 × 1000 when not given).
|
|
25
|
+
*/
|
|
26
|
+
export function renderPng(data: Uint8Array, format: string, max_width?: number | null, max_height?: number | null): Promise<Uint8Array>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The editor's SVG preview of `data` read as `format`.
|
|
30
|
+
*/
|
|
31
|
+
export function renderSvg(data: Uint8Array, format: string): Promise<string>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The SMILES of `data` read as `format`.
|
|
35
|
+
*/
|
|
36
|
+
export function smiles(data: Uint8Array, format: string): Promise<string>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Report panics on the console; the browser build aborts on them.
|
|
40
|
+
*/
|
|
41
|
+
export function start(): void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This library's version.
|
|
45
|
+
*/
|
|
46
|
+
export function version(): string;
|
|
47
|
+
|
|
48
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
49
|
+
|
|
50
|
+
export interface InitOutput {
|
|
51
|
+
readonly memory: WebAssembly.Memory;
|
|
52
|
+
readonly addFont: (a: number, b: number, c: number) => void;
|
|
53
|
+
readonly convert: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
54
|
+
readonly inchi: (a: number, b: number, c: number, d: number) => number;
|
|
55
|
+
readonly renderPng: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
56
|
+
readonly renderSvg: (a: number, b: number, c: number, d: number) => number;
|
|
57
|
+
readonly smiles: (a: number, b: number, c: number, d: number) => number;
|
|
58
|
+
readonly start: () => void;
|
|
59
|
+
readonly version: (a: number) => void;
|
|
60
|
+
readonly __wasm_bindgen_func_elem_3437: (a: number, b: number, c: number, d: number) => void;
|
|
61
|
+
readonly __wasm_bindgen_func_elem_3468: (a: number, b: number, c: number, d: number) => void;
|
|
62
|
+
readonly __wbindgen_export: (a: number) => void;
|
|
63
|
+
readonly __wbindgen_export2: (a: number, b: number) => void;
|
|
64
|
+
readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
65
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
66
|
+
readonly __wbindgen_export4: (a: number, b: number) => number;
|
|
67
|
+
readonly __wbindgen_export5: (a: number, b: number, c: number, d: number) => number;
|
|
68
|
+
readonly __wbindgen_start: () => void;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
75
|
+
* a precompiled `WebAssembly.Module`.
|
|
76
|
+
*
|
|
77
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
78
|
+
*
|
|
79
|
+
* @returns {InitOutput}
|
|
80
|
+
*/
|
|
81
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
85
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
86
|
+
*
|
|
87
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
88
|
+
*
|
|
89
|
+
* @returns {Promise<InitOutput>}
|
|
90
|
+
*/
|
|
91
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
/* @ts-self-types="./reshiki_web.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Add a TrueType or OpenType font (or collection) for figures and previews.
|
|
5
|
+
* Text whose own font lacks a glyph, such as Japanese, falls back to it.
|
|
6
|
+
* Returns how many faces it holds.
|
|
7
|
+
* @param {Uint8Array} bytes
|
|
8
|
+
* @returns {number}
|
|
9
|
+
*/
|
|
10
|
+
export function addFont(bytes) {
|
|
11
|
+
try {
|
|
12
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
13
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export4);
|
|
14
|
+
const len0 = WASM_VECTOR_LEN;
|
|
15
|
+
wasm.addFont(retptr, ptr0, len0);
|
|
16
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
17
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
18
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
19
|
+
if (r2) {
|
|
20
|
+
throw takeObject(r1);
|
|
21
|
+
}
|
|
22
|
+
return r0 >>> 0;
|
|
23
|
+
} finally {
|
|
24
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Convert `data` read as `from` into the format `to`. The formats are those of
|
|
30
|
+
* [`reshiki_io::formats`].
|
|
31
|
+
* @param {Uint8Array} data
|
|
32
|
+
* @param {string} from
|
|
33
|
+
* @param {string} to
|
|
34
|
+
* @returns {Promise<Uint8Array>}
|
|
35
|
+
*/
|
|
36
|
+
export function convert(data, from, to) {
|
|
37
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
38
|
+
const len0 = WASM_VECTOR_LEN;
|
|
39
|
+
const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
40
|
+
const len1 = WASM_VECTOR_LEN;
|
|
41
|
+
const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
42
|
+
const len2 = WASM_VECTOR_LEN;
|
|
43
|
+
const ret = wasm.convert(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
44
|
+
return takeObject(ret);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The standard InChI of `data` read as `format`.
|
|
49
|
+
* @param {Uint8Array} data
|
|
50
|
+
* @param {string} format
|
|
51
|
+
* @returns {Promise<string>}
|
|
52
|
+
*/
|
|
53
|
+
export function inchi(data, format) {
|
|
54
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
55
|
+
const len0 = WASM_VECTOR_LEN;
|
|
56
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
57
|
+
const len1 = WASM_VECTOR_LEN;
|
|
58
|
+
const ret = wasm.inchi(ptr0, len0, ptr1, len1);
|
|
59
|
+
return takeObject(ret);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The editor's PNG preview of `data` read as `format`, within
|
|
64
|
+
* `max_width` × `max_height` (1600 × 1000 when not given).
|
|
65
|
+
* @param {Uint8Array} data
|
|
66
|
+
* @param {string} format
|
|
67
|
+
* @param {number | null} [max_width]
|
|
68
|
+
* @param {number | null} [max_height]
|
|
69
|
+
* @returns {Promise<Uint8Array>}
|
|
70
|
+
*/
|
|
71
|
+
export function renderPng(data, format, max_width, max_height) {
|
|
72
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
73
|
+
const len0 = WASM_VECTOR_LEN;
|
|
74
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
75
|
+
const len1 = WASM_VECTOR_LEN;
|
|
76
|
+
const ret = wasm.renderPng(ptr0, len0, ptr1, len1, isLikeNone(max_width) ? Number.MAX_SAFE_INTEGER : (max_width) >>> 0, isLikeNone(max_height) ? Number.MAX_SAFE_INTEGER : (max_height) >>> 0);
|
|
77
|
+
return takeObject(ret);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The editor's SVG preview of `data` read as `format`.
|
|
82
|
+
* @param {Uint8Array} data
|
|
83
|
+
* @param {string} format
|
|
84
|
+
* @returns {Promise<string>}
|
|
85
|
+
*/
|
|
86
|
+
export function renderSvg(data, format) {
|
|
87
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
90
|
+
const len1 = WASM_VECTOR_LEN;
|
|
91
|
+
const ret = wasm.renderSvg(ptr0, len0, ptr1, len1);
|
|
92
|
+
return takeObject(ret);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The SMILES of `data` read as `format`.
|
|
97
|
+
* @param {Uint8Array} data
|
|
98
|
+
* @param {string} format
|
|
99
|
+
* @returns {Promise<string>}
|
|
100
|
+
*/
|
|
101
|
+
export function smiles(data, format) {
|
|
102
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export4);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ptr1 = passStringToWasm0(format, wasm.__wbindgen_export4, wasm.__wbindgen_export5);
|
|
105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
106
|
+
const ret = wasm.smiles(ptr0, len0, ptr1, len1);
|
|
107
|
+
return takeObject(ret);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Report panics on the console; the browser build aborts on them.
|
|
112
|
+
*/
|
|
113
|
+
export function start() {
|
|
114
|
+
wasm.start();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* This library's version.
|
|
119
|
+
* @returns {string}
|
|
120
|
+
*/
|
|
121
|
+
export function version() {
|
|
122
|
+
let deferred1_0;
|
|
123
|
+
let deferred1_1;
|
|
124
|
+
try {
|
|
125
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
126
|
+
wasm.version(retptr);
|
|
127
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
128
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
129
|
+
deferred1_0 = r0;
|
|
130
|
+
deferred1_1 = r1;
|
|
131
|
+
return getStringFromWasm0(r0, r1);
|
|
132
|
+
} finally {
|
|
133
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
134
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function __wbg_get_imports() {
|
|
138
|
+
const import0 = {
|
|
139
|
+
__proto__: null,
|
|
140
|
+
__wbg_Error_67e7344beaa85059: function(arg0, arg1) {
|
|
141
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
142
|
+
return addHeapObject(ret);
|
|
143
|
+
},
|
|
144
|
+
__wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
|
|
145
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
146
|
+
return ret;
|
|
147
|
+
},
|
|
148
|
+
__wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
|
|
149
|
+
const ret = getObject(arg0) === undefined;
|
|
150
|
+
return ret;
|
|
151
|
+
},
|
|
152
|
+
__wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
|
|
153
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
154
|
+
},
|
|
155
|
+
__wbg__wbg_cb_unref_997e73d32238e655: function(arg0) {
|
|
156
|
+
getObject(arg0)._wbg_cb_unref();
|
|
157
|
+
},
|
|
158
|
+
__wbg_call_6bcf8d3e20937e46: function() { return handleError(function (arg0, arg1, arg2) {
|
|
159
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
160
|
+
return addHeapObject(ret);
|
|
161
|
+
}, arguments); },
|
|
162
|
+
__wbg_error_554f9ffb6fdfd2de: function(arg0, arg1) {
|
|
163
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
164
|
+
},
|
|
165
|
+
__wbg_new_typed_6f8b0d724fe26c07: function(arg0, arg1) {
|
|
166
|
+
try {
|
|
167
|
+
var state0 = {a: arg0, b: arg1};
|
|
168
|
+
var cb0 = (arg0, arg1) => {
|
|
169
|
+
const a = state0.a;
|
|
170
|
+
state0.a = 0;
|
|
171
|
+
try {
|
|
172
|
+
return __wasm_bindgen_func_elem_3468(a, state0.b, arg0, arg1);
|
|
173
|
+
} finally {
|
|
174
|
+
state0.a = a;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const ret = new Promise(cb0);
|
|
178
|
+
return addHeapObject(ret);
|
|
179
|
+
} finally {
|
|
180
|
+
state0.a = 0;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
__wbg_now_e7c6795a7f81e10f: function(arg0) {
|
|
184
|
+
const ret = getObject(arg0).now();
|
|
185
|
+
return ret;
|
|
186
|
+
},
|
|
187
|
+
__wbg_performance_3fcf6e32a7e1ed0a: function(arg0) {
|
|
188
|
+
const ret = getObject(arg0).performance;
|
|
189
|
+
return addHeapObject(ret);
|
|
190
|
+
},
|
|
191
|
+
__wbg_queueMicrotask_85c90f6987555d65: function(arg0) {
|
|
192
|
+
const ret = getObject(arg0).queueMicrotask;
|
|
193
|
+
return addHeapObject(ret);
|
|
194
|
+
},
|
|
195
|
+
__wbg_queueMicrotask_f6a1fa10b81d1fc0: function(arg0) {
|
|
196
|
+
queueMicrotask(getObject(arg0));
|
|
197
|
+
},
|
|
198
|
+
__wbg_resolve_35ec7e0c6af4c82c: function(arg0) {
|
|
199
|
+
const ret = Promise.resolve(getObject(arg0));
|
|
200
|
+
return addHeapObject(ret);
|
|
201
|
+
},
|
|
202
|
+
__wbg_static_accessor_GLOBAL_8eb4cd83130a11a0: function() {
|
|
203
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
204
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
205
|
+
},
|
|
206
|
+
__wbg_static_accessor_GLOBAL_THIS_1e7044f654e934db: function() {
|
|
207
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
208
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
209
|
+
},
|
|
210
|
+
__wbg_static_accessor_SELF_d8b50611246a6d92: function() {
|
|
211
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
212
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
213
|
+
},
|
|
214
|
+
__wbg_static_accessor_WINDOW_fd0bc376bf0f8b42: function() {
|
|
215
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
216
|
+
return isLikeNone(ret) ? 0 : addHeapObject(ret);
|
|
217
|
+
},
|
|
218
|
+
__wbg_then_b830475380919203: function(arg0, arg1) {
|
|
219
|
+
const ret = getObject(arg0).then(getObject(arg1));
|
|
220
|
+
return addHeapObject(ret);
|
|
221
|
+
},
|
|
222
|
+
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
223
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 243, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
224
|
+
const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_3437);
|
|
225
|
+
return addHeapObject(ret);
|
|
226
|
+
},
|
|
227
|
+
__wbindgen_generic_0000000000000002: function(arg0, arg1) {
|
|
228
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
229
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
230
|
+
return addHeapObject(ret);
|
|
231
|
+
},
|
|
232
|
+
__wbindgen_generic_0000000000000003: function(arg0, arg1) {
|
|
233
|
+
var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
|
|
234
|
+
wasm.__wbindgen_export3(arg0, arg1 * 1, 1);
|
|
235
|
+
// Cast intrinsic for `Vector(U8) -> Externref`.
|
|
236
|
+
const ret = v0;
|
|
237
|
+
return addHeapObject(ret);
|
|
238
|
+
},
|
|
239
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
240
|
+
const ret = getObject(arg0);
|
|
241
|
+
return addHeapObject(ret);
|
|
242
|
+
},
|
|
243
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
244
|
+
takeObject(arg0);
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
return {
|
|
248
|
+
__proto__: null,
|
|
249
|
+
"./reshiki_web_bg.js": import0,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function __wasm_bindgen_func_elem_3468(arg0, arg1, arg2, arg3) {
|
|
254
|
+
wasm.__wasm_bindgen_func_elem_3468(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function __wasm_bindgen_func_elem_3437(arg0, arg1, arg2) {
|
|
258
|
+
try {
|
|
259
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
260
|
+
wasm.__wasm_bindgen_func_elem_3437(retptr, arg0, arg1, addHeapObject(arg2));
|
|
261
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
262
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
263
|
+
if (r1) {
|
|
264
|
+
throw takeObject(r0);
|
|
265
|
+
}
|
|
266
|
+
} finally {
|
|
267
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function addHeapObject(obj) {
|
|
272
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
273
|
+
const idx = heap_next;
|
|
274
|
+
heap_next = heap[idx];
|
|
275
|
+
|
|
276
|
+
heap[idx] = obj;
|
|
277
|
+
return idx;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
|
281
|
+
? { register: () => {}, unregister: () => {} }
|
|
282
|
+
: new FinalizationRegistry(state => wasm.__wbindgen_export2(state.a, state.b));
|
|
283
|
+
|
|
284
|
+
function dropObject(idx) {
|
|
285
|
+
if (idx < 1028) return;
|
|
286
|
+
heap[idx] = heap_next;
|
|
287
|
+
heap_next = idx;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
291
|
+
ptr = ptr >>> 0;
|
|
292
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let cachedDataViewMemory0 = null;
|
|
296
|
+
function getDataViewMemory0() {
|
|
297
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
298
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
299
|
+
}
|
|
300
|
+
return cachedDataViewMemory0;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function getStringFromWasm0(ptr, len) {
|
|
304
|
+
return decodeText(ptr >>> 0, len);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
let cachedUint8ArrayMemory0 = null;
|
|
308
|
+
function getUint8ArrayMemory0() {
|
|
309
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
310
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
311
|
+
}
|
|
312
|
+
return cachedUint8ArrayMemory0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function getObject(idx) { return heap[idx]; }
|
|
316
|
+
|
|
317
|
+
function handleError(f, args) {
|
|
318
|
+
try {
|
|
319
|
+
return f.apply(this, args);
|
|
320
|
+
} catch (e) {
|
|
321
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let heap = new Array(1024).fill(undefined);
|
|
326
|
+
heap.push(undefined, null, true, false);
|
|
327
|
+
|
|
328
|
+
let heap_next = heap.length;
|
|
329
|
+
|
|
330
|
+
function isLikeNone(x) {
|
|
331
|
+
return x === undefined || x === null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function makeMutClosure(arg0, arg1, f) {
|
|
335
|
+
const state = { a: arg0, b: arg1, cnt: 1 };
|
|
336
|
+
const real = (...args) => {
|
|
337
|
+
|
|
338
|
+
// First up with a closure we increment the internal reference
|
|
339
|
+
// count. This ensures that the Rust closure environment won't
|
|
340
|
+
// be deallocated while we're invoking it.
|
|
341
|
+
state.cnt++;
|
|
342
|
+
const a = state.a;
|
|
343
|
+
state.a = 0;
|
|
344
|
+
try {
|
|
345
|
+
return f(a, state.b, ...args);
|
|
346
|
+
} finally {
|
|
347
|
+
state.a = a;
|
|
348
|
+
real._wbg_cb_unref();
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
real._wbg_cb_unref = () => {
|
|
352
|
+
if (--state.cnt === 0) {
|
|
353
|
+
wasm.__wbindgen_export2(state.a, state.b);
|
|
354
|
+
state.a = 0;
|
|
355
|
+
CLOSURE_DTORS.unregister(state);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
CLOSURE_DTORS.register(real, state, state);
|
|
359
|
+
return real;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
363
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
364
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
365
|
+
WASM_VECTOR_LEN = arg.length;
|
|
366
|
+
return ptr;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
370
|
+
if (realloc === undefined) {
|
|
371
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
372
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
373
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
374
|
+
WASM_VECTOR_LEN = buf.length;
|
|
375
|
+
return ptr;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let len = arg.length;
|
|
379
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
380
|
+
|
|
381
|
+
const mem = getUint8ArrayMemory0();
|
|
382
|
+
|
|
383
|
+
let offset = 0;
|
|
384
|
+
|
|
385
|
+
for (; offset < len; offset++) {
|
|
386
|
+
const code = arg.charCodeAt(offset);
|
|
387
|
+
if (code > 0x7F) break;
|
|
388
|
+
mem[ptr + offset] = code;
|
|
389
|
+
}
|
|
390
|
+
if (offset !== len) {
|
|
391
|
+
if (offset !== 0) {
|
|
392
|
+
arg = arg.slice(offset);
|
|
393
|
+
}
|
|
394
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
395
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
396
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
397
|
+
|
|
398
|
+
offset += ret.written;
|
|
399
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
WASM_VECTOR_LEN = offset;
|
|
403
|
+
return ptr;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function takeObject(idx) {
|
|
407
|
+
const ret = getObject(idx);
|
|
408
|
+
dropObject(idx);
|
|
409
|
+
return ret;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
413
|
+
cachedTextDecoder.decode();
|
|
414
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
415
|
+
let numBytesDecoded = 0;
|
|
416
|
+
function decodeText(ptr, len) {
|
|
417
|
+
numBytesDecoded += len;
|
|
418
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
419
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
420
|
+
cachedTextDecoder.decode();
|
|
421
|
+
numBytesDecoded = len;
|
|
422
|
+
}
|
|
423
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const cachedTextEncoder = new TextEncoder();
|
|
427
|
+
|
|
428
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
429
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
430
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
431
|
+
view.set(buf);
|
|
432
|
+
return {
|
|
433
|
+
read: arg.length,
|
|
434
|
+
written: buf.length
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
let WASM_VECTOR_LEN = 0;
|
|
440
|
+
|
|
441
|
+
let wasmModule, wasmInstance, wasm;
|
|
442
|
+
function __wbg_finalize_init(instance, module) {
|
|
443
|
+
wasmInstance = instance;
|
|
444
|
+
wasm = instance.exports;
|
|
445
|
+
wasmModule = module;
|
|
446
|
+
cachedDataViewMemory0 = null;
|
|
447
|
+
cachedUint8ArrayMemory0 = null;
|
|
448
|
+
wasm.__wbindgen_start();
|
|
449
|
+
return wasm;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async function __wbg_load(module, imports) {
|
|
453
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
454
|
+
if (!module.ok) {
|
|
455
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
459
|
+
try {
|
|
460
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
461
|
+
} catch (e) {
|
|
462
|
+
const validResponse = expectedResponseType(module.type);
|
|
463
|
+
|
|
464
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
465
|
+
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);
|
|
466
|
+
|
|
467
|
+
} else { throw e; }
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const bytes = await module.arrayBuffer();
|
|
472
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
473
|
+
} else {
|
|
474
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
475
|
+
|
|
476
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
477
|
+
return { instance, module };
|
|
478
|
+
} else {
|
|
479
|
+
return instance;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function expectedResponseType(type) {
|
|
484
|
+
switch (type) {
|
|
485
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
486
|
+
}
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function initSync(module) {
|
|
492
|
+
if (wasm !== undefined) return wasm;
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
if (module !== undefined) {
|
|
496
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
497
|
+
({module} = module)
|
|
498
|
+
} else {
|
|
499
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
const imports = __wbg_get_imports();
|
|
504
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
505
|
+
module = new WebAssembly.Module(module);
|
|
506
|
+
}
|
|
507
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
508
|
+
return __wbg_finalize_init(instance, module);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async function __wbg_init(module_or_path) {
|
|
512
|
+
if (wasm !== undefined) return wasm;
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
if (module_or_path !== undefined) {
|
|
516
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
517
|
+
({module_or_path} = module_or_path)
|
|
518
|
+
} else {
|
|
519
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (module_or_path === undefined) {
|
|
524
|
+
module_or_path = new URL('reshiki_web_bg.wasm', import.meta.url);
|
|
525
|
+
}
|
|
526
|
+
const imports = __wbg_get_imports();
|
|
527
|
+
|
|
528
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
529
|
+
module_or_path = fetch(module_or_path);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
533
|
+
|
|
534
|
+
return __wbg_finalize_init(instance, module);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const addFont: (a: number, b: number, c: number) => void;
|
|
5
|
+
export const convert: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
6
|
+
export const inchi: (a: number, b: number, c: number, d: number) => number;
|
|
7
|
+
export const renderPng: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
8
|
+
export const renderSvg: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const smiles: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const start: () => void;
|
|
11
|
+
export const version: (a: number) => void;
|
|
12
|
+
export const __wasm_bindgen_func_elem_3437: (a: number, b: number, c: number, d: number) => void;
|
|
13
|
+
export const __wasm_bindgen_func_elem_3468: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const __wbindgen_export: (a: number) => void;
|
|
15
|
+
export const __wbindgen_export2: (a: number, b: number) => void;
|
|
16
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
18
|
+
export const __wbindgen_export4: (a: number, b: number) => number;
|
|
19
|
+
export const __wbindgen_export5: (a: number, b: number, c: number, d: number) => number;
|
|
20
|
+
export const __wbindgen_start: () => void;
|