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