@zktx.io/sui-move-builder 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 +84 -0
- package/dist/index.cjs +542 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +100 -0
- package/dist/index.d.ts +100 -0
- package/dist/index.js +494 -0
- package/dist/index.js.map +1 -0
- package/dist/sui_move_wasm.d.ts +55 -0
- package/dist/sui_move_wasm.js +314 -0
- package/dist/sui_move_wasm_bg.wasm +0 -0
- package/dist/sui_move_wasm_bg.wasm.d.ts +14 -0
- package/package.json +54 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedDataViewMemory0 = null;
|
|
4
|
+
function getDataViewMemory0() {
|
|
5
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
6
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
7
|
+
}
|
|
8
|
+
return cachedDataViewMemory0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getStringFromWasm0(ptr, len) {
|
|
12
|
+
ptr = ptr >>> 0;
|
|
13
|
+
return decodeText(ptr, len);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let cachedUint8ArrayMemory0 = null;
|
|
17
|
+
function getUint8ArrayMemory0() {
|
|
18
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
19
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
20
|
+
}
|
|
21
|
+
return cachedUint8ArrayMemory0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
25
|
+
if (realloc === undefined) {
|
|
26
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
27
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
28
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
29
|
+
WASM_VECTOR_LEN = buf.length;
|
|
30
|
+
return ptr;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let len = arg.length;
|
|
34
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
35
|
+
|
|
36
|
+
const mem = getUint8ArrayMemory0();
|
|
37
|
+
|
|
38
|
+
let offset = 0;
|
|
39
|
+
|
|
40
|
+
for (; offset < len; offset++) {
|
|
41
|
+
const code = arg.charCodeAt(offset);
|
|
42
|
+
if (code > 0x7F) break;
|
|
43
|
+
mem[ptr + offset] = code;
|
|
44
|
+
}
|
|
45
|
+
if (offset !== len) {
|
|
46
|
+
if (offset !== 0) {
|
|
47
|
+
arg = arg.slice(offset);
|
|
48
|
+
}
|
|
49
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
50
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
51
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
52
|
+
|
|
53
|
+
offset += ret.written;
|
|
54
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
WASM_VECTOR_LEN = offset;
|
|
58
|
+
return ptr;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
62
|
+
cachedTextDecoder.decode();
|
|
63
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
64
|
+
let numBytesDecoded = 0;
|
|
65
|
+
function decodeText(ptr, len) {
|
|
66
|
+
numBytesDecoded += len;
|
|
67
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
68
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
69
|
+
cachedTextDecoder.decode();
|
|
70
|
+
numBytesDecoded = len;
|
|
71
|
+
}
|
|
72
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const cachedTextEncoder = new TextEncoder();
|
|
76
|
+
|
|
77
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
78
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
79
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
80
|
+
view.set(buf);
|
|
81
|
+
return {
|
|
82
|
+
read: arg.length,
|
|
83
|
+
written: buf.length
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let WASM_VECTOR_LEN = 0;
|
|
89
|
+
|
|
90
|
+
const MoveCompilerResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
91
|
+
? { register: () => {}, unregister: () => {} }
|
|
92
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_movecompilerresult_free(ptr >>> 0, 1));
|
|
93
|
+
|
|
94
|
+
export class MoveCompilerResult {
|
|
95
|
+
static __wrap(ptr) {
|
|
96
|
+
ptr = ptr >>> 0;
|
|
97
|
+
const obj = Object.create(MoveCompilerResult.prototype);
|
|
98
|
+
obj.__wbg_ptr = ptr;
|
|
99
|
+
MoveCompilerResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
100
|
+
return obj;
|
|
101
|
+
}
|
|
102
|
+
__destroy_into_raw() {
|
|
103
|
+
const ptr = this.__wbg_ptr;
|
|
104
|
+
this.__wbg_ptr = 0;
|
|
105
|
+
MoveCompilerResultFinalization.unregister(this);
|
|
106
|
+
return ptr;
|
|
107
|
+
}
|
|
108
|
+
free() {
|
|
109
|
+
const ptr = this.__destroy_into_raw();
|
|
110
|
+
wasm.__wbg_movecompilerresult_free(ptr, 0);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @returns {boolean}
|
|
114
|
+
*/
|
|
115
|
+
get success() {
|
|
116
|
+
const ret = wasm.movecompilerresult_success(this.__wbg_ptr);
|
|
117
|
+
return ret !== 0;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @returns {string}
|
|
121
|
+
*/
|
|
122
|
+
get output() {
|
|
123
|
+
let deferred1_0;
|
|
124
|
+
let deferred1_1;
|
|
125
|
+
try {
|
|
126
|
+
const ret = wasm.movecompilerresult_output(this.__wbg_ptr);
|
|
127
|
+
deferred1_0 = ret[0];
|
|
128
|
+
deferred1_1 = ret[1];
|
|
129
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
130
|
+
} finally {
|
|
131
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (Symbol.dispose) MoveCompilerResult.prototype[Symbol.dispose] = MoveCompilerResult.prototype.free;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {string} files_json
|
|
139
|
+
* @param {string} dependencies_json
|
|
140
|
+
* @returns {MoveCompilerResult}
|
|
141
|
+
*/
|
|
142
|
+
export function compile(files_json, dependencies_json) {
|
|
143
|
+
const ptr0 = passStringToWasm0(files_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
144
|
+
const len0 = WASM_VECTOR_LEN;
|
|
145
|
+
const ptr1 = passStringToWasm0(dependencies_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
146
|
+
const len1 = WASM_VECTOR_LEN;
|
|
147
|
+
const ret = wasm.compile(ptr0, len0, ptr1, len1);
|
|
148
|
+
return MoveCompilerResult.__wrap(ret);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @returns {string}
|
|
153
|
+
*/
|
|
154
|
+
export function sui_move_version() {
|
|
155
|
+
let deferred1_0;
|
|
156
|
+
let deferred1_1;
|
|
157
|
+
try {
|
|
158
|
+
const ret = wasm.sui_move_version();
|
|
159
|
+
deferred1_0 = ret[0];
|
|
160
|
+
deferred1_1 = ret[1];
|
|
161
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
162
|
+
} finally {
|
|
163
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* @returns {string}
|
|
169
|
+
*/
|
|
170
|
+
export function sui_version() {
|
|
171
|
+
let deferred1_0;
|
|
172
|
+
let deferred1_1;
|
|
173
|
+
try {
|
|
174
|
+
const ret = wasm.sui_version();
|
|
175
|
+
deferred1_0 = ret[0];
|
|
176
|
+
deferred1_1 = ret[1];
|
|
177
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
178
|
+
} finally {
|
|
179
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
184
|
+
|
|
185
|
+
async function __wbg_load(module, imports) {
|
|
186
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
187
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
188
|
+
try {
|
|
189
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
190
|
+
} catch (e) {
|
|
191
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
192
|
+
|
|
193
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
194
|
+
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);
|
|
195
|
+
|
|
196
|
+
} else {
|
|
197
|
+
throw e;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const bytes = await module.arrayBuffer();
|
|
203
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
204
|
+
} else {
|
|
205
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
206
|
+
|
|
207
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
208
|
+
return { instance, module };
|
|
209
|
+
} else {
|
|
210
|
+
return instance;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function __wbg_get_imports() {
|
|
216
|
+
const imports = {};
|
|
217
|
+
imports.wbg = {};
|
|
218
|
+
imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
|
|
219
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
220
|
+
};
|
|
221
|
+
imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
|
|
222
|
+
let deferred0_0;
|
|
223
|
+
let deferred0_1;
|
|
224
|
+
try {
|
|
225
|
+
deferred0_0 = arg0;
|
|
226
|
+
deferred0_1 = arg1;
|
|
227
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
228
|
+
} finally {
|
|
229
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
233
|
+
const ret = new Error();
|
|
234
|
+
return ret;
|
|
235
|
+
};
|
|
236
|
+
imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
|
|
237
|
+
const ret = arg1.stack;
|
|
238
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
239
|
+
const len1 = WASM_VECTOR_LEN;
|
|
240
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
241
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
242
|
+
};
|
|
243
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
244
|
+
const table = wasm.__wbindgen_externrefs;
|
|
245
|
+
const offset = table.grow(4);
|
|
246
|
+
table.set(0, undefined);
|
|
247
|
+
table.set(offset + 0, undefined);
|
|
248
|
+
table.set(offset + 1, null);
|
|
249
|
+
table.set(offset + 2, true);
|
|
250
|
+
table.set(offset + 3, false);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return imports;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function __wbg_finalize_init(instance, module) {
|
|
257
|
+
wasm = instance.exports;
|
|
258
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
259
|
+
cachedDataViewMemory0 = null;
|
|
260
|
+
cachedUint8ArrayMemory0 = null;
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
wasm.__wbindgen_start();
|
|
264
|
+
return wasm;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function initSync(module) {
|
|
268
|
+
if (wasm !== undefined) return wasm;
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
if (typeof module !== 'undefined') {
|
|
272
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
273
|
+
({module} = module)
|
|
274
|
+
} else {
|
|
275
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const imports = __wbg_get_imports();
|
|
280
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
281
|
+
module = new WebAssembly.Module(module);
|
|
282
|
+
}
|
|
283
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
284
|
+
return __wbg_finalize_init(instance, module);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function __wbg_init(module_or_path) {
|
|
288
|
+
if (wasm !== undefined) return wasm;
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
if (typeof module_or_path !== 'undefined') {
|
|
292
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
293
|
+
({module_or_path} = module_or_path)
|
|
294
|
+
} else {
|
|
295
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (typeof module_or_path === 'undefined') {
|
|
300
|
+
module_or_path = new URL('sui_move_wasm_bg.wasm', import.meta.url);
|
|
301
|
+
}
|
|
302
|
+
const imports = __wbg_get_imports();
|
|
303
|
+
|
|
304
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
305
|
+
module_or_path = fetch(module_or_path);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
309
|
+
|
|
310
|
+
return __wbg_finalize_init(instance, module);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export { initSync };
|
|
314
|
+
export default __wbg_init;
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_movecompilerresult_free: (a: number, b: number) => void;
|
|
5
|
+
export const movecompilerresult_success: (a: number) => number;
|
|
6
|
+
export const movecompilerresult_output: (a: number) => [number, number];
|
|
7
|
+
export const sui_move_version: () => [number, number];
|
|
8
|
+
export const compile: (a: number, b: number, c: number, d: number) => number;
|
|
9
|
+
export const sui_version: () => [number, number];
|
|
10
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
11
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
12
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
13
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
14
|
+
export const __wbindgen_start: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zktx.io/sui-move-builder",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Build Move packages in web or Node.js with dependency fetching and dump outputs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zktx-io/sui-move-builder.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/zktx-io/sui-move-builder",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/zktx-io/sui-move-builder/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.cjs",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": false,
|
|
33
|
+
"scripts": {
|
|
34
|
+
"clean": "rm -rf dist",
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"format": "prettier --write .",
|
|
37
|
+
"format:check": "prettier --check .",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"build:wasm": "node scripts/build-wasm.mjs",
|
|
40
|
+
"build:js": "tsup",
|
|
41
|
+
"build": "npm run build:js && npm run build:wasm",
|
|
42
|
+
"serve:test": "python3 -m http.server 8000 --directory .",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/js": "^9.39.0",
|
|
47
|
+
"eslint": "^9.39.0",
|
|
48
|
+
"eslint-config-prettier": "^9.1.0",
|
|
49
|
+
"prettier": "^3.3.3",
|
|
50
|
+
"tsup": "^8.0.1",
|
|
51
|
+
"typescript": "^5.4.0",
|
|
52
|
+
"typescript-eslint": "^8.26.0"
|
|
53
|
+
}
|
|
54
|
+
}
|