@tychosdk/disasm 0.2.1 → 0.2.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.
@@ -3,6 +3,6 @@
3
3
  * @returns {string}
4
4
  */
5
5
  export function disasm_structured(code: string): string;
6
- export default __wbg_init;
7
6
  export function initSync(module: any): any;
8
7
  declare function __wbg_init(module_or_path: any): Promise<any>;
8
+ export { __wbg_init as default };
@@ -1,21 +1,69 @@
1
1
  "use strict";
2
- let wasm;
3
- let cachedUint8ArrayMemory0 = null;
4
- function getUint8ArrayMemory0() {
5
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
6
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2
+ /* @ts-self-types="./tycho_disasm.d.ts" */
3
+ /**
4
+ * @param {string} code
5
+ * @returns {string}
6
+ */
7
+ export function disasm_structured(code) {
8
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.disasm_structured(ptr0, len0);
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
7
13
  }
8
- return cachedUint8ArrayMemory0;
14
+ return takeFromExternrefTable0(ret[0]);
9
15
  }
10
- function getArrayU8FromWasm0(ptr, len) {
11
- ptr = ptr >>> 0;
12
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
16
+ function __wbg_get_imports() {
17
+ const import0 = {
18
+ __proto__: null,
19
+ __wbg___wbindgen_throw_6ddd609b62940d55: function (arg0, arg1) {
20
+ throw new Error(getStringFromWasm0(arg0, arg1));
21
+ },
22
+ __wbg_getRandomValues_3f44b700395062e5: function () {
23
+ return handleError(function (arg0, arg1) {
24
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
25
+ }, arguments);
26
+ },
27
+ __wbindgen_cast_0000000000000001: function (arg0, arg1) {
28
+ // Cast intrinsic for `Ref(String) -> Externref`.
29
+ const ret = getStringFromWasm0(arg0, arg1);
30
+ return ret;
31
+ },
32
+ __wbindgen_init_externref_table: function () {
33
+ const table = wasm.__wbindgen_externrefs;
34
+ const offset = table.grow(4);
35
+ table.set(0, undefined);
36
+ table.set(offset + 0, undefined);
37
+ table.set(offset + 1, null);
38
+ table.set(offset + 2, true);
39
+ table.set(offset + 3, false);
40
+ },
41
+ };
42
+ return {
43
+ __proto__: null,
44
+ "./tycho_disasm_bg.js": import0,
45
+ };
13
46
  }
14
47
  function addToExternrefTable0(obj) {
15
48
  const idx = wasm.__externref_table_alloc();
16
- wasm.__wbindgen_export_2.set(idx, obj);
49
+ wasm.__wbindgen_externrefs.set(idx, obj);
17
50
  return idx;
18
51
  }
52
+ function getArrayU8FromWasm0(ptr, len) {
53
+ ptr = ptr >>> 0;
54
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
55
+ }
56
+ function getStringFromWasm0(ptr, len) {
57
+ ptr = ptr >>> 0;
58
+ return decodeText(ptr, len);
59
+ }
60
+ let cachedUint8ArrayMemory0 = null;
61
+ function getUint8ArrayMemory0() {
62
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
63
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
64
+ }
65
+ return cachedUint8ArrayMemory0;
66
+ }
19
67
  function handleError(f, args) {
20
68
  try {
21
69
  return f.apply(this, args);
@@ -25,35 +73,6 @@ function handleError(f, args) {
25
73
  wasm.__wbindgen_exn_store(idx);
26
74
  }
27
75
  }
28
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
29
- cachedTextDecoder.decode();
30
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
31
- let numBytesDecoded = 0;
32
- function decodeText(ptr, len) {
33
- numBytesDecoded += len;
34
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
35
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
36
- cachedTextDecoder.decode();
37
- numBytesDecoded = len;
38
- }
39
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
40
- }
41
- function getStringFromWasm0(ptr, len) {
42
- ptr = ptr >>> 0;
43
- return decodeText(ptr, len);
44
- }
45
- let WASM_VECTOR_LEN = 0;
46
- const cachedTextEncoder = new TextEncoder();
47
- if (!('encodeInto' in cachedTextEncoder)) {
48
- cachedTextEncoder.encodeInto = function (arg, view) {
49
- const buf = cachedTextEncoder.encode(arg);
50
- view.set(buf);
51
- return {
52
- read: arg.length,
53
- written: buf.length
54
- };
55
- };
56
- }
57
76
  function passStringToWasm0(arg, malloc, realloc) {
58
77
  if (realloc === undefined) {
59
78
  const buf = cachedTextEncoder.encode(arg);
@@ -86,24 +105,43 @@ function passStringToWasm0(arg, malloc, realloc) {
86
105
  return ptr;
87
106
  }
88
107
  function takeFromExternrefTable0(idx) {
89
- const value = wasm.__wbindgen_export_2.get(idx);
108
+ const value = wasm.__wbindgen_externrefs.get(idx);
90
109
  wasm.__externref_table_dealloc(idx);
91
110
  return value;
92
111
  }
93
- /**
94
- * @param {string} code
95
- * @returns {string}
96
- */
97
- export function disasm_structured(code) {
98
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
- const len0 = WASM_VECTOR_LEN;
100
- const ret = wasm.disasm_structured(ptr0, len0);
101
- if (ret[2]) {
102
- throw takeFromExternrefTable0(ret[1]);
112
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
113
+ cachedTextDecoder.decode();
114
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
115
+ let numBytesDecoded = 0;
116
+ function decodeText(ptr, len) {
117
+ numBytesDecoded += len;
118
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
119
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
120
+ cachedTextDecoder.decode();
121
+ numBytesDecoded = len;
103
122
  }
104
- return takeFromExternrefTable0(ret[0]);
123
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
124
+ }
125
+ const cachedTextEncoder = new TextEncoder();
126
+ if (!('encodeInto' in cachedTextEncoder)) {
127
+ cachedTextEncoder.encodeInto = function (arg, view) {
128
+ const buf = cachedTextEncoder.encode(arg);
129
+ view.set(buf);
130
+ return {
131
+ read: arg.length,
132
+ written: buf.length
133
+ };
134
+ };
135
+ }
136
+ let WASM_VECTOR_LEN = 0;
137
+ let wasmModule, wasm;
138
+ function __wbg_finalize_init(instance, module) {
139
+ wasm = instance.exports;
140
+ wasmModule = module;
141
+ cachedUint8ArrayMemory0 = null;
142
+ wasm.__wbindgen_start();
143
+ return wasm;
105
144
  }
106
- const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
107
145
  async function __wbg_load(module, imports) {
108
146
  if (typeof Response === 'function' && module instanceof Response) {
109
147
  if (typeof WebAssembly.instantiateStreaming === 'function') {
@@ -111,7 +149,7 @@ async function __wbg_load(module, imports) {
111
149
  return await WebAssembly.instantiateStreaming(module, imports);
112
150
  }
113
151
  catch (e) {
114
- const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
152
+ const validResponse = module.ok && expectedResponseType(module.type);
115
153
  if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
116
154
  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
155
  }
@@ -132,48 +170,19 @@ async function __wbg_load(module, imports) {
132
170
  return instance;
133
171
  }
134
172
  }
135
- }
136
- function __wbg_get_imports() {
137
- const imports = {};
138
- imports.wbg = {};
139
- imports.wbg.__wbg_getRandomValues_3c9c0d586e575a16 = function () {
140
- return handleError(function (arg0, arg1) {
141
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
142
- }, arguments);
143
- };
144
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function (arg0, arg1) {
145
- throw new Error(getStringFromWasm0(arg0, arg1));
146
- };
147
- imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
148
- // Cast intrinsic for `Ref(String) -> Externref`.
149
- const ret = getStringFromWasm0(arg0, arg1);
150
- return ret;
151
- };
152
- imports.wbg.__wbindgen_init_externref_table = function () {
153
- const table = wasm.__wbindgen_export_2;
154
- const offset = table.grow(4);
155
- table.set(0, undefined);
156
- table.set(offset + 0, undefined);
157
- table.set(offset + 1, null);
158
- table.set(offset + 2, true);
159
- table.set(offset + 3, false);
160
- ;
161
- };
162
- return imports;
163
- }
164
- function __wbg_init_memory(imports, memory) {
165
- }
166
- function __wbg_finalize_init(instance, module) {
167
- wasm = instance.exports;
168
- __wbg_init.__wbindgen_wasm_module = module;
169
- cachedUint8ArrayMemory0 = null;
170
- wasm.__wbindgen_start();
171
- return wasm;
173
+ function expectedResponseType(type) {
174
+ switch (type) {
175
+ case 'basic':
176
+ case 'cors':
177
+ case 'default': return true;
178
+ }
179
+ return false;
180
+ }
172
181
  }
173
182
  function initSync(module) {
174
183
  if (wasm !== undefined)
175
184
  return wasm;
176
- if (typeof module !== 'undefined') {
185
+ if (module !== undefined) {
177
186
  if (Object.getPrototypeOf(module) === Object.prototype) {
178
187
  ({ module } = module);
179
188
  }
@@ -182,7 +191,6 @@ function initSync(module) {
182
191
  }
183
192
  }
184
193
  const imports = __wbg_get_imports();
185
- __wbg_init_memory(imports);
186
194
  if (!(module instanceof WebAssembly.Module)) {
187
195
  module = new WebAssembly.Module(module);
188
196
  }
@@ -192,7 +200,7 @@ function initSync(module) {
192
200
  async function __wbg_init(module_or_path) {
193
201
  if (wasm !== undefined)
194
202
  return wasm;
195
- if (typeof module_or_path !== 'undefined') {
203
+ if (module_or_path !== undefined) {
196
204
  if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
197
205
  ({ module_or_path } = module_or_path);
198
206
  }
@@ -200,16 +208,14 @@ async function __wbg_init(module_or_path) {
200
208
  console.warn('using deprecated parameters for the initialization function; pass a single object instead');
201
209
  }
202
210
  }
203
- if (typeof module_or_path === 'undefined') {
211
+ if (module_or_path === undefined) {
204
212
  module_or_path = new URL('tycho_disasm_bg.wasm', import.meta.url);
205
213
  }
206
214
  const imports = __wbg_get_imports();
207
215
  if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
208
216
  module_or_path = fetch(module_or_path);
209
217
  }
210
- __wbg_init_memory(imports);
211
218
  const { instance, module } = await __wbg_load(await module_or_path, imports);
212
219
  return __wbg_finalize_init(instance, module);
213
220
  }
214
- export { initSync };
215
- export default __wbg_init;
221
+ export { initSync, __wbg_init as default };
Binary file
@@ -4,7 +4,7 @@ export const memory: WebAssembly.Memory;
4
4
  export const disasm_structured: (a: number, b: number) => [number, number, number];
5
5
  export const __wbindgen_exn_store: (a: number) => void;
6
6
  export const __externref_table_alloc: () => number;
7
- export const __wbindgen_export_2: WebAssembly.Table;
7
+ export const __wbindgen_externrefs: WebAssembly.Table;
8
8
  export const __wbindgen_malloc: (a: number, b: number) => number;
9
9
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
10
10
  export const __externref_table_dealloc: (a: number) => void;
@@ -1,6 +1,5 @@
1
+ /**
2
+ * @param {string} code
3
+ * @returns {string}
4
+ */
1
5
  export function disasm_structured(code: string): string;
2
- export function __wbg_getRandomValues_3c9c0d586e575a16(...args: any[]): any;
3
- export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0: any, arg1: any): never;
4
- export function __wbindgen_cast_2241b6af4c4b2941(arg0: any, arg1: any): string;
5
- export function __wbindgen_init_externref_table(): void;
6
- export const __wasm: WebAssembly.Exports;
@@ -1,22 +1,70 @@
1
1
  "use strict";
2
- let imports = {};
3
- imports['wbg'] = module.exports;
4
- let cachedUint8ArrayMemory0 = null;
5
- function getUint8ArrayMemory0() {
6
- if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
- cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2
+ /* @ts-self-types="./tycho_disasm.d.ts" */
3
+ /**
4
+ * @param {string} code
5
+ * @returns {string}
6
+ */
7
+ function disasm_structured(code) {
8
+ const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.disasm_structured(ptr0, len0);
11
+ if (ret[2]) {
12
+ throw takeFromExternrefTable0(ret[1]);
8
13
  }
9
- return cachedUint8ArrayMemory0;
14
+ return takeFromExternrefTable0(ret[0]);
10
15
  }
11
- function getArrayU8FromWasm0(ptr, len) {
12
- ptr = ptr >>> 0;
13
- return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
16
+ exports.disasm_structured = disasm_structured;
17
+ function __wbg_get_imports() {
18
+ const import0 = {
19
+ __proto__: null,
20
+ __wbg___wbindgen_throw_6ddd609b62940d55: function (arg0, arg1) {
21
+ throw new Error(getStringFromWasm0(arg0, arg1));
22
+ },
23
+ __wbg_getRandomValues_3f44b700395062e5: function () {
24
+ return handleError(function (arg0, arg1) {
25
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
26
+ }, arguments);
27
+ },
28
+ __wbindgen_cast_0000000000000001: function (arg0, arg1) {
29
+ // Cast intrinsic for `Ref(String) -> Externref`.
30
+ const ret = getStringFromWasm0(arg0, arg1);
31
+ return ret;
32
+ },
33
+ __wbindgen_init_externref_table: function () {
34
+ const table = wasm.__wbindgen_externrefs;
35
+ const offset = table.grow(4);
36
+ table.set(0, undefined);
37
+ table.set(offset + 0, undefined);
38
+ table.set(offset + 1, null);
39
+ table.set(offset + 2, true);
40
+ table.set(offset + 3, false);
41
+ },
42
+ };
43
+ return {
44
+ __proto__: null,
45
+ "./tycho_disasm_bg.js": import0,
46
+ };
14
47
  }
15
48
  function addToExternrefTable0(obj) {
16
49
  const idx = wasm.__externref_table_alloc();
17
- wasm.__wbindgen_export_2.set(idx, obj);
50
+ wasm.__wbindgen_externrefs.set(idx, obj);
18
51
  return idx;
19
52
  }
53
+ function getArrayU8FromWasm0(ptr, len) {
54
+ ptr = ptr >>> 0;
55
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
56
+ }
57
+ function getStringFromWasm0(ptr, len) {
58
+ ptr = ptr >>> 0;
59
+ return decodeText(ptr, len);
60
+ }
61
+ let cachedUint8ArrayMemory0 = null;
62
+ function getUint8ArrayMemory0() {
63
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
64
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
65
+ }
66
+ return cachedUint8ArrayMemory0;
67
+ }
20
68
  function handleError(f, args) {
21
69
  try {
22
70
  return f.apply(this, args);
@@ -26,27 +74,6 @@ function handleError(f, args) {
26
74
  wasm.__wbindgen_exn_store(idx);
27
75
  }
28
76
  }
29
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
30
- cachedTextDecoder.decode();
31
- function decodeText(ptr, len) {
32
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
33
- }
34
- function getStringFromWasm0(ptr, len) {
35
- ptr = ptr >>> 0;
36
- return decodeText(ptr, len);
37
- }
38
- let WASM_VECTOR_LEN = 0;
39
- const cachedTextEncoder = new TextEncoder();
40
- if (!('encodeInto' in cachedTextEncoder)) {
41
- cachedTextEncoder.encodeInto = function (arg, view) {
42
- const buf = cachedTextEncoder.encode(arg);
43
- view.set(buf);
44
- return {
45
- read: arg.length,
46
- written: buf.length
47
- };
48
- };
49
- }
50
77
  function passStringToWasm0(arg, malloc, realloc) {
51
78
  if (realloc === undefined) {
52
79
  const buf = cachedTextEncoder.encode(arg);
@@ -79,48 +106,29 @@ function passStringToWasm0(arg, malloc, realloc) {
79
106
  return ptr;
80
107
  }
81
108
  function takeFromExternrefTable0(idx) {
82
- const value = wasm.__wbindgen_export_2.get(idx);
109
+ const value = wasm.__wbindgen_externrefs.get(idx);
83
110
  wasm.__externref_table_dealloc(idx);
84
111
  return value;
85
112
  }
86
- /**
87
- * @param {string} code
88
- * @returns {string}
89
- */
90
- exports.disasm_structured = function (code) {
91
- const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
92
- const len0 = WASM_VECTOR_LEN;
93
- const ret = wasm.disasm_structured(ptr0, len0);
94
- if (ret[2]) {
95
- throw takeFromExternrefTable0(ret[1]);
96
- }
97
- return takeFromExternrefTable0(ret[0]);
98
- };
99
- exports.__wbg_getRandomValues_3c9c0d586e575a16 = function () {
100
- return handleError(function (arg0, arg1) {
101
- globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
102
- }, arguments);
103
- };
104
- exports.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function (arg0, arg1) {
105
- throw new Error(getStringFromWasm0(arg0, arg1));
106
- };
107
- exports.__wbindgen_cast_2241b6af4c4b2941 = function (arg0, arg1) {
108
- // Cast intrinsic for `Ref(String) -> Externref`.
109
- const ret = getStringFromWasm0(arg0, arg1);
110
- return ret;
111
- };
112
- exports.__wbindgen_init_externref_table = function () {
113
- const table = wasm.__wbindgen_export_2;
114
- const offset = table.grow(4);
115
- table.set(0, undefined);
116
- table.set(offset + 0, undefined);
117
- table.set(offset + 1, null);
118
- table.set(offset + 2, true);
119
- table.set(offset + 3, false);
120
- ;
121
- };
113
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
114
+ cachedTextDecoder.decode();
115
+ function decodeText(ptr, len) {
116
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
117
+ }
118
+ const cachedTextEncoder = new TextEncoder();
119
+ if (!('encodeInto' in cachedTextEncoder)) {
120
+ cachedTextEncoder.encodeInto = function (arg, view) {
121
+ const buf = cachedTextEncoder.encode(arg);
122
+ view.set(buf);
123
+ return {
124
+ read: arg.length,
125
+ written: buf.length
126
+ };
127
+ };
128
+ }
129
+ let WASM_VECTOR_LEN = 0;
122
130
  const wasmPath = `${__dirname}/tycho_disasm_bg.wasm`;
123
131
  const wasmBytes = require('fs').readFileSync(wasmPath);
124
132
  const wasmModule = new WebAssembly.Module(wasmBytes);
125
- const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
133
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
126
134
  wasm.__wbindgen_start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tychosdk/disasm",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Tycho TVM disasm",
5
5
  "main": "dist/index.js",
6
6
  "browser": {