mons-rust 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/mons_rust.d.ts CHANGED
@@ -5,35 +5,3 @@
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
- /**
22
- * Instantiates the given `module`, which can either be bytes or
23
- * a precompiled `WebAssembly.Module`.
24
- *
25
- * @param {SyncInitInput} module
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>}
38
- */
39
- export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
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
- const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
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
- const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
79
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
78
80
 
79
- if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
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
- export function greet(name) {
91
+ module.exports.greet = function(name) {
90
92
  let deferred2_0;
91
93
  let deferred2_1;
92
94
  try {
@@ -103,94 +105,13 @@ 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;
108
+ };
155
109
 
110
+ const path = require('path').join(__dirname, 'mons_rust_bg.wasm');
111
+ const bytes = require('fs').readFileSync(path);
156
112
 
157
- return wasm;
158
- }
159
-
160
- function initSync(module) {
161
- if (wasm !== undefined) return wasm;
162
-
163
- const imports = __wbg_get_imports();
164
-
165
- __wbg_init_memory(imports);
166
-
167
- if (!(module instanceof WebAssembly.Module)) {
168
- module = new WebAssembly.Module(module);
169
- }
170
-
171
- const instance = new WebAssembly.Instance(module, imports);
172
-
173
- return __wbg_finalize_init(instance, module);
174
- }
175
-
176
- async function __wbg_init(input) {
177
- if (wasm !== undefined) return wasm;
178
-
179
- if (typeof input === 'undefined') {
180
- input = new URL('mons_rust_bg.wasm', import.meta.url);
181
- }
182
- const imports = __wbg_get_imports();
183
-
184
- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
185
- input = fetch(input);
186
- }
187
-
188
- __wbg_init_memory(imports);
189
-
190
- const { instance, module } = await __wbg_load(await input, imports);
191
-
192
- return __wbg_finalize_init(instance, module);
193
- }
113
+ const wasmModule = new WebAssembly.Module(bytes);
114
+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
115
+ wasm = wasmInstance.exports;
116
+ module.exports.__wasm = wasm;
194
117
 
195
- export { initSync }
196
- export default __wbg_init;
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "mons-rust",
3
3
  "description": "super metal mons",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
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
- "sideEffects": [
14
- "./snippets/*"
15
- ]
11
+ "main": "mons_rust.js",
12
+ "types": "mons_rust.d.ts"
16
13
  }