libchai 0.1.0 → 0.1.2

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 CHANGED
@@ -1,3 +1,50 @@
1
- # libchai
1
+ # chai: 汉字自动拆分系统[命令行版]
2
2
 
3
- 汉字编码输入方案核心算法
3
+ `chai` 是一个使用 Rust 编写的命令行程序。用户提供拆分表以及方案配置文件,本程序能够生成单字、词组的编码并评测一系列指标,以及基于退火算法优化元素的布局。
4
+
5
+ ## 使用
6
+
7
+ 压缩包解压后,根目录中有两个文件:`chai.exe` 是 Windows 系统上的可执行文件,而 `chai` 是 macOS 系统上的可执行文件,请根据您的系统选用。
8
+
9
+ ### 输入格式解释及示例
10
+
11
+ 压缩包中有以下的示例文件:
12
+
13
+ - `config.yaml`: 方案文件(米十五笔),具体的格式解释参见 [config.md](./config.md);这个文件也可以由[汉字自动拆分系统](https://chaifen.app/)生成;
14
+ - `elements.txt`: 拆分表文件(米十五笔),每个字一行,每行的内容依次为汉字、制表符和以空格分隔的汉字拆分序列;这个文件也可由自动拆分系统生成;
15
+ - `assets/character_frequency.txt`:字频文件,每个字一行,每行的内容为以制表符分隔的字和字频;
16
+ - `assets/word_frequency.txt`:词频文件,每个字一行,每行的内容为以制表符分隔的词和词频;
17
+ - `assets/key_equivalence.txt`:单键用指当量文件,每个按键一行,每行的内容为以制表符分隔的按键和当量;
18
+ - `assets/pair_equivalence.txt`:双键速度当量文件,每个按键组合一行,每行的内容为以制表符分隔的按键组合和当量;
19
+
20
+ 可执行文件支持两个不同的命令:`encode` 和 `optimize`,例如
21
+
22
+ ```bash
23
+ ./chai encode
24
+ ```
25
+
26
+ 将使用方案文件和拆分表计算出字词编码并统计各类评测指标,而
27
+
28
+ ```bash
29
+ ./chai optimize
30
+ ```
31
+
32
+ 将基于拆分表和方案文件中的配置优化元素布局。另外,如果方案文件和拆分表文件的路径不为以上的默认值,可以通过命令行参数提供,例如
33
+
34
+ ```bash
35
+ ./chai yima.yaml -e yima.txt optimize
36
+ ```
37
+
38
+ 完整的使用说明可用 `./chai --help` 查看。
39
+
40
+ ## 开发
41
+
42
+ 需要首先运行 `make assets` 下载相关数据资源。然后 `cargo run` 即可编译运行。
43
+
44
+ ## 构建和部署
45
+
46
+ 在任何平台上只需要 `make build` 或者 `cargo build` 即可编译。
47
+
48
+ 在 `.cargo/config` 中有一个 `target.x86_64-pc-windows-gnu` 目标,是给 macOS 交叉编译 Windows 可执行文件用的,如果不做交叉编译或者不是为 Windows 平台编译的话可以忽略。
49
+
50
+ `make package` 命令在 macOS 上运行的时候可以同时编译当前平台(x86_64 或 arm64)以及 Windows 的可执行文件,并打包为一个 zip 压缩文件,便于发布。
package/libchai.d.ts CHANGED
@@ -1,14 +1,33 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * @param {any} js_input
5
+ * @returns {string}
4
6
  */
5
- export function greet(): void;
7
+ export function evaluate(js_input: any): string;
8
+ /**
9
+ * @param {any} js_input
10
+ * @param {Function} post_message
11
+ */
12
+ export function optimize(js_input: any, post_message: Function): void;
13
+ /**
14
+ */
15
+ export class WebInterface {
16
+ free(): void;
17
+ }
6
18
 
7
19
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
8
20
 
9
21
  export interface InitOutput {
10
22
  readonly memory: WebAssembly.Memory;
11
- readonly greet: () => void;
23
+ readonly __wbg_webinterface_free: (a: number) => void;
24
+ readonly evaluate: (a: number, b: number) => void;
25
+ readonly optimize: (a: number, b: number) => void;
26
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
27
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
28
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
29
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
30
+ readonly __wbindgen_exn_store: (a: number) => void;
12
31
  }
13
32
 
14
33
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/libchai.js CHANGED
@@ -1,8 +1,57 @@
1
1
  let wasm;
2
2
 
3
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
3
+ const heap = new Array(128).fill(undefined);
4
4
 
5
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
5
+ heap.push(undefined, null, true, false);
6
+
7
+ function getObject(idx) { return heap[idx]; }
8
+
9
+ let heap_next = heap.length;
10
+
11
+ function addHeapObject(obj) {
12
+ if (heap_next === heap.length) heap.push(heap.length + 1);
13
+ const idx = heap_next;
14
+ heap_next = heap[idx];
15
+
16
+ heap[idx] = obj;
17
+ return idx;
18
+ }
19
+
20
+ function dropObject(idx) {
21
+ if (idx < 132) return;
22
+ heap[idx] = heap_next;
23
+ heap_next = idx;
24
+ }
25
+
26
+ function takeObject(idx) {
27
+ const ret = getObject(idx);
28
+ dropObject(idx);
29
+ return ret;
30
+ }
31
+
32
+ function isLikeNone(x) {
33
+ return x === undefined || x === null;
34
+ }
35
+
36
+ let cachedFloat64Memory0 = null;
37
+
38
+ function getFloat64Memory0() {
39
+ if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
40
+ cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
41
+ }
42
+ return cachedFloat64Memory0;
43
+ }
44
+
45
+ let cachedInt32Memory0 = null;
46
+
47
+ function getInt32Memory0() {
48
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
49
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
50
+ }
51
+ return cachedInt32Memory0;
52
+ }
53
+
54
+ let WASM_VECTOR_LEN = 0;
6
55
 
7
56
  let cachedUint8Memory0 = null;
8
57
 
@@ -13,14 +62,192 @@ function getUint8Memory0() {
13
62
  return cachedUint8Memory0;
14
63
  }
15
64
 
65
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
66
+
67
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
68
+ ? function (arg, view) {
69
+ return cachedTextEncoder.encodeInto(arg, view);
70
+ }
71
+ : function (arg, view) {
72
+ const buf = cachedTextEncoder.encode(arg);
73
+ view.set(buf);
74
+ return {
75
+ read: arg.length,
76
+ written: buf.length
77
+ };
78
+ });
79
+
80
+ function passStringToWasm0(arg, malloc, realloc) {
81
+
82
+ if (realloc === undefined) {
83
+ const buf = cachedTextEncoder.encode(arg);
84
+ const ptr = malloc(buf.length, 1) >>> 0;
85
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
86
+ WASM_VECTOR_LEN = buf.length;
87
+ return ptr;
88
+ }
89
+
90
+ let len = arg.length;
91
+ let ptr = malloc(len, 1) >>> 0;
92
+
93
+ const mem = getUint8Memory0();
94
+
95
+ let offset = 0;
96
+
97
+ for (; offset < len; offset++) {
98
+ const code = arg.charCodeAt(offset);
99
+ if (code > 0x7F) break;
100
+ mem[ptr + offset] = code;
101
+ }
102
+
103
+ if (offset !== len) {
104
+ if (offset !== 0) {
105
+ arg = arg.slice(offset);
106
+ }
107
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
108
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
109
+ const ret = encodeString(arg, view);
110
+
111
+ offset += ret.written;
112
+ }
113
+
114
+ WASM_VECTOR_LEN = offset;
115
+ return ptr;
116
+ }
117
+
118
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
119
+
120
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
121
+
16
122
  function getStringFromWasm0(ptr, len) {
17
123
  ptr = ptr >>> 0;
18
124
  return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
125
  }
126
+
127
+ let cachedBigInt64Memory0 = null;
128
+
129
+ function getBigInt64Memory0() {
130
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
131
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
132
+ }
133
+ return cachedBigInt64Memory0;
134
+ }
135
+
136
+ function debugString(val) {
137
+ // primitive types
138
+ const type = typeof val;
139
+ if (type == 'number' || type == 'boolean' || val == null) {
140
+ return `${val}`;
141
+ }
142
+ if (type == 'string') {
143
+ return `"${val}"`;
144
+ }
145
+ if (type == 'symbol') {
146
+ const description = val.description;
147
+ if (description == null) {
148
+ return 'Symbol';
149
+ } else {
150
+ return `Symbol(${description})`;
151
+ }
152
+ }
153
+ if (type == 'function') {
154
+ const name = val.name;
155
+ if (typeof name == 'string' && name.length > 0) {
156
+ return `Function(${name})`;
157
+ } else {
158
+ return 'Function';
159
+ }
160
+ }
161
+ // objects
162
+ if (Array.isArray(val)) {
163
+ const length = val.length;
164
+ let debug = '[';
165
+ if (length > 0) {
166
+ debug += debugString(val[0]);
167
+ }
168
+ for(let i = 1; i < length; i++) {
169
+ debug += ', ' + debugString(val[i]);
170
+ }
171
+ debug += ']';
172
+ return debug;
173
+ }
174
+ // Test for built-in
175
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
176
+ let className;
177
+ if (builtInMatches.length > 1) {
178
+ className = builtInMatches[1];
179
+ } else {
180
+ // Failed to match the standard '[object ClassName]'
181
+ return toString.call(val);
182
+ }
183
+ if (className == 'Object') {
184
+ // we're a user defined class or Object
185
+ // JSON.stringify avoids problems with cycles, and is generally much
186
+ // easier than looping through ownProperties of `val`.
187
+ try {
188
+ return 'Object(' + JSON.stringify(val) + ')';
189
+ } catch (_) {
190
+ return 'Object';
191
+ }
192
+ }
193
+ // errors
194
+ if (val instanceof Error) {
195
+ return `${val.name}: ${val.message}\n${val.stack}`;
196
+ }
197
+ // TODO we could test for more things here, like `Set`s and `Map`s.
198
+ return className;
199
+ }
200
+ /**
201
+ * @param {any} js_input
202
+ * @returns {string}
203
+ */
204
+ export function evaluate(js_input) {
205
+ let deferred1_0;
206
+ let deferred1_1;
207
+ try {
208
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
209
+ wasm.evaluate(retptr, addHeapObject(js_input));
210
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
211
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
212
+ deferred1_0 = r0;
213
+ deferred1_1 = r1;
214
+ return getStringFromWasm0(r0, r1);
215
+ } finally {
216
+ wasm.__wbindgen_add_to_stack_pointer(16);
217
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
218
+ }
219
+ }
220
+
20
221
  /**
222
+ * @param {any} js_input
223
+ * @param {Function} post_message
21
224
  */
22
- export function greet() {
23
- wasm.greet();
225
+ export function optimize(js_input, post_message) {
226
+ wasm.optimize(addHeapObject(js_input), addHeapObject(post_message));
227
+ }
228
+
229
+ function handleError(f, args) {
230
+ try {
231
+ return f.apply(this, args);
232
+ } catch (e) {
233
+ wasm.__wbindgen_exn_store(addHeapObject(e));
234
+ }
235
+ }
236
+ /**
237
+ */
238
+ export class WebInterface {
239
+
240
+ __destroy_into_raw() {
241
+ const ptr = this.__wbg_ptr;
242
+ this.__wbg_ptr = 0;
243
+
244
+ return ptr;
245
+ }
246
+
247
+ free() {
248
+ const ptr = this.__destroy_into_raw();
249
+ wasm.__wbg_webinterface_free(ptr);
250
+ }
24
251
  }
25
252
 
26
253
  async function __wbg_load(module, imports) {
@@ -57,8 +284,306 @@ async function __wbg_load(module, imports) {
57
284
  function __wbg_get_imports() {
58
285
  const imports = {};
59
286
  imports.wbg = {};
60
- imports.wbg.__wbg_alert_bc2b46846616b07c = function(arg0, arg1) {
61
- alert(getStringFromWasm0(arg0, arg1));
287
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
288
+ const v = getObject(arg0);
289
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
290
+ return ret;
291
+ };
292
+ imports.wbg.__wbindgen_is_bigint = function(arg0) {
293
+ const ret = typeof(getObject(arg0)) === 'bigint';
294
+ return ret;
295
+ };
296
+ imports.wbg.__wbindgen_bigint_from_i64 = function(arg0) {
297
+ const ret = arg0;
298
+ return addHeapObject(ret);
299
+ };
300
+ imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
301
+ const ret = getObject(arg0) === getObject(arg1);
302
+ return ret;
303
+ };
304
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
305
+ takeObject(arg0);
306
+ };
307
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
308
+ const ret = BigInt.asUintN(64, arg0);
309
+ return addHeapObject(ret);
310
+ };
311
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
312
+ const obj = getObject(arg1);
313
+ const ret = typeof(obj) === 'number' ? obj : undefined;
314
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
315
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
316
+ };
317
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
318
+ const obj = getObject(arg1);
319
+ const ret = typeof(obj) === 'string' ? obj : undefined;
320
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ var len1 = WASM_VECTOR_LEN;
322
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
323
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
324
+ };
325
+ imports.wbg.__wbindgen_is_object = function(arg0) {
326
+ const val = getObject(arg0);
327
+ const ret = typeof(val) === 'object' && val !== null;
328
+ return ret;
329
+ };
330
+ imports.wbg.__wbindgen_in = function(arg0, arg1) {
331
+ const ret = getObject(arg0) in getObject(arg1);
332
+ return ret;
333
+ };
334
+ imports.wbg.__wbindgen_is_string = function(arg0) {
335
+ const ret = typeof(getObject(arg0)) === 'string';
336
+ return ret;
337
+ };
338
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
339
+ const ret = getObject(arg0) === undefined;
340
+ return ret;
341
+ };
342
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
343
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
344
+ return addHeapObject(ret);
345
+ };
346
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
347
+ const ret = new Error();
348
+ return addHeapObject(ret);
349
+ };
350
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
351
+ const ret = getObject(arg1).stack;
352
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
353
+ const len1 = WASM_VECTOR_LEN;
354
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
355
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
356
+ };
357
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
358
+ let deferred0_0;
359
+ let deferred0_1;
360
+ try {
361
+ deferred0_0 = arg0;
362
+ deferred0_1 = arg1;
363
+ console.error(getStringFromWasm0(arg0, arg1));
364
+ } finally {
365
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
366
+ }
367
+ };
368
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
369
+ const ret = getObject(arg0);
370
+ return addHeapObject(ret);
371
+ };
372
+ imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
373
+ const ret = getObject(arg0) == getObject(arg1);
374
+ return ret;
375
+ };
376
+ imports.wbg.__wbindgen_as_number = function(arg0) {
377
+ const ret = +getObject(arg0);
378
+ return ret;
379
+ };
380
+ imports.wbg.__wbindgen_number_new = function(arg0) {
381
+ const ret = arg0;
382
+ return addHeapObject(ret);
383
+ };
384
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
385
+ const ret = getStringFromWasm0(arg0, arg1);
386
+ return addHeapObject(ret);
387
+ };
388
+ imports.wbg.__wbg_getwithrefkey_4a92a5eca60879b9 = function(arg0, arg1) {
389
+ const ret = getObject(arg0)[getObject(arg1)];
390
+ return addHeapObject(ret);
391
+ };
392
+ imports.wbg.__wbg_set_9182712abebf82ef = function(arg0, arg1, arg2) {
393
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
394
+ };
395
+ imports.wbg.__wbg_performance_bdf4f1a290fc5c5c = function(arg0) {
396
+ const ret = getObject(arg0).performance;
397
+ return addHeapObject(ret);
398
+ };
399
+ imports.wbg.__wbg_now_d87295c25be68e8b = function(arg0) {
400
+ const ret = getObject(arg0).now();
401
+ return ret;
402
+ };
403
+ imports.wbg.__wbg_crypto_58f13aa23ffcb166 = function(arg0) {
404
+ const ret = getObject(arg0).crypto;
405
+ return addHeapObject(ret);
406
+ };
407
+ imports.wbg.__wbg_process_5b786e71d465a513 = function(arg0) {
408
+ const ret = getObject(arg0).process;
409
+ return addHeapObject(ret);
410
+ };
411
+ imports.wbg.__wbg_versions_c2ab80650590b6a2 = function(arg0) {
412
+ const ret = getObject(arg0).versions;
413
+ return addHeapObject(ret);
414
+ };
415
+ imports.wbg.__wbg_node_523d7bd03ef69fba = function(arg0) {
416
+ const ret = getObject(arg0).node;
417
+ return addHeapObject(ret);
418
+ };
419
+ imports.wbg.__wbg_msCrypto_abcb1295e768d1f2 = function(arg0) {
420
+ const ret = getObject(arg0).msCrypto;
421
+ return addHeapObject(ret);
422
+ };
423
+ imports.wbg.__wbg_require_2784e593a4674877 = function() { return handleError(function () {
424
+ const ret = module.require;
425
+ return addHeapObject(ret);
426
+ }, arguments) };
427
+ imports.wbg.__wbindgen_is_function = function(arg0) {
428
+ const ret = typeof(getObject(arg0)) === 'function';
429
+ return ret;
430
+ };
431
+ imports.wbg.__wbg_randomFillSync_a0d98aa11c81fe89 = function() { return handleError(function (arg0, arg1) {
432
+ getObject(arg0).randomFillSync(takeObject(arg1));
433
+ }, arguments) };
434
+ imports.wbg.__wbg_getRandomValues_504510b5564925af = function() { return handleError(function (arg0, arg1) {
435
+ getObject(arg0).getRandomValues(getObject(arg1));
436
+ }, arguments) };
437
+ imports.wbg.__wbg_get_f01601b5a68d10e3 = function(arg0, arg1) {
438
+ const ret = getObject(arg0)[arg1 >>> 0];
439
+ return addHeapObject(ret);
440
+ };
441
+ imports.wbg.__wbg_length_1009b1af0c481d7b = function(arg0) {
442
+ const ret = getObject(arg0).length;
443
+ return ret;
444
+ };
445
+ imports.wbg.__wbg_newnoargs_c62ea9419c21fbac = function(arg0, arg1) {
446
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
447
+ return addHeapObject(ret);
448
+ };
449
+ imports.wbg.__wbg_next_9b877f231f476d01 = function(arg0) {
450
+ const ret = getObject(arg0).next;
451
+ return addHeapObject(ret);
452
+ };
453
+ imports.wbg.__wbg_next_6529ee0cca8d57ed = function() { return handleError(function (arg0) {
454
+ const ret = getObject(arg0).next();
455
+ return addHeapObject(ret);
456
+ }, arguments) };
457
+ imports.wbg.__wbg_done_5fe336b092d60cf2 = function(arg0) {
458
+ const ret = getObject(arg0).done;
459
+ return ret;
460
+ };
461
+ imports.wbg.__wbg_value_0c248a78fdc8e19f = function(arg0) {
462
+ const ret = getObject(arg0).value;
463
+ return addHeapObject(ret);
464
+ };
465
+ imports.wbg.__wbg_iterator_db7ca081358d4fb2 = function() {
466
+ const ret = Symbol.iterator;
467
+ return addHeapObject(ret);
468
+ };
469
+ imports.wbg.__wbg_get_7b48513de5dc5ea4 = function() { return handleError(function (arg0, arg1) {
470
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
471
+ return addHeapObject(ret);
472
+ }, arguments) };
473
+ imports.wbg.__wbg_call_90c26b09837aba1c = function() { return handleError(function (arg0, arg1) {
474
+ const ret = getObject(arg0).call(getObject(arg1));
475
+ return addHeapObject(ret);
476
+ }, arguments) };
477
+ imports.wbg.__wbg_new_9fb8d994e1c0aaac = function() {
478
+ const ret = new Object();
479
+ return addHeapObject(ret);
480
+ };
481
+ imports.wbg.__wbg_length_36658cb09b6ec34a = function(arg0) {
482
+ const ret = getObject(arg0).length;
483
+ return ret;
484
+ };
485
+ imports.wbg.__wbg_codePointAt_8ce1187388f5c427 = function(arg0, arg1) {
486
+ const ret = getObject(arg0).codePointAt(arg1 >>> 0);
487
+ return addHeapObject(ret);
488
+ };
489
+ imports.wbg.__wbg_self_f0e34d89f33b99fd = function() { return handleError(function () {
490
+ const ret = self.self;
491
+ return addHeapObject(ret);
492
+ }, arguments) };
493
+ imports.wbg.__wbg_window_d3b084224f4774d7 = function() { return handleError(function () {
494
+ const ret = window.window;
495
+ return addHeapObject(ret);
496
+ }, arguments) };
497
+ imports.wbg.__wbg_globalThis_9caa27ff917c6860 = function() { return handleError(function () {
498
+ const ret = globalThis.globalThis;
499
+ return addHeapObject(ret);
500
+ }, arguments) };
501
+ imports.wbg.__wbg_global_35dfdd59a4da3e74 = function() { return handleError(function () {
502
+ const ret = global.global;
503
+ return addHeapObject(ret);
504
+ }, arguments) };
505
+ imports.wbg.__wbg_isArray_74fb723e24f76012 = function(arg0) {
506
+ const ret = Array.isArray(getObject(arg0));
507
+ return ret;
508
+ };
509
+ imports.wbg.__wbg_instanceof_ArrayBuffer_e7d53d51371448e2 = function(arg0) {
510
+ let result;
511
+ try {
512
+ result = getObject(arg0) instanceof ArrayBuffer;
513
+ } catch (_) {
514
+ result = false;
515
+ }
516
+ const ret = result;
517
+ return ret;
518
+ };
519
+ imports.wbg.__wbg_call_5da1969d7cd31ccd = function() { return handleError(function (arg0, arg1, arg2) {
520
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
521
+ return addHeapObject(ret);
522
+ }, arguments) };
523
+ imports.wbg.__wbg_isSafeInteger_f93fde0dca9820f8 = function(arg0) {
524
+ const ret = Number.isSafeInteger(getObject(arg0));
525
+ return ret;
526
+ };
527
+ imports.wbg.__wbg_entries_9e2e2aa45aa5094a = function(arg0) {
528
+ const ret = Object.entries(getObject(arg0));
529
+ return addHeapObject(ret);
530
+ };
531
+ imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
532
+ const ret = getObject(arg0).buffer;
533
+ return addHeapObject(ret);
534
+ };
535
+ imports.wbg.__wbg_newwithbyteoffsetandlength_d0482f893617af71 = function(arg0, arg1, arg2) {
536
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
537
+ return addHeapObject(ret);
538
+ };
539
+ imports.wbg.__wbg_new_8f67e318f15d7254 = function(arg0) {
540
+ const ret = new Uint8Array(getObject(arg0));
541
+ return addHeapObject(ret);
542
+ };
543
+ imports.wbg.__wbg_set_2357bf09366ee480 = function(arg0, arg1, arg2) {
544
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
545
+ };
546
+ imports.wbg.__wbg_length_1d25fa9e4ac21ce7 = function(arg0) {
547
+ const ret = getObject(arg0).length;
548
+ return ret;
549
+ };
550
+ imports.wbg.__wbg_instanceof_Uint8Array_bced6f43aed8c1aa = function(arg0) {
551
+ let result;
552
+ try {
553
+ result = getObject(arg0) instanceof Uint8Array;
554
+ } catch (_) {
555
+ result = false;
556
+ }
557
+ const ret = result;
558
+ return ret;
559
+ };
560
+ imports.wbg.__wbg_newwithlength_6c2df9e2f3028c43 = function(arg0) {
561
+ const ret = new Uint8Array(arg0 >>> 0);
562
+ return addHeapObject(ret);
563
+ };
564
+ imports.wbg.__wbg_subarray_2e940e41c0f5a1d9 = function(arg0, arg1, arg2) {
565
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
566
+ return addHeapObject(ret);
567
+ };
568
+ imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
569
+ const v = getObject(arg1);
570
+ const ret = typeof(v) === 'bigint' ? v : undefined;
571
+ getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
572
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
573
+ };
574
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
575
+ const ret = debugString(getObject(arg1));
576
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
577
+ const len1 = WASM_VECTOR_LEN;
578
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
579
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
580
+ };
581
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
582
+ throw new Error(getStringFromWasm0(arg0, arg1));
583
+ };
584
+ imports.wbg.__wbindgen_memory = function() {
585
+ const ret = wasm.memory;
586
+ return addHeapObject(ret);
62
587
  };
63
588
 
64
589
  return imports;
@@ -71,6 +596,9 @@ function __wbg_init_memory(imports, maybe_memory) {
71
596
  function __wbg_finalize_init(instance, module) {
72
597
  wasm = instance.exports;
73
598
  __wbg_init.__wbindgen_wasm_module = module;
599
+ cachedBigInt64Memory0 = null;
600
+ cachedFloat64Memory0 = null;
601
+ cachedInt32Memory0 = null;
74
602
  cachedUint8Memory0 = null;
75
603
 
76
604
 
package/libchai_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Songchen Tan <i@tansongchen.com>"
5
5
  ],
6
- "version": "0.1.0",
6
+ "version": "0.1.2",
7
7
  "files": [
8
8
  "libchai_bg.wasm",
9
9
  "libchai.js",