libchai 0.1.2 → 0.1.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 +9 -1
- package/{libchai.d.ts → chai.d.ts} +9 -4
- package/{libchai.js → chai.js} +48 -40
- package/chai_bg.wasm +0 -0
- package/package.json +6 -6
- package/libchai_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
## 使用
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
压缩包解压后,根目录中有几个不同的二进制文件:
|
|
8
|
+
|
|
9
|
+
- `chai` 是 macOS 系统上的可执行文件,它是一个通用二进制文件,意味着 x86_64 架构和 arm64 架构的 Mac 电脑都能使用;
|
|
10
|
+
- `chai.exe` 是 Windows 系统上的可执行文件(基于 MinGW);
|
|
11
|
+
- `chai-musl` 和 `chai-gnu` 是 Linux 系统上的可执行文件,分别基于 musl libc 和 glibc
|
|
12
|
+
- 使用 musl libc 的二进制通常兼容性较好
|
|
13
|
+
- 使用 glibc 的二进制要依赖于运行环境中的 glibc,但是通常运行效率较高
|
|
14
|
+
|
|
15
|
+
请根据您的运行环境选用适当的二进制文件。
|
|
8
16
|
|
|
9
17
|
### 输入格式解释及示例
|
|
10
18
|
|
|
@@ -2,9 +2,14 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/**
|
|
4
4
|
* @param {any} js_input
|
|
5
|
-
* @returns {
|
|
5
|
+
* @returns {any}
|
|
6
6
|
*/
|
|
7
|
-
export function
|
|
7
|
+
export function encode(js_input: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} js_input
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function evaluate(js_input: any): any;
|
|
8
13
|
/**
|
|
9
14
|
* @param {any} js_input
|
|
10
15
|
* @param {Function} post_message
|
|
@@ -21,11 +26,11 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
21
26
|
export interface InitOutput {
|
|
22
27
|
readonly memory: WebAssembly.Memory;
|
|
23
28
|
readonly __wbg_webinterface_free: (a: number) => void;
|
|
24
|
-
readonly
|
|
29
|
+
readonly encode: (a: number) => number;
|
|
30
|
+
readonly evaluate: (a: number) => number;
|
|
25
31
|
readonly optimize: (a: number, b: number) => void;
|
|
26
32
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
27
33
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
28
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
29
34
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
30
35
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
31
36
|
}
|
package/{libchai.js → chai.js}
RENAMED
|
@@ -29,6 +29,24 @@ function takeObject(idx) {
|
|
|
29
29
|
return ret;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
33
|
+
|
|
34
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
35
|
+
|
|
36
|
+
let cachedUint8Memory0 = null;
|
|
37
|
+
|
|
38
|
+
function getUint8Memory0() {
|
|
39
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
40
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
41
|
+
}
|
|
42
|
+
return cachedUint8Memory0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getStringFromWasm0(ptr, len) {
|
|
46
|
+
ptr = ptr >>> 0;
|
|
47
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
function isLikeNone(x) {
|
|
33
51
|
return x === undefined || x === null;
|
|
34
52
|
}
|
|
@@ -53,15 +71,6 @@ function getInt32Memory0() {
|
|
|
53
71
|
|
|
54
72
|
let WASM_VECTOR_LEN = 0;
|
|
55
73
|
|
|
56
|
-
let cachedUint8Memory0 = null;
|
|
57
|
-
|
|
58
|
-
function getUint8Memory0() {
|
|
59
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
60
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
61
|
-
}
|
|
62
|
-
return cachedUint8Memory0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
74
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
66
75
|
|
|
67
76
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -115,15 +124,6 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
115
124
|
return ptr;
|
|
116
125
|
}
|
|
117
126
|
|
|
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
|
-
|
|
122
|
-
function getStringFromWasm0(ptr, len) {
|
|
123
|
-
ptr = ptr >>> 0;
|
|
124
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
127
|
let cachedBigInt64Memory0 = null;
|
|
128
128
|
|
|
129
129
|
function getBigInt64Memory0() {
|
|
@@ -199,23 +199,20 @@ function debugString(val) {
|
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* @param {any} js_input
|
|
202
|
-
* @returns {
|
|
202
|
+
* @returns {any}
|
|
203
|
+
*/
|
|
204
|
+
export function encode(js_input) {
|
|
205
|
+
const ret = wasm.encode(addHeapObject(js_input));
|
|
206
|
+
return takeObject(ret);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {any} js_input
|
|
211
|
+
* @returns {any}
|
|
203
212
|
*/
|
|
204
213
|
export function evaluate(js_input) {
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
}
|
|
214
|
+
const ret = wasm.evaluate(addHeapObject(js_input));
|
|
215
|
+
return takeObject(ret);
|
|
219
216
|
}
|
|
220
217
|
|
|
221
218
|
/**
|
|
@@ -308,6 +305,10 @@ function __wbg_get_imports() {
|
|
|
308
305
|
const ret = BigInt.asUintN(64, arg0);
|
|
309
306
|
return addHeapObject(ret);
|
|
310
307
|
};
|
|
308
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
309
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
310
|
+
return addHeapObject(ret);
|
|
311
|
+
};
|
|
311
312
|
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
312
313
|
const obj = getObject(arg1);
|
|
313
314
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
@@ -339,10 +340,6 @@ function __wbg_get_imports() {
|
|
|
339
340
|
const ret = getObject(arg0) === undefined;
|
|
340
341
|
return ret;
|
|
341
342
|
};
|
|
342
|
-
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
343
|
-
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
344
|
-
return addHeapObject(ret);
|
|
345
|
-
};
|
|
346
343
|
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
347
344
|
const ret = new Error();
|
|
348
345
|
return addHeapObject(ret);
|
|
@@ -392,11 +389,11 @@ function __wbg_get_imports() {
|
|
|
392
389
|
imports.wbg.__wbg_set_9182712abebf82ef = function(arg0, arg1, arg2) {
|
|
393
390
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
394
391
|
};
|
|
395
|
-
imports.wbg.
|
|
392
|
+
imports.wbg.__wbg_performance_eeefc685c9bc38b4 = function(arg0) {
|
|
396
393
|
const ret = getObject(arg0).performance;
|
|
397
394
|
return addHeapObject(ret);
|
|
398
395
|
};
|
|
399
|
-
imports.wbg.
|
|
396
|
+
imports.wbg.__wbg_now_e0d8ec93dd25766a = function(arg0) {
|
|
400
397
|
const ret = getObject(arg0).now();
|
|
401
398
|
return ret;
|
|
402
399
|
};
|
|
@@ -442,6 +439,10 @@ function __wbg_get_imports() {
|
|
|
442
439
|
const ret = getObject(arg0).length;
|
|
443
440
|
return ret;
|
|
444
441
|
};
|
|
442
|
+
imports.wbg.__wbg_new_ffc6d4d085022169 = function() {
|
|
443
|
+
const ret = new Array();
|
|
444
|
+
return addHeapObject(ret);
|
|
445
|
+
};
|
|
445
446
|
imports.wbg.__wbg_newnoargs_c62ea9419c21fbac = function(arg0, arg1) {
|
|
446
447
|
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
447
448
|
return addHeapObject(ret);
|
|
@@ -502,6 +503,9 @@ function __wbg_get_imports() {
|
|
|
502
503
|
const ret = global.global;
|
|
503
504
|
return addHeapObject(ret);
|
|
504
505
|
}, arguments) };
|
|
506
|
+
imports.wbg.__wbg_set_f2740edb12e318cd = function(arg0, arg1, arg2) {
|
|
507
|
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
508
|
+
};
|
|
505
509
|
imports.wbg.__wbg_isArray_74fb723e24f76012 = function(arg0) {
|
|
506
510
|
const ret = Array.isArray(getObject(arg0));
|
|
507
511
|
return ret;
|
|
@@ -528,6 +532,10 @@ function __wbg_get_imports() {
|
|
|
528
532
|
const ret = Object.entries(getObject(arg0));
|
|
529
533
|
return addHeapObject(ret);
|
|
530
534
|
};
|
|
535
|
+
imports.wbg.__wbg_fromCodePoint_fd9383eff8873c75 = function() { return handleError(function (arg0) {
|
|
536
|
+
const ret = String.fromCodePoint(arg0 >>> 0);
|
|
537
|
+
return addHeapObject(ret);
|
|
538
|
+
}, arguments) };
|
|
531
539
|
imports.wbg.__wbg_buffer_a448f833075b71ba = function(arg0) {
|
|
532
540
|
const ret = getObject(arg0).buffer;
|
|
533
541
|
return addHeapObject(ret);
|
|
@@ -625,7 +633,7 @@ async function __wbg_init(input) {
|
|
|
625
633
|
if (wasm !== undefined) return wasm;
|
|
626
634
|
|
|
627
635
|
if (typeof input === 'undefined') {
|
|
628
|
-
input = new URL('
|
|
636
|
+
input = new URL('chai_bg.wasm', import.meta.url);
|
|
629
637
|
}
|
|
630
638
|
const imports = __wbg_get_imports();
|
|
631
639
|
|
package/chai_bg.wasm
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
"collaborators": [
|
|
4
4
|
"Songchen Tan <i@tansongchen.com>"
|
|
5
5
|
],
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.3",
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
8
|
+
"chai_bg.wasm",
|
|
9
|
+
"chai.js",
|
|
10
|
+
"chai.d.ts"
|
|
11
11
|
],
|
|
12
|
-
"module": "
|
|
13
|
-
"types": "
|
|
12
|
+
"module": "chai.js",
|
|
13
|
+
"types": "chai.d.ts",
|
|
14
14
|
"sideEffects": [
|
|
15
15
|
"./snippets/*"
|
|
16
16
|
]
|
package/libchai_bg.wasm
DELETED
|
Binary file
|