@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/dist/index.js ADDED
@@ -0,0 +1,494 @@
1
+ // src/tomlParser.ts
2
+ function stripInlineComment(line) {
3
+ let inQuote = false;
4
+ let quoteChar = "";
5
+ for (let i = 0; i < line.length; i++) {
6
+ const ch = line[i];
7
+ if ((ch === '"' || ch === "'") && (!inQuote || ch === quoteChar)) {
8
+ inQuote = !inQuote;
9
+ quoteChar = ch;
10
+ }
11
+ if (!inQuote && ch === "#") {
12
+ return line.slice(0, i);
13
+ }
14
+ }
15
+ return line;
16
+ }
17
+ function parseScalar(value) {
18
+ const trimmed = value.trim();
19
+ if (!trimmed) return "";
20
+ if (trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'")) {
21
+ return trimmed.slice(1, -1);
22
+ }
23
+ if (trimmed === "true") return true;
24
+ if (trimmed === "false") return false;
25
+ const num = Number(trimmed);
26
+ if (!Number.isNaN(num)) return num;
27
+ return trimmed;
28
+ }
29
+ function parseInlineTable(value) {
30
+ const result = {};
31
+ const inner = value.trim().replace(/^\{/, "").replace(/\}$/, "");
32
+ let current = "";
33
+ let inQuote = false;
34
+ let quoteChar = "";
35
+ const parts = [];
36
+ for (let i = 0; i < inner.length; i++) {
37
+ const ch = inner[i];
38
+ if ((ch === '"' || ch === "'") && (!inQuote || ch === quoteChar)) {
39
+ inQuote = !inQuote;
40
+ quoteChar = ch;
41
+ }
42
+ if (!inQuote && ch === ",") {
43
+ parts.push(current);
44
+ current = "";
45
+ continue;
46
+ }
47
+ current += ch;
48
+ }
49
+ if (current.trim()) {
50
+ parts.push(current);
51
+ }
52
+ for (const part of parts) {
53
+ const eq = part.indexOf("=");
54
+ if (eq === -1) continue;
55
+ const key = part.slice(0, eq).trim();
56
+ const val = part.slice(eq + 1).trim();
57
+ result[key] = parseScalar(val);
58
+ }
59
+ return result;
60
+ }
61
+ function parseToml(content) {
62
+ const result = {
63
+ package: {},
64
+ dependencies: {},
65
+ addresses: {}
66
+ };
67
+ let section = null;
68
+ const lines = content.split(/\r?\n/);
69
+ for (const rawLine of lines) {
70
+ const line = stripInlineComment(rawLine).trim();
71
+ if (!line) continue;
72
+ const sectionMatch = line.match(/^\[([^\]]+)\]$/);
73
+ if (sectionMatch) {
74
+ section = sectionMatch[1].trim();
75
+ continue;
76
+ }
77
+ const eq = line.indexOf("=");
78
+ if (eq === -1 || !section) continue;
79
+ const key = line.slice(0, eq).trim();
80
+ const value = line.slice(eq + 1).trim();
81
+ if (section === "package") {
82
+ result.package[key.replace(/-/g, "_")] = parseScalar(value);
83
+ } else if (section === "dependencies") {
84
+ if (value.startsWith("{")) {
85
+ result.dependencies[key] = parseInlineTable(value);
86
+ } else {
87
+ result.dependencies[key] = parseScalar(value);
88
+ }
89
+ } else if (section === "addresses") {
90
+ result.addresses[key] = parseScalar(value);
91
+ }
92
+ }
93
+ return result;
94
+ }
95
+
96
+ // src/resolver.ts
97
+ var Resolver = class {
98
+ constructor(fetcher) {
99
+ this.fetcher = fetcher;
100
+ this.globalAddresses = {};
101
+ this.visited = /* @__PURE__ */ new Set();
102
+ this.dependencyFiles = {};
103
+ this.systemDepsLoaded = /* @__PURE__ */ new Set();
104
+ }
105
+ async resolve(rootMoveToml, rootFiles) {
106
+ const parsedToml = parseToml(rootMoveToml);
107
+ if (parsedToml.addresses) {
108
+ this.mergeAddresses(parsedToml.addresses);
109
+ }
110
+ if (parsedToml.dependencies) {
111
+ await this.resolveDeps(parsedToml.dependencies);
112
+ await this.injectSystemDepsFromRoot(parsedToml.dependencies);
113
+ }
114
+ const finalMoveToml = this.reconstructMoveToml(parsedToml, this.globalAddresses);
115
+ const finalFiles = { ...rootFiles, "Move.toml": finalMoveToml };
116
+ return {
117
+ files: JSON.stringify(finalFiles),
118
+ dependencies: JSON.stringify(this.dependencyFiles)
119
+ };
120
+ }
121
+ mergeAddresses(addresses) {
122
+ for (const [name, val] of Object.entries(addresses)) {
123
+ this.globalAddresses[name] = this.normalizeAddress(val);
124
+ }
125
+ }
126
+ normalizeAddress(addr) {
127
+ if (!addr) return addr;
128
+ let clean = addr;
129
+ if (clean.startsWith("0x")) clean = clean.slice(2);
130
+ if (/^[0-9a-fA-F]+$/.test(clean)) {
131
+ return "0x" + clean.padStart(64, "0");
132
+ }
133
+ return addr;
134
+ }
135
+ async resolveDeps(depsObj, parentContext = null) {
136
+ for (const [name, depInfo] of Object.entries(depsObj)) {
137
+ let gitUrl;
138
+ let rev;
139
+ let subdir;
140
+ if (depInfo.git) {
141
+ gitUrl = depInfo.git;
142
+ rev = depInfo.rev;
143
+ subdir = depInfo.subdir;
144
+ } else if (depInfo.local) {
145
+ if (!parentContext) continue;
146
+ gitUrl = parentContext.git;
147
+ rev = parentContext.rev;
148
+ subdir = this.resolvePath(parentContext.subdir || "", depInfo.local);
149
+ } else {
150
+ continue;
151
+ }
152
+ const cacheKey = `${gitUrl}|${rev}|${subdir || ""}`;
153
+ if (this.visited.has(cacheKey)) continue;
154
+ this.visited.add(cacheKey);
155
+ const files = await this.fetcher.fetch(gitUrl, rev, subdir);
156
+ let pkgMoveToml = null;
157
+ for (const [path, content] of Object.entries(files)) {
158
+ if (path.endsWith("Move.toml")) {
159
+ pkgMoveToml = content;
160
+ break;
161
+ }
162
+ }
163
+ if (pkgMoveToml) {
164
+ const parsed = parseToml(pkgMoveToml);
165
+ if (parsed.addresses) {
166
+ this.mergeAddresses(parsed.addresses);
167
+ }
168
+ if (parsed.dependencies) {
169
+ await this.resolveDeps(parsed.dependencies, { git: gitUrl, rev, subdir });
170
+ }
171
+ }
172
+ for (const [path, content] of Object.entries(files)) {
173
+ if (path.endsWith(".move") || path.endsWith("Move.toml")) {
174
+ const targetPath = `dependencies/${name}/${path}`;
175
+ this.dependencyFiles[targetPath] = content;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ resolvePath(base, relative) {
181
+ const stack = base.split("/").filter((p) => p && p !== ".");
182
+ const parts = relative.split("/").filter((p) => p && p !== ".");
183
+ for (const part of parts) {
184
+ if (part === "..") {
185
+ stack.pop();
186
+ } else {
187
+ stack.push(part);
188
+ }
189
+ }
190
+ return stack.join("/");
191
+ }
192
+ reconstructMoveToml(originalParsed, addresses) {
193
+ let newToml = `[package]
194
+ name = "${originalParsed.package.name}"
195
+ version = "${originalParsed.package.version}"
196
+ `;
197
+ if (originalParsed.package.edition) {
198
+ newToml += `edition = "${originalParsed.package.edition}"
199
+ `;
200
+ }
201
+ newToml += `
202
+ [dependencies]
203
+ `;
204
+ if (originalParsed.dependencies) {
205
+ for (const [name, info] of Object.entries(originalParsed.dependencies)) {
206
+ newToml += `${name} = { git = "${info.git}", rev = "${info.rev}" }
207
+ `;
208
+ }
209
+ }
210
+ newToml += `
211
+ [addresses]
212
+ `;
213
+ for (const [addrName, addrVal] of Object.entries(addresses)) {
214
+ newToml += `${addrName} = "${addrVal}"
215
+ `;
216
+ }
217
+ return newToml;
218
+ }
219
+ async injectSystemDepsFromRoot(depsObj) {
220
+ for (const depInfo of Object.values(depsObj)) {
221
+ if (!depInfo || !depInfo.git || !depInfo.rev) continue;
222
+ if (!this.isSuiRepo(depInfo.git)) continue;
223
+ await this.addImplicitSystemDepsForRepo(depInfo.git, depInfo.rev);
224
+ return;
225
+ }
226
+ }
227
+ async addImplicitSystemDepsForRepo(gitUrl, rev) {
228
+ if (!this.isSuiRepo(gitUrl)) return;
229
+ const cacheKey = `${gitUrl}|${rev}`;
230
+ if (this.systemDepsLoaded.has(cacheKey)) return;
231
+ this.systemDepsLoaded.add(cacheKey);
232
+ const manifestPath = "crates/sui-framework-snapshot/manifest.json";
233
+ if (!this.fetcher.fetchFile) return;
234
+ let packages = null;
235
+ try {
236
+ const manifestText = await this.fetcher.fetchFile(gitUrl, rev, manifestPath);
237
+ if (manifestText) {
238
+ const manifest = JSON.parse(manifestText);
239
+ const versions = Object.keys(manifest).map((v) => Number(v)).filter((v) => !Number.isNaN(v)).sort((a, b) => a - b);
240
+ const latestVersion = versions[versions.length - 1];
241
+ const latest = manifest[String(latestVersion)];
242
+ if (latest && latest.packages) {
243
+ packages = latest.packages;
244
+ }
245
+ }
246
+ } catch (e) {
247
+ }
248
+ if (!packages) {
249
+ packages = [
250
+ { name: "MoveStdlib", id: "0x1" },
251
+ { name: "Sui", id: "0x2" },
252
+ { name: "SuiSystem", id: "0x3" },
253
+ { name: "Bridge", id: "0xb" }
254
+ ];
255
+ }
256
+ for (const pkg of packages) {
257
+ if (!pkg || !pkg.name || !pkg.id) continue;
258
+ if (pkg.name === "DeepBook") continue;
259
+ const targetPath = `dependencies/${pkg.name}/Move.toml`;
260
+ if (this.dependencyFiles[targetPath]) continue;
261
+ const moveToml = [
262
+ "[package]",
263
+ `name = "${pkg.name}"`,
264
+ 'version = "0.0.0"',
265
+ `published-at = "${pkg.id}"`,
266
+ ""
267
+ ].join("\n");
268
+ this.dependencyFiles[targetPath] = moveToml;
269
+ }
270
+ }
271
+ isSuiRepo(gitUrl) {
272
+ return gitUrl.includes("github.com/MystenLabs/sui");
273
+ }
274
+ };
275
+ async function resolve(rootMoveTomlContent, rootSourceFiles, fetcher) {
276
+ const resolver = new Resolver(fetcher);
277
+ return resolver.resolve(rootMoveTomlContent, rootSourceFiles);
278
+ }
279
+
280
+ // src/fetcher.ts
281
+ var Fetcher = class {
282
+ /** Fetch a package. Return map of path -> content. */
283
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
284
+ async fetch(_gitUrl, _rev, _subdir) {
285
+ throw new Error("Not implemented");
286
+ }
287
+ /** Fetch a single file from a repository. */
288
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
289
+ async fetchFile(_gitUrl, _rev, _path) {
290
+ throw new Error("Not implemented");
291
+ }
292
+ };
293
+ var GitHubFetcher = class extends Fetcher {
294
+ constructor() {
295
+ super();
296
+ this.cache = /* @__PURE__ */ new Map();
297
+ }
298
+ async fetch(gitUrl, rev, subdir) {
299
+ const { owner, repo } = this.parseGitUrl(gitUrl);
300
+ if (!owner || !repo) {
301
+ throw new Error(`Invalid git URL: ${gitUrl}`);
302
+ }
303
+ const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${rev}?recursive=1`;
304
+ let treeData;
305
+ try {
306
+ const resp = await fetch(treeUrl);
307
+ if (!resp.ok) {
308
+ if (resp.status === 403 || resp.status === 429) {
309
+ throw new Error("GitHub API rate limit exceeded.");
310
+ }
311
+ throw new Error(`Failed to fetch tree: ${resp.statusText}`);
312
+ }
313
+ treeData = await resp.json();
314
+ } catch (e) {
315
+ return {};
316
+ }
317
+ const files = {};
318
+ const fetchPromises = [];
319
+ for (const item of treeData.tree) {
320
+ if (item.type !== "blob") continue;
321
+ let relativePath = item.path;
322
+ if (subdir) {
323
+ if (!item.path.startsWith(subdir)) continue;
324
+ relativePath = item.path.slice(subdir.length);
325
+ if (relativePath.startsWith("/")) {
326
+ relativePath = relativePath.slice(1);
327
+ }
328
+ }
329
+ if (!relativePath.endsWith(".move") && relativePath !== "Move.toml") {
330
+ continue;
331
+ }
332
+ const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${rev}/${item.path}`;
333
+ const p = this.fetchContent(rawUrl).then((content) => {
334
+ if (content) {
335
+ files[relativePath] = content;
336
+ }
337
+ });
338
+ fetchPromises.push(p);
339
+ }
340
+ await Promise.all(fetchPromises);
341
+ return files;
342
+ }
343
+ async fetchFile(gitUrl, rev, path) {
344
+ const { owner, repo } = this.parseGitUrl(gitUrl);
345
+ if (!owner || !repo) {
346
+ throw new Error(`Invalid git URL: ${gitUrl}`);
347
+ }
348
+ const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${rev}/${path}`;
349
+ return this.fetchContent(rawUrl);
350
+ }
351
+ async fetchContent(url) {
352
+ if (this.cache.has(url)) {
353
+ return this.cache.get(url) ?? null;
354
+ }
355
+ try {
356
+ const resp = await fetch(url);
357
+ if (!resp.ok) return null;
358
+ const text = await resp.text();
359
+ this.cache.set(url, text);
360
+ return text;
361
+ } catch (e) {
362
+ return null;
363
+ }
364
+ }
365
+ parseGitUrl(url) {
366
+ try {
367
+ const urlObj = new URL(url);
368
+ const parts = urlObj.pathname.split("/").filter((p) => p);
369
+ if (parts.length >= 2) {
370
+ let repo = parts[1];
371
+ if (repo.endsWith(".git")) {
372
+ repo = repo.slice(0, -4);
373
+ }
374
+ return { owner: parts[0], repo };
375
+ }
376
+ } catch (e) {
377
+ }
378
+ return { owner: null, repo: null };
379
+ }
380
+ };
381
+
382
+ // src/index.ts
383
+ var wasmUrl = (() => {
384
+ try {
385
+ return new URL("./sui_move_wasm_bg.wasm", import.meta.url);
386
+ } catch {
387
+ return "./sui_move_wasm_bg.wasm";
388
+ }
389
+ })();
390
+ var wasmReady;
391
+ async function loadWasm(customWasm) {
392
+ if (!wasmReady) {
393
+ wasmReady = import("./sui_move_wasm.js").then(async (mod) => {
394
+ await mod.default(customWasm ?? wasmUrl);
395
+ return mod;
396
+ });
397
+ }
398
+ return wasmReady;
399
+ }
400
+ function toJson(value) {
401
+ return JSON.stringify(value ?? {});
402
+ }
403
+ function asFailure(err) {
404
+ const msg = err instanceof Error ? err.message : typeof err === "string" ? err : "Unknown error";
405
+ return { success: false, error: msg };
406
+ }
407
+ function ensureCompileResult(result) {
408
+ if (typeof result !== "object" || result === null) {
409
+ throw new Error("Unexpected compile result shape from wasm");
410
+ }
411
+ const asAny = result;
412
+ if (typeof asAny.success === "function" && typeof asAny.output === "function") {
413
+ return asAny;
414
+ }
415
+ if (typeof asAny.success === "boolean" && typeof asAny.output === "string") {
416
+ return {
417
+ success: () => asAny.success,
418
+ output: () => asAny.output
419
+ };
420
+ }
421
+ throw new Error("Unexpected compile result shape from wasm");
422
+ }
423
+ function parseCompileResult(output) {
424
+ const toHex = (bytes) => bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
425
+ try {
426
+ const parsed = JSON.parse(output);
427
+ if (!parsed.modules || !parsed.dependencies || !parsed.digest) {
428
+ throw new Error("missing fields in compiler output");
429
+ }
430
+ const digestHex = typeof parsed.digest === "string" ? parsed.digest : toHex(parsed.digest);
431
+ return {
432
+ success: true,
433
+ modules: parsed.modules,
434
+ dependencies: parsed.dependencies,
435
+ digest: digestHex
436
+ };
437
+ } catch (error) {
438
+ return asFailure(error);
439
+ }
440
+ }
441
+ async function initMoveCompiler(options) {
442
+ await loadWasm(options?.wasm);
443
+ }
444
+ async function buildMovePackage(input) {
445
+ try {
446
+ const mod = await loadWasm(input.wasm);
447
+ const raw = mod.compile(
448
+ toJson(input.files),
449
+ toJson(input.dependencies ?? {})
450
+ );
451
+ const result = ensureCompileResult(raw);
452
+ const ok = result.success();
453
+ const output = result.output();
454
+ if (!ok) {
455
+ return asFailure(output);
456
+ }
457
+ return parseCompileResult(output);
458
+ } catch (error) {
459
+ return asFailure(error);
460
+ }
461
+ }
462
+ async function getSuiMoveVersion(options) {
463
+ const mod = await loadWasm(options?.wasm);
464
+ return mod.sui_move_version();
465
+ }
466
+ async function getSuiVersion(options) {
467
+ const mod = await loadWasm(options?.wasm);
468
+ return mod.sui_version();
469
+ }
470
+ async function getWasmBindings(options) {
471
+ return loadWasm(options?.wasm);
472
+ }
473
+ async function compileRaw(filesJson, depsJson, options) {
474
+ const mod = await loadWasm(options?.wasm);
475
+ const result = ensureCompileResult(mod.compile(filesJson, depsJson));
476
+ return {
477
+ success: result.success(),
478
+ output: result.output()
479
+ };
480
+ }
481
+ export {
482
+ Fetcher,
483
+ GitHubFetcher,
484
+ Resolver,
485
+ buildMovePackage,
486
+ compileRaw,
487
+ getSuiMoveVersion,
488
+ getSuiVersion,
489
+ getWasmBindings,
490
+ initMoveCompiler,
491
+ parseToml,
492
+ resolve
493
+ };
494
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/tomlParser.ts","../src/resolver.ts","../src/fetcher.ts","../src/index.ts"],"sourcesContent":["function stripInlineComment(line: string): string {\n let inQuote = false;\n let quoteChar = \"\";\n for (let i = 0; i < line.length; i++) {\n const ch = line[i];\n if ((ch === '\"' || ch === \"'\") && (!inQuote || ch === quoteChar)) {\n inQuote = !inQuote;\n quoteChar = ch;\n }\n if (!inQuote && ch === \"#\") {\n return line.slice(0, i);\n }\n }\n return line;\n}\n\nfunction parseScalar(value: string): any {\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n if (\n (trimmed.startsWith('\"') && trimmed.endsWith('\"')) ||\n (trimmed.startsWith(\"'\") && trimmed.endsWith(\"'\"))\n ) {\n return trimmed.slice(1, -1);\n }\n if (trimmed === \"true\") return true;\n if (trimmed === \"false\") return false;\n const num = Number(trimmed);\n if (!Number.isNaN(num)) return num;\n return trimmed;\n}\n\nfunction parseInlineTable(value: string): Record<string, any> {\n const result: Record<string, any> = {};\n const inner = value.trim().replace(/^\\{/, \"\").replace(/\\}$/, \"\");\n let current = \"\";\n let inQuote = false;\n let quoteChar = \"\";\n const parts: string[] = [];\n\n for (let i = 0; i < inner.length; i++) {\n const ch = inner[i];\n if ((ch === '\"' || ch === \"'\") && (!inQuote || ch === quoteChar)) {\n inQuote = !inQuote;\n quoteChar = ch;\n }\n if (!inQuote && ch === \",\") {\n parts.push(current);\n current = \"\";\n continue;\n }\n current += ch;\n }\n if (current.trim()) {\n parts.push(current);\n }\n\n for (const part of parts) {\n const eq = part.indexOf(\"=\");\n if (eq === -1) continue;\n const key = part.slice(0, eq).trim();\n const val = part.slice(eq + 1).trim();\n result[key] = parseScalar(val);\n }\n return result;\n}\n\nexport function parseToml(content: string): {\n package: Record<string, any>;\n dependencies: Record<string, any>;\n addresses: Record<string, any>;\n} {\n const result = {\n package: {},\n dependencies: {},\n addresses: {},\n } as {\n package: Record<string, any>;\n dependencies: Record<string, any>;\n addresses: Record<string, any>;\n };\n let section: string | null = null;\n const lines = content.split(/\\r?\\n/);\n\n for (const rawLine of lines) {\n const line = stripInlineComment(rawLine).trim();\n if (!line) continue;\n const sectionMatch = line.match(/^\\[([^\\]]+)\\]$/);\n if (sectionMatch) {\n section = sectionMatch[1].trim();\n continue;\n }\n const eq = line.indexOf(\"=\");\n if (eq === -1 || !section) continue;\n\n const key = line.slice(0, eq).trim();\n const value = line.slice(eq + 1).trim();\n\n if (section === \"package\") {\n result.package[key.replace(/-/g, \"_\")] = parseScalar(value);\n } else if (section === \"dependencies\") {\n if (value.startsWith(\"{\")) {\n result.dependencies[key] = parseInlineTable(value);\n } else {\n result.dependencies[key] = parseScalar(value);\n }\n } else if (section === \"addresses\") {\n result.addresses[key] = parseScalar(value);\n }\n }\n\n return result;\n}\n","import { parseToml } from \"./tomlParser.js\";\nimport type { Fetcher } from \"./fetcher.js\";\n\nexport class Resolver {\n private fetcher: Fetcher;\n private globalAddresses: Record<string, string>;\n private visited: Set<string>;\n private dependencyFiles: Record<string, string>;\n private systemDepsLoaded: Set<string>;\n\n constructor(fetcher: Fetcher) {\n this.fetcher = fetcher;\n this.globalAddresses = {};\n this.visited = new Set();\n this.dependencyFiles = {};\n this.systemDepsLoaded = new Set();\n }\n\n async resolve(\n rootMoveToml: string,\n rootFiles: Record<string, string>\n ): Promise<{ files: string; dependencies: string }> {\n const parsedToml = parseToml(rootMoveToml);\n\n if (parsedToml.addresses) {\n this.mergeAddresses(parsedToml.addresses);\n }\n\n if (parsedToml.dependencies) {\n await this.resolveDeps(parsedToml.dependencies);\n await this.injectSystemDepsFromRoot(parsedToml.dependencies);\n }\n\n const finalMoveToml = this.reconstructMoveToml(parsedToml, this.globalAddresses);\n const finalFiles = { ...rootFiles, \"Move.toml\": finalMoveToml };\n\n return {\n files: JSON.stringify(finalFiles),\n dependencies: JSON.stringify(this.dependencyFiles),\n };\n }\n\n private mergeAddresses(addresses: Record<string, string>) {\n for (const [name, val] of Object.entries(addresses)) {\n this.globalAddresses[name] = this.normalizeAddress(val);\n }\n }\n\n private normalizeAddress(addr: string) {\n if (!addr) return addr;\n let clean = addr;\n if (clean.startsWith(\"0x\")) clean = clean.slice(2);\n if (/^[0-9a-fA-F]+$/.test(clean)) {\n return \"0x\" + clean.padStart(64, \"0\");\n }\n return addr;\n }\n\n private async resolveDeps(\n depsObj: Record<string, any>,\n parentContext: { git?: string; rev?: string; subdir?: string } | null = null\n ) {\n for (const [name, depInfo] of Object.entries(depsObj)) {\n let gitUrl: string | undefined;\n let rev: string | undefined;\n let subdir: string | undefined;\n\n if ((depInfo as any).git) {\n gitUrl = (depInfo as any).git;\n rev = (depInfo as any).rev;\n subdir = (depInfo as any).subdir;\n } else if ((depInfo as any).local) {\n if (!parentContext) continue;\n gitUrl = parentContext.git;\n rev = parentContext.rev;\n subdir = this.resolvePath(parentContext.subdir || \"\", (depInfo as any).local);\n } else {\n continue;\n }\n\n const cacheKey = `${gitUrl}|${rev}|${subdir || \"\"}`;\n if (this.visited.has(cacheKey)) continue;\n this.visited.add(cacheKey);\n\n const files = await this.fetcher.fetch(gitUrl!, rev!, subdir);\n\n let pkgMoveToml: string | null = null;\n for (const [path, content] of Object.entries(files)) {\n if (path.endsWith(\"Move.toml\")) {\n pkgMoveToml = content;\n break;\n }\n }\n\n if (pkgMoveToml) {\n const parsed = parseToml(pkgMoveToml);\n if (parsed.addresses) {\n this.mergeAddresses(parsed.addresses);\n }\n if (parsed.dependencies) {\n await this.resolveDeps(parsed.dependencies, { git: gitUrl, rev, subdir });\n }\n }\n\n for (const [path, content] of Object.entries(files)) {\n if (path.endsWith(\".move\") || path.endsWith(\"Move.toml\")) {\n const targetPath = `dependencies/${name}/${path}`;\n this.dependencyFiles[targetPath] = content;\n }\n }\n }\n }\n\n private resolvePath(base: string, relative: string): string {\n const stack = base.split(\"/\").filter((p) => p && p !== \".\");\n const parts = relative.split(\"/\").filter((p) => p && p !== \".\");\n for (const part of parts) {\n if (part === \"..\") {\n stack.pop();\n } else {\n stack.push(part);\n }\n }\n return stack.join(\"/\");\n }\n\n private reconstructMoveToml(originalParsed: any, addresses: Record<string, string>) {\n let newToml = `[package]\\nname = \"${originalParsed.package.name}\"\\nversion = \"${originalParsed.package.version}\"\\n`;\n if (originalParsed.package.edition) {\n newToml += `edition = \"${originalParsed.package.edition}\"\\n`;\n }\n\n newToml += `\\n[dependencies]\\n`;\n if (originalParsed.dependencies) {\n for (const [name, info] of Object.entries(originalParsed.dependencies)) {\n newToml += `${name} = { git = \"${(info as any).git}\", rev = \"${(info as any).rev}\" }\\n`;\n }\n }\n\n newToml += `\\n[addresses]\\n`;\n for (const [addrName, addrVal] of Object.entries(addresses)) {\n newToml += `${addrName} = \"${addrVal}\"\\n`;\n }\n return newToml;\n }\n\n private async injectSystemDepsFromRoot(depsObj: Record<string, any>) {\n for (const depInfo of Object.values(depsObj)) {\n if (!depInfo || !(depInfo as any).git || !(depInfo as any).rev) continue;\n if (!this.isSuiRepo((depInfo as any).git)) continue;\n await this.addImplicitSystemDepsForRepo((depInfo as any).git, (depInfo as any).rev);\n return;\n }\n }\n\n private async addImplicitSystemDepsForRepo(gitUrl: string, rev: string) {\n if (!this.isSuiRepo(gitUrl)) return;\n const cacheKey = `${gitUrl}|${rev}`;\n if (this.systemDepsLoaded.has(cacheKey)) return;\n this.systemDepsLoaded.add(cacheKey);\n\n const manifestPath = \"crates/sui-framework-snapshot/manifest.json\";\n if (!(this.fetcher as any).fetchFile) return;\n\n let packages: { name: string; id: string }[] | null = null;\n try {\n const manifestText = await (this.fetcher as any).fetchFile(gitUrl, rev, manifestPath);\n if (manifestText) {\n const manifest = JSON.parse(manifestText);\n const versions = Object.keys(manifest)\n .map((v) => Number(v))\n .filter((v) => !Number.isNaN(v))\n .sort((a, b) => a - b);\n const latestVersion = versions[versions.length - 1];\n const latest = manifest[String(latestVersion)];\n if (latest && latest.packages) {\n packages = latest.packages;\n }\n }\n } catch (e) {}\n\n if (!packages) {\n packages = [\n { name: \"MoveStdlib\", id: \"0x1\" },\n { name: \"Sui\", id: \"0x2\" },\n { name: \"SuiSystem\", id: \"0x3\" },\n { name: \"Bridge\", id: \"0xb\" },\n ];\n }\n\n for (const pkg of packages) {\n if (!pkg || !pkg.name || !pkg.id) continue;\n if (pkg.name === \"DeepBook\") continue;\n const targetPath = `dependencies/${pkg.name}/Move.toml`;\n if (this.dependencyFiles[targetPath]) continue;\n const moveToml = [\n \"[package]\",\n `name = \"${pkg.name}\"`,\n 'version = \"0.0.0\"',\n `published-at = \"${pkg.id}\"`,\n \"\",\n ].join(\"\\n\");\n this.dependencyFiles[targetPath] = moveToml;\n }\n }\n\n private isSuiRepo(gitUrl: string): boolean {\n return gitUrl.includes(\"github.com/MystenLabs/sui\");\n }\n}\n\nexport async function resolve(\n rootMoveTomlContent: string,\n rootSourceFiles: Record<string, string>,\n fetcher: Fetcher\n): Promise<{ files: string; dependencies: string }> {\n const resolver = new Resolver(fetcher);\n return resolver.resolve(rootMoveTomlContent, rootSourceFiles);\n}\n","/** Abstract interface for fetching package content. */\nexport class Fetcher {\n /** Fetch a package. Return map of path -> content. */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise<Record<string, string>> {\n throw new Error(\"Not implemented\");\n }\n\n /** Fetch a single file from a repository. */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async fetchFile(_gitUrl: string, _rev: string, _path: string): Promise<string | null> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/** Fetcher that retrieves files from public GitHub repositories via fetch(). */\nexport class GitHubFetcher extends Fetcher {\n private cache: Map<string, string>;\n\n constructor() {\n super();\n this.cache = new Map();\n }\n\n async fetch(gitUrl: string, rev: string, subdir?: string): Promise<Record<string, string>> {\n const { owner, repo } = this.parseGitUrl(gitUrl);\n if (!owner || !repo) {\n throw new Error(`Invalid git URL: ${gitUrl}`);\n }\n\n const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${rev}?recursive=1`;\n let treeData: any;\n try {\n const resp = await fetch(treeUrl);\n if (!resp.ok) {\n if (resp.status === 403 || resp.status === 429) {\n throw new Error(\"GitHub API rate limit exceeded.\");\n }\n throw new Error(`Failed to fetch tree: ${resp.statusText}`);\n }\n treeData = await resp.json();\n } catch (e) {\n return {};\n }\n\n const files: Record<string, string> = {};\n const fetchPromises: Promise<void>[] = [];\n\n for (const item of treeData.tree as any[]) {\n if (item.type !== \"blob\") continue;\n\n let relativePath: string = item.path;\n if (subdir) {\n if (!item.path.startsWith(subdir)) continue;\n relativePath = item.path.slice(subdir.length);\n if (relativePath.startsWith(\"/\")) {\n relativePath = relativePath.slice(1);\n }\n }\n\n if (!relativePath.endsWith(\".move\") && relativePath !== \"Move.toml\") {\n continue;\n }\n\n const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${rev}/${item.path}`;\n const p = this.fetchContent(rawUrl).then((content) => {\n if (content) {\n files[relativePath] = content;\n }\n });\n fetchPromises.push(p);\n }\n\n await Promise.all(fetchPromises);\n return files;\n }\n\n async fetchFile(gitUrl: string, rev: string, path: string): Promise<string | null> {\n const { owner, repo } = this.parseGitUrl(gitUrl);\n if (!owner || !repo) {\n throw new Error(`Invalid git URL: ${gitUrl}`);\n }\n const rawUrl = `https://raw.githubusercontent.com/${owner}/${repo}/${rev}/${path}`;\n return this.fetchContent(rawUrl);\n }\n\n private async fetchContent(url: string): Promise<string | null> {\n if (this.cache.has(url)) {\n return this.cache.get(url) ?? null;\n }\n try {\n const resp = await fetch(url);\n if (!resp.ok) return null;\n const text = await resp.text();\n this.cache.set(url, text);\n return text;\n } catch (e) {\n return null;\n }\n }\n\n private parseGitUrl(url: string): { owner: string | null; repo: string | null } {\n try {\n const urlObj = new URL(url);\n const parts = urlObj.pathname.split(\"/\").filter((p) => p);\n if (parts.length >= 2) {\n let repo = parts[1];\n if (repo.endsWith(\".git\")) {\n repo = repo.slice(0, -4);\n }\n return { owner: parts[0], repo };\n }\n } catch (e) {}\n return { owner: null, repo: null };\n }\n}\n","type MaybePromise<T> = T | Promise<T>;\n\nexport interface BuildInput {\n /** Virtual file system contents. Keys are paths (e.g. \"Move.toml\", \"sources/Module.move\"). */\n files: Record<string, string>;\n /** Optional dependency files keyed by path. */\n dependencies?: Record<string, string>;\n /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */\n wasm?: string | URL;\n}\n\nexport interface BuildSuccess {\n success: true;\n /** Base64-encoded bytecode modules. */\n modules: string[];\n /** Hex-encoded dependency IDs. */\n dependencies: string[];\n /** Hex-encoded Blake2b-256 package digest. */\n digest: string;\n}\n\nexport interface BuildFailure {\n success: false;\n error: string;\n}\n\ntype WasmModule = typeof import(\"./sui_move_wasm.js\");\n\nconst wasmUrl = (() => {\n try {\n // Works in ESM builds; CJS bundle falls back to plain string.\n return new URL(\"./sui_move_wasm_bg.wasm\", import.meta.url);\n } catch {\n return \"./sui_move_wasm_bg.wasm\";\n }\n})();\nlet wasmReady: Promise<WasmModule> | undefined;\n\nasync function loadWasm(customWasm?: string | URL): Promise<WasmModule> {\n if (!wasmReady) {\n wasmReady = import(\"./sui_move_wasm.js\").then(async (mod) => {\n await mod.default(customWasm ?? wasmUrl);\n return mod;\n });\n }\n return wasmReady;\n}\n\nfunction toJson(value: unknown): string {\n return JSON.stringify(value ?? {});\n}\n\nfunction asFailure(err: unknown): BuildFailure {\n const msg =\n err instanceof Error\n ? err.message\n : typeof err === \"string\"\n ? err\n : \"Unknown error\";\n return { success: false, error: msg };\n}\n\nfunction ensureCompileResult(result: unknown): {\n success: () => boolean;\n output: () => string;\n} {\n if (typeof result !== \"object\" || result === null) {\n throw new Error(\"Unexpected compile result shape from wasm\");\n }\n\n const asAny = result as any;\n\n // wasm-bindgen structs expose methods\n if (\n typeof asAny.success === \"function\" &&\n typeof asAny.output === \"function\"\n ) {\n return asAny as { success: () => boolean; output: () => string };\n }\n\n // Some builds may expose plain fields; wrap them into functions.\n if (typeof asAny.success === \"boolean\" && typeof asAny.output === \"string\") {\n return {\n success: () => asAny.success as boolean,\n output: () => asAny.output as string,\n };\n }\n\n throw new Error(\"Unexpected compile result shape from wasm\");\n}\n\nfunction parseCompileResult(output: string): BuildSuccess | BuildFailure {\n const toHex = (bytes: number[]): string =>\n bytes.map((b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n try {\n const parsed = JSON.parse(output) as {\n modules?: string[];\n dependencies?: string[];\n digest?: number[] | string;\n };\n if (!parsed.modules || !parsed.dependencies || !parsed.digest) {\n throw new Error(\"missing fields in compiler output\");\n }\n const digestHex =\n typeof parsed.digest === \"string\" ? parsed.digest : toHex(parsed.digest);\n return {\n success: true,\n modules: parsed.modules,\n dependencies: parsed.dependencies,\n digest: digestHex,\n };\n } catch (error) {\n return asFailure(error);\n }\n}\n\n/** Initialize the wasm module (idempotent). Provide a custom wasm URL if hosting separately. */\nexport async function initMoveCompiler(options?: {\n wasm?: string | URL;\n}): Promise<void> {\n await loadWasm(options?.wasm);\n}\n\n/** Compile a Move package in memory using the bundled Move compiler wasm. */\nexport async function buildMovePackage(\n input: BuildInput\n): Promise<BuildSuccess | BuildFailure> {\n try {\n const mod = await loadWasm(input.wasm);\n const raw = mod.compile(\n toJson(input.files),\n toJson(input.dependencies ?? {})\n );\n const result = ensureCompileResult(raw);\n const ok = result.success();\n const output = result.output();\n\n if (!ok) {\n return asFailure(output);\n }\n return parseCompileResult(output);\n } catch (error) {\n return asFailure(error);\n }\n}\n\n/** Sui Move version baked into the wasm (e.g. from Cargo.lock). */\nexport async function getSuiMoveVersion(options?: {\n wasm?: string | URL;\n}): Promise<string> {\n const mod = await loadWasm(options?.wasm);\n return mod.sui_move_version();\n}\n\n/** Sui repo version baked into the wasm (e.g. from Cargo.lock). */\nexport async function getSuiVersion(options?: {\n wasm?: string | URL;\n}): Promise<string> {\n const mod = await loadWasm(options?.wasm);\n return mod.sui_version();\n}\n\n/** Get the raw wasm bindings (low-level interface). */\nexport async function getWasmBindings(options?: {\n wasm?: string | URL;\n}): Promise<WasmModule> {\n return loadWasm(options?.wasm);\n}\n\n/** Low-level helper to call wasm compile directly with JSON strings. */\nexport async function compileRaw(\n filesJson: string,\n depsJson: string,\n options?: { wasm?: string | URL }\n) {\n const mod = await loadWasm(options?.wasm);\n const result = ensureCompileResult(mod.compile(filesJson, depsJson));\n return {\n success: result.success(),\n output: result.output(),\n };\n}\n\nexport type BuildResult = BuildSuccess | BuildFailure;\n\n// Resolver utilities (optional dependency fetching)\nexport { resolve, Resolver } from \"./resolver.js\";\nexport { GitHubFetcher, Fetcher } from \"./fetcher.js\";\nexport { parseToml } from \"./tomlParser.js\";\n"],"mappings":";AAAA,SAAS,mBAAmB,MAAsB;AAChD,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,KAAK,KAAK,CAAC;AACjB,SAAK,OAAO,OAAO,OAAO,SAAS,CAAC,WAAW,OAAO,YAAY;AAChE,gBAAU,CAAC;AACX,kBAAY;AAAA,IACd;AACA,QAAI,CAAC,WAAW,OAAO,KAAK;AAC1B,aAAO,KAAK,MAAM,GAAG,CAAC;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;AAEA,SAAS,YAAY,OAAoB;AACvC,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,CAAC,QAAS,QAAO;AACrB,MACG,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,KAC/C,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GAChD;AACA,WAAO,QAAQ,MAAM,GAAG,EAAE;AAAA,EAC5B;AACA,MAAI,YAAY,OAAQ,QAAO;AAC/B,MAAI,YAAY,QAAS,QAAO;AAChC,QAAM,MAAM,OAAO,OAAO;AAC1B,MAAI,CAAC,OAAO,MAAM,GAAG,EAAG,QAAO;AAC/B,SAAO;AACT;AAEA,SAAS,iBAAiB,OAAoC;AAC5D,QAAM,SAA8B,CAAC;AACrC,QAAM,QAAQ,MAAM,KAAK,EAAE,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,EAAE;AAC/D,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,QAAM,QAAkB,CAAC;AAEzB,WAAS,IAAI,GAAG,I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MAAM,MAAM,SAAS,MAAM,IAAI;AACrC,UAAM,MAAM,IAAI;AAAA,MACd,OAAO,MAAM,KAAK;AAAA,MAClB,OAAO,MAAM,gBAAgB,CAAC,CAAC;AAAA,IACjC;AACA,UAAM,SAAS,oBAAoB,GAAG;AACtC,UAAM,KAAK,OAAO,QAAQ;AAC1B,UAAM,SAAS,OAAO,OAAO;AAE7B,QAAI,CAAC,IAAI;AACP,aAAO,UAAU,MAAM;AAAA,IACzB;AACA,WAAO,mBAAmB,MAAM;AAAA,EAClC,SAAS,OAAO;AACd,WAAO,UAAU,KAAK;AAAA,EACxB;AACF;AAGA,eAAsB,kBAAkB,SAEpB;AAClB,QAAM,MAAM,MAAM,SAAS,SAAS,IAAI;AACxC,SAAO,IAAI,iBAAiB;AAC9B;AAGA,eAAsB,cAAc,SAEhB;AAClB,QAAM,MAAM,MAAM,SAAS,SAAS,IAAI;AACxC,SAAO,IAAI,YAAY;AACzB;AAGA,eAAsB,gBAAgB,SAEd;AACtB,SAAO,SAAS,SAAS,IAAI;AAC/B;AAGA,eAAsB,WACpB,WACA,UACA,SACA;AACA,QAAM,MAAM,MAAM,SAAS,SAAS,IAAI;AACxC,QAAM,SAAS,oBAAoB,IAAI,QAAQ,WAAW,QAAQ,CAAC;AACnE,SAAO;AAAA,IACL,SAAS,OAAO,QAAQ;AAAA,IACxB,QAAQ,OAAO,OAAO;AAAA,EACxB;AACF;","names":[]}
@@ -0,0 +1,55 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class MoveCompilerResult {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ readonly success: boolean;
9
+ readonly output: string;
10
+ }
11
+
12
+ export function compile(files_json: string, dependencies_json: string): MoveCompilerResult;
13
+
14
+ export function sui_move_version(): string;
15
+
16
+ export function sui_version(): string;
17
+
18
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
19
+
20
+ export interface InitOutput {
21
+ readonly memory: WebAssembly.Memory;
22
+ readonly __wbg_movecompilerresult_free: (a: number, b: number) => void;
23
+ readonly movecompilerresult_success: (a: number) => number;
24
+ readonly movecompilerresult_output: (a: number) => [number, number];
25
+ readonly sui_move_version: () => [number, number];
26
+ readonly compile: (a: number, b: number, c: number, d: number) => number;
27
+ readonly sui_version: () => [number, number];
28
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
29
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
30
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
31
+ readonly __wbindgen_externrefs: WebAssembly.Table;
32
+ readonly __wbindgen_start: () => void;
33
+ }
34
+
35
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
36
+
37
+ /**
38
+ * Instantiates the given `module`, which can either be bytes or
39
+ * a precompiled `WebAssembly.Module`.
40
+ *
41
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
42
+ *
43
+ * @returns {InitOutput}
44
+ */
45
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
46
+
47
+ /**
48
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
49
+ * for everything else, calls `WebAssembly.instantiate` directly.
50
+ *
51
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
52
+ *
53
+ * @returns {Promise<InitOutput>}
54
+ */
55
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;