ms-toollib 0.1.0

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 ADDED
@@ -0,0 +1,69 @@
1
+ <div align="center">
2
+
3
+ <h1><code>wasm-pack-template</code></h1>
4
+
5
+ <strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong>
6
+
7
+ <p>
8
+ <a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
9
+ </p>
10
+
11
+ <h3>
12
+ <a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
13
+ <span> | </span>
14
+ <a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
15
+ </h3>
16
+
17
+ <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
18
+ </div>
19
+
20
+ ## About
21
+
22
+ [**📚 Read this template tutorial! 📚**][template-docs]
23
+
24
+ This template is designed for compiling Rust libraries into WebAssembly and
25
+ publishing the resulting package to NPM.
26
+
27
+ Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other
28
+ templates and usages of `wasm-pack`.
29
+
30
+ [tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html
31
+ [template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html
32
+
33
+ ## 🚴 Usage
34
+
35
+ ### 🐑 Use `cargo generate` to Clone this Template
36
+
37
+ [Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate)
38
+
39
+ ```
40
+ cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project
41
+ cd my-project
42
+ ```
43
+
44
+ ### 🛠️ Build with `wasm-pack build`
45
+
46
+ ```
47
+ wasm-pack build
48
+ ```
49
+
50
+ ### 🔬 Test in Headless Browsers with `wasm-pack test`
51
+
52
+ ```
53
+ wasm-pack test --headless --firefox
54
+ ```
55
+
56
+ ### 🎁 Publish to NPM with `wasm-pack publish`
57
+
58
+ ```
59
+ wasm-pack publish
60
+ ```
61
+
62
+ ## 🔋 Batteries Included
63
+
64
+ * [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating
65
+ between WebAssembly and JavaScript.
66
+ * [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)
67
+ for logging panic messages to the developer console.
68
+ * [`wee_alloc`](https://github.com/rustwasm/wee_alloc), an allocator optimized
69
+ for small code size.
@@ -0,0 +1,16 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ */
5
+ export function greet(): void;
6
+ /**
7
+ * @param {string} board_json
8
+ * @returns {number}
9
+ */
10
+ export function wasm_cal3BV(board_json: string): number;
11
+ /**
12
+ * @param {string} board_json
13
+ * @param {number} mine_num
14
+ * @returns {string}
15
+ */
16
+ export function wasm_cal_possibility_onboard(board_json: string, mine_num: number): string;
package/ms_toollib.js ADDED
@@ -0,0 +1,2 @@
1
+ import * as wasm from "./ms_toollib_bg.wasm";
2
+ export * from "./ms_toollib_bg.js";
@@ -0,0 +1,127 @@
1
+ import * as wasm from './ms_toollib_bg.wasm';
2
+
3
+ const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
4
+
5
+ let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
6
+
7
+ cachedTextDecoder.decode();
8
+
9
+ let cachegetUint8Memory0 = null;
10
+ function getUint8Memory0() {
11
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
12
+ cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
13
+ }
14
+ return cachegetUint8Memory0;
15
+ }
16
+
17
+ function getStringFromWasm0(ptr, len) {
18
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
19
+ }
20
+ /**
21
+ */
22
+ export function greet() {
23
+ wasm.greet();
24
+ }
25
+
26
+ let WASM_VECTOR_LEN = 0;
27
+
28
+ const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
29
+
30
+ let cachedTextEncoder = new lTextEncoder('utf-8');
31
+
32
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
33
+ ? function (arg, view) {
34
+ return cachedTextEncoder.encodeInto(arg, view);
35
+ }
36
+ : function (arg, view) {
37
+ const buf = cachedTextEncoder.encode(arg);
38
+ view.set(buf);
39
+ return {
40
+ read: arg.length,
41
+ written: buf.length
42
+ };
43
+ });
44
+
45
+ function passStringToWasm0(arg, malloc, realloc) {
46
+
47
+ if (realloc === undefined) {
48
+ const buf = cachedTextEncoder.encode(arg);
49
+ const ptr = malloc(buf.length);
50
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
51
+ WASM_VECTOR_LEN = buf.length;
52
+ return ptr;
53
+ }
54
+
55
+ let len = arg.length;
56
+ let ptr = malloc(len);
57
+
58
+ const mem = getUint8Memory0();
59
+
60
+ let offset = 0;
61
+
62
+ for (; offset < len; offset++) {
63
+ const code = arg.charCodeAt(offset);
64
+ if (code > 0x7F) break;
65
+ mem[ptr + offset] = code;
66
+ }
67
+
68
+ if (offset !== len) {
69
+ if (offset !== 0) {
70
+ arg = arg.slice(offset);
71
+ }
72
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
73
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
74
+ const ret = encodeString(arg, view);
75
+
76
+ offset += ret.written;
77
+ }
78
+
79
+ WASM_VECTOR_LEN = offset;
80
+ return ptr;
81
+ }
82
+ /**
83
+ * @param {string} board_json
84
+ * @returns {number}
85
+ */
86
+ export function wasm_cal3BV(board_json) {
87
+ var ptr0 = passStringToWasm0(board_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
88
+ var len0 = WASM_VECTOR_LEN;
89
+ var ret = wasm.wasm_cal3BV(ptr0, len0);
90
+ return ret;
91
+ }
92
+
93
+ let cachegetInt32Memory0 = null;
94
+ function getInt32Memory0() {
95
+ if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
96
+ cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
97
+ }
98
+ return cachegetInt32Memory0;
99
+ }
100
+ /**
101
+ * @param {string} board_json
102
+ * @param {number} mine_num
103
+ * @returns {string}
104
+ */
105
+ export function wasm_cal_possibility_onboard(board_json, mine_num) {
106
+ try {
107
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
108
+ var ptr0 = passStringToWasm0(board_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
109
+ var len0 = WASM_VECTOR_LEN;
110
+ wasm.wasm_cal_possibility_onboard(retptr, ptr0, len0, mine_num);
111
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
112
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
113
+ return getStringFromWasm0(r0, r1);
114
+ } finally {
115
+ wasm.__wbindgen_add_to_stack_pointer(16);
116
+ wasm.__wbindgen_free(r0, r1);
117
+ }
118
+ }
119
+
120
+ export function __wbg_alert_25568c47dfd92690(arg0, arg1) {
121
+ alert(getStringFromWasm0(arg0, arg1));
122
+ };
123
+
124
+ export function __wbindgen_throw(arg0, arg1) {
125
+ throw new Error(getStringFromWasm0(arg0, arg1));
126
+ };
127
+
Binary file
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "ms-toollib",
3
+ "collaborators": [
4
+ "eee555 <50390200+eee555@users.noreply.github.com>"
5
+ ],
6
+ "version": "0.1.0",
7
+ "files": [
8
+ "ms_toollib_bg.wasm",
9
+ "ms_toollib.js",
10
+ "ms_toollib_bg.js",
11
+ "ms_toollib.d.ts"
12
+ ],
13
+ "module": "ms_toollib.js",
14
+ "types": "ms_toollib.d.ts",
15
+ "sideEffects": false
16
+ }