mons-web 0.1.5 → 0.1.7

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 +1,6 @@
1
- `npm install mons-web`
1
+ # mons-rust
2
+ `cargo add mons-rust`
3
+
4
+ or
5
+
6
+ `npm install mons-rust`
package/mons_rust.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
+ * @returns {string}
5
+ */
6
+ export function hello(): string;
7
+ /**
4
8
  * @param {string} fen_w
5
9
  * @param {string} fen_b
6
10
  * @param {string} flat_moves_string_w
@@ -8,16 +12,46 @@
8
12
  * @returns {string}
9
13
  */
10
14
  export function winner(fen_w: string, fen_b: string, flat_moves_string_w: string, flat_moves_string_b: string): string;
15
+ /**
16
+ */
17
+ export enum Modifier {
18
+ SelectPotion = 0,
19
+ SelectBomb = 1,
20
+ Cancel = 2,
21
+ }
22
+ /**
23
+ */
24
+ export enum Color {
25
+ White = 0,
26
+ Black = 1,
27
+ }
28
+ /**
29
+ */
30
+ export class Location {
31
+ free(): void;
32
+ /**
33
+ */
34
+ i: number;
35
+ /**
36
+ */
37
+ j: number;
38
+ }
11
39
 
12
40
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
13
41
 
14
42
  export interface InitOutput {
15
43
  readonly memory: WebAssembly.Memory;
44
+ readonly __wbg_location_free: (a: number) => void;
45
+ readonly __wbg_get_location_i: (a: number) => number;
46
+ readonly __wbg_set_location_i: (a: number, b: number) => void;
47
+ readonly __wbg_get_location_j: (a: number) => number;
48
+ readonly __wbg_set_location_j: (a: number, b: number) => void;
49
+ readonly hello: (a: number) => void;
16
50
  readonly winner: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
17
51
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
52
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
18
53
  readonly __wbindgen_malloc: (a: number, b: number) => number;
19
54
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
20
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
21
55
  }
22
56
 
23
57
  export type SyncInitInput = BufferSource | WebAssembly.Module;
package/mons_rust.js CHANGED
@@ -1,6 +1,8 @@
1
1
  let wasm;
2
2
 
3
- let WASM_VECTOR_LEN = 0;
3
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
4
+
5
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
4
6
 
5
7
  let cachedUint8Memory0 = null;
6
8
 
@@ -11,6 +13,41 @@ function getUint8Memory0() {
11
13
  return cachedUint8Memory0;
12
14
  }
13
15
 
16
+ function getStringFromWasm0(ptr, len) {
17
+ ptr = ptr >>> 0;
18
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
+ }
20
+
21
+ let cachedInt32Memory0 = null;
22
+
23
+ function getInt32Memory0() {
24
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
25
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
26
+ }
27
+ return cachedInt32Memory0;
28
+ }
29
+ /**
30
+ * @returns {string}
31
+ */
32
+ export function hello() {
33
+ let deferred1_0;
34
+ let deferred1_1;
35
+ try {
36
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
37
+ wasm.hello(retptr);
38
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
39
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
40
+ deferred1_0 = r0;
41
+ deferred1_1 = r1;
42
+ return getStringFromWasm0(r0, r1);
43
+ } finally {
44
+ wasm.__wbindgen_add_to_stack_pointer(16);
45
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
46
+ }
47
+ }
48
+
49
+ let WASM_VECTOR_LEN = 0;
50
+
14
51
  const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
15
52
 
16
53
  const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
@@ -64,24 +101,6 @@ function passStringToWasm0(arg, malloc, realloc) {
64
101
  WASM_VECTOR_LEN = offset;
65
102
  return ptr;
66
103
  }
67
-
68
- let cachedInt32Memory0 = null;
69
-
70
- function getInt32Memory0() {
71
- if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
72
- cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
73
- }
74
- return cachedInt32Memory0;
75
- }
76
-
77
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
78
-
79
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
80
-
81
- function getStringFromWasm0(ptr, len) {
82
- ptr = ptr >>> 0;
83
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
84
- }
85
104
  /**
86
105
  * @param {string} fen_w
87
106
  * @param {string} fen_b
@@ -114,6 +133,59 @@ export function winner(fen_w, fen_b, flat_moves_string_w, flat_moves_string_b) {
114
133
  }
115
134
  }
116
135
 
136
+ /**
137
+ */
138
+ export const Modifier = Object.freeze({ SelectPotion:0,"0":"SelectPotion",SelectBomb:1,"1":"SelectBomb",Cancel:2,"2":"Cancel", });
139
+ /**
140
+ */
141
+ export const Color = Object.freeze({ White:0,"0":"White",Black:1,"1":"Black", });
142
+
143
+ const LocationFinalization = (typeof FinalizationRegistry === 'undefined')
144
+ ? { register: () => {}, unregister: () => {} }
145
+ : new FinalizationRegistry(ptr => wasm.__wbg_location_free(ptr >>> 0));
146
+ /**
147
+ */
148
+ export class Location {
149
+
150
+ __destroy_into_raw() {
151
+ const ptr = this.__wbg_ptr;
152
+ this.__wbg_ptr = 0;
153
+ LocationFinalization.unregister(this);
154
+ return ptr;
155
+ }
156
+
157
+ free() {
158
+ const ptr = this.__destroy_into_raw();
159
+ wasm.__wbg_location_free(ptr);
160
+ }
161
+ /**
162
+ * @returns {number}
163
+ */
164
+ get i() {
165
+ const ret = wasm.__wbg_get_location_i(this.__wbg_ptr);
166
+ return ret;
167
+ }
168
+ /**
169
+ * @param {number} arg0
170
+ */
171
+ set i(arg0) {
172
+ wasm.__wbg_set_location_i(this.__wbg_ptr, arg0);
173
+ }
174
+ /**
175
+ * @returns {number}
176
+ */
177
+ get j() {
178
+ const ret = wasm.__wbg_get_location_j(this.__wbg_ptr);
179
+ return ret;
180
+ }
181
+ /**
182
+ * @param {number} arg0
183
+ */
184
+ set j(arg0) {
185
+ wasm.__wbg_set_location_j(this.__wbg_ptr, arg0);
186
+ }
187
+ }
188
+
117
189
  async function __wbg_load(module, imports) {
118
190
  if (typeof Response === 'function' && module instanceof Response) {
119
191
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -148,6 +220,9 @@ async function __wbg_load(module, imports) {
148
220
  function __wbg_get_imports() {
149
221
  const imports = {};
150
222
  imports.wbg = {};
223
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
224
+ throw new Error(getStringFromWasm0(arg0, arg1));
225
+ };
151
226
 
152
227
  return imports;
153
228
  }
package/mons_rust_bg.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mons-web",
3
3
  "description": "super metal mons",
4
- "version": "0.1.5",
4
+ "version": "0.1.7",
5
5
  "license": "CC0-1.0",
6
6
  "files": [
7
7
  "mons_rust_bg.wasm",