@robomaster-cone/rplc-wasm 0.3.0 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robomaster-cone/rplc-wasm",
3
- "version": "v0.3.0",
3
+ "version": "v0.6.0",
4
4
  "description": "WASM bindings for RPLC - RoboMaster Packet Library Compiler",
5
5
  "main": "rplc_wasm.js",
6
6
  "module": "rplc_wasm.js",
package/rplc_wasm.d.ts CHANGED
@@ -10,36 +10,36 @@ export function init(): void;
10
10
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
11
11
 
12
12
  export interface InitOutput {
13
- readonly memory: WebAssembly.Memory;
14
- readonly check_json: (a: number, b: number) => any;
15
- readonly compile_cpp: (a: number, b: number) => [number, number, number, number];
16
- readonly init: () => void;
17
- readonly __wbindgen_malloc: (a: number, b: number) => number;
18
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
19
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
20
- readonly __wbindgen_externrefs: WebAssembly.Table;
21
- readonly __externref_table_dealloc: (a: number) => void;
22
- readonly __wbindgen_start: () => void;
13
+ readonly memory: WebAssembly.Memory;
14
+ readonly check_json: (a: number, b: number) => any;
15
+ readonly compile_cpp: (a: number, b: number) => [number, number, number, number];
16
+ readonly init: () => void;
17
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
18
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
19
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
20
+ readonly __wbindgen_externrefs: WebAssembly.Table;
21
+ readonly __externref_table_dealloc: (a: number) => void;
22
+ readonly __wbindgen_start: () => void;
23
23
  }
24
24
 
25
25
  export type SyncInitInput = BufferSource | WebAssembly.Module;
26
26
 
27
27
  /**
28
- * Instantiates the given `module`, which can either be bytes or
29
- * a precompiled `WebAssembly.Module`.
30
- *
31
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
32
- *
33
- * @returns {InitOutput}
34
- */
28
+ * Instantiates the given `module`, which can either be bytes or
29
+ * a precompiled `WebAssembly.Module`.
30
+ *
31
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
32
+ *
33
+ * @returns {InitOutput}
34
+ */
35
35
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
36
36
 
37
37
  /**
38
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
39
- * for everything else, calls `WebAssembly.instantiate` directly.
40
- *
41
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
42
- *
43
- * @returns {Promise<InitOutput>}
44
- */
38
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
39
+ * for everything else, calls `WebAssembly.instantiate` directly.
40
+ *
41
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
42
+ *
43
+ * @returns {Promise<InitOutput>}
44
+ */
45
45
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
package/rplc_wasm.js CHANGED
@@ -1,4 +1,128 @@
1
- let wasm;
1
+ /* @ts-self-types="./rplc_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {string} input
5
+ * @returns {any}
6
+ */
7
+ export function check_json(input) {
8
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.check_json(ptr0, len0);
11
+ return ret;
12
+ }
13
+
14
+ /**
15
+ * @param {string} input
16
+ * @returns {string}
17
+ */
18
+ export function compile_cpp(input) {
19
+ let deferred3_0;
20
+ let deferred3_1;
21
+ try {
22
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
23
+ const len0 = WASM_VECTOR_LEN;
24
+ const ret = wasm.compile_cpp(ptr0, len0);
25
+ var ptr2 = ret[0];
26
+ var len2 = ret[1];
27
+ if (ret[3]) {
28
+ ptr2 = 0; len2 = 0;
29
+ throw takeFromExternrefTable0(ret[2]);
30
+ }
31
+ deferred3_0 = ptr2;
32
+ deferred3_1 = len2;
33
+ return getStringFromWasm0(ptr2, len2);
34
+ } finally {
35
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
36
+ }
37
+ }
38
+
39
+ export function init() {
40
+ wasm.init();
41
+ }
42
+
43
+ function __wbg_get_imports() {
44
+ const import0 = {
45
+ __proto__: null,
46
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
47
+ const ret = Error(getStringFromWasm0(arg0, arg1));
48
+ return ret;
49
+ },
50
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
51
+ const ret = debugString(arg1);
52
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
+ const len1 = WASM_VECTOR_LEN;
54
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
55
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
56
+ },
57
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
58
+ throw new Error(getStringFromWasm0(arg0, arg1));
59
+ },
60
+ __wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
61
+ let deferred0_0;
62
+ let deferred0_1;
63
+ try {
64
+ deferred0_0 = arg0;
65
+ deferred0_1 = arg1;
66
+ console.error(getStringFromWasm0(arg0, arg1));
67
+ } finally {
68
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
69
+ }
70
+ },
71
+ __wbg_new_227d7c05414eb861: function() {
72
+ const ret = new Error();
73
+ return ret;
74
+ },
75
+ __wbg_new_4f9fafbb3909af72: function() {
76
+ const ret = new Object();
77
+ return ret;
78
+ },
79
+ __wbg_new_f3c9df4f38f3f798: function() {
80
+ const ret = new Array();
81
+ return ret;
82
+ },
83
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
84
+ arg0[arg1] = arg2;
85
+ },
86
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
87
+ arg0[arg1 >>> 0] = arg2;
88
+ },
89
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
90
+ const ret = arg1.stack;
91
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
+ const len1 = WASM_VECTOR_LEN;
93
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
94
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
95
+ },
96
+ __wbindgen_cast_0000000000000001: function(arg0) {
97
+ // Cast intrinsic for `F64 -> Externref`.
98
+ const ret = arg0;
99
+ return ret;
100
+ },
101
+ __wbindgen_cast_0000000000000002: function(arg0, arg1) {
102
+ // Cast intrinsic for `Ref(String) -> Externref`.
103
+ const ret = getStringFromWasm0(arg0, arg1);
104
+ return ret;
105
+ },
106
+ __wbindgen_cast_0000000000000003: function(arg0) {
107
+ // Cast intrinsic for `U64 -> Externref`.
108
+ const ret = BigInt.asUintN(64, arg0);
109
+ return ret;
110
+ },
111
+ __wbindgen_init_externref_table: function() {
112
+ const table = wasm.__wbindgen_externrefs;
113
+ const offset = table.grow(4);
114
+ table.set(0, undefined);
115
+ table.set(offset + 0, undefined);
116
+ table.set(offset + 1, null);
117
+ table.set(offset + 2, true);
118
+ table.set(offset + 3, false);
119
+ },
120
+ };
121
+ return {
122
+ __proto__: null,
123
+ "./rplc_wasm_bg.js": import0,
124
+ };
125
+ }
2
126
 
3
127
  function debugString(val) {
4
128
  // primitive types
@@ -153,67 +277,33 @@ if (!('encodeInto' in cachedTextEncoder)) {
153
277
  read: arg.length,
154
278
  written: buf.length
155
279
  };
156
- }
280
+ };
157
281
  }
158
282
 
159
283
  let WASM_VECTOR_LEN = 0;
160
284
 
161
- /**
162
- * @param {string} input
163
- * @returns {any}
164
- */
165
- export function check_json(input) {
166
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
167
- const len0 = WASM_VECTOR_LEN;
168
- const ret = wasm.check_json(ptr0, len0);
169
- return ret;
170
- }
171
-
172
- /**
173
- * @param {string} input
174
- * @returns {string}
175
- */
176
- export function compile_cpp(input) {
177
- let deferred3_0;
178
- let deferred3_1;
179
- try {
180
- const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
181
- const len0 = WASM_VECTOR_LEN;
182
- const ret = wasm.compile_cpp(ptr0, len0);
183
- var ptr2 = ret[0];
184
- var len2 = ret[1];
185
- if (ret[3]) {
186
- ptr2 = 0; len2 = 0;
187
- throw takeFromExternrefTable0(ret[2]);
188
- }
189
- deferred3_0 = ptr2;
190
- deferred3_1 = len2;
191
- return getStringFromWasm0(ptr2, len2);
192
- } finally {
193
- wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
194
- }
195
- }
196
-
197
- export function init() {
198
- wasm.init();
285
+ let wasmModule, wasm;
286
+ function __wbg_finalize_init(instance, module) {
287
+ wasm = instance.exports;
288
+ wasmModule = module;
289
+ cachedDataViewMemory0 = null;
290
+ cachedUint8ArrayMemory0 = null;
291
+ wasm.__wbindgen_start();
292
+ return wasm;
199
293
  }
200
294
 
201
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
202
-
203
295
  async function __wbg_load(module, imports) {
204
296
  if (typeof Response === 'function' && module instanceof Response) {
205
297
  if (typeof WebAssembly.instantiateStreaming === 'function') {
206
298
  try {
207
299
  return await WebAssembly.instantiateStreaming(module, imports);
208
300
  } catch (e) {
209
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
301
+ const validResponse = module.ok && expectedResponseType(module.type);
210
302
 
211
303
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
212
304
  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);
213
305
 
214
- } else {
215
- throw e;
216
- }
306
+ } else { throw e; }
217
307
  }
218
308
  }
219
309
 
@@ -228,105 +318,20 @@ async function __wbg_load(module, imports) {
228
318
  return instance;
229
319
  }
230
320
  }
231
- }
232
321
 
233
- function __wbg_get_imports() {
234
- const imports = {};
235
- imports.wbg = {};
236
- imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
237
- const ret = Error(getStringFromWasm0(arg0, arg1));
238
- return ret;
239
- };
240
- imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
241
- const ret = debugString(arg1);
242
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
243
- const len1 = WASM_VECTOR_LEN;
244
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
245
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
246
- };
247
- imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
248
- throw new Error(getStringFromWasm0(arg0, arg1));
249
- };
250
- imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
251
- let deferred0_0;
252
- let deferred0_1;
253
- try {
254
- deferred0_0 = arg0;
255
- deferred0_1 = arg1;
256
- console.error(getStringFromWasm0(arg0, arg1));
257
- } finally {
258
- wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
322
+ function expectedResponseType(type) {
323
+ switch (type) {
324
+ case 'basic': case 'cors': case 'default': return true;
259
325
  }
260
- };
261
- imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
262
- const ret = new Object();
263
- return ret;
264
- };
265
- imports.wbg.__wbg_new_25f239778d6112b9 = function() {
266
- const ret = new Array();
267
- return ret;
268
- };
269
- imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
270
- const ret = new Error();
271
- return ret;
272
- };
273
- imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
274
- arg0[arg1] = arg2;
275
- };
276
- imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
277
- arg0[arg1 >>> 0] = arg2;
278
- };
279
- imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
280
- const ret = arg1.stack;
281
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
282
- const len1 = WASM_VECTOR_LEN;
283
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
284
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
285
- };
286
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
287
- // Cast intrinsic for `Ref(String) -> Externref`.
288
- const ret = getStringFromWasm0(arg0, arg1);
289
- return ret;
290
- };
291
- imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
292
- // Cast intrinsic for `U64 -> Externref`.
293
- const ret = BigInt.asUintN(64, arg0);
294
- return ret;
295
- };
296
- imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
297
- // Cast intrinsic for `F64 -> Externref`.
298
- const ret = arg0;
299
- return ret;
300
- };
301
- imports.wbg.__wbindgen_init_externref_table = function() {
302
- const table = wasm.__wbindgen_externrefs;
303
- const offset = table.grow(4);
304
- table.set(0, undefined);
305
- table.set(offset + 0, undefined);
306
- table.set(offset + 1, null);
307
- table.set(offset + 2, true);
308
- table.set(offset + 3, false);
309
- };
310
-
311
- return imports;
312
- }
313
-
314
- function __wbg_finalize_init(instance, module) {
315
- wasm = instance.exports;
316
- __wbg_init.__wbindgen_wasm_module = module;
317
- cachedDataViewMemory0 = null;
318
- cachedUint8ArrayMemory0 = null;
319
-
320
-
321
- wasm.__wbindgen_start();
322
- return wasm;
326
+ return false;
327
+ }
323
328
  }
324
329
 
325
330
  function initSync(module) {
326
331
  if (wasm !== undefined) return wasm;
327
332
 
328
333
 
329
- if (typeof module !== 'undefined') {
334
+ if (module !== undefined) {
330
335
  if (Object.getPrototypeOf(module) === Object.prototype) {
331
336
  ({module} = module)
332
337
  } else {
@@ -346,7 +351,7 @@ async function __wbg_init(module_or_path) {
346
351
  if (wasm !== undefined) return wasm;
347
352
 
348
353
 
349
- if (typeof module_or_path !== 'undefined') {
354
+ if (module_or_path !== undefined) {
350
355
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
351
356
  ({module_or_path} = module_or_path)
352
357
  } else {
@@ -354,7 +359,7 @@ async function __wbg_init(module_or_path) {
354
359
  }
355
360
  }
356
361
 
357
- if (typeof module_or_path === 'undefined') {
362
+ if (module_or_path === undefined) {
358
363
  module_or_path = new URL('rplc_wasm_bg.wasm', import.meta.url);
359
364
  }
360
365
  const imports = __wbg_get_imports();
@@ -368,5 +373,4 @@ async function __wbg_init(module_or_path) {
368
373
  return __wbg_finalize_init(instance, module);
369
374
  }
370
375
 
371
- export { initSync };
372
- export default __wbg_init;
376
+ export { initSync, __wbg_init as default };
package/rplc_wasm_bg.wasm CHANGED
Binary file