interface MovePackageFetchLocalContext { dependencyName: string; parentPackageName: string; parentSource?: { type: string; git?: string; rev?: string; subdir?: string; local?: string; }; network: "mainnet" | "testnet" | "devnet"; } /** Abstract interface for fetching package content. */ declare class MovePackageFetcher { /** * Optional host-provided local package loader. * * Browser callers should implement this with a supplied snapshot, * File System Access API, or a server endpoint. The library does not read the * host filesystem directly. */ fetchLocal?: (localPath: string, context: MovePackageFetchLocalContext) => Promise>; /** Fetch a package. Return map of path -> content. */ fetch(_gitUrl: string, _rev: string, _subdir?: string): Promise>; /** Fetch a single file from a repository. */ fetchFile(_gitUrl: string, _rev: string, _path: string): Promise; /** Get the resolved commit SHA for a git URL and rev (after fetch). */ getResolvedSha(_gitUrl: string, _rev: string): string | undefined; } /** MovePackageFetcher that retrieves files from public GitHub repositories via fetch(). */ declare class GitHubMovePackageFetcher extends MovePackageFetcher { private cache; private treeCache; private resolvedShaCache; private rateLimitRemaining; private rateLimitReset; private token; constructor(token?: string); /** * Get the resolved commit SHA for a git URL and rev. * This returns the actual commit SHA that was fetched, resolving tags/branches. * Must be called after fetch() to get the resolved SHA. */ getResolvedSha(gitUrl: string, rev: string): string | undefined; /** * Update rate limit info from response headers */ private updateRateLimit; fetch(gitUrl: string, rev: string, subdir?: string, _context?: any): Promise>; private isIncludedPackageFile; private isPackageSourcePath; private isGitSymlinkMode; private relativePathForSubdir; private fetchGitTreeFile; private fetchRawGitPathContent; private resolveGitSymlinkTarget; private dirnameGitPath; private normalizeGitPath; fetchFile(gitUrl: string, rev: string, path: string): Promise; private fetchContent; private fetchRequiredContent; private parseGitUrl; } interface MovePackageStageReport { stage: string; packageId?: string; environment: string; modes: string[]; nodeCount?: number; edgeCount?: number; activeEdgeCount?: number; linkedNodeCount?: number; code?: string; } interface MovePackageFetchFailedSource { type: string; git?: string; rev?: string; subdir?: string; local?: string; address?: string; } interface MovePackageFetchFailedReport { dependencyName: string; source: MovePackageFetchFailedSource; parentPackageName?: string; parentSource?: MovePackageFetchFailedSource; error: string; code?: string; } /** Build progress event types for tracking build status */ type MovePackageProgressEvent = { type: "resolve_start"; } | { type: "resolve_dep"; name: string; source: string; current: number; total: number; } | { type: "resolve_complete"; count: number; } | { type: "compile_start"; } | { type: "compile_complete"; } | { type: "lockfile_generate"; } | ({ type: "fetch_failed"; } & MovePackageFetchFailedReport) | ({ type: "stage_trace"; } & MovePackageStageReport); /** Callback function for receiving build progress events */ type MovePackageProgressCallback = (event: MovePackageProgressEvent) => void; interface MovePackageResolvedDependencies { /** JSON string of resolved files for the root package */ files: string; /** JSON string of resolved dependencies (linkage applied, for compilation) */ dependencies: string; /** JSON string of all dependencies including diamond duplicates (for lockfile) */ lockfileDependencies: string; } declare const MOVE_PACKAGE_INTENTS: readonly ["dump", "publish", "upgrade"]; type MovePackageIntent = (typeof MOVE_PACKAGE_INTENTS)[number]; interface MovePackageGitSource { git: string; rev: string; subdir?: string; } interface MovePackageInput { /** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */ files: Record; /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */ wasm?: string | URL | BufferSource; /** Optional root package git source for resolving relative local deps from Move.lock. */ rootGit?: MovePackageGitSource; /** Optional GitHub token to raise API limits when resolving dependencies. */ githubToken?: string; /** Optional dependency fetcher. Defaults to GitHubMovePackageFetcher. */ fetcher?: MovePackageFetcher; /** Emit ANSI color codes in diagnostics when available. */ ansiColor?: boolean; /** Network environment (mainnet, testnet, devnet). Defaults to mainnet. */ network?: "mainnet" | "testnet" | "devnet"; /** Optional pre-resolved dependencies. If provided, dependency resolution will be skipped. */ resolvedDependencies?: MovePackageResolvedDependencies; /** Use this option to silence warnings. */ silenceWarnings?: boolean; /** Compile with unpublished dependencies using the CLI BuildConfig behavior. */ withUnpublishedDependencies?: boolean; /** Arbitrary Move compiler modes, equivalent to CLI --mode values. */ modes?: string[]; /** Move compiler lint level. Accepted values: "none", "default", "all". */ lintFlag?: "none" | "default" | "all"; /** Reserved for metadata stripping; not applied by the current WASM compiler path. */ stripMetadata?: boolean; /** Optional progress callback for build events */ onProgress?: MovePackageProgressCallback; } interface MovePackageUpgradeInput extends MovePackageInput { /** Published package ID to upgrade. Defaults to the selected environment publication metadata. */ packageId?: string; } interface MovePackageSuccess { /** Base64-encoded bytecode modules. */ modules: string[]; /** Hex-encoded dependency IDs. */ dependencies: string[]; /** Blake2b-256 package digest as byte array (matches Sui CLI JSON). */ digest: number[]; /** Move.lock V4 content (TOML string) */ moveLock: string; /** Build environment used */ environment: string; /** Generated Published.toml content (if migration occurred) */ publishedToml?: string; /** Compiler warnings (if any) */ warnings?: string; } interface MovePackageDumpSuccess extends MovePackageSuccess { intent: "dump"; } interface MovePackagePublishSuccess extends MovePackageSuccess { intent: "publish"; } interface MovePackageUpgradeSuccess extends MovePackageSuccess { intent: "upgrade"; packageId: string; } type MovePackageFailureCategory = "dependency_resolution" | "compile" | "compiler_output" | "input_validation" | "lockfile_generation" | "test_runner" | "wasm_init" | "unknown"; interface MovePackageFailure { error: string; /** Broad failing stage. Intended for reporting; the error string remains the detailed diagnostic. */ category?: MovePackageFailureCategory; /** Optional structured failure code produced by Rust/WASM helpers. */ code?: string; } /** Initialize the wasm module (idempotent). Provide a custom wasm URL if hosting separately. */ declare function initMovePackageBuilder(options?: { wasm?: string | URL | BufferSource; }): Promise; /** * Resolve dependencies for a Move package without compiling. * Resolves dependencies once for reuse across multiple builds. */ declare function resolveMovePackageDependencies(input: Omit): Promise; /** * Prepare CLI dump-style bytecode output for a Move package. * Browser WASM builds use declared host/crypto/network compatibility boundaries; see SECURITY.md. */ declare function dumpMovePackage(input: MovePackageInput): Promise; /** Prepare modules, dependencies, and digest for a publish transaction payload. */ declare function prepareMovePackagePublish(input: MovePackageInput): Promise; /** Prepare modules, dependencies, digest, and package ID for an upgrade transaction payload. */ declare function prepareMovePackageUpgrade(input: MovePackageUpgradeInput): Promise; /** Sui Move version baked into the wasm (e.g. from Cargo.lock). */ declare function getPinnedSuiMoveVersion(options?: { wasm?: string | URL | BufferSource; }): Promise; /** Sui repo version baked into the wasm (e.g. from Cargo.lock). */ declare function getPinnedSuiVersion(options?: { wasm?: string | URL | BufferSource; }): Promise; type MovePackageResult = MovePackageDumpSuccess | MovePackagePublishSuccess | MovePackageUpgradeSuccess | MovePackageFailure; interface MovePackagePublication { network: string; chainId: string; publishedAt: string; originalId: string; version: number; suiVersion?: string; buildConfig?: { edition: string; flavor: string; }; upgradeCapability?: string; transactionDigest?: string; } interface MovePackagePublicationUpdateInput { files: Record; prepared: MovePackagePublishSuccess | MovePackageUpgradeSuccess; network: string; chainId: string; result?: unknown; effects?: unknown; wasm?: string | URL | BufferSource; } interface MovePackagePublicationUpdateResult { files: Record; publishedToml: string; publication: MovePackagePublication; } declare function updateMovePackagePublication(input: MovePackagePublicationUpdateInput): Promise; /** * Utility functions for fetching Move packages from GitHub */ interface FetchedMovePackage { files: Record; rootGit: MovePackageGitSource; } /** * Fetch a Move package from GitHub URL * * @param url - GitHub repository URL (e.g., "https://github.com/MystenLabs/sui/tree/main/crates/sui-framework/packages/sui-framework") * @param options - Optional configuration * @returns Object with package files and root Git source metadata * * @example * ```ts * const input = await fetchMovePackageFromGitHub( * 'https://github.com/org/repo/tree/main/packages/example_package' * ); * * const result = await dumpMovePackage(input); * ``` */ declare function fetchMovePackageFromGitHub(url: string, options?: { /** Custom fetcher instance (default: GitHubMovePackageFetcher) */ fetcher?: GitHubMovePackageFetcher; /** Optional GitHub token to raise API limits (used when fetcher not provided). */ githubToken?: string; /** Include Move.lock file (default: true) */ includeLock?: boolean; }): Promise; export { type FetchedMovePackage, GitHubMovePackageFetcher, type MovePackageDumpSuccess, type MovePackageFailure, type MovePackageFailureCategory, type MovePackageFetchFailedReport, type MovePackageFetchFailedSource, type MovePackageFetchLocalContext, MovePackageFetcher, type MovePackageGitSource, type MovePackageInput, type MovePackageIntent, type MovePackageProgressCallback, type MovePackageProgressEvent, type MovePackagePublication, type MovePackagePublicationUpdateInput, type MovePackagePublicationUpdateResult, type MovePackagePublishSuccess, type MovePackageResolvedDependencies, type MovePackageResult, type MovePackageStageReport, type MovePackageSuccess, type MovePackageUpgradeInput, type MovePackageUpgradeSuccess, dumpMovePackage, fetchMovePackageFromGitHub, getPinnedSuiMoveVersion, getPinnedSuiVersion, initMovePackageBuilder, prepareMovePackagePublish, prepareMovePackageUpgrade, resolveMovePackageDependencies, updateMovePackagePublication };