mons-rust 0.1.1 → 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/mons_rust.d.ts +6 -30
- package/mons_rust.js +43 -90
- package/mons_rust_bg.wasm +0 -0
- package/package.json +2 -6
package/mons_rust.d.ts
CHANGED
|
@@ -5,35 +5,11 @@
|
|
|
5
5
|
* @returns {string}
|
|
6
6
|
*/
|
|
7
7
|
export function greet(name: string): string;
|
|
8
|
-
|
|
9
|
-
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
10
|
-
|
|
11
|
-
export interface InitOutput {
|
|
12
|
-
readonly memory: WebAssembly.Memory;
|
|
13
|
-
readonly greet: (a: number, b: number, c: number) => void;
|
|
14
|
-
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
15
|
-
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
16
|
-
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
17
|
-
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
21
8
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param {
|
|
26
|
-
*
|
|
27
|
-
* @returns {InitOutput}
|
|
28
|
-
*/
|
|
29
|
-
export function initSync(module: SyncInitInput): InitOutput;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
33
|
-
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
34
|
-
*
|
|
35
|
-
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
36
|
-
*
|
|
37
|
-
* @returns {Promise<InitOutput>}
|
|
9
|
+
* @param {string} fen1
|
|
10
|
+
* @param {string} fen2
|
|
11
|
+
* @param {string} flatMovesString1
|
|
12
|
+
* @param {string} flatMovesString2
|
|
13
|
+
* @returns {string}
|
|
38
14
|
*/
|
|
39
|
-
export
|
|
15
|
+
export function winner(fen1: string, fen2: string, flatMovesString1: string, flatMovesString2: string): string;
|
package/mons_rust.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
let imports = {};
|
|
1
2
|
let wasm;
|
|
3
|
+
const { TextEncoder, TextDecoder } = require(`util`);
|
|
2
4
|
|
|
3
5
|
let WASM_VECTOR_LEN = 0;
|
|
4
6
|
|
|
@@ -11,7 +13,7 @@ function getUint8Memory0() {
|
|
|
11
13
|
return cachedUint8Memory0;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
let cachedTextEncoder = new TextEncoder('utf-8');
|
|
15
17
|
|
|
16
18
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
17
19
|
? function (arg, view) {
|
|
@@ -74,9 +76,9 @@ function getInt32Memory0() {
|
|
|
74
76
|
return cachedInt32Memory0;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
cachedTextDecoder.decode();
|
|
80
82
|
|
|
81
83
|
function getStringFromWasm0(ptr, len) {
|
|
82
84
|
ptr = ptr >>> 0;
|
|
@@ -86,7 +88,7 @@ function getStringFromWasm0(ptr, len) {
|
|
|
86
88
|
* @param {string} name
|
|
87
89
|
* @returns {string}
|
|
88
90
|
*/
|
|
89
|
-
|
|
91
|
+
module.exports.greet = function(name) {
|
|
90
92
|
let deferred2_0;
|
|
91
93
|
let deferred2_1;
|
|
92
94
|
try {
|
|
@@ -103,94 +105,45 @@ export function greet(name) {
|
|
|
103
105
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
104
106
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
105
107
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async function __wbg_load(module, imports) {
|
|
109
|
-
if (typeof Response === 'function' && module instanceof Response) {
|
|
110
|
-
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
111
|
-
try {
|
|
112
|
-
return await WebAssembly.instantiateStreaming(module, imports);
|
|
113
|
-
|
|
114
|
-
} catch (e) {
|
|
115
|
-
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
116
|
-
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);
|
|
117
|
-
|
|
118
|
-
} else {
|
|
119
|
-
throw e;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const bytes = await module.arrayBuffer();
|
|
125
|
-
return await WebAssembly.instantiate(bytes, imports);
|
|
126
|
-
|
|
127
|
-
} else {
|
|
128
|
-
const instance = await WebAssembly.instantiate(module, imports);
|
|
129
|
-
|
|
130
|
-
if (instance instanceof WebAssembly.Instance) {
|
|
131
|
-
return { instance, module };
|
|
132
|
-
|
|
133
|
-
} else {
|
|
134
|
-
return instance;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function __wbg_get_imports() {
|
|
140
|
-
const imports = {};
|
|
141
|
-
imports.wbg = {};
|
|
142
|
-
|
|
143
|
-
return imports;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function __wbg_init_memory(imports, maybe_memory) {
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function __wbg_finalize_init(instance, module) {
|
|
151
|
-
wasm = instance.exports;
|
|
152
|
-
__wbg_init.__wbindgen_wasm_module = module;
|
|
153
|
-
cachedInt32Memory0 = null;
|
|
154
|
-
cachedUint8Memory0 = null;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return wasm;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function initSync(module) {
|
|
161
|
-
if (wasm !== undefined) return wasm;
|
|
108
|
+
};
|
|
162
109
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
110
|
+
/**
|
|
111
|
+
* @param {string} fen1
|
|
112
|
+
* @param {string} fen2
|
|
113
|
+
* @param {string} flatMovesString1
|
|
114
|
+
* @param {string} flatMovesString2
|
|
115
|
+
* @returns {string}
|
|
116
|
+
*/
|
|
117
|
+
module.exports.winner = function(fen1, fen2, flatMovesString1, flatMovesString2) {
|
|
118
|
+
let deferred5_0;
|
|
119
|
+
let deferred5_1;
|
|
120
|
+
try {
|
|
121
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
122
|
+
const ptr0 = passStringToWasm0(fen1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
123
|
+
const len0 = WASM_VECTOR_LEN;
|
|
124
|
+
const ptr1 = passStringToWasm0(fen2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
125
|
+
const len1 = WASM_VECTOR_LEN;
|
|
126
|
+
const ptr2 = passStringToWasm0(flatMovesString1, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
127
|
+
const len2 = WASM_VECTOR_LEN;
|
|
128
|
+
const ptr3 = passStringToWasm0(flatMovesString2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
129
|
+
const len3 = WASM_VECTOR_LEN;
|
|
130
|
+
wasm.winner(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
131
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
132
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
133
|
+
deferred5_0 = r0;
|
|
134
|
+
deferred5_1 = r1;
|
|
135
|
+
return getStringFromWasm0(r0, r1);
|
|
136
|
+
} finally {
|
|
137
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
138
|
+
wasm.__wbindgen_free(deferred5_0, deferred5_1, 1);
|
|
186
139
|
}
|
|
140
|
+
};
|
|
187
141
|
|
|
188
|
-
|
|
142
|
+
const path = require('path').join(__dirname, 'mons_rust_bg.wasm');
|
|
143
|
+
const bytes = require('fs').readFileSync(path);
|
|
189
144
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
145
|
+
const wasmModule = new WebAssembly.Module(bytes);
|
|
146
|
+
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
|
147
|
+
wasm = wasmInstance.exports;
|
|
148
|
+
module.exports.__wasm = wasm;
|
|
194
149
|
|
|
195
|
-
export { initSync }
|
|
196
|
-
export default __wbg_init;
|
package/mons_rust_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mons-rust",
|
|
3
3
|
"description": "super metal mons",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3",
|
|
5
5
|
"license": "CC0-1.0",
|
|
6
6
|
"files": [
|
|
7
7
|
"mons_rust_bg.wasm",
|
|
8
8
|
"mons_rust.js",
|
|
9
9
|
"mons_rust.d.ts"
|
|
10
10
|
],
|
|
11
|
-
"module": "mons_rust.js",
|
|
12
|
-
"types": "mons_rust.d.ts",
|
|
13
11
|
"main": "mons_rust.js",
|
|
14
|
-
"
|
|
15
|
-
"./snippets/*"
|
|
16
|
-
]
|
|
12
|
+
"types": "mons_rust.d.ts"
|
|
17
13
|
}
|