@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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/tomlParser.ts","../src/resolver.ts","../src/fetcher.ts"],"sourcesContent":["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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,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,OA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,OAAO,OAAO;AAAA,EACxB;AACF;","names":[]}
@@ -0,0 +1,100 @@
1
+ import * as __sui_move_wasm_js from './sui_move_wasm.js';
2
+
3
+ /** Abstract interface for fetching package content. */
4
+ declare class Fetcher {
5
+ /** Fetch a package. Return map of path -> content. */
6
+ fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise<Record<string, string>>;
7
+ /** Fetch a single file from a repository. */
8
+ fetchFile(_gitUrl: string, _rev: string, _path: string): Promise<string | null>;
9
+ }
10
+ /** Fetcher that retrieves files from public GitHub repositories via fetch(). */
11
+ declare class GitHubFetcher extends Fetcher {
12
+ private cache;
13
+ constructor();
14
+ fetch(gitUrl: string, rev: string, subdir?: string): Promise<Record<string, string>>;
15
+ fetchFile(gitUrl: string, rev: string, path: string): Promise<string | null>;
16
+ private fetchContent;
17
+ private parseGitUrl;
18
+ }
19
+
20
+ declare class Resolver {
21
+ private fetcher;
22
+ private globalAddresses;
23
+ private visited;
24
+ private dependencyFiles;
25
+ private systemDepsLoaded;
26
+ constructor(fetcher: Fetcher);
27
+ resolve(rootMoveToml: string, rootFiles: Record<string, string>): Promise<{
28
+ files: string;
29
+ dependencies: string;
30
+ }>;
31
+ private mergeAddresses;
32
+ private normalizeAddress;
33
+ private resolveDeps;
34
+ private resolvePath;
35
+ private reconstructMoveToml;
36
+ private injectSystemDepsFromRoot;
37
+ private addImplicitSystemDepsForRepo;
38
+ private isSuiRepo;
39
+ }
40
+ declare function resolve(rootMoveTomlContent: string, rootSourceFiles: Record<string, string>, fetcher: Fetcher): Promise<{
41
+ files: string;
42
+ dependencies: string;
43
+ }>;
44
+
45
+ declare function parseToml(content: string): {
46
+ package: Record<string, any>;
47
+ dependencies: Record<string, any>;
48
+ addresses: Record<string, any>;
49
+ };
50
+
51
+ interface BuildInput {
52
+ /** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
53
+ files: Record<string, string>;
54
+ /** Optional dependency files keyed by path. */
55
+ dependencies?: Record<string, string>;
56
+ /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */
57
+ wasm?: string | URL;
58
+ }
59
+ interface BuildSuccess {
60
+ success: true;
61
+ /** Base64-encoded bytecode modules. */
62
+ modules: string[];
63
+ /** Hex-encoded dependency IDs. */
64
+ dependencies: string[];
65
+ /** Hex-encoded Blake2b-256 package digest. */
66
+ digest: string;
67
+ }
68
+ interface BuildFailure {
69
+ success: false;
70
+ error: string;
71
+ }
72
+ type WasmModule = typeof __sui_move_wasm_js;
73
+ /** Initialize the wasm module (idempotent). Provide a custom wasm URL if hosting separately. */
74
+ declare function initMoveCompiler(options?: {
75
+ wasm?: string | URL;
76
+ }): Promise<void>;
77
+ /** Compile a Move package in memory using the bundled Move compiler wasm. */
78
+ declare function buildMovePackage(input: BuildInput): Promise<BuildSuccess | BuildFailure>;
79
+ /** Sui Move version baked into the wasm (e.g. from Cargo.lock). */
80
+ declare function getSuiMoveVersion(options?: {
81
+ wasm?: string | URL;
82
+ }): Promise<string>;
83
+ /** Sui repo version baked into the wasm (e.g. from Cargo.lock). */
84
+ declare function getSuiVersion(options?: {
85
+ wasm?: string | URL;
86
+ }): Promise<string>;
87
+ /** Get the raw wasm bindings (low-level interface). */
88
+ declare function getWasmBindings(options?: {
89
+ wasm?: string | URL;
90
+ }): Promise<WasmModule>;
91
+ /** Low-level helper to call wasm compile directly with JSON strings. */
92
+ declare function compileRaw(filesJson: string, depsJson: string, options?: {
93
+ wasm?: string | URL;
94
+ }): Promise<{
95
+ success: boolean;
96
+ output: string;
97
+ }>;
98
+ type BuildResult = BuildSuccess | BuildFailure;
99
+
100
+ export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, Fetcher, GitHubFetcher, Resolver, buildMovePackage, compileRaw, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, parseToml, resolve };
@@ -0,0 +1,100 @@
1
+ import * as __sui_move_wasm_js from './sui_move_wasm.js';
2
+
3
+ /** Abstract interface for fetching package content. */
4
+ declare class Fetcher {
5
+ /** Fetch a package. Return map of path -> content. */
6
+ fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise<Record<string, string>>;
7
+ /** Fetch a single file from a repository. */
8
+ fetchFile(_gitUrl: string, _rev: string, _path: string): Promise<string | null>;
9
+ }
10
+ /** Fetcher that retrieves files from public GitHub repositories via fetch(). */
11
+ declare class GitHubFetcher extends Fetcher {
12
+ private cache;
13
+ constructor();
14
+ fetch(gitUrl: string, rev: string, subdir?: string): Promise<Record<string, string>>;
15
+ fetchFile(gitUrl: string, rev: string, path: string): Promise<string | null>;
16
+ private fetchContent;
17
+ private parseGitUrl;
18
+ }
19
+
20
+ declare class Resolver {
21
+ private fetcher;
22
+ private globalAddresses;
23
+ private visited;
24
+ private dependencyFiles;
25
+ private systemDepsLoaded;
26
+ constructor(fetcher: Fetcher);
27
+ resolve(rootMoveToml: string, rootFiles: Record<string, string>): Promise<{
28
+ files: string;
29
+ dependencies: string;
30
+ }>;
31
+ private mergeAddresses;
32
+ private normalizeAddress;
33
+ private resolveDeps;
34
+ private resolvePath;
35
+ private reconstructMoveToml;
36
+ private injectSystemDepsFromRoot;
37
+ private addImplicitSystemDepsForRepo;
38
+ private isSuiRepo;
39
+ }
40
+ declare function resolve(rootMoveTomlContent: string, rootSourceFiles: Record<string, string>, fetcher: Fetcher): Promise<{
41
+ files: string;
42
+ dependencies: string;
43
+ }>;
44
+
45
+ declare function parseToml(content: string): {
46
+ package: Record<string, any>;
47
+ dependencies: Record<string, any>;
48
+ addresses: Record<string, any>;
49
+ };
50
+
51
+ interface BuildInput {
52
+ /** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
53
+ files: Record<string, string>;
54
+ /** Optional dependency files keyed by path. */
55
+ dependencies?: Record<string, string>;
56
+ /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */
57
+ wasm?: string | URL;
58
+ }
59
+ interface BuildSuccess {
60
+ success: true;
61
+ /** Base64-encoded bytecode modules. */
62
+ modules: string[];
63
+ /** Hex-encoded dependency IDs. */
64
+ dependencies: string[];
65
+ /** Hex-encoded Blake2b-256 package digest. */
66
+ digest: string;
67
+ }
68
+ interface BuildFailure {
69
+ success: false;
70
+ error: string;
71
+ }
72
+ type WasmModule = typeof __sui_move_wasm_js;
73
+ /** Initialize the wasm module (idempotent). Provide a custom wasm URL if hosting separately. */
74
+ declare function initMoveCompiler(options?: {
75
+ wasm?: string | URL;
76
+ }): Promise<void>;
77
+ /** Compile a Move package in memory using the bundled Move compiler wasm. */
78
+ declare function buildMovePackage(input: BuildInput): Promise<BuildSuccess | BuildFailure>;
79
+ /** Sui Move version baked into the wasm (e.g. from Cargo.lock). */
80
+ declare function getSuiMoveVersion(options?: {
81
+ wasm?: string | URL;
82
+ }): Promise<string>;
83
+ /** Sui repo version baked into the wasm (e.g. from Cargo.lock). */
84
+ declare function getSuiVersion(options?: {
85
+ wasm?: string | URL;
86
+ }): Promise<string>;
87
+ /** Get the raw wasm bindings (low-level interface). */
88
+ declare function getWasmBindings(options?: {
89
+ wasm?: string | URL;
90
+ }): Promise<WasmModule>;
91
+ /** Low-level helper to call wasm compile directly with JSON strings. */
92
+ declare function compileRaw(filesJson: string, depsJson: string, options?: {
93
+ wasm?: string | URL;
94
+ }): Promise<{
95
+ success: boolean;
96
+ output: string;
97
+ }>;
98
+ type BuildResult = BuildSuccess | BuildFailure;
99
+
100
+ export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, Fetcher, GitHubFetcher, Resolver, buildMovePackage, compileRaw, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, parseToml, resolve };