@file-viewer/assets-chm 3.0.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 +196 -0
- package/README.en.md +5 -0
- package/README.md +5 -0
- package/RUST_NOTICE.md +47 -0
- package/RUST_THIRD_PARTY_LICENSES.md +365 -0
- package/THIRD_PARTY_NOTICES.md +12 -0
- package/bin/install.mjs +14 -0
- package/file-viewer.asset-pack.json +7 -0
- package/package.json +49 -0
- package/viewer/file-viewer-asset-pack.json +49 -0
- package/viewer/vendor/chm/LICENSE +196 -0
- package/viewer/vendor/chm/RUST_NOTICE.md +47 -0
- package/viewer/vendor/chm/RUST_THIRD_PARTY_LICENSES.md +365 -0
- package/viewer/vendor/chm/THIRD_PARTY_NOTICES.md +12 -0
- package/viewer/vendor/chm/chm.worker.js +2 -0
- package/viewer/vendor/chm/chm_wasm.js +583 -0
- package/viewer/vendor/chm/chm_wasm_bg.wasm +0 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
/* @ts-self-types="./chm_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A parsed CHM archive whose bytes remain private to the WASM instance.
|
|
5
|
+
*/
|
|
6
|
+
export class ChmArchive {
|
|
7
|
+
__destroy_into_raw() {
|
|
8
|
+
const ptr = this.__wbg_ptr;
|
|
9
|
+
this.__wbg_ptr = 0;
|
|
10
|
+
ChmArchiveFinalization.unregister(this);
|
|
11
|
+
return ptr;
|
|
12
|
+
}
|
|
13
|
+
free() {
|
|
14
|
+
const ptr = this.__destroy_into_raw();
|
|
15
|
+
wasm.__wbg_chmarchive_free(ptr, 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Release archive bytes and all decompression caches immediately.
|
|
19
|
+
*/
|
|
20
|
+
dispose() {
|
|
21
|
+
wasm.chmarchive_dispose(this.__wbg_ptr);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @returns {boolean}
|
|
25
|
+
*/
|
|
26
|
+
get disposed() {
|
|
27
|
+
const ret = wasm.chmarchive_disposed(this.__wbg_ptr);
|
|
28
|
+
return ret !== 0;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Return the complete bounded directory listing.
|
|
32
|
+
* @returns {any}
|
|
33
|
+
*/
|
|
34
|
+
entries() {
|
|
35
|
+
try {
|
|
36
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
37
|
+
wasm.chmarchive_entries(retptr, this.__wbg_ptr);
|
|
38
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
39
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
40
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
41
|
+
if (r2) {
|
|
42
|
+
throw takeObject(r1);
|
|
43
|
+
}
|
|
44
|
+
return takeObject(r0);
|
|
45
|
+
} finally {
|
|
46
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Return renderer-ready metadata, topics, contents and keyword index.
|
|
51
|
+
* @returns {any}
|
|
52
|
+
*/
|
|
53
|
+
manifest() {
|
|
54
|
+
try {
|
|
55
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
56
|
+
wasm.chmarchive_manifest(retptr, this.__wbg_ptr);
|
|
57
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
58
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
59
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
60
|
+
if (r2) {
|
|
61
|
+
throw takeObject(r1);
|
|
62
|
+
}
|
|
63
|
+
return takeObject(r0);
|
|
64
|
+
} finally {
|
|
65
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Validate and open an archive. `limits` is an optional JS object using
|
|
70
|
+
* camelCase fields from [`Limits`].
|
|
71
|
+
* @param {Uint8Array} bytes
|
|
72
|
+
* @param {any | null} [limits]
|
|
73
|
+
*/
|
|
74
|
+
constructor(bytes, limits) {
|
|
75
|
+
try {
|
|
76
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
77
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
wasm.chmarchive_new(retptr, ptr0, len0, isLikeNone(limits) ? 0 : addHeapObject(limits));
|
|
80
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
81
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
82
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
83
|
+
if (r2) {
|
|
84
|
+
throw takeObject(r1);
|
|
85
|
+
}
|
|
86
|
+
this.__wbg_ptr = r0;
|
|
87
|
+
ChmArchiveFinalization.register(this, this.__wbg_ptr, this);
|
|
88
|
+
return this;
|
|
89
|
+
} finally {
|
|
90
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Read one internal path. Compressed entries are decoded by reset block and
|
|
95
|
+
* cached, so sequential topic/assets do not inflate the entire CHM.
|
|
96
|
+
* @param {string} path
|
|
97
|
+
* @returns {Uint8Array}
|
|
98
|
+
*/
|
|
99
|
+
read(path) {
|
|
100
|
+
try {
|
|
101
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
102
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
wasm.chmarchive_read(retptr, this.__wbg_ptr, ptr0, len0);
|
|
105
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
106
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
107
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
108
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
109
|
+
if (r3) {
|
|
110
|
+
throw takeObject(r2);
|
|
111
|
+
}
|
|
112
|
+
var v2 = getArrayU8FromWasm0(r0, r1).slice();
|
|
113
|
+
wasm.__wbindgen_export3(r0, r1 * 1, 1);
|
|
114
|
+
return v2;
|
|
115
|
+
} finally {
|
|
116
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (Symbol.dispose) ChmArchive.prototype[Symbol.dispose] = ChmArchive.prototype.free;
|
|
121
|
+
function __wbg_get_imports() {
|
|
122
|
+
const import0 = {
|
|
123
|
+
__proto__: null,
|
|
124
|
+
__wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
|
|
125
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
126
|
+
return addHeapObject(ret);
|
|
127
|
+
},
|
|
128
|
+
__wbg_Number_3890faa6d3ff057d: function(arg0) {
|
|
129
|
+
const ret = Number(getObject(arg0));
|
|
130
|
+
return ret;
|
|
131
|
+
},
|
|
132
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
133
|
+
const ret = String(getObject(arg1));
|
|
134
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
135
|
+
const len1 = WASM_VECTOR_LEN;
|
|
136
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
137
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
138
|
+
},
|
|
139
|
+
__wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
|
|
140
|
+
const v = getObject(arg1);
|
|
141
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
142
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
143
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
144
|
+
},
|
|
145
|
+
__wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
|
|
146
|
+
const v = getObject(arg0);
|
|
147
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
148
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
149
|
+
},
|
|
150
|
+
__wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
|
|
151
|
+
const ret = debugString(getObject(arg1));
|
|
152
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
153
|
+
const len1 = WASM_VECTOR_LEN;
|
|
154
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
155
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
156
|
+
},
|
|
157
|
+
__wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
|
|
158
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
159
|
+
return ret;
|
|
160
|
+
},
|
|
161
|
+
__wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
|
|
162
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
163
|
+
return ret;
|
|
164
|
+
},
|
|
165
|
+
__wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
|
|
166
|
+
const ret = getObject(arg0) === null;
|
|
167
|
+
return ret;
|
|
168
|
+
},
|
|
169
|
+
__wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
|
|
170
|
+
const val = getObject(arg0);
|
|
171
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
|
|
175
|
+
const ret = getObject(arg0) === undefined;
|
|
176
|
+
return ret;
|
|
177
|
+
},
|
|
178
|
+
__wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
|
|
179
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
180
|
+
return ret;
|
|
181
|
+
},
|
|
182
|
+
__wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
|
|
183
|
+
const ret = getObject(arg0) == getObject(arg1);
|
|
184
|
+
return ret;
|
|
185
|
+
},
|
|
186
|
+
__wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
|
|
187
|
+
const obj = getObject(arg1);
|
|
188
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
189
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
190
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
191
|
+
},
|
|
192
|
+
__wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
|
|
193
|
+
const obj = getObject(arg1);
|
|
194
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
195
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
196
|
+
var len1 = WASM_VECTOR_LEN;
|
|
197
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
198
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
199
|
+
},
|
|
200
|
+
__wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
|
|
201
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
202
|
+
},
|
|
203
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
204
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
205
|
+
return addHeapObject(ret);
|
|
206
|
+
},
|
|
207
|
+
__wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
|
|
208
|
+
let result;
|
|
209
|
+
try {
|
|
210
|
+
result = getObject(arg0) instanceof ArrayBuffer;
|
|
211
|
+
} catch (_) {
|
|
212
|
+
result = false;
|
|
213
|
+
}
|
|
214
|
+
const ret = result;
|
|
215
|
+
return ret;
|
|
216
|
+
},
|
|
217
|
+
__wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
|
|
218
|
+
let result;
|
|
219
|
+
try {
|
|
220
|
+
result = getObject(arg0) instanceof Uint8Array;
|
|
221
|
+
} catch (_) {
|
|
222
|
+
result = false;
|
|
223
|
+
}
|
|
224
|
+
const ret = result;
|
|
225
|
+
return ret;
|
|
226
|
+
},
|
|
227
|
+
__wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
|
|
228
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
229
|
+
return ret;
|
|
230
|
+
},
|
|
231
|
+
__wbg_length_36bd29c6848c2144: function(arg0) {
|
|
232
|
+
const ret = getObject(arg0).length;
|
|
233
|
+
return ret;
|
|
234
|
+
},
|
|
235
|
+
__wbg_new_116be93542d39019: function() {
|
|
236
|
+
const ret = new Array();
|
|
237
|
+
return addHeapObject(ret);
|
|
238
|
+
},
|
|
239
|
+
__wbg_new_358857d90afd5a2d: function(arg0, arg1) {
|
|
240
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
241
|
+
return addHeapObject(ret);
|
|
242
|
+
},
|
|
243
|
+
__wbg_new_77cc4f4f472aeb81: function(arg0) {
|
|
244
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
245
|
+
return addHeapObject(ret);
|
|
246
|
+
},
|
|
247
|
+
__wbg_new_ebe3e0f6837f0879: function() {
|
|
248
|
+
const ret = new Object();
|
|
249
|
+
return addHeapObject(ret);
|
|
250
|
+
},
|
|
251
|
+
__wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
|
|
252
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
|
|
253
|
+
},
|
|
254
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
255
|
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
256
|
+
},
|
|
257
|
+
__wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
|
|
258
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
259
|
+
},
|
|
260
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
261
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
262
|
+
const ret = arg0;
|
|
263
|
+
return addHeapObject(ret);
|
|
264
|
+
},
|
|
265
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
266
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
267
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
268
|
+
return addHeapObject(ret);
|
|
269
|
+
},
|
|
270
|
+
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
271
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
272
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
273
|
+
return addHeapObject(ret);
|
|
274
|
+
},
|
|
275
|
+
__wbindgen_object_clone_ref: function(arg0) {
|
|
276
|
+
const ret = getObject(arg0);
|
|
277
|
+
return addHeapObject(ret);
|
|
278
|
+
},
|
|
279
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
280
|
+
takeObject(arg0);
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
return {
|
|
284
|
+
__proto__: null,
|
|
285
|
+
"./chm_wasm_bg.js": import0,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const ChmArchiveFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
290
|
+
? { register: () => {}, unregister: () => {} }
|
|
291
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_chmarchive_free(ptr, 1));
|
|
292
|
+
|
|
293
|
+
function addHeapObject(obj) {
|
|
294
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
295
|
+
const idx = heap_next;
|
|
296
|
+
heap_next = heap[idx];
|
|
297
|
+
|
|
298
|
+
heap[idx] = obj;
|
|
299
|
+
return idx;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function debugString(val) {
|
|
303
|
+
// primitive types
|
|
304
|
+
const type = typeof val;
|
|
305
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
306
|
+
return `${val}`;
|
|
307
|
+
}
|
|
308
|
+
if (type == 'string') {
|
|
309
|
+
return `"${val}"`;
|
|
310
|
+
}
|
|
311
|
+
if (type == 'symbol') {
|
|
312
|
+
const description = val.description;
|
|
313
|
+
if (description == null) {
|
|
314
|
+
return 'Symbol';
|
|
315
|
+
} else {
|
|
316
|
+
return `Symbol(${description})`;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (type == 'function') {
|
|
320
|
+
const name = val.name;
|
|
321
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
322
|
+
return `Function(${name})`;
|
|
323
|
+
} else {
|
|
324
|
+
return 'Function';
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// objects
|
|
328
|
+
if (Array.isArray(val)) {
|
|
329
|
+
const length = val.length;
|
|
330
|
+
let debug = '[';
|
|
331
|
+
if (length > 0) {
|
|
332
|
+
debug += debugString(val[0]);
|
|
333
|
+
}
|
|
334
|
+
for(let i = 1; i < length; i++) {
|
|
335
|
+
debug += ', ' + debugString(val[i]);
|
|
336
|
+
}
|
|
337
|
+
debug += ']';
|
|
338
|
+
return debug;
|
|
339
|
+
}
|
|
340
|
+
// Test for built-in
|
|
341
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
342
|
+
let className;
|
|
343
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
344
|
+
className = builtInMatches[1];
|
|
345
|
+
} else {
|
|
346
|
+
// Failed to match the standard '[object ClassName]'
|
|
347
|
+
return toString.call(val);
|
|
348
|
+
}
|
|
349
|
+
if (className == 'Object') {
|
|
350
|
+
// we're a user defined class or Object
|
|
351
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
352
|
+
// easier than looping through ownProperties of `val`.
|
|
353
|
+
try {
|
|
354
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
355
|
+
} catch (_) {
|
|
356
|
+
return 'Object';
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
// errors
|
|
360
|
+
if (val instanceof Error) {
|
|
361
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
362
|
+
}
|
|
363
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
364
|
+
return className;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function dropObject(idx) {
|
|
368
|
+
if (idx < 1028) return;
|
|
369
|
+
heap[idx] = heap_next;
|
|
370
|
+
heap_next = idx;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
374
|
+
ptr = ptr >>> 0;
|
|
375
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let cachedDataViewMemory0 = null;
|
|
379
|
+
function getDataViewMemory0() {
|
|
380
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
381
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
382
|
+
}
|
|
383
|
+
return cachedDataViewMemory0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function getStringFromWasm0(ptr, len) {
|
|
387
|
+
return decodeText(ptr >>> 0, len);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
let cachedUint8ArrayMemory0 = null;
|
|
391
|
+
function getUint8ArrayMemory0() {
|
|
392
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
393
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
394
|
+
}
|
|
395
|
+
return cachedUint8ArrayMemory0;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function getObject(idx) { return heap[idx]; }
|
|
399
|
+
|
|
400
|
+
let heap = new Array(1024).fill(undefined);
|
|
401
|
+
heap.push(undefined, null, true, false);
|
|
402
|
+
|
|
403
|
+
let heap_next = heap.length;
|
|
404
|
+
|
|
405
|
+
function isLikeNone(x) {
|
|
406
|
+
return x === undefined || x === null;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
410
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
411
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
412
|
+
WASM_VECTOR_LEN = arg.length;
|
|
413
|
+
return ptr;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
417
|
+
if (realloc === undefined) {
|
|
418
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
419
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
420
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
421
|
+
WASM_VECTOR_LEN = buf.length;
|
|
422
|
+
return ptr;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let len = arg.length;
|
|
426
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
427
|
+
|
|
428
|
+
const mem = getUint8ArrayMemory0();
|
|
429
|
+
|
|
430
|
+
let offset = 0;
|
|
431
|
+
|
|
432
|
+
for (; offset < len; offset++) {
|
|
433
|
+
const code = arg.charCodeAt(offset);
|
|
434
|
+
if (code > 0x7F) break;
|
|
435
|
+
mem[ptr + offset] = code;
|
|
436
|
+
}
|
|
437
|
+
if (offset !== len) {
|
|
438
|
+
if (offset !== 0) {
|
|
439
|
+
arg = arg.slice(offset);
|
|
440
|
+
}
|
|
441
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
442
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
443
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
444
|
+
|
|
445
|
+
offset += ret.written;
|
|
446
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
WASM_VECTOR_LEN = offset;
|
|
450
|
+
return ptr;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function takeObject(idx) {
|
|
454
|
+
const ret = getObject(idx);
|
|
455
|
+
dropObject(idx);
|
|
456
|
+
return ret;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
460
|
+
cachedTextDecoder.decode();
|
|
461
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
462
|
+
let numBytesDecoded = 0;
|
|
463
|
+
function decodeText(ptr, len) {
|
|
464
|
+
numBytesDecoded += len;
|
|
465
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
466
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
467
|
+
cachedTextDecoder.decode();
|
|
468
|
+
numBytesDecoded = len;
|
|
469
|
+
}
|
|
470
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const cachedTextEncoder = new TextEncoder();
|
|
474
|
+
|
|
475
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
476
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
477
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
478
|
+
view.set(buf);
|
|
479
|
+
return {
|
|
480
|
+
read: arg.length,
|
|
481
|
+
written: buf.length
|
|
482
|
+
};
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
let WASM_VECTOR_LEN = 0;
|
|
487
|
+
|
|
488
|
+
let wasmModule, wasmInstance, wasm;
|
|
489
|
+
function __wbg_finalize_init(instance, module) {
|
|
490
|
+
wasmInstance = instance;
|
|
491
|
+
wasm = instance.exports;
|
|
492
|
+
wasmModule = module;
|
|
493
|
+
cachedDataViewMemory0 = null;
|
|
494
|
+
cachedUint8ArrayMemory0 = null;
|
|
495
|
+
return wasm;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
async function __wbg_load(module, imports) {
|
|
499
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
500
|
+
if (!module.ok) {
|
|
501
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
505
|
+
try {
|
|
506
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
507
|
+
} catch (e) {
|
|
508
|
+
const validResponse = expectedResponseType(module.type);
|
|
509
|
+
|
|
510
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
511
|
+
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);
|
|
512
|
+
|
|
513
|
+
} else { throw e; }
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const bytes = await module.arrayBuffer();
|
|
518
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
519
|
+
} else {
|
|
520
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
521
|
+
|
|
522
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
523
|
+
return { instance, module };
|
|
524
|
+
} else {
|
|
525
|
+
return instance;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function expectedResponseType(type) {
|
|
530
|
+
switch (type) {
|
|
531
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
532
|
+
}
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function initSync(module) {
|
|
538
|
+
if (wasm !== undefined) return wasm;
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
if (module !== undefined) {
|
|
542
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
543
|
+
({module} = module)
|
|
544
|
+
} else {
|
|
545
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const imports = __wbg_get_imports();
|
|
550
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
551
|
+
module = new WebAssembly.Module(module);
|
|
552
|
+
}
|
|
553
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
554
|
+
return __wbg_finalize_init(instance, module);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
async function __wbg_init(module_or_path) {
|
|
558
|
+
if (wasm !== undefined) return wasm;
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
if (module_or_path !== undefined) {
|
|
562
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
563
|
+
({module_or_path} = module_or_path)
|
|
564
|
+
} else {
|
|
565
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (module_or_path === undefined) {
|
|
570
|
+
module_or_path = new URL('chm_wasm_bg.wasm', import.meta.url);
|
|
571
|
+
}
|
|
572
|
+
const imports = __wbg_get_imports();
|
|
573
|
+
|
|
574
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
575
|
+
module_or_path = fetch(module_or_path);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
579
|
+
|
|
580
|
+
return __wbg_finalize_init(instance, module);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|