@zktx.io/sui-move-builder 0.1.4 → 0.1.6

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 CHANGED
@@ -8,9 +8,10 @@ Build Move packages in web or Node.js with Sui CLI-compatible dependency resolut
8
8
  - ✅ **Lockfile Support**: Reads `Move.lock` for faster, deterministic builds
9
9
  - ✅ **Per-Package Editions**: Each package can use its own Move edition (legacy, 2024.alpha, 2024.beta)
10
10
  - ✅ **Monorepo Support**: Handles local dependencies in monorepo structures
11
- - ✅ **Version Conflict Resolution**: Automatically resolves dependency version conflicts
11
+ - ✅ **Version Conflict Detection**: Matches Sui CLI behavior for conflicting dependency versions
12
12
  - ✅ **Browser & Node.js**: Works in both environments with WASM-based compilation
13
13
  - ✅ **GitHub Integration**: Fetches dependencies directly from git repositories
14
+ - ✅ **GitHub Token Support**: Optional token to raise rate limits (API calls only; raw fetch remains CORS-safe)
14
15
 
15
16
  ## Install
16
17
 
@@ -46,22 +47,20 @@ module hello_world::hello_world {
46
47
  // 3) Compile
47
48
  const result = await buildMovePackage({
48
49
  files,
49
- dependencies: {},
50
- autoSystemDeps: true, // Sui CLI-like defaults for std/Sui packages
50
+ // optional: bump GitHub API limits during dependency resolution
51
+ githubToken: process.env.GITHUB_TOKEN,
51
52
  });
52
53
 
53
54
  if (result.success) {
54
- console.log(result.digest);
55
- console.log(result.modules); // Base64-encoded Move modules
55
+ console.log("Digest:", result.digest);
56
+ console.log("Modules:", result.modules); // Base64-encoded bytecode
56
57
  } else {
57
- console.error(result.error);
58
+ console.error("Build failed:", result.error);
58
59
  }
59
60
  ```
60
61
 
61
62
  ## Fetching packages from GitHub
62
63
 
63
- Use the utility functions to fetch Move packages directly from GitHub URLs:
64
-
65
64
  ```ts
66
65
  import {
67
66
  fetchPackageFromGitHub,
@@ -73,51 +72,33 @@ await initMoveCompiler();
73
72
 
74
73
  // Fetch a package from GitHub URL
75
74
  const files = await fetchPackageFromGitHub(
76
- "https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework"
75
+ "https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework",
76
+ {
77
+ githubToken: process.env.GITHUB_TOKEN, // optional
78
+ }
77
79
  );
78
80
 
79
- // files = {
80
- // 'Move.toml': '...',
81
- // 'Move.lock': '...',
82
- // 'sources/object.move': '...',
83
- // ...
84
- // }
85
-
86
81
  // Compile directly
87
- const result = await buildMovePackage({ files });
88
- ```
89
-
90
- ### Fetch multiple packages
91
-
92
- ```ts
93
- import { fetchPackagesFromGitHub, githubUrl } from "@zktx.io/sui-move-builder";
94
-
95
- const packages = await fetchPackagesFromGitHub({
96
- Sui: githubUrl(
97
- "MystenLabs/sui",
98
- "framework/mainnet",
99
- "crates/sui-framework/packages/sui-framework"
100
- ),
101
- deepbook: githubUrl("MystenLabs/deepbookv3", "main", "packages/deepbook"),
82
+ const result = await buildMovePackage({
83
+ files,
84
+ githubToken: process.env.GITHUB_TOKEN, // optional
102
85
  });
103
-
104
- // packages = {
105
- // 'Sui': { 'Move.toml': '...', ... },
106
- // 'deepbook': { 'Move.toml': '...', ... }
107
- // }
108
86
  ```
109
87
 
110
- ## Resolving dependencies from GitHub
88
+ ## How it works
111
89
 
112
- The dependency resolver works exactly like Sui CLI:
90
+ Dependencies are automatically resolved from `Move.toml`:
113
91
 
114
92
  1. **Tries Move.lock first**: If a valid `Move.lock` exists, dependencies are loaded from it (faster, deterministic)
115
93
  2. **Falls back to manifests**: If lockfile is missing/invalid, resolves dependencies from `Move.toml` files
116
94
  3. **Validates digests**: Checks manifest digests to detect changes
117
95
  4. **Handles monorepos**: Converts local dependencies to git dependencies automatically
96
+ 5. **Injects system packages**: Automatically adds Sui, MoveStdlib, SuiSystem, and Bridge packages if missing
118
97
 
119
98
  ```ts
120
- import { resolve, GitHubFetcher } from "@zktx.io/sui-move-builder";
99
+ import { initMoveCompiler, buildMovePackage } from "@zktx.io/sui-move-builder";
100
+
101
+ await initMoveCompiler();
121
102
 
122
103
  const files = {
123
104
  "Move.toml": `
@@ -126,55 +107,72 @@ name = "my_package"
126
107
  edition = "2024.beta"
127
108
 
128
109
  [dependencies]
129
- Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "framework/mainnet" }
130
110
  deepbook = { git = "https://github.com/MystenLabs/deepbookv3.git", subdir = "packages/deepbook", rev = "main" }
131
111
  `,
132
- "Move.lock": "...", // Optional: will be used if valid
133
112
  "sources/main.move": "...",
134
113
  };
135
114
 
136
- const resolution = await resolve(
137
- files["Move.toml"],
138
- files,
139
- new GitHubFetcher(),
140
- "mainnet" // network: 'mainnet' | 'testnet' | 'devnet'
141
- );
142
-
143
- const filesJson = JSON.parse(resolution.files);
144
- const depsJson = JSON.parse(resolution.dependencies);
115
+ const result = await buildMovePackage({ files });
145
116
 
146
- const result = await buildMovePackage({
147
- files: filesJson,
148
- dependencies: depsJson,
149
- autoSystemDeps: true,
150
- });
117
+ if (result.success) {
118
+ console.log("Modules:", result.modules); // Base64-encoded bytecode
119
+ console.log("Dependencies:", result.dependencies); // Hex-encoded IDs
120
+ console.log("Digest:", result.digest); // Package digest
121
+ } else {
122
+ console.error("Build failed:", result.error);
123
+ }
151
124
  ```
152
125
 
153
- ### How it works
126
+ ## Dependency caching and reuse
154
127
 
155
- The resolver implements Sui CLI's 3-layer architecture:
128
+ For faster builds when compiling multiple times with the same dependencies, you can resolve dependencies once and reuse them:
156
129
 
157
- 1. **Layer 1: Dependency Graph**
158
- - Builds a DAG of all packages
159
- - Resolves transitive dependencies recursively
160
- - Handles version conflicts (first version wins)
161
- - Converts local dependencies to git dependencies for monorepos
130
+ ```ts
131
+ import {
132
+ initMoveCompiler,
133
+ resolveDependencies,
134
+ buildMovePackage,
135
+ } from "@zktx.io/sui-move-builder";
136
+
137
+ await initMoveCompiler();
138
+
139
+ const files = {
140
+ "Move.toml": `...`,
141
+ "sources/main.move": "...",
142
+ };
143
+
144
+ // 1. Resolve dependencies once
145
+ const deps = await resolveDependencies({ files, network: "mainnet" });
146
+
147
+ // 2. Build multiple times without re-resolving dependencies
148
+ const result1 = await buildMovePackage({
149
+ files,
150
+ network: "mainnet",
151
+ githubToken: process.env.GITHUB_TOKEN, // optional
152
+ resolvedDependencies: deps, // Skip dependency resolution
153
+ });
154
+
155
+ // Modify source code
156
+ files["sources/main.move"] = "// updated code...";
157
+
158
+ // 3. Build again with cached dependencies (much faster!)
159
+ const result2 = await buildMovePackage({
160
+ files,
161
+ network: "mainnet",
162
+ githubToken: process.env.GITHUB_TOKEN, // optional
163
+ resolvedDependencies: deps, // Reuse same dependencies
164
+ });
165
+ ```
162
166
 
163
- 2. **Layer 2: Address Resolution**
164
- - Creates unified address table
165
- - Resolves all named addresses across packages
166
- - Uses `Move.lock` addresses when available
167
+ **Benefits:**
167
168
 
168
- 3. **Layer 3: Compilation Format**
169
- - Groups dependencies by package
170
- - Each package compiles with its own edition
171
- - Prepares format for WASM compiler
169
+ - Faster builds when dependencies haven't changed
170
+ - 🔄 Useful for watch mode or iterative development
171
+ - 💾 Reduce network requests by caching dependency resolution
172
172
 
173
- `buildMovePackage` returns:
173
+ ## Limitations
174
174
 
175
- - `success: true | false`
176
- - on success: `modules` (Base64), `dependencies`, `digest`
177
- - on failure: `error` with compiler logs
175
+ - Dependencies are always compiled from source. Bytecode-only deps (.mv fallback used by the Sui CLI when sources are missing) are not supported in the wasm path.
178
176
 
179
177
  ## Local test page
180
178
 
package/dist/index.cjs CHANGED
@@ -1,30 +1,28 @@
1
- "use strict";var H=Object.create;var S=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(s,e)=>{for(var t in e)S(s,t,{get:e[t],enumerable:!0})},_=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of V(e))!J.call(s,n)&&n!==t&&S(s,n,{get:()=>e[n],enumerable:!(i=z(e,n))||i.enumerable});return s};var Q=(s,e,t)=>(t=s!=null?H(q(s)):{},_(e||!s||!s.__esModule?S(t,"default",{value:s,enumerable:!0}):t,s)),Z=s=>_(S({},"__esModule",{value:!0}),s);var le={};K(le,{Fetcher:()=>w,GitHubFetcher:()=>k,Resolver:()=>P,buildMovePackage:()=>re,compileRaw:()=>de,fetchPackageFromGitHub:()=>L,fetchPackagesFromGitHub:()=>I,getSuiMoveVersion:()=>oe,getSuiVersion:()=>ae,getWasmBindings:()=>ce,githubUrl:()=>U,initMoveCompiler:()=>se,parseGitHubUrl:()=>F,parseToml:()=>v,resolve:()=>x});module.exports=Z(le);var w=class{async fetch(e,t,i){throw new Error("Not implemented")}async fetchFile(e,t,i){throw new Error("Not implemented")}},k=class extends w{constructor(){super(),this.cache=new Map}async fetch(e,t,i){let{owner:n,repo:o}=this.parseGitUrl(e);if(!n||!o)throw new Error(`Invalid git URL: ${e}`);let a=`https://api.github.com/repos/${n}/${o}/git/trees/${t}?recursive=1`,c;try{let d=await fetch(a);if(!d.ok)throw d.status===403||d.status===429?new Error("GitHub API rate limit exceeded."):new Error(`Failed to fetch tree: ${d.statusText}`);c=await d.json()}catch{return{}}let r={},l=[];for(let d of c.tree){if(d.type!=="blob")continue;let f=d.path;if(i){if(!d.path.startsWith(i))continue;f=d.path.slice(i.length),f.startsWith("/")&&(f=f.slice(1))}if(!f.endsWith(".move")&&f!=="Move.toml"&&f!=="Move.lock"&&!f.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;let m=`https://raw.githubusercontent.com/${n}/${o}/${t}/${d.path}`,g=this.fetchContent(m).then(u=>{u&&(r[f]=u)});l.push(g)}return await Promise.all(l),r}async fetchFile(e,t,i){let{owner:n,repo:o}=this.parseGitUrl(e);if(!n||!o)throw new Error(`Invalid git URL: ${e}`);let a=`https://raw.githubusercontent.com/${n}/${o}/${t}/${i}`;return this.fetchContent(a)}async fetchContent(e){if(this.cache.has(e))return this.cache.get(e)??null;try{let t=await fetch(e);if(!t.ok)return null;let i=await t.text();return this.cache.set(e,i),i}catch{return null}}parseGitUrl(e){try{let i=new URL(e).pathname.split("/").filter(n=>n);if(i.length>=2){let n=i[1];return n.endsWith(".git")&&(n=n.slice(0,-4)),{owner:i[0],repo:n}}}catch{}return{owner:null,repo:null}}};function X(s){let e=!1,t="";for(let i=0;i<s.length;i++){let n=s[i];if((n==='"'||n==="'")&&(!e||n===t)&&(e=!e,t=n),!e&&n==="#")return s.slice(0,i)}return s}function T(s){let e=s.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function C(s){let e={},t=s.trim().replace(/^\{/,"").replace(/\}$/,""),i="",n=!1,o="",a=[];for(let c=0;c<t.length;c++){let r=t[c];if((r==='"'||r==="'")&&(!n||r===o)&&(n=!n,o=r),!n&&r===","){a.push(i),i="";continue}i+=r}i.trim()&&a.push(i);for(let c of a){let r=c.indexOf("=");if(r===-1)continue;let l=c.slice(0,r).trim(),d=c.slice(r+1).trim();e[l]=T(d)}return e}function Y(s){let e=[],t=s.trim().replace(/^\[/,"").replace(/\]$/,""),i="",n=!1,o="",a=0;for(let c=0;c<t.length;c++){let r=t[c];if((r==='"'||r==="'")&&(!n||r===o)&&(n=!n,o=n?r:""),!n&&(r==="{"&&a++,r==="}"&&a--,r===","&&a===0)){i.trim()&&e.push(j(i.trim())),i="";continue}i+=r}return i.trim()&&e.push(j(i.trim())),e}function j(s){return s.startsWith("{")?C(s):T(s)}function v(s){let e={},t=null,i=!1,n=s.split(/\r?\n/);function o(a,c){let r=a;for(let l of c){if(!(l in r))return;r=r[l]}return r}for(let a of n){let c=X(a).trim();if(!c)continue;let r=c.match(/^\[\[([^\]]+)\]\]$/);if(r){t=r[1].trim(),i=!0;let u=t.split("."),p=e;for(let y=0;y<u.length-1;y++){let A=u[y];A in p||(p[A]={}),p=p[A]}let h=u[u.length-1];Array.isArray(p[h])||(p[h]=[]),p[h].push({});continue}let l=c.match(/^\[([^\]]+)\]$/);if(l){t=l[1].trim(),i=!1;continue}let d=c.indexOf("=");if(d===-1||!t)continue;let f=c.slice(0,d).trim(),m=c.slice(d+1).trim(),g;if(m.startsWith("{")?g=C(m):m.startsWith("[")?g=Y(m):g=T(m),i){let u=t.split("."),p=o(e,u);if(Array.isArray(p)&&p.length>0){let h=p[p.length-1];h[f]=g}}else{let u=t.split("."),p=e;for(let y of u)y in p||(p[y]={}),p=p[y];let h=t==="package"?f.replace(/-/g,"_"):f;p[h]=g}}return e}var M=class{constructor(e){this.packageTable=new Map;this.graph=new Map;this.alwaysDeps=new Set(["Sui","MoveStdlib"]);this.root=e}addPackage(e){this.packageTable.set(e.id.name,e),this.graph.has(e.id.name)||this.graph.set(e.id.name,new Set)}addDependency(e,t,i){this.graph.has(e)||this.graph.set(e,new Set),this.graph.get(e).add(t)}getPackage(e){return this.packageTable.get(e)}getAllPackages(){return Array.from(this.packageTable.values())}getImmediateDependencies(e){return this.graph.get(e)||new Set}getTransitiveDependencies(e){let t=new Set,i=new Set,n=o=>{if(i.has(o))return;i.add(o),t.add(o);let a=this.graph.get(o);if(a)for(let c of a)n(c)};return n(e),t.delete(e),t}topologicalOrder(){let e=new Set,t=[],i=n=>{if(e.has(n))return;e.add(n);let o=this.graph.get(n);if(o)for(let a of o)i(a);t.push(n)};i(this.root);for(let n of this.packageTable.keys())i(n);return t}detectCycle(){let e=new Set,t=new Set,i=new Map,n=o=>{e.add(o),t.add(o);let a=this.graph.get(o);if(a)for(let c of a)if(e.has(c)){if(t.has(c)){let r=[c],l=o;for(;l!==c;)r.unshift(l),l=i.get(l);return r.unshift(c),r}}else{i.set(c,o);let r=n(c);if(r)return r}return t.delete(o),null};for(let o of this.packageTable.keys())if(!e.has(o)){let a=n(o);if(a)return a}return null}getRootPackage(){return this.packageTable.get(this.root)}getRootName(){return this.root}isAlwaysDep(e){return this.alwaysDeps.has(e)}};var R=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let e=this.graph.topologicalOrder();for(let t of e){let i=this.graph.getPackage(t);if(i)for(let[n,o]of Object.entries(i.manifest.addresses)){let a=this.normalizeAddress(o);this.unifiedAddressTable.has(n)&&this.unifiedAddressTable.get(n)!==a||this.unifiedAddressTable.set(n,a)}}for(let t of this.graph.getAllPackages()){let i={};for(let[n,o]of this.unifiedAddressTable.entries())i[n]=o;this.packageResolvedTables.set(t.id.name,i),t.resolvedTable=i}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,i]of this.unifiedAddressTable.entries())e[t]=i;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}};var D=class{constructor(e){this.dependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let i=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),n=this.resolvedGraph.topologicalOrder();for(let o of n){if(o===this.rootPackageName)continue;let a=this.resolvedGraph.getPackage(o);if(!a)continue;let c=e.get(o)||{},r=this.extractSourcePaths(o,c),l=a.manifest.edition||"legacy",d={name:o,isImmediate:i.has(o),sourcePaths:r,addressMapping:a.resolvedTable||{},compilerConfig:{edition:l,flavor:"sui"},moduleFormat:r.length>0?"Source":"Bytecode",edition:l};this.dependencies.push(d)}}extractSourcePaths(e,t){let i=[];for(let n of Object.keys(t))n.endsWith("Move.toml")||n.endsWith("Move.lock")||n.endsWith(".move")&&i.push(n);return i}toPackageGroupedFormat(e){let t=[];for(let i of this.dependencies){let n=e.get(i.name)||{},o={};for(let[a,c]of Object.entries(n)){if(a.endsWith("Move.lock"))continue;let r=`dependencies/${i.name}/${a}`;if(a.endsWith("Move.toml")){let l=this.reconstructDependencyMoveToml(i.name,c,i.edition,i.addressMapping);o[r]=l}else o[r]=c}t.push({name:i.name,files:o,edition:i.edition})}return t}reconstructDependencyMoveToml(e,t,i,n){let o=t.split(`
2
- `),a=[],c=[],r=!1,l=!1;for(let g of o){let u=g.trim();if(u.startsWith("[package]")){r=!0,l=!1;continue}if(u.startsWith("[dependencies]")){r=!1,l=!0;continue}if(u.startsWith("[")){r=!1,l=!1;continue}r&&u&&a.push(g),l&&u&&c.push(g)}let d=`[package]
3
- `,f=!1,m=!1;for(let g of a)if(g.includes("name ="))d+=g+`
4
- `,f=!0;else if(g.includes("version ="))d+=g+`
5
- `,m=!0;else{if(g.includes("edition ="))continue;d+=g+`
6
- `}f||(d+=`name = "${e}"
7
- `),m||(d+=`version = "0.0.0"
8
- `),d+=`edition = "${i}"
9
- `,d+=`
1
+ "use strict";var W=Object.create;var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var H=(d,e)=>{for(var t in e)S(d,t,{get:e[t],enumerable:!0})},L=(d,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of E(e))!V.call(d,n)&&n!==t&&S(d,n,{get:()=>e[n],enumerable:!(i=U(e,n))||i.enumerable});return d};var q=(d,e,t)=>(t=d!=null?W(z(d)):{},L(e||!d||!d.__esModule?S(t,"default",{value:d,enumerable:!0}):t,d)),K=d=>L(S({},"__esModule",{value:!0}),d);var re={};H(re,{buildMovePackage:()=>ee,compileRaw:()=>se,fetchPackageFromGitHub:()=>B,getSuiMoveVersion:()=>te,getSuiVersion:()=>ne,getWasmBindings:()=>ie,initMoveCompiler:()=>Z,resolveDependencies:()=>j});module.exports=K(re);var I=class{async fetch(e,t,i){throw new Error("Not implemented")}async fetchFile(e,t,i){throw new Error("Not implemented")}},P=class extends I{constructor(t){super();this.rateLimitRemaining=60;this.rateLimitReset=0;this.cache=new Map,this.treeCache=new Map,this.token=t}updateRateLimit(t){let i=t.headers.get("x-ratelimit-remaining"),n=t.headers.get("x-ratelimit-reset");i&&(this.rateLimitRemaining=parseInt(i,10)),n&&(this.rateLimitReset=parseInt(n,10)*1e3)}async fetch(t,i,n,o){let{owner:s,repo:c}=this.parseGitUrl(t);if(!s||!c)throw new Error(`Invalid git URL: ${t}`);let a=`${s}/${c}@${i}`,l=`https://api.github.com/repos/${s}/${c}/git/trees/${i}?recursive=1`,r;if(this.treeCache.has(a))r=this.treeCache.get(a);else{let p=null;for(let m=1;m<=3;m++)try{if(m>1){let k=Math.pow(2,m-1)*1e3;await new Promise(v=>setTimeout(v,k))}let y={};this.token&&(y.Authorization=`Bearer ${this.token}`);let h=await fetch(l,{headers:y});if(this.updateRateLimit(h),!h.ok){if(h.status===403||h.status===429){let k=new Date(this.rateLimitReset);throw new Error(`GitHub API rate limit exceeded. Resets at ${k.toLocaleTimeString()}`)}if(h.status>=500&&h.status<600&&m<3){p=new Error(`Failed to fetch tree: ${h.statusText}`);continue}throw new Error(`Failed to fetch tree: ${h.statusText}`)}r=await h.json(),this.treeCache.set(a,r);break}catch(y){if(p=y instanceof Error?y:new Error(String(y)),m===3)return{}}if(p)return{}}let g={},f=[];for(let u of r.tree){if(u.type!=="blob")continue;let p=u.path;if(n){if(!u.path.startsWith(n))continue;p=u.path.slice(n.length),p.startsWith("/")&&(p=p.slice(1))}if(!p.endsWith(".move")&&p!=="Move.toml"&&p!=="Move.lock"&&!p.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;let m=`https://raw.githubusercontent.com/${s}/${c}/${i}/${u.path}`,y=this.fetchContent(m).then(h=>{h&&(g[p]=h)});f.push(y)}if(await Promise.all(f),g["Move.toml"]){let u=g["Move.toml"].trim();if(u.match(/^Move\.(mainnet|testnet|devnet)\.toml$/)&&!u.includes("[")&&!u.includes("=")){let p=u,m=n?`${n}/${p}`.replace(/\/+/g,"/"):p,y=`https://raw.githubusercontent.com/${s}/${c}/${i}/${m}`,h=await this.fetchContent(y);h&&(g["Move.toml"]=h,g[p]=h)}}return g}async fetchFile(t,i,n){let{owner:o,repo:s}=this.parseGitUrl(t);if(!o||!s)throw new Error(`Invalid git URL: ${t}`);let c=`https://raw.githubusercontent.com/${o}/${s}/${i}/${n}`;return this.fetchContent(c)}async fetchContent(t){if(this.cache.has(t))return this.cache.get(t)??null;try{let i={},n=typeof window<"u",o=t.startsWith("https://api.github.com/");this.token&&(!n||o)&&(i.Authorization=`Bearer ${this.token}`);let s=await fetch(t,{headers:i});if(!s.ok)return null;let c=await s.text();return this.cache.set(t,c),c}catch{return null}}parseGitUrl(t){try{let n=new URL(t).pathname.split("/").filter(o=>o);if(n.length>=2){let o=n[1];return o.endsWith(".git")&&(o=o.slice(0,-4)),{owner:n[0],repo:o}}}catch{}return{owner:null,repo:null}}};function M(d){let e=!1,t="";for(let i=0;i<d.length;i++){let n=d[i];if((n==='"'||n==="'")&&(!e||n===t)&&(e=!e,t=n),!e&&n==="#")return d.slice(0,i)}return d}function x(d){let e=d.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function N(d){let e={},t=d.trim().replace(/^\{/,"").replace(/\}$/,""),i="",n=!1,o="",s=[];for(let c=0;c<t.length;c++){let a=t[c];if((a==='"'||a==="'")&&(!n||a===o)&&(n=!n,o=a),!n&&a===","){s.push(i),i="";continue}i+=a}i.trim()&&s.push(i);for(let c of s){let a=c.indexOf("=");if(a===-1)continue;let l=c.slice(0,a).trim(),r=c.slice(a+1).trim();e[l]=x(r)}return e}function J(d){let e=[],t=d.trim().replace(/^\[/,"").replace(/\]$/,""),i="",n=!1,o="",s=0;for(let c=0;c<t.length;c++){let a=t[c];if((a==='"'||a==="'")&&(!n||a===o)&&(n=!n,o=n?a:""),!n&&(a==="{"&&s++,a==="}"&&s--,a===","&&s===0)){i.trim()&&e.push(G(i.trim())),i="";continue}i+=a}return i.trim()&&e.push(G(i.trim())),e}function G(d){return d.startsWith("{")?N(d):x(d)}function b(d){let e={},t=null,i=!1,n=d.split(/\r?\n/),o=[],s=0;for(;s<n.length;){let a=M(n[s]);if(a.match(/=\s*\[\s*$/)||a.includes("=")&&a.includes("[")&&!a.includes("]")){let l=a;for(s++;s<n.length&&!l.includes("]");)l+=" "+M(n[s]).trim(),s++;s<n.length&&l.includes("[")&&!l.includes("]")&&(l+=" "+M(n[s]).trim(),s++),o.push(l)}else o.push(a),s++}function c(a,l){let r=a;for(let g of l){if(!(g in r))return;r=r[g]}return r}for(let a of o){let l=M(a).trim();if(!l)continue;let r=l.match(/^\[\[([^\]]+)\]\]$/);if(r){t=r[1].trim(),i=!0;let y=t.split("."),h=e;for(let v=0;v<y.length-1;v++){let w=y[v];w in h||(h[w]={}),h=h[w]}let k=y[y.length-1];Array.isArray(h[k])||(h[k]=[]),h[k].push({});continue}let g=l.match(/^\[([^\]]+)\]$/);if(g){t=g[1].trim(),i=!1;continue}let f=l.indexOf("=");if(f===-1||!t)continue;let u=l.slice(0,f).trim(),p=l.slice(f+1).trim(),m;if(p.startsWith("{")?m=N(p):p.startsWith("[")?m=J(p):m=x(p),i){let y=t.split("."),h=c(e,y);if(Array.isArray(h)&&h.length>0){let k=h[h.length-1];k[u]=m}}else{let y=t.split("."),h=e;for(let v of y)v in h||(h[v]={}),h=h[v];let k=t==="package"?u.replace(/-/g,"_"):u;h[k]=m}}return e}var D=class{constructor(e){this.packageTable=new Map;this.graph=new Map;this.alwaysDeps=new Set(["Sui","MoveStdlib","SuiSystem","Bridge"]);this.lockfileOrder=[];this.root=e}setLockfileOrder(e){this.lockfileOrder=e}addPackage(e){this.packageTable.set(e.id.name,e),this.graph.has(e.id.name)||this.graph.set(e.id.name,new Set)}addDependency(e,t,i){this.graph.has(e)||this.graph.set(e,new Set),this.graph.get(e).add(t)}getPackage(e){return this.packageTable.get(e)}getAllPackages(){return Array.from(this.packageTable.values())}getImmediateDependencies(e){return this.graph.get(e)||new Set}getTransitiveDependencies(e){let t=new Set,i=new Set,n=o=>{if(i.has(o))return;i.add(o),t.add(o);let s=this.graph.get(o);if(s)for(let c of s)n(c)};return n(e),t.delete(e),t}topologicalOrder(){if(!this.lockfileOrder.length)return this.topologicalOrderDFS().filter(s=>s!==this.root);let e=new Set,t=new Set,i=o=>{if(t.has(o))return;t.add(o),e.add(o);let s=this.graph.get(o);if(s)for(let c of s)i(c)};i(this.root);let n=[];for(let o of this.lockfileOrder)o!==this.root&&e.has(o)&&n.push(o);return n}topologicalOrderDFS(){let e=new Set,t=[],i=n=>{if(e.has(n))return;e.add(n);let o=this.graph.get(n);if(o)for(let s of Array.from(o))i(s);t.push(n)};i(this.root);for(let n of this.packageTable.keys())i(n);return t}detectCycle(){let e=new Set,t=new Set,i=new Map,n=o=>{e.add(o),t.add(o);let s=this.graph.get(o);if(s)for(let c of s)if(e.has(c)){if(t.has(c)){let a=[c],l=o;for(;l!==c;)a.unshift(l),l=i.get(l);return a.unshift(c),a}}else{i.set(c,o);let a=n(c);if(a)return a}return t.delete(o),null};for(let o of this.packageTable.keys())if(!e.has(o)){let s=n(o);if(s)return s}return null}getRootPackage(){return this.packageTable.get(this.root)}getRootName(){return this.root}isAlwaysDep(e){return this.alwaysDeps.has(e)}};var $=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let t=[this.graph.getRootName(),...this.graph.topologicalOrder()];for(let i of t){let n=this.graph.getPackage(i);if(n)for(let[o,s]of Object.entries(n.manifest.addresses)){let c=this.normalizeAddress(s);this.unifiedAddressTable.has(o)&&this.unifiedAddressTable.get(o)!==c||this.unifiedAddressTable.set(o,c)}}for(let i of this.graph.getAllPackages()){let n={};for(let[o,s]of this.unifiedAddressTable.entries())n[o]=s;this.packageResolvedTables.set(i.id.name,n),i.resolvedTable=n}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,i]of this.unifiedAddressTable.entries())e[t]=i;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}};var A=class{constructor(e){this.dependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let i=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),n=this.resolvedGraph.topologicalOrder(),o=new Set(["Bridge","SuiSystem"]);for(let s of n){if(s===this.rootPackageName)continue;let c=this.resolvedGraph.getPackage(s);if(!c||o.has(s))continue;let a=e.get(s)||{},l=this.extractSourcePaths(s,a),r=c.manifest.edition||"legacy",g=c.manifest.latestPublishedId||c.manifest.originalId||c.manifest.publishedAt||c.resolvedTable?.[s],f={name:s,isImmediate:i.has(s),sourcePaths:l,addressMapping:c.resolvedTable||{},compilerConfig:{edition:r,flavor:"sui"},moduleFormat:l.length>0?"Source":"Bytecode",edition:r,publishedIdForOutput:g};this.dependencies.push(f)}}extractSourcePaths(e,t){let i=Object.keys(t).filter(s=>s.endsWith("Move.toml")||s.endsWith("Move.lock")?!1:s.endsWith(".move")),n=new TextEncoder,o=(s,c)=>{let a=n.encode(`/vfs/deps/${e}/${s}`),l=n.encode(`/vfs/deps/${e}/${c}`),r=Math.min(a.length,l.length);for(let g=0;g<r;g++)if(a[g]!==l[g])return a[g]-l[g];return a.length-l.length};return i.sort(o),i}toPackageGroupedFormat(e){let t=[];for(let i of this.dependencies){let n=e.get(i.name)||{},o={};for(let[s,c]of Object.entries(n)){if(s.endsWith("Move.lock"))continue;let a=`dependencies/${i.name}/${s}`;s.endsWith("Move.toml")?o[a]=this.reconstructDependencyMoveToml(i.name,c,i.edition,i.addressMapping):o[a]=c}t.push({name:i.name,files:o,edition:i.edition,addressMapping:i.addressMapping,publishedIdForOutput:i.publishedIdForOutput})}return t}reconstructDependencyMoveToml(e,t,i,n){let o=(t||"").split(`
2
+ `),s=[],c=[],a=!1,l=!1;for(let u of o){let p=u.trim();if(p.startsWith("[package]")){a=!0,l=!1;continue}if(p.startsWith("[dependencies]")){a=!1,l=!0;continue}if(p.startsWith("[")){a=!1,l=!1;continue}a&&p&&s.push(u),l&&p&&c.push(u)}let r=`[package]
3
+ `,g=!1,f=!1;for(let u of s)if(u.includes("name ="))r+=u+`
4
+ `,g=!0;else if(u.includes("version ="))r+=u+`
5
+ `,f=!0;else{if(u.includes("edition ="))continue;r+=u+`
6
+ `}g||(r+=`name = "${e}"
7
+ `),f||(r+=`version = "0.0.0"
8
+ `),r+=`edition = "${i}"
9
+ `,r+=`
10
10
  [dependencies]
11
- `;for(let g of c)d+=g+`
12
- `;d+=`
11
+ `;for(let u of c)r+=u+`
12
+ `;r+=`
13
13
  [addresses]
14
- `;for(let[g,u]of Object.entries(n))d+=`${g} = "${u}"
15
- `;return d}getUnifiedAddressTable(){return this.resolvedGraph.getUnifiedAddressTable()}};var P=class{constructor(e,t="mainnet"){this.visited=new Set;this.packageNameCache=new Map;this.packageFiles=new Map;this.fetcher=e,this.network=t}async resolve(e,t){let i=v(e),n=i.package?.name||"RootPackage",o=i.package?.edition;if(t["Move.lock"]){let h=v(t["Move.lock"]);h.move?.["toolchain-version"]?.edition&&(o=h.move["toolchain-version"].edition)}let a=o||"2024.beta",c=new M(n),r=await this.buildPackage(n,null,e,t);o&&(r.manifest.edition=o),c.addPackage(r),this.packageFiles.set(n,t),await this.loadFromLockfile(c,r,t)||await this.buildDependencyGraph(c,r);let d=c.detectCycle();if(d)throw new Error(`Dependency cycle detected: ${d.join(" \u2192 ")}`);let f=new R(c,{});await f.resolve();let m=new D(f);await m.compute(this.packageFiles);let g=this.reconstructMoveToml(i,f.getUnifiedAddressTable(),!0,a),u={...t};delete u["Move.lock"],u["Move.toml"]=g;let p=m.toPackageGroupedFormat(this.packageFiles);return{files:JSON.stringify(u),dependencies:JSON.stringify(p)}}async buildPackage(e,t,i,n){let o=v(i),a={name:o.package?.name||e,version:o.package?.version||"0.0.0",edition:o.package?.edition,publishedAt:o.package?.published_at,addresses:o.addresses||{},dependencies:o.dependencies||{},devDependencies:o["dev-dependencies"]},c=new Map;if(a.dependencies)for(let[l,d]of Object.entries(a.dependencies)){let f=this.parseDependencyInfo(d);f&&c.set(l,f)}return{id:{name:a.name,version:a.version,source:t||{type:"local"}},manifest:a,dependencies:c,devDependencies:new Map}}parseDependencyInfo(e){return e?e.git&&e.rev?{source:{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}}:e.local?{source:{type:"local",local:e.local}}:null:null}async buildDependencyGraph(e,t){for(let[i,n]of t.dependencies.entries()){if(n.source.type==="local")if(t.id.source.type==="git"&&n.source.local){let g=t.id.source.subdir||"",u=n.source.local,p=this.resolveRelativePath(g,u);n.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:p}}else continue;if(n.source.type!=="git")continue;let o=`${n.source.git}|${n.source.rev}|${n.source.subdir||""}`;if(this.visited.has(o)){let g=this.findPackageBySource(e,n.source);g&&e.addDependency(t.id.name,g.id.name,n);continue}this.visited.add(o);let a=n.source.subdir;!a&&n.source.git&&this.isSuiRepo(n.source.git)&&(a=this.inferSuiFrameworkSubdir(i),a&&(n.source.subdir=a));let c=await this.fetcher.fetch(n.source.git,n.source.rev,a),r=null,l=`Move.${this.network}.toml`;for(let[g,u]of Object.entries(c))if(g.endsWith(l)){r=u;break}if(!r){for(let[g,u]of Object.entries(c))if(g.endsWith("Move.toml")){r=u;break}}if(!r)continue;let d=await this.buildPackage(i,n.source,r,c),f=this.packageNameCache.get(d.manifest.name);if(f){let g=this.findPackageBySource(e,f);g&&e.addDependency(t.id.name,g.id.name,n);continue}this.packageNameCache.set(d.manifest.name,n.source);let m=c["Move.lock"];if(m){let g=v(m);if(g.env?.[this.network]){let u=g.env[this.network]["latest-published-id"]||g.env[this.network]["original-published-id"];u&&(d.manifest.publishedAt=u,d.manifest.addresses[d.manifest.name]=this.normalizeAddress(u))}d.manifest.edition||(d.manifest.edition="legacy")}if(!d.manifest.publishedAt){let g={Sui:"0x2",MoveStdlib:"0x1",SuiSystem:"0x3",Bridge:"0xb"};g[i]&&(d.manifest.publishedAt=g[i])}e.addPackage(d),e.addDependency(t.id.name,d.id.name,n),this.packageFiles.set(d.id.name,c),await this.buildDependencyGraph(e,d)}}findPackageBySource(e,t){for(let i of e.getAllPackages()){let n=i.id.source;if(n.type===t.type&&n.git===t.git&&n.rev===t.rev&&n.subdir===t.subdir)return i}}resolveRelativePath(e,t){let i=e?e.split("/").filter(Boolean):[],n=t.split("/").filter(Boolean),o=[...i];for(let a of n)a===".."?o.length>0&&o.pop():a!=="."&&o.push(a);return o.join("/")}async computeManifestDigest(e){let i=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,i){let n=i["Move.lock"];if(!n)return!1;let o=v(n),a=o.pinned?.[this.network];if(!a)return!1;let c=i["Move.toml"];if(c&&o.move?.manifest_digest&&await this.computeManifestDigest(c)!==o.move.manifest_digest)return!1;let r=new Map;for(let[l,d]of Object.entries(a)){let f=this.lockfileSourceToDependencySource(d.source);if(!f)continue;let m=await this.fetchFromSource(f);if(!m)return!1;let g=m["Move.toml"];if(!g||d["manifest-digest"]&&await this.computeManifestDigest(g)!==d["manifest-digest"])return!1;let u=await this.buildPackage(l,f,g,m);r.set(l,u),this.packageFiles.set(u.manifest.name,m),(f.type!=="local"||!("root"in d.source))&&e.addPackage(u)}for(let[l,d]of Object.entries(a)){let f=r.get(l);if(f&&d.deps)for(let[m,g]of Object.entries(d.deps)){let u=r.get(g);if(u){let p=f.dependencies.get(m);p&&e.addDependency(f.id.name,u.id.name,p)}}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir)}catch{return null}return null}reconstructMoveToml(e,t,i,n){let a=`[package]
14
+ `;for(let[u,p]of Object.entries(n))r+=`${u} = "${p}"
15
+ `;return r}};var F=class{constructor(e,t="mainnet",i=null){this.visited=new Set;this.packageNameCache=new Map;this.packageFiles=new Map;this.fetcher=e,this.network=t,this.rootSource=i}async resolve(e,t){let i=b(e),n=i.package?.name||"RootPackage",o=i.package?.edition;if(t["Move.lock"]){let v=b(t["Move.lock"]);v.move?.["toolchain-version"]?.edition&&(o=v.move["toolchain-version"].edition)}let s=o||"2024.beta",c=new D(n),a=await this.buildPackage(n,this.rootSource,e,t);o&&(a.manifest.edition=o);let l=a.manifest.addresses[n];this.normalizeAddress(l||"")==="0x0000000000000000000000000000000000000000000000000000000000000000"&&a.manifest.originalId&&(a.manifest.addresses[n]=this.normalizeAddress(a.manifest.originalId)),c.addPackage(a),this.packageFiles.set(n,t);let g=await this.loadFromLockfile(c,a,t),f=Array.from(a.dependencies.keys()).filter(v=>!c.getPackage(v));(!g||f.length>0)&&await this.buildDependencyGraph(c,a);let u=c.detectCycle();if(u)throw new Error(`Dependency cycle detected: ${u.join(" \u2192 ")}`);let p=new $(c,{});await p.resolve();let m=new A(p);await m.compute(this.packageFiles);let y=this.reconstructMoveToml(i,p.getUnifiedAddressTable(),!0,s),h={...t};delete h["Move.lock"],h["Move.toml"]=y;let k=m.toPackageGroupedFormat(this.packageFiles);return{files:JSON.stringify(h),dependencies:JSON.stringify(k)}}async buildPackage(e,t,i,n){let o=b(i),s=n["Move.lock"],c=this.getChainIdForNetwork(this.network),a=this.resolvePublishedAt(i,s,c),l=a.latestId?this.normalizeAddress(a.latestId):void 0;a.error;let r={name:o.package?.name||e,version:o.package?.version||"0.0.0",edition:o.package?.edition,publishedAt:a.publishedAt,originalId:a.originalId,latestPublishedId:l,addresses:o.addresses||{},dependencies:o.dependencies||{},devDependencies:o["dev-dependencies"]},g=r.publishedAt&&r.publishedAt!=="0x0"?this.normalizeAddress(r.publishedAt):void 0,f=r.addresses[r.name],u=f?this.normalizeAddress(f):void 0;g?r.addresses[r.name]=g:u?r.addresses[r.name]=u:r.addresses[r.name]="0x0";let p=new Map;if(r.dependencies)for(let[y,h]of Object.entries(r.dependencies)){let k=this.parseDependencyInfo(h);k&&p.set(y,k)}return{id:{name:r.name,version:r.version,source:t||{type:"local"}},manifest:r,dependencies:p,devDependencies:new Map}}parseDependencyInfo(e){if(!e)return null;let t={source:{type:"local"}};if(e.git&&e.rev)t.source={type:"git",git:e.git,rev:e.rev,subdir:e.subdir};else if(e.local)t.source={type:"local",local:e.local};else return null;if(e["addr-subst"]||e.addr_subst){let i=e["addr-subst"]||e.addr_subst,n={};for(let[o,s]of Object.entries(i))typeof s=="string"&&(s.startsWith("0x")||/^[0-9a-fA-F]+$/.test(s)?n[o]={type:"assign",address:s}:n[o]={type:"renameFrom",name:s});Object.keys(n).length>0&&(t.subst=n)}return t}async buildDependencyGraph(e,t){for(let[i,n]of t.dependencies.entries()){if(n.source.type==="local")if(t.id.source.type==="git"&&n.source.local){let g=t.id.source.subdir||"",f=n.source.local,u=this.resolveRelativePath(g,f);n.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:u}}else continue;if(n.source.type!=="git")continue;let o=`${n.source.git}|${n.source.rev}|${n.source.subdir||""}`;if(this.visited.has(o)){let g=this.findPackageBySource(e,n.source);g&&e.addDependency(t.id.name,g.id.name,n);continue}this.visited.add(o);let s=n.source.subdir;!s&&n.source.git&&this.isSuiRepo(n.source.git)&&(s=this.inferSuiFrameworkSubdir(i),s&&(n.source.subdir=s));let c=await this.fetcher.fetch(n.source.git,n.source.rev,s,`${t.id.name} -> ${i}`),a=null,l=`Move.${this.network}.toml`;for(let[g,f]of Object.entries(c))if(g.endsWith(l)){a=f;break}if(!a){for(let[g,f]of Object.entries(c))if(g.endsWith("Move.toml")){a=f;break}}if(!a)continue;let r=await this.buildPackage(i,n.source,a,c);if(!this.lockfileVersion||this.lockfileVersion<4){let g=this.packageNameCache.get(r.manifest.name);if(g){let f=u=>JSON.stringify(u);throw new Error([`Conflicting versions of package '${r.manifest.name}' found`,`Existing: ${f(g)}`,`New: ${f(n.source)}`,`When resolving dependencies for '${t.id.name}' -> '${i}'`].join(`
16
+ `))}this.packageNameCache.set(r.manifest.name,n.source)}r.manifest.publishedAt&&(r.manifest.addresses[r.manifest.name]=this.normalizeAddress(r.manifest.publishedAt)),r.manifest.edition||(r.manifest.edition="legacy"),e.addPackage(r),e.addDependency(t.id.name,r.id.name,n),this.packageFiles.set(r.id.name,c),await this.buildDependencyGraph(e,r)}}getChainIdForNetwork(e){return{mainnet:"35834a8a",testnet:"4c78adac",devnet:"2",localnet:"localnet"}[e]||e}resolvePublishedAt(e,t,i){let n=b(e),o=n.package?.published_at||n.package?.["published-at"],s=o&&o!=="0x0"?o:void 0,c=s?this.normalizeAddress(s):void 0,a=n.package?.["original-id"];if(!t||!i)return{publishedAt:c,originalId:a};let l=b(t),r,g,f;if(l.env)for(let[,u]of Object.entries(l.env)){let p=u["latest-published-id"],m=u["original-published-id"],y=u["chain-id"];if(y===i||!y){let h=p&&p!=="0x0"?this.normalizeAddress(p):void 0,k=m&&m!=="0x0"?this.normalizeAddress(m):void 0;g=h,f=k,r=h||k;break}}return!f&&r&&(f=r),r&&c&&r!==c?{error:`Conflicting 'published-at' addresses between Move.toml (${c}) and Move.lock (${r})`}:{publishedAt:f||c||r,originalId:f||a,latestId:g||r||c}}findPackageBySource(e,t){for(let i of e.getAllPackages()){let n=i.id.source;if(n.type===t.type&&n.git===t.git&&n.rev===t.rev&&n.subdir===t.subdir)return i}}resolveRelativePath(e,t){let i=e?e.split("/").filter(Boolean):[],n=t.split("/").filter(Boolean),o=[...i];for(let s of n)s===".."?o.length>0&&o.pop():s!=="."&&o.push(s);return o.join("/")}async computeManifestDigest(e){let i=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,i){let n=i["Move.lock"];if(!n)return!1;let o=b(n);this.lockfileVersion=o.move?.version;let s=o.move?.version;return s===3?await this.loadFromLockfileV3(e,o,t):s&&s>=4?await this.loadFromLockfileV4(e,o,i):await this.loadFromLockfileV0(e,o,t)}async loadFromLockfileV0(e,t,i){let n=t.move?.package;if(!n||!Array.isArray(n))return!1;let o=Array.isArray(t.move?.dependencies)?t.move.dependencies.map(r=>r.name||r.id||r).filter(Boolean):[],s=n.map(r=>r.name||r.id).filter(Boolean),c=[...o,...s.filter(r=>!o.includes(r))],a=new Map,l=new Map;for(let r of n){let g=r.id||r.name,f=r.source;if(!g||!f)continue;let u=null;if(f.git&&f.rev)u={type:"git",git:f.git,rev:f.rev,subdir:f.subdir};else if(f.local&&this.rootSource?.type==="git"){let h=this.resolveRelativePath(this.rootSource.subdir||"",f.local);u={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:h}}else continue;let p=await this.fetcher.fetch(u.git,u.rev,u.subdir,`lockfile:${g}`);if(Object.keys(p).length===0)continue;let m=p["Move.toml"];if(!m)continue;let y=await this.buildPackage(g,u,m,p);a.set(g,y),l.set(y.manifest.name,y),this.packageFiles.set(y.manifest.name,p),e.addPackage(y)}c.length&&e.setLockfileOrder(c);for(let r of n){let g=r.id||r.name,f=a.get(g);if(!f)continue;let u=r.dependencies;if(u&&Array.isArray(u))for(let p of u){let m=p.id||p.name,y=a.get(m)||l.get(m);if(y){let h={source:y.id.source};e.addDependency(f.id.name,y.id.name,h)}}}for(let r of i.dependencies.keys()){let g=l.get(r);if(g){let f=i.dependencies.get(r);e.addDependency(i.id.name,g.id.name,f)}}return a.size>0}async loadFromLockfileV3(e,t,i){let n=t.move?.package;if(!n||!Array.isArray(n))return!1;let o=new Map,s=new Map,c=[];for(let a of n)a.id&&s.set(a.id,a);for(let a of n){let l=a.id,r=a.source;c.push(l);let g=null;if(r?.git&&r.rev)g={type:"git",git:r.git,rev:r.rev,subdir:r.subdir};else if(r?.local&&this.rootSource?.type==="git"){let m=this.resolveRelativePath(this.rootSource.subdir||"",r.local);g={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:m}}else continue;let f=await this.fetcher.fetch(r.git,r.rev,r.subdir,`lockfile:${l}`);if(Object.keys(f).length===0)continue;let u=f["Move.toml"];if(!u)continue;let p=await this.buildPackage(l,g,u,f);o.set(l,p),this.packageFiles.set(p.manifest.name,f),e.addPackage(p)}e.setLockfileOrder(c);for(let a of n){let l=a.id,r=o.get(l);if(!r)continue;let g=a.dependencies;if(!(!g||!Array.isArray(g)))for(let f of g){let u=f.id,p=o.get(u);if(!p){let m=s.get(u);if(m?.source?.local&&r.id.source.type==="git"){let y=this.resolveRelativePath(r.id.source.subdir||"",m.source.local),h={type:"git",git:r.id.source.git,rev:r.id.source.rev,subdir:y},k=await this.fetcher.fetch(h.git,h.rev,h.subdir,`lockfile:${u}`),v=k["Move.toml"];if(v){let w=await this.buildPackage(u,h,v,k);o.set(u,w),this.packageFiles.set(w.manifest.name,k),e.addPackage(w),p=w}}}if(p){let m={source:p.id.source};e.addDependency(r.id.name,p.id.name,m)}}}for(let a of i.dependencies.keys()){let l=o.get(a);if(l){let r=i.dependencies.get(a);e.addDependency(i.id.name,l.id.name,r)}}return!0}async loadFromLockfileV4(e,t,i){let n=t.pinned?.[this.network];if(!n)return!1;let o=rootFiles["Move.toml"];if(o&&t.move?.manifest_digest&&await this.computeManifestDigest(o)!==t.move.manifest_digest)return!1;let s=new Map,c=new Map,a=[];for(let[l,r]of Object.entries(n)){a.push(l);let g=this.lockfileSourceToDependencySource(r.source);if(!g)continue;let f=await this.fetchFromSource(g);if(!f)return!1;let u=f["Move.toml"];if(!u||r["manifest-digest"]&&await this.computeManifestDigest(u)!==r["manifest-digest"])return!1;let p=await this.buildPackage(l,g,u,f);s.set(l,p),c.set(p.manifest.name,p),this.packageFiles.set(p.manifest.name,f),(g.type!=="local"||!("root"in r.source))&&e.addPackage(p)}a.length>0&&e.setLockfileOrder(a);for(let[l,r]of Object.entries(n)){let g=s.get(l);if(g&&r.deps)for(let[f,u]of Object.entries(r.deps)){let p=s.get(u);if(p){let m=g.dependencies.get(f);m&&e.addDependency(g.id.name,p.id.name,m)}}}for(let l of rootPackage.dependencies.keys()){let r=c.get(l)||s.get(l);if(r){let g=rootPackage.dependencies.get(l);e.addDependency(rootPackage.id.name,r.id.name,g)}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir,"lockfile:dependency")}catch{return null}return null}reconstructMoveToml(e,t,i,n){let s=`[package]
16
17
  name = "${e.package.name}"
17
18
  version = "${e.package.version}"
18
- `,c=n||e.package.edition;if(c&&(a+=`edition = "${c}"
19
- `),a+=`
19
+ `,c=n||e.package.edition;if(c&&(s+=`edition = "${c}"
20
+ `),s+=`
20
21
  [dependencies]
21
- `,e.dependencies)for(let[r,l]of Object.entries(e.dependencies)){let d=l;d.local?a+=`${r} = { local = "${d.local}" }
22
- `:d.git&&d.rev&&(d.subdir?a+=`${r} = { git = "${d.git}", subdir = "${d.subdir}", rev = "${d.rev}" }
23
- `:a+=`${r} = { git = "${d.git}", rev = "${d.rev}" }
24
- `)}a+=`
22
+ `,e.dependencies)for(let[a,l]of Object.entries(e.dependencies)){let r=l;r.local?s+=`${a} = { local = "${r.local}" }
23
+ `:r.git&&r.rev&&(r.subdir?s+=`${a} = { git = "${r.git}", subdir = "${r.subdir}", rev = "${r.rev}" }
24
+ `:s+=`${a} = { git = "${r.git}", rev = "${r.rev}" }
25
+ `)}s+=`
25
26
  [addresses]
26
- `;for(let[r,l]of Object.entries(t))a+=`${r} = "${l}"
27
- `;return a}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}isSuiRepo(e){return e.includes("github.com/MystenLabs/sui")}inferSuiFrameworkSubdir(e){let t={Sui:"crates/sui-framework/packages/sui-framework",MoveStdlib:"crates/sui-framework/packages/move-stdlib",SuiSystem:"crates/sui-framework/packages/sui-system",Bridge:"crates/sui-framework/packages/bridge",DeepBook:"crates/sui-framework/packages/deepbook",SuiFramework:"crates/sui-framework/packages/sui-framework"};return t[e]||t[e.toLowerCase()]}};async function x(s,e,t,i="mainnet"){return new P(t,i).resolve(s,e)}function F(s){try{let e=new URL(s);if(e.hostname!=="github.com")return null;let t=e.pathname.split("/").filter(Boolean);if(t.length<2)return null;let i=t[0],n=t[1],o="main",a;return t.length>=4&&t[2]==="tree"&&(o=t[3],t.length>4&&(a=t.slice(4).join("/"))),{owner:i,repo:n,ref:o,subdir:a}}catch{return null}}async function L(s,e){let t=F(s);if(!t)throw new Error(`Invalid GitHub URL: ${s}`);let i=e?.fetcher||new k,n=e?.includeLock!==!1,o=`https://github.com/${t.owner}/${t.repo}.git`,a=await i.fetch(o,t.ref,t.subdir);if(!n&&a["Move.lock"]){let{"Move.lock":c,...r}=a;return r}return a}async function I(s,e){let t=Array.isArray(s)?Object.fromEntries(s.map((n,o)=>[`package_${o}`,n])):s,i={};for(let[n,o]of Object.entries(t))i[n]=await L(o,e);return i}function U(s,e="main",t){let i=`https://github.com/${s}`;return(e||t)&&(i+=`/tree/${e}`),t&&(i+=`/${t}`),i}var G;async function b(s){return G||(G=import("./sui_move_wasm.js").then(async e=>(s?await e.default({module_or_path:s}):await e.default(),e))),G}function $(s){return JSON.stringify(s??{})}function N(s){return{success:!1,error:s instanceof Error?s.message:typeof s=="string"?s:"Unknown error"}}function W(s){if(typeof s!="object"||s===null)throw new Error("Unexpected compile result shape from wasm");let e=s;if(typeof e.success=="function"&&typeof e.output=="function")return e;if(typeof e.success=="boolean"&&typeof e.output=="string")return{success:()=>e.success,output:()=>e.output};throw new Error("Unexpected compile result shape from wasm")}function ee(s){let e=t=>t.map(i=>i.toString(16).padStart(2,"0")).join("");try{let t=JSON.parse(s);if(!t.modules||!t.dependencies||!t.digest)throw new Error("missing fields in compiler output");let i=typeof t.digest=="string"?t.digest:e(t.digest);return{success:!0,modules:t.modules,dependencies:t.dependencies,digest:i}}catch(t){return N(t)}}function E(s){if(!s)return s;let e=s;return e.startsWith("0x")&&(e=e.slice(2)),/^[0-9a-fA-F]+$/.test(e)?"0x"+e.padStart(64,"0"):s}function te(s){let e={std:"0x1",sui:"0x2",sui_system:"0x3",bridge:"0xb"},t=s.split(/\r?\n/),i=/^\s*\[[^\]]+\]\s*$/,n=-1,o=t.length;for(let r=0;r<t.length;r++)if(/^\s*\[addresses\]\s*$/.test(t[r])){n=r;for(let l=r+1;l<t.length;l++)if(i.test(t[l])){o=l;break}break}let a=new Set;if(n>=0)for(let r=n+1;r<o;r++){let l=t[r].trim();if(!l||l.startsWith("#"))continue;let d=l.match(/^([A-Za-z0-9_.-]+)\s*=/);d&&a.add(d[1])}let c=Object.entries(e).filter(([r])=>!a.has(r)).map(([r,l])=>`${r} = "${E(l)}"`);return c.length===0?s:(n>=0?t.splice(o,0,...c):t.push("","[addresses]",...c),t.join(`
28
- `))}function ne(s){let e=[{name:"Sui",git:"https://github.com/MystenLabs/sui.git",subdir:"crates/sui-framework/packages/sui-framework",rev:"framework/mainnet"},{name:"MoveStdlib",git:"https://github.com/MystenLabs/sui.git",subdir:"crates/sui-framework/packages/move-stdlib",rev:"framework/mainnet"}],t=s.split(/\r?\n/),i=/^\s*\[[^\]]+\]\s*$/,n=-1,o=t.length;for(let r=0;r<t.length;r++)if(/^\s*\[dependencies\]\s*$/.test(t[r])){n=r;for(let l=r+1;l<t.length;l++)if(i.test(t[l])){o=l;break}break}let a=new Set;if(n>=0)for(let r=n+1;r<o;r++){let l=t[r].trim();if(!l||l.startsWith("#"))continue;let d=l.match(/^([A-Za-z0-9_.-]+)\s*=/);d&&a.add(d[1])}let c=e.filter(r=>!a.has(r.name)).map(r=>`${r.name} = { git = "${r.git}", subdir = "${r.subdir}", rev = "${r.rev}" }`);return c.length===0?s:(n>=0?t.splice(o,0,...c):t.push("","[dependencies]",...c),t.join(`
29
- `))}function ie(s){let e={...s??{}};if(e["dependencies/MoveStdlib/Move.toml"])return e;let t=[{name:"MoveStdlib",id:"0x1"},{name:"Sui",id:"0x2"},{name:"SuiSystem",id:"0x3"},{name:"Bridge",id:"0xb"}];for(let i of t){let n=`dependencies/${i.name}/Move.toml`;e[n]||(e[n]=["[package]",`name = "${i.name}"`,'version = "0.0.0"',`published-at = "${E(i.id)}"`,""].join(`
30
- `))}return e}function O(s){return!!(s?.["dependencies/MoveStdlib/Move.toml"]&&s?.["dependencies/Sui/Move.toml"])}function B(s){return typeof s=="string"?JSON.parse(s):s}async function se(s){await b(s?.wasm)}async function re(s){try{let e=s.dependencies??{},t={...s.files},i=typeof t["Move.toml"]=="string";if(s.autoSystemDeps&&i){let l=te(t["Move.toml"]);O(e)||(l=ne(l)),t["Move.toml"]=l}if(s.autoSystemDeps&&!O(e)&&i){let l=await x(t["Move.toml"],t,new k,s.network);t=B(l.files),e=B(l.dependencies)}else s.autoSystemDeps&&(e=ie(e));let n=await b(s.wasm),o=s.ansiColor&&typeof n.compile_with_color=="function"?n.compile_with_color($(t),$(e),!0):n.compile($(t),$(e)),a=W(o),c=a.success(),r=a.output();return c?ee(r):N(r)}catch(e){return N(e)}}async function oe(s){return(await b(s?.wasm)).sui_move_version()}async function ae(s){return(await b(s?.wasm)).sui_version()}async function ce(s){return b(s?.wasm)}async function de(s,e,t){let i=await b(t?.wasm),n=t?.ansiColor&&typeof i.compile_with_color=="function"?i.compile_with_color(s,e,!0):i.compile(s,e),o=W(n);return{success:o.success(),output:o.output()}}0&&(module.exports={Fetcher,GitHubFetcher,Resolver,buildMovePackage,compileRaw,fetchPackageFromGitHub,fetchPackagesFromGitHub,getSuiMoveVersion,getSuiVersion,getWasmBindings,githubUrl,initMoveCompiler,parseGitHubUrl,parseToml,resolve});
27
+ `;for(let[a,l]of Object.entries(t))s+=`${a} = "${l}"
28
+ `;return s}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}isSuiRepo(e){return e.includes("github.com/MystenLabs/sui")}inferSuiFrameworkSubdir(e){let t={Sui:"crates/sui-framework/packages/sui-framework",MoveStdlib:"crates/sui-framework/packages/move-stdlib",SuiSystem:"crates/sui-framework/packages/sui-system",Bridge:"crates/sui-framework/packages/bridge",DeepBook:"crates/sui-framework/packages/deepbook",SuiFramework:"crates/sui-framework/packages/sui-framework"};return t[e]||t[e.toLowerCase()]}};async function C(d,e,t,i="mainnet",n){return new F(t,i,n||null).resolve(d,e)}function Q(d){try{let e=new URL(d);if(e.hostname!=="github.com")return null;let t=e.pathname.split("/").filter(Boolean);if(t.length<2)return null;let i=t[0],n=t[1],o="main",s;return t.length>=4&&t[2]==="tree"&&(o=t[3],t.length>4&&(s=t.slice(4).join("/"))),{owner:i,repo:n,ref:o,subdir:s}}catch{return null}}async function B(d,e){let t=Q(d);if(!t)throw new Error(`Invalid GitHub URL: ${d}`);let i=e?.fetcher||new P(e?.githubToken),n=e?.includeLock!==!1,o=`https://github.com/${t.owner}/${t.repo}.git`,s=await i.fetch(o,t.ref,t.subdir,`root:${t.owner}/${t.repo}`);if(Object.defineProperty(s,"__rootGit",{value:{git:o,rev:t.ref,subdir:t.subdir},enumerable:!1}),!n&&s["Move.lock"]){let{"Move.lock":c,...a}=s;return a}return s}var O;async function R(d){return O||(O=import("./sui_move_wasm.js").then(async e=>(d?await e.default({module_or_path:d}):await e.default(),e))),O}function T(d){return{error:d instanceof Error?d.message:typeof d=="string"?d:"Unknown error"}}function _(d){if(typeof d!="object"||d===null)throw new Error("Unexpected compile result shape from wasm");let e=d;if(typeof e.success=="function"&&typeof e.output=="function")return e;if(typeof e.success=="boolean"&&typeof e.output=="string")return{success:()=>e.success,output:()=>e.output};throw new Error("Unexpected compile result shape from wasm")}function X(d){let e=t=>{let i=t.startsWith("0x")?t.slice(2):t,n=i.length%2===0?i:`0${i}`,o=[];for(let s=0;s<n.length;s+=2){let c=parseInt(n.slice(s,s+2),16);if(Number.isNaN(c))throw new Error("invalid hex digest");o.push(c)}return o};try{let t=JSON.parse(d);if(!t.modules||!t.dependencies||!t.digest)throw new Error("missing fields in compiler output");let i=typeof t.digest=="string"?e(t.digest):Array.from(t.digest);return{modules:t.modules,dependencies:t.dependencies,digest:i}}catch(t){return T(t)}}function Y(d){try{let e=JSON.parse(d);for(let t of e){let i=t.addressMapping?.[t.name]??(()=>{let n=Object.entries(t.files).find(([s])=>s.endsWith("Move.toml"));if(!n)return;let o=b(n[1]);return o.addresses&&o.addresses[t.name]||o.package?.published_at||o.package?.["published-at"]})()}}catch{}}async function Z(d){await R(d?.wasm)}async function j(d){let e=d.files["Move.toml"]||"",t=d.rootGit||d.files.__rootGit,i=await C(e,{...d.files,"Move.toml":e},new P(d.githubToken),d.network,t?{type:"git",git:t.git,rev:t.rev,subdir:t.subdir}:void 0);return{files:i.files,dependencies:i.dependencies}}async function ee(d){try{let e=d.resolvedDependencies?d.resolvedDependencies:await j(d),t=await R(d.wasm);Y(e.dependencies);let i=d.ansiColor&&typeof t.compile_with_color=="function"?t.compile_with_color(e.files,e.dependencies,!0):t.compile(e.files,e.dependencies),n=_(i),o=n.success(),s=n.output();return o?X(s):T(s)}catch(e){return T(e)}}async function te(d){return(await R(d?.wasm)).sui_move_version()}async function ne(d){return(await R(d?.wasm)).sui_version()}async function ie(d){return R(d?.wasm)}async function se(d,e,t){let i=await R(t?.wasm),n=t?.ansiColor&&typeof i.compile_with_color=="function"?i.compile_with_color(d,e,!0):i.compile(d,e),o=_(n);return{success:o.success(),output:o.output()}}0&&(module.exports={buildMovePackage,compileRaw,fetchPackageFromGitHub,getSuiMoveVersion,getSuiVersion,getWasmBindings,initMoveCompiler,resolveDependencies});
package/dist/index.d.cts CHANGED
@@ -10,119 +10,25 @@ declare class Fetcher {
10
10
  /** Fetcher that retrieves files from public GitHub repositories via fetch(). */
11
11
  declare class GitHubFetcher extends Fetcher {
12
12
  private cache;
13
- constructor();
14
- fetch(gitUrl: string, rev: string, subdir?: string): Promise<Record<string, string>>;
13
+ private treeCache;
14
+ private rateLimitRemaining;
15
+ private rateLimitReset;
16
+ private token;
17
+ constructor(token?: string);
18
+ /**
19
+ * Update rate limit info from response headers
20
+ */
21
+ private updateRateLimit;
22
+ fetch(gitUrl: string, rev: string, subdir?: string, context?: string): Promise<Record<string, string>>;
15
23
  fetchFile(gitUrl: string, rev: string, path: string): Promise<string | null>;
16
24
  private fetchContent;
17
25
  private parseGitUrl;
18
26
  }
19
27
 
20
- /**
21
- * New Resolver using 3-layer architecture matching Sui CLI
22
- *
23
- * Layer 1: DependencyGraph - Build DAG of packages
24
- * Layer 2: ResolvedGraph - Unified address resolution
25
- * Layer 3: CompilationDependencies - Compiler-ready format
26
- */
27
-
28
- declare class Resolver {
29
- private fetcher;
30
- private network;
31
- private visited;
32
- private packageNameCache;
33
- private packageFiles;
34
- constructor(fetcher: Fetcher, network?: "mainnet" | "testnet" | "devnet");
35
- /**
36
- * Main resolve function using 3-layer architecture
37
- */
38
- resolve(rootMoveToml: string, rootFiles: Record<string, string>): Promise<{
39
- files: string;
40
- dependencies: string;
41
- }>;
42
- /**
43
- * Build a Package object from Move.toml and files
44
- */
45
- private buildPackage;
46
- /**
47
- * Parse dependency info from Move.toml
48
- */
49
- private parseDependencyInfo;
50
- /**
51
- * Recursively build the dependency graph
52
- */
53
- private buildDependencyGraph;
54
- /**
55
- * Find a package in the graph by its source
56
- */
57
- private findPackageBySource;
58
- /**
59
- * Resolve relative path for local dependencies
60
- * Example: parentSubdir="packages/deepbook", localPath="../token" -> "packages/token"
61
- */
62
- private resolveRelativePath;
63
- /**
64
- * Compute manifest digest for lockfile validation (Sui CLI compatible)
65
- */
66
- private computeManifestDigest;
67
- /**
68
- * Load dependency graph from lockfile (Sui CLI: load_from_lockfile)
69
- * Returns null if lockfile is missing or invalid
70
- */
71
- private loadFromLockfile;
72
- /**
73
- * Convert lockfile dependency source to our DependencySource format
74
- */
75
- private lockfileSourceToDependencySource;
76
- /**
77
- * Fetch files from a dependency source
78
- */
79
- private fetchFromSource;
80
- /**
81
- * Reconstruct Move.toml with unified addresses
82
- */
83
- private reconstructMoveToml;
84
- /**
85
- * Normalize address to 0x-prefixed 64-char hex
86
- */
87
- private normalizeAddress;
88
- /**
89
- * Check if git URL is Sui repository
90
- */
91
- private isSuiRepo;
92
- /**
93
- * Infer subdir for Sui framework packages
94
- */
95
- private inferSuiFrameworkSubdir;
96
- }
97
- /**
98
- * Main resolve function (backward compatible)
99
- */
100
- declare function resolve(rootMoveTomlContent: string, rootSourceFiles: Record<string, string>, fetcher: Fetcher, network?: "mainnet" | "testnet" | "devnet"): Promise<{
101
- files: string;
102
- dependencies: string;
103
- }>;
104
-
105
- declare function parseToml(content: string): any;
106
-
107
28
  /**
108
29
  * Utility functions for fetching Move packages from GitHub
109
30
  */
110
31
 
111
- /**
112
- * Parse GitHub URL to extract owner, repo, branch/tag, and subdir
113
- *
114
- * Supported formats:
115
- * - https://github.com/owner/repo
116
- * - https://github.com/owner/repo/tree/branch
117
- * - https://github.com/owner/repo/tree/branch/path/to/package
118
- * - https://github.com/owner/repo/tree/tag/path/to/package
119
- */
120
- declare function parseGitHubUrl(url: string): {
121
- owner: string;
122
- repo: string;
123
- ref: string;
124
- subdir?: string;
125
- } | null;
126
32
  /**
127
33
  * Fetch a Move package from GitHub URL
128
34
  *
@@ -147,69 +53,47 @@ declare function parseGitHubUrl(url: string): {
147
53
  declare function fetchPackageFromGitHub(url: string, options?: {
148
54
  /** Custom fetcher instance (default: GitHubFetcher) */
149
55
  fetcher?: GitHubFetcher;
56
+ /** Optional GitHub token to raise API limits (used when fetcher not provided). */
57
+ githubToken?: string;
150
58
  /** Include Move.lock file (default: true) */
151
59
  includeLock?: boolean;
152
60
  }): Promise<Record<string, string>>;
153
- /**
154
- * Fetch multiple packages from GitHub URLs
155
- *
156
- * @param urls - Array of GitHub URLs or URL-to-alias mappings
157
- * @returns Object mapping package names to their files
158
- *
159
- * @example
160
- * ```ts
161
- * const packages = await fetchPackagesFromGitHub([
162
- * 'https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework',
163
- * 'https://github.com/MystenLabs/deepbookv3/tree/main/packages/deepbook'
164
- * ]);
165
- *
166
- * // packages = {
167
- * // 'Sui': { 'Move.toml': '...', ... },
168
- * // 'deepbook': { 'Move.toml': '...', ... }
169
- * // }
170
- * ```
171
- */
172
- declare function fetchPackagesFromGitHub(urls: string[] | Record<string, string>, options?: {
173
- fetcher?: GitHubFetcher;
174
- includeLock?: boolean;
175
- }): Promise<Record<string, Record<string, string>>>;
176
- /**
177
- * Create a shorthand GitHub URL for common repositories
178
- *
179
- * @example
180
- * ```ts
181
- * githubUrl('MystenLabs/sui', 'framework/mainnet', 'crates/sui-framework/packages/sui-framework')
182
- * // Returns: https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework
183
- * ```
184
- */
185
- declare function githubUrl(repo: string, // 'owner/repo'
186
- ref?: string, subdir?: string): string;
187
61
 
62
+ interface ResolvedDependencies {
63
+ /** JSON string of resolved files for the root package */
64
+ files: string;
65
+ /** JSON string of resolved dependencies */
66
+ dependencies: string;
67
+ }
188
68
  interface BuildInput {
189
69
  /** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
190
70
  files: Record<string, string>;
191
- /** Optional dependency files keyed by path. */
192
- dependencies?: Record<string, string>;
193
71
  /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */
194
72
  wasm?: string | URL;
73
+ /** Optional hint for the root package git source (enables resolving local deps from Move.lock). */
74
+ rootGit?: {
75
+ git: string;
76
+ rev: string;
77
+ subdir?: string;
78
+ };
79
+ /** Optional GitHub token to raise API limits when resolving dependencies. */
80
+ githubToken?: string;
195
81
  /** Emit ANSI color codes in diagnostics when available. */
196
82
  ansiColor?: boolean;
197
- /** Inject standard Sui system packages when missing (CLI-like behavior). */
198
- autoSystemDeps?: boolean;
199
83
  /** Network environment (mainnet, testnet, devnet). Defaults to mainnet. */
200
84
  network?: "mainnet" | "testnet" | "devnet";
85
+ /** Optional pre-resolved dependencies. If provided, dependency resolution will be skipped. */
86
+ resolvedDependencies?: ResolvedDependencies;
201
87
  }
202
88
  interface BuildSuccess {
203
- success: true;
204
89
  /** Base64-encoded bytecode modules. */
205
90
  modules: string[];
206
91
  /** Hex-encoded dependency IDs. */
207
92
  dependencies: string[];
208
- /** Hex-encoded Blake2b-256 package digest. */
209
- digest: string;
93
+ /** Blake2b-256 package digest as byte array (matches Sui CLI JSON). */
94
+ digest: number[];
210
95
  }
211
96
  interface BuildFailure {
212
- success: false;
213
97
  error: string;
214
98
  }
215
99
  type WasmModule = typeof __sui_move_wasm_js;
@@ -217,6 +101,11 @@ type WasmModule = typeof __sui_move_wasm_js;
217
101
  declare function initMoveCompiler(options?: {
218
102
  wasm?: string | URL;
219
103
  }): Promise<void>;
104
+ /**
105
+ * Resolve dependencies for a Move package without compiling.
106
+ * This function can be used to resolve dependencies once and reuse them across multiple builds.
107
+ */
108
+ declare function resolveDependencies(input: Omit<BuildInput, "resolvedDependencies">): Promise<ResolvedDependencies>;
220
109
  /** Compile a Move package in memory using the bundled Move compiler wasm. */
221
110
  declare function buildMovePackage(input: BuildInput): Promise<BuildSuccess | BuildFailure>;
222
111
  /** Sui Move version baked into the wasm (e.g. from Cargo.lock). */
@@ -241,4 +130,4 @@ declare function compileRaw(filesJson: string, depsJson: string, options?: {
241
130
  }>;
242
131
  type BuildResult = BuildSuccess | BuildFailure;
243
132
 
244
- export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, Fetcher, GitHubFetcher, Resolver, buildMovePackage, compileRaw, fetchPackageFromGitHub, fetchPackagesFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, githubUrl, initMoveCompiler, parseGitHubUrl, parseToml, resolve };
133
+ export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, type ResolvedDependencies, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies };
package/dist/index.d.ts CHANGED
@@ -10,119 +10,25 @@ declare class Fetcher {
10
10
  /** Fetcher that retrieves files from public GitHub repositories via fetch(). */
11
11
  declare class GitHubFetcher extends Fetcher {
12
12
  private cache;
13
- constructor();
14
- fetch(gitUrl: string, rev: string, subdir?: string): Promise<Record<string, string>>;
13
+ private treeCache;
14
+ private rateLimitRemaining;
15
+ private rateLimitReset;
16
+ private token;
17
+ constructor(token?: string);
18
+ /**
19
+ * Update rate limit info from response headers
20
+ */
21
+ private updateRateLimit;
22
+ fetch(gitUrl: string, rev: string, subdir?: string, context?: string): Promise<Record<string, string>>;
15
23
  fetchFile(gitUrl: string, rev: string, path: string): Promise<string | null>;
16
24
  private fetchContent;
17
25
  private parseGitUrl;
18
26
  }
19
27
 
20
- /**
21
- * New Resolver using 3-layer architecture matching Sui CLI
22
- *
23
- * Layer 1: DependencyGraph - Build DAG of packages
24
- * Layer 2: ResolvedGraph - Unified address resolution
25
- * Layer 3: CompilationDependencies - Compiler-ready format
26
- */
27
-
28
- declare class Resolver {
29
- private fetcher;
30
- private network;
31
- private visited;
32
- private packageNameCache;
33
- private packageFiles;
34
- constructor(fetcher: Fetcher, network?: "mainnet" | "testnet" | "devnet");
35
- /**
36
- * Main resolve function using 3-layer architecture
37
- */
38
- resolve(rootMoveToml: string, rootFiles: Record<string, string>): Promise<{
39
- files: string;
40
- dependencies: string;
41
- }>;
42
- /**
43
- * Build a Package object from Move.toml and files
44
- */
45
- private buildPackage;
46
- /**
47
- * Parse dependency info from Move.toml
48
- */
49
- private parseDependencyInfo;
50
- /**
51
- * Recursively build the dependency graph
52
- */
53
- private buildDependencyGraph;
54
- /**
55
- * Find a package in the graph by its source
56
- */
57
- private findPackageBySource;
58
- /**
59
- * Resolve relative path for local dependencies
60
- * Example: parentSubdir="packages/deepbook", localPath="../token" -> "packages/token"
61
- */
62
- private resolveRelativePath;
63
- /**
64
- * Compute manifest digest for lockfile validation (Sui CLI compatible)
65
- */
66
- private computeManifestDigest;
67
- /**
68
- * Load dependency graph from lockfile (Sui CLI: load_from_lockfile)
69
- * Returns null if lockfile is missing or invalid
70
- */
71
- private loadFromLockfile;
72
- /**
73
- * Convert lockfile dependency source to our DependencySource format
74
- */
75
- private lockfileSourceToDependencySource;
76
- /**
77
- * Fetch files from a dependency source
78
- */
79
- private fetchFromSource;
80
- /**
81
- * Reconstruct Move.toml with unified addresses
82
- */
83
- private reconstructMoveToml;
84
- /**
85
- * Normalize address to 0x-prefixed 64-char hex
86
- */
87
- private normalizeAddress;
88
- /**
89
- * Check if git URL is Sui repository
90
- */
91
- private isSuiRepo;
92
- /**
93
- * Infer subdir for Sui framework packages
94
- */
95
- private inferSuiFrameworkSubdir;
96
- }
97
- /**
98
- * Main resolve function (backward compatible)
99
- */
100
- declare function resolve(rootMoveTomlContent: string, rootSourceFiles: Record<string, string>, fetcher: Fetcher, network?: "mainnet" | "testnet" | "devnet"): Promise<{
101
- files: string;
102
- dependencies: string;
103
- }>;
104
-
105
- declare function parseToml(content: string): any;
106
-
107
28
  /**
108
29
  * Utility functions for fetching Move packages from GitHub
109
30
  */
110
31
 
111
- /**
112
- * Parse GitHub URL to extract owner, repo, branch/tag, and subdir
113
- *
114
- * Supported formats:
115
- * - https://github.com/owner/repo
116
- * - https://github.com/owner/repo/tree/branch
117
- * - https://github.com/owner/repo/tree/branch/path/to/package
118
- * - https://github.com/owner/repo/tree/tag/path/to/package
119
- */
120
- declare function parseGitHubUrl(url: string): {
121
- owner: string;
122
- repo: string;
123
- ref: string;
124
- subdir?: string;
125
- } | null;
126
32
  /**
127
33
  * Fetch a Move package from GitHub URL
128
34
  *
@@ -147,69 +53,47 @@ declare function parseGitHubUrl(url: string): {
147
53
  declare function fetchPackageFromGitHub(url: string, options?: {
148
54
  /** Custom fetcher instance (default: GitHubFetcher) */
149
55
  fetcher?: GitHubFetcher;
56
+ /** Optional GitHub token to raise API limits (used when fetcher not provided). */
57
+ githubToken?: string;
150
58
  /** Include Move.lock file (default: true) */
151
59
  includeLock?: boolean;
152
60
  }): Promise<Record<string, string>>;
153
- /**
154
- * Fetch multiple packages from GitHub URLs
155
- *
156
- * @param urls - Array of GitHub URLs or URL-to-alias mappings
157
- * @returns Object mapping package names to their files
158
- *
159
- * @example
160
- * ```ts
161
- * const packages = await fetchPackagesFromGitHub([
162
- * 'https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework',
163
- * 'https://github.com/MystenLabs/deepbookv3/tree/main/packages/deepbook'
164
- * ]);
165
- *
166
- * // packages = {
167
- * // 'Sui': { 'Move.toml': '...', ... },
168
- * // 'deepbook': { 'Move.toml': '...', ... }
169
- * // }
170
- * ```
171
- */
172
- declare function fetchPackagesFromGitHub(urls: string[] | Record<string, string>, options?: {
173
- fetcher?: GitHubFetcher;
174
- includeLock?: boolean;
175
- }): Promise<Record<string, Record<string, string>>>;
176
- /**
177
- * Create a shorthand GitHub URL for common repositories
178
- *
179
- * @example
180
- * ```ts
181
- * githubUrl('MystenLabs/sui', 'framework/mainnet', 'crates/sui-framework/packages/sui-framework')
182
- * // Returns: https://github.com/MystenLabs/sui/tree/framework/mainnet/crates/sui-framework/packages/sui-framework
183
- * ```
184
- */
185
- declare function githubUrl(repo: string, // 'owner/repo'
186
- ref?: string, subdir?: string): string;
187
61
 
62
+ interface ResolvedDependencies {
63
+ /** JSON string of resolved files for the root package */
64
+ files: string;
65
+ /** JSON string of resolved dependencies */
66
+ dependencies: string;
67
+ }
188
68
  interface BuildInput {
189
69
  /** Virtual file system contents. Keys are paths (e.g. "Move.toml", "sources/Module.move"). */
190
70
  files: Record<string, string>;
191
- /** Optional dependency files keyed by path. */
192
- dependencies?: Record<string, string>;
193
71
  /** Optional custom URL for the wasm binary. Defaults to bundled wasm next to this module. */
194
72
  wasm?: string | URL;
73
+ /** Optional hint for the root package git source (enables resolving local deps from Move.lock). */
74
+ rootGit?: {
75
+ git: string;
76
+ rev: string;
77
+ subdir?: string;
78
+ };
79
+ /** Optional GitHub token to raise API limits when resolving dependencies. */
80
+ githubToken?: string;
195
81
  /** Emit ANSI color codes in diagnostics when available. */
196
82
  ansiColor?: boolean;
197
- /** Inject standard Sui system packages when missing (CLI-like behavior). */
198
- autoSystemDeps?: boolean;
199
83
  /** Network environment (mainnet, testnet, devnet). Defaults to mainnet. */
200
84
  network?: "mainnet" | "testnet" | "devnet";
85
+ /** Optional pre-resolved dependencies. If provided, dependency resolution will be skipped. */
86
+ resolvedDependencies?: ResolvedDependencies;
201
87
  }
202
88
  interface BuildSuccess {
203
- success: true;
204
89
  /** Base64-encoded bytecode modules. */
205
90
  modules: string[];
206
91
  /** Hex-encoded dependency IDs. */
207
92
  dependencies: string[];
208
- /** Hex-encoded Blake2b-256 package digest. */
209
- digest: string;
93
+ /** Blake2b-256 package digest as byte array (matches Sui CLI JSON). */
94
+ digest: number[];
210
95
  }
211
96
  interface BuildFailure {
212
- success: false;
213
97
  error: string;
214
98
  }
215
99
  type WasmModule = typeof __sui_move_wasm_js;
@@ -217,6 +101,11 @@ type WasmModule = typeof __sui_move_wasm_js;
217
101
  declare function initMoveCompiler(options?: {
218
102
  wasm?: string | URL;
219
103
  }): Promise<void>;
104
+ /**
105
+ * Resolve dependencies for a Move package without compiling.
106
+ * This function can be used to resolve dependencies once and reuse them across multiple builds.
107
+ */
108
+ declare function resolveDependencies(input: Omit<BuildInput, "resolvedDependencies">): Promise<ResolvedDependencies>;
220
109
  /** Compile a Move package in memory using the bundled Move compiler wasm. */
221
110
  declare function buildMovePackage(input: BuildInput): Promise<BuildSuccess | BuildFailure>;
222
111
  /** Sui Move version baked into the wasm (e.g. from Cargo.lock). */
@@ -241,4 +130,4 @@ declare function compileRaw(filesJson: string, depsJson: string, options?: {
241
130
  }>;
242
131
  type BuildResult = BuildSuccess | BuildFailure;
243
132
 
244
- export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, Fetcher, GitHubFetcher, Resolver, buildMovePackage, compileRaw, fetchPackageFromGitHub, fetchPackagesFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, githubUrl, initMoveCompiler, parseGitHubUrl, parseToml, resolve };
133
+ export { type BuildFailure, type BuildInput, type BuildResult, type BuildSuccess, type ResolvedDependencies, buildMovePackage, compileRaw, fetchPackageFromGitHub, getSuiMoveVersion, getSuiVersion, getWasmBindings, initMoveCompiler, resolveDependencies };
package/dist/index.js CHANGED
@@ -1,30 +1,28 @@
1
- var w=class{async fetch(e,t,i){throw new Error("Not implemented")}async fetchFile(e,t,i){throw new Error("Not implemented")}},v=class extends w{constructor(){super(),this.cache=new Map}async fetch(e,t,i){let{owner:n,repo:r}=this.parseGitUrl(e);if(!n||!r)throw new Error(`Invalid git URL: ${e}`);let a=`https://api.github.com/repos/${n}/${r}/git/trees/${t}?recursive=1`,c;try{let d=await fetch(a);if(!d.ok)throw d.status===403||d.status===429?new Error("GitHub API rate limit exceeded."):new Error(`Failed to fetch tree: ${d.statusText}`);c=await d.json()}catch{return{}}let s={},l=[];for(let d of c.tree){if(d.type!=="blob")continue;let f=d.path;if(i){if(!d.path.startsWith(i))continue;f=d.path.slice(i.length),f.startsWith("/")&&(f=f.slice(1))}if(!f.endsWith(".move")&&f!=="Move.toml"&&f!=="Move.lock"&&!f.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;let m=`https://raw.githubusercontent.com/${n}/${r}/${t}/${d.path}`,g=this.fetchContent(m).then(u=>{u&&(s[f]=u)});l.push(g)}return await Promise.all(l),s}async fetchFile(e,t,i){let{owner:n,repo:r}=this.parseGitUrl(e);if(!n||!r)throw new Error(`Invalid git URL: ${e}`);let a=`https://raw.githubusercontent.com/${n}/${r}/${t}/${i}`;return this.fetchContent(a)}async fetchContent(e){if(this.cache.has(e))return this.cache.get(e)??null;try{let t=await fetch(e);if(!t.ok)return null;let i=await t.text();return this.cache.set(e,i),i}catch{return null}}parseGitUrl(e){try{let i=new URL(e).pathname.split("/").filter(n=>n);if(i.length>=2){let n=i[1];return n.endsWith(".git")&&(n=n.slice(0,-4)),{owner:i[0],repo:n}}}catch{}return{owner:null,repo:null}}};function O(o){let e=!1,t="";for(let i=0;i<o.length;i++){let n=o[i];if((n==='"'||n==="'")&&(!e||n===t)&&(e=!e,t=n),!e&&n==="#")return o.slice(0,i)}return o}function $(o){let e=o.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function G(o){let e={},t=o.trim().replace(/^\{/,"").replace(/\}$/,""),i="",n=!1,r="",a=[];for(let c=0;c<t.length;c++){let s=t[c];if((s==='"'||s==="'")&&(!n||s===r)&&(n=!n,r=s),!n&&s===","){a.push(i),i="";continue}i+=s}i.trim()&&a.push(i);for(let c of a){let s=c.indexOf("=");if(s===-1)continue;let l=c.slice(0,s).trim(),d=c.slice(s+1).trim();e[l]=$(d)}return e}function B(o){let e=[],t=o.trim().replace(/^\[/,"").replace(/\]$/,""),i="",n=!1,r="",a=0;for(let c=0;c<t.length;c++){let s=t[c];if((s==='"'||s==="'")&&(!n||s===r)&&(n=!n,r=n?s:""),!n&&(s==="{"&&a++,s==="}"&&a--,s===","&&a===0)){i.trim()&&e.push(L(i.trim())),i="";continue}i+=s}return i.trim()&&e.push(L(i.trim())),e}function L(o){return o.startsWith("{")?G(o):$(o)}function y(o){let e={},t=null,i=!1,n=o.split(/\r?\n/);function r(a,c){let s=a;for(let l of c){if(!(l in s))return;s=s[l]}return s}for(let a of n){let c=O(a).trim();if(!c)continue;let s=c.match(/^\[\[([^\]]+)\]\]$/);if(s){t=s[1].trim(),i=!0;let u=t.split("."),p=e;for(let k=0;k<u.length-1;k++){let x=u[k];x in p||(p[x]={}),p=p[x]}let h=u[u.length-1];Array.isArray(p[h])||(p[h]=[]),p[h].push({});continue}let l=c.match(/^\[([^\]]+)\]$/);if(l){t=l[1].trim(),i=!1;continue}let d=c.indexOf("=");if(d===-1||!t)continue;let f=c.slice(0,d).trim(),m=c.slice(d+1).trim(),g;if(m.startsWith("{")?g=G(m):m.startsWith("[")?g=B(m):g=$(m),i){let u=t.split("."),p=r(e,u);if(Array.isArray(p)&&p.length>0){let h=p[p.length-1];h[f]=g}}else{let u=t.split("."),p=e;for(let k of u)k in p||(p[k]={}),p=p[k];let h=t==="package"?f.replace(/-/g,"_"):f;p[h]=g}}return e}var P=class{constructor(e){this.packageTable=new Map;this.graph=new Map;this.alwaysDeps=new Set(["Sui","MoveStdlib"]);this.root=e}addPackage(e){this.packageTable.set(e.id.name,e),this.graph.has(e.id.name)||this.graph.set(e.id.name,new Set)}addDependency(e,t,i){this.graph.has(e)||this.graph.set(e,new Set),this.graph.get(e).add(t)}getPackage(e){return this.packageTable.get(e)}getAllPackages(){return Array.from(this.packageTable.values())}getImmediateDependencies(e){return this.graph.get(e)||new Set}getTransitiveDependencies(e){let t=new Set,i=new Set,n=r=>{if(i.has(r))return;i.add(r),t.add(r);let a=this.graph.get(r);if(a)for(let c of a)n(c)};return n(e),t.delete(e),t}topologicalOrder(){let e=new Set,t=[],i=n=>{if(e.has(n))return;e.add(n);let r=this.graph.get(n);if(r)for(let a of r)i(a);t.push(n)};i(this.root);for(let n of this.packageTable.keys())i(n);return t}detectCycle(){let e=new Set,t=new Set,i=new Map,n=r=>{e.add(r),t.add(r);let a=this.graph.get(r);if(a)for(let c of a)if(e.has(c)){if(t.has(c)){let s=[c],l=r;for(;l!==c;)s.unshift(l),l=i.get(l);return s.unshift(c),s}}else{i.set(c,r);let s=n(c);if(s)return s}return t.delete(r),null};for(let r of this.packageTable.keys())if(!e.has(r)){let a=n(r);if(a)return a}return null}getRootPackage(){return this.packageTable.get(this.root)}getRootName(){return this.root}isAlwaysDep(e){return this.alwaysDeps.has(e)}};var S=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let e=this.graph.topologicalOrder();for(let t of e){let i=this.graph.getPackage(t);if(i)for(let[n,r]of Object.entries(i.manifest.addresses)){let a=this.normalizeAddress(r);this.unifiedAddressTable.has(n)&&this.unifiedAddressTable.get(n)!==a||this.unifiedAddressTable.set(n,a)}}for(let t of this.graph.getAllPackages()){let i={};for(let[n,r]of this.unifiedAddressTable.entries())i[n]=r;this.packageResolvedTables.set(t.id.name,i),t.resolvedTable=i}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,i]of this.unifiedAddressTable.entries())e[t]=i;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}};var M=class{constructor(e){this.dependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let i=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),n=this.resolvedGraph.topologicalOrder();for(let r of n){if(r===this.rootPackageName)continue;let a=this.resolvedGraph.getPackage(r);if(!a)continue;let c=e.get(r)||{},s=this.extractSourcePaths(r,c),l=a.manifest.edition||"legacy",d={name:r,isImmediate:i.has(r),sourcePaths:s,addressMapping:a.resolvedTable||{},compilerConfig:{edition:l,flavor:"sui"},moduleFormat:s.length>0?"Source":"Bytecode",edition:l};this.dependencies.push(d)}}extractSourcePaths(e,t){let i=[];for(let n of Object.keys(t))n.endsWith("Move.toml")||n.endsWith("Move.lock")||n.endsWith(".move")&&i.push(n);return i}toPackageGroupedFormat(e){let t=[];for(let i of this.dependencies){let n=e.get(i.name)||{},r={};for(let[a,c]of Object.entries(n)){if(a.endsWith("Move.lock"))continue;let s=`dependencies/${i.name}/${a}`;if(a.endsWith("Move.toml")){let l=this.reconstructDependencyMoveToml(i.name,c,i.edition,i.addressMapping);r[s]=l}else r[s]=c}t.push({name:i.name,files:r,edition:i.edition})}return t}reconstructDependencyMoveToml(e,t,i,n){let r=t.split(`
2
- `),a=[],c=[],s=!1,l=!1;for(let g of r){let u=g.trim();if(u.startsWith("[package]")){s=!0,l=!1;continue}if(u.startsWith("[dependencies]")){s=!1,l=!0;continue}if(u.startsWith("[")){s=!1,l=!1;continue}s&&u&&a.push(g),l&&u&&c.push(g)}let d=`[package]
3
- `,f=!1,m=!1;for(let g of a)if(g.includes("name ="))d+=g+`
4
- `,f=!0;else if(g.includes("version ="))d+=g+`
5
- `,m=!0;else{if(g.includes("edition ="))continue;d+=g+`
6
- `}f||(d+=`name = "${e}"
7
- `),m||(d+=`version = "0.0.0"
8
- `),d+=`edition = "${i}"
9
- `,d+=`
1
+ var A=class{async fetch(e,t,i){throw new Error("Not implemented")}async fetchFile(e,t,i){throw new Error("Not implemented")}},P=class extends A{constructor(t){super();this.rateLimitRemaining=60;this.rateLimitReset=0;this.cache=new Map,this.treeCache=new Map,this.token=t}updateRateLimit(t){let i=t.headers.get("x-ratelimit-remaining"),n=t.headers.get("x-ratelimit-reset");i&&(this.rateLimitRemaining=parseInt(i,10)),n&&(this.rateLimitReset=parseInt(n,10)*1e3)}async fetch(t,i,n,o){let{owner:s,repo:c}=this.parseGitUrl(t);if(!s||!c)throw new Error(`Invalid git URL: ${t}`);let a=`${s}/${c}@${i}`,d=`https://api.github.com/repos/${s}/${c}/git/trees/${i}?recursive=1`,r;if(this.treeCache.has(a))r=this.treeCache.get(a);else{let p=null;for(let m=1;m<=3;m++)try{if(m>1){let k=Math.pow(2,m-1)*1e3;await new Promise(v=>setTimeout(v,k))}let y={};this.token&&(y.Authorization=`Bearer ${this.token}`);let h=await fetch(d,{headers:y});if(this.updateRateLimit(h),!h.ok){if(h.status===403||h.status===429){let k=new Date(this.rateLimitReset);throw new Error(`GitHub API rate limit exceeded. Resets at ${k.toLocaleTimeString()}`)}if(h.status>=500&&h.status<600&&m<3){p=new Error(`Failed to fetch tree: ${h.statusText}`);continue}throw new Error(`Failed to fetch tree: ${h.statusText}`)}r=await h.json(),this.treeCache.set(a,r);break}catch(y){if(p=y instanceof Error?y:new Error(String(y)),m===3)return{}}if(p)return{}}let l={},f=[];for(let g of r.tree){if(g.type!=="blob")continue;let p=g.path;if(n){if(!g.path.startsWith(n))continue;p=g.path.slice(n.length),p.startsWith("/")&&(p=p.slice(1))}if(!p.endsWith(".move")&&p!=="Move.toml"&&p!=="Move.lock"&&!p.match(/^Move\.(mainnet|testnet|devnet)\.toml$/))continue;let m=`https://raw.githubusercontent.com/${s}/${c}/${i}/${g.path}`,y=this.fetchContent(m).then(h=>{h&&(l[p]=h)});f.push(y)}if(await Promise.all(f),l["Move.toml"]){let g=l["Move.toml"].trim();if(g.match(/^Move\.(mainnet|testnet|devnet)\.toml$/)&&!g.includes("[")&&!g.includes("=")){let p=g,m=n?`${n}/${p}`.replace(/\/+/g,"/"):p,y=`https://raw.githubusercontent.com/${s}/${c}/${i}/${m}`,h=await this.fetchContent(y);h&&(l["Move.toml"]=h,l[p]=h)}}return l}async fetchFile(t,i,n){let{owner:o,repo:s}=this.parseGitUrl(t);if(!o||!s)throw new Error(`Invalid git URL: ${t}`);let c=`https://raw.githubusercontent.com/${o}/${s}/${i}/${n}`;return this.fetchContent(c)}async fetchContent(t){if(this.cache.has(t))return this.cache.get(t)??null;try{let i={},n=typeof window<"u",o=t.startsWith("https://api.github.com/");this.token&&(!n||o)&&(i.Authorization=`Bearer ${this.token}`);let s=await fetch(t,{headers:i});if(!s.ok)return null;let c=await s.text();return this.cache.set(t,c),c}catch{return null}}parseGitUrl(t){try{let n=new URL(t).pathname.split("/").filter(o=>o);if(n.length>=2){let o=n[1];return o.endsWith(".git")&&(o=o.slice(0,-4)),{owner:n[0],repo:o}}}catch{}return{owner:null,repo:null}}};function S(u){let e=!1,t="";for(let i=0;i<u.length;i++){let n=u[i];if((n==='"'||n==="'")&&(!e||n===t)&&(e=!e,t=n),!e&&n==="#")return u.slice(0,i)}return u}function I(u){let e=u.trim();if(!e)return"";if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return e.slice(1,-1);if(e==="true")return!0;if(e==="false")return!1;let t=Number(e);return Number.isNaN(t)?e:t}function L(u){let e={},t=u.trim().replace(/^\{/,"").replace(/\}$/,""),i="",n=!1,o="",s=[];for(let c=0;c<t.length;c++){let a=t[c];if((a==='"'||a==="'")&&(!n||a===o)&&(n=!n,o=a),!n&&a===","){s.push(i),i="";continue}i+=a}i.trim()&&s.push(i);for(let c of s){let a=c.indexOf("=");if(a===-1)continue;let d=c.slice(0,a).trim(),r=c.slice(a+1).trim();e[d]=I(r)}return e}function C(u){let e=[],t=u.trim().replace(/^\[/,"").replace(/\]$/,""),i="",n=!1,o="",s=0;for(let c=0;c<t.length;c++){let a=t[c];if((a==='"'||a==="'")&&(!n||a===o)&&(n=!n,o=n?a:""),!n&&(a==="{"&&s++,a==="}"&&s--,a===","&&s===0)){i.trim()&&e.push(T(i.trim())),i="";continue}i+=a}return i.trim()&&e.push(T(i.trim())),e}function T(u){return u.startsWith("{")?L(u):I(u)}function b(u){let e={},t=null,i=!1,n=u.split(/\r?\n/),o=[],s=0;for(;s<n.length;){let a=S(n[s]);if(a.match(/=\s*\[\s*$/)||a.includes("=")&&a.includes("[")&&!a.includes("]")){let d=a;for(s++;s<n.length&&!d.includes("]");)d+=" "+S(n[s]).trim(),s++;s<n.length&&d.includes("[")&&!d.includes("]")&&(d+=" "+S(n[s]).trim(),s++),o.push(d)}else o.push(a),s++}function c(a,d){let r=a;for(let l of d){if(!(l in r))return;r=r[l]}return r}for(let a of o){let d=S(a).trim();if(!d)continue;let r=d.match(/^\[\[([^\]]+)\]\]$/);if(r){t=r[1].trim(),i=!0;let y=t.split("."),h=e;for(let v=0;v<y.length-1;v++){let w=y[v];w in h||(h[w]={}),h=h[w]}let k=y[y.length-1];Array.isArray(h[k])||(h[k]=[]),h[k].push({});continue}let l=d.match(/^\[([^\]]+)\]$/);if(l){t=l[1].trim(),i=!1;continue}let f=d.indexOf("=");if(f===-1||!t)continue;let g=d.slice(0,f).trim(),p=d.slice(f+1).trim(),m;if(p.startsWith("{")?m=L(p):p.startsWith("[")?m=C(p):m=I(p),i){let y=t.split("."),h=c(e,y);if(Array.isArray(h)&&h.length>0){let k=h[h.length-1];k[g]=m}}else{let y=t.split("."),h=e;for(let v of y)v in h||(h[v]={}),h=h[v];let k=t==="package"?g.replace(/-/g,"_"):g;h[k]=m}}return e}var M=class{constructor(e){this.packageTable=new Map;this.graph=new Map;this.alwaysDeps=new Set(["Sui","MoveStdlib","SuiSystem","Bridge"]);this.lockfileOrder=[];this.root=e}setLockfileOrder(e){this.lockfileOrder=e}addPackage(e){this.packageTable.set(e.id.name,e),this.graph.has(e.id.name)||this.graph.set(e.id.name,new Set)}addDependency(e,t,i){this.graph.has(e)||this.graph.set(e,new Set),this.graph.get(e).add(t)}getPackage(e){return this.packageTable.get(e)}getAllPackages(){return Array.from(this.packageTable.values())}getImmediateDependencies(e){return this.graph.get(e)||new Set}getTransitiveDependencies(e){let t=new Set,i=new Set,n=o=>{if(i.has(o))return;i.add(o),t.add(o);let s=this.graph.get(o);if(s)for(let c of s)n(c)};return n(e),t.delete(e),t}topologicalOrder(){if(!this.lockfileOrder.length)return this.topologicalOrderDFS().filter(s=>s!==this.root);let e=new Set,t=new Set,i=o=>{if(t.has(o))return;t.add(o),e.add(o);let s=this.graph.get(o);if(s)for(let c of s)i(c)};i(this.root);let n=[];for(let o of this.lockfileOrder)o!==this.root&&e.has(o)&&n.push(o);return n}topologicalOrderDFS(){let e=new Set,t=[],i=n=>{if(e.has(n))return;e.add(n);let o=this.graph.get(n);if(o)for(let s of Array.from(o))i(s);t.push(n)};i(this.root);for(let n of this.packageTable.keys())i(n);return t}detectCycle(){let e=new Set,t=new Set,i=new Map,n=o=>{e.add(o),t.add(o);let s=this.graph.get(o);if(s)for(let c of s)if(e.has(c)){if(t.has(c)){let a=[c],d=o;for(;d!==c;)a.unshift(d),d=i.get(d);return a.unshift(c),a}}else{i.set(c,o);let a=n(c);if(a)return a}return t.delete(o),null};for(let o of this.packageTable.keys())if(!e.has(o)){let s=n(o);if(s)return s}return null}getRootPackage(){return this.packageTable.get(this.root)}getRootName(){return this.root}isAlwaysDep(e){return this.alwaysDeps.has(e)}};var D=class{constructor(e,t={}){this.unifiedAddressTable=new Map;this.packageResolvedTables=new Map;this.graph=e,this.buildConfig=t}async resolve(){let t=[this.graph.getRootName(),...this.graph.topologicalOrder()];for(let i of t){let n=this.graph.getPackage(i);if(n)for(let[o,s]of Object.entries(n.manifest.addresses)){let c=this.normalizeAddress(s);this.unifiedAddressTable.has(o)&&this.unifiedAddressTable.get(o)!==c||this.unifiedAddressTable.set(o,c)}}for(let i of this.graph.getAllPackages()){let n={};for(let[o,s]of this.unifiedAddressTable.entries())n[o]=s;this.packageResolvedTables.set(i.id.name,n),i.resolvedTable=n}}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}getUnifiedAddressTable(){let e={};for(let[t,i]of this.unifiedAddressTable.entries())e[t]=i;return e}getPackageResolvedTable(e){return this.packageResolvedTables.get(e)}getGraph(){return this.graph}topologicalOrder(){return this.graph.topologicalOrder()}getRootName(){return this.graph.getRootName()}getPackage(e){return this.graph.getPackage(e)}getImmediateDependencies(e){return this.graph.getImmediateDependencies(e)}};var $=class{constructor(e){this.dependencies=[];this.resolvedGraph=e,this.rootPackageName=e.getRootName()}async compute(e){if(!this.resolvedGraph.getPackage(this.rootPackageName))throw new Error(`Root package '${this.rootPackageName}' not found`);let i=this.resolvedGraph.getImmediateDependencies(this.rootPackageName),n=this.resolvedGraph.topologicalOrder(),o=new Set(["Bridge","SuiSystem"]);for(let s of n){if(s===this.rootPackageName)continue;let c=this.resolvedGraph.getPackage(s);if(!c||o.has(s))continue;let a=e.get(s)||{},d=this.extractSourcePaths(s,a),r=c.manifest.edition||"legacy",l=c.manifest.latestPublishedId||c.manifest.originalId||c.manifest.publishedAt||c.resolvedTable?.[s],f={name:s,isImmediate:i.has(s),sourcePaths:d,addressMapping:c.resolvedTable||{},compilerConfig:{edition:r,flavor:"sui"},moduleFormat:d.length>0?"Source":"Bytecode",edition:r,publishedIdForOutput:l};this.dependencies.push(f)}}extractSourcePaths(e,t){let i=Object.keys(t).filter(s=>s.endsWith("Move.toml")||s.endsWith("Move.lock")?!1:s.endsWith(".move")),n=new TextEncoder,o=(s,c)=>{let a=n.encode(`/vfs/deps/${e}/${s}`),d=n.encode(`/vfs/deps/${e}/${c}`),r=Math.min(a.length,d.length);for(let l=0;l<r;l++)if(a[l]!==d[l])return a[l]-d[l];return a.length-d.length};return i.sort(o),i}toPackageGroupedFormat(e){let t=[];for(let i of this.dependencies){let n=e.get(i.name)||{},o={};for(let[s,c]of Object.entries(n)){if(s.endsWith("Move.lock"))continue;let a=`dependencies/${i.name}/${s}`;s.endsWith("Move.toml")?o[a]=this.reconstructDependencyMoveToml(i.name,c,i.edition,i.addressMapping):o[a]=c}t.push({name:i.name,files:o,edition:i.edition,addressMapping:i.addressMapping,publishedIdForOutput:i.publishedIdForOutput})}return t}reconstructDependencyMoveToml(e,t,i,n){let o=(t||"").split(`
2
+ `),s=[],c=[],a=!1,d=!1;for(let g of o){let p=g.trim();if(p.startsWith("[package]")){a=!0,d=!1;continue}if(p.startsWith("[dependencies]")){a=!1,d=!0;continue}if(p.startsWith("[")){a=!1,d=!1;continue}a&&p&&s.push(g),d&&p&&c.push(g)}let r=`[package]
3
+ `,l=!1,f=!1;for(let g of s)if(g.includes("name ="))r+=g+`
4
+ `,l=!0;else if(g.includes("version ="))r+=g+`
5
+ `,f=!0;else{if(g.includes("edition ="))continue;r+=g+`
6
+ `}l||(r+=`name = "${e}"
7
+ `),f||(r+=`version = "0.0.0"
8
+ `),r+=`edition = "${i}"
9
+ `,r+=`
10
10
  [dependencies]
11
- `;for(let g of c)d+=g+`
12
- `;d+=`
11
+ `;for(let g of c)r+=g+`
12
+ `;r+=`
13
13
  [addresses]
14
- `;for(let[g,u]of Object.entries(n))d+=`${g} = "${u}"
15
- `;return d}getUnifiedAddressTable(){return this.resolvedGraph.getUnifiedAddressTable()}};var R=class{constructor(e,t="mainnet"){this.visited=new Set;this.packageNameCache=new Map;this.packageFiles=new Map;this.fetcher=e,this.network=t}async resolve(e,t){let i=y(e),n=i.package?.name||"RootPackage",r=i.package?.edition;if(t["Move.lock"]){let h=y(t["Move.lock"]);h.move?.["toolchain-version"]?.edition&&(r=h.move["toolchain-version"].edition)}let a=r||"2024.beta",c=new P(n),s=await this.buildPackage(n,null,e,t);r&&(s.manifest.edition=r),c.addPackage(s),this.packageFiles.set(n,t),await this.loadFromLockfile(c,s,t)||await this.buildDependencyGraph(c,s);let d=c.detectCycle();if(d)throw new Error(`Dependency cycle detected: ${d.join(" \u2192 ")}`);let f=new S(c,{});await f.resolve();let m=new M(f);await m.compute(this.packageFiles);let g=this.reconstructMoveToml(i,f.getUnifiedAddressTable(),!0,a),u={...t};delete u["Move.lock"],u["Move.toml"]=g;let p=m.toPackageGroupedFormat(this.packageFiles);return{files:JSON.stringify(u),dependencies:JSON.stringify(p)}}async buildPackage(e,t,i,n){let r=y(i),a={name:r.package?.name||e,version:r.package?.version||"0.0.0",edition:r.package?.edition,publishedAt:r.package?.published_at,addresses:r.addresses||{},dependencies:r.dependencies||{},devDependencies:r["dev-dependencies"]},c=new Map;if(a.dependencies)for(let[l,d]of Object.entries(a.dependencies)){let f=this.parseDependencyInfo(d);f&&c.set(l,f)}return{id:{name:a.name,version:a.version,source:t||{type:"local"}},manifest:a,dependencies:c,devDependencies:new Map}}parseDependencyInfo(e){return e?e.git&&e.rev?{source:{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}}:e.local?{source:{type:"local",local:e.local}}:null:null}async buildDependencyGraph(e,t){for(let[i,n]of t.dependencies.entries()){if(n.source.type==="local")if(t.id.source.type==="git"&&n.source.local){let g=t.id.source.subdir||"",u=n.source.local,p=this.resolveRelativePath(g,u);n.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:p}}else continue;if(n.source.type!=="git")continue;let r=`${n.source.git}|${n.source.rev}|${n.source.subdir||""}`;if(this.visited.has(r)){let g=this.findPackageBySource(e,n.source);g&&e.addDependency(t.id.name,g.id.name,n);continue}this.visited.add(r);let a=n.source.subdir;!a&&n.source.git&&this.isSuiRepo(n.source.git)&&(a=this.inferSuiFrameworkSubdir(i),a&&(n.source.subdir=a));let c=await this.fetcher.fetch(n.source.git,n.source.rev,a),s=null,l=`Move.${this.network}.toml`;for(let[g,u]of Object.entries(c))if(g.endsWith(l)){s=u;break}if(!s){for(let[g,u]of Object.entries(c))if(g.endsWith("Move.toml")){s=u;break}}if(!s)continue;let d=await this.buildPackage(i,n.source,s,c),f=this.packageNameCache.get(d.manifest.name);if(f){let g=this.findPackageBySource(e,f);g&&e.addDependency(t.id.name,g.id.name,n);continue}this.packageNameCache.set(d.manifest.name,n.source);let m=c["Move.lock"];if(m){let g=y(m);if(g.env?.[this.network]){let u=g.env[this.network]["latest-published-id"]||g.env[this.network]["original-published-id"];u&&(d.manifest.publishedAt=u,d.manifest.addresses[d.manifest.name]=this.normalizeAddress(u))}d.manifest.edition||(d.manifest.edition="legacy")}if(!d.manifest.publishedAt){let g={Sui:"0x2",MoveStdlib:"0x1",SuiSystem:"0x3",Bridge:"0xb"};g[i]&&(d.manifest.publishedAt=g[i])}e.addPackage(d),e.addDependency(t.id.name,d.id.name,n),this.packageFiles.set(d.id.name,c),await this.buildDependencyGraph(e,d)}}findPackageBySource(e,t){for(let i of e.getAllPackages()){let n=i.id.source;if(n.type===t.type&&n.git===t.git&&n.rev===t.rev&&n.subdir===t.subdir)return i}}resolveRelativePath(e,t){let i=e?e.split("/").filter(Boolean):[],n=t.split("/").filter(Boolean),r=[...i];for(let a of n)a===".."?r.length>0&&r.pop():a!=="."&&r.push(a);return r.join("/")}async computeManifestDigest(e){let i=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,i){let n=i["Move.lock"];if(!n)return!1;let r=y(n),a=r.pinned?.[this.network];if(!a)return!1;let c=i["Move.toml"];if(c&&r.move?.manifest_digest&&await this.computeManifestDigest(c)!==r.move.manifest_digest)return!1;let s=new Map;for(let[l,d]of Object.entries(a)){let f=this.lockfileSourceToDependencySource(d.source);if(!f)continue;let m=await this.fetchFromSource(f);if(!m)return!1;let g=m["Move.toml"];if(!g||d["manifest-digest"]&&await this.computeManifestDigest(g)!==d["manifest-digest"])return!1;let u=await this.buildPackage(l,f,g,m);s.set(l,u),this.packageFiles.set(u.manifest.name,m),(f.type!=="local"||!("root"in d.source))&&e.addPackage(u)}for(let[l,d]of Object.entries(a)){let f=s.get(l);if(f&&d.deps)for(let[m,g]of Object.entries(d.deps)){let u=s.get(g);if(u){let p=f.dependencies.get(m);p&&e.addDependency(f.id.name,u.id.name,p)}}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir)}catch{return null}return null}reconstructMoveToml(e,t,i,n){let a=`[package]
14
+ `;for(let[g,p]of Object.entries(n))r+=`${g} = "${p}"
15
+ `;return r}};var x=class{constructor(e,t="mainnet",i=null){this.visited=new Set;this.packageNameCache=new Map;this.packageFiles=new Map;this.fetcher=e,this.network=t,this.rootSource=i}async resolve(e,t){let i=b(e),n=i.package?.name||"RootPackage",o=i.package?.edition;if(t["Move.lock"]){let v=b(t["Move.lock"]);v.move?.["toolchain-version"]?.edition&&(o=v.move["toolchain-version"].edition)}let s=o||"2024.beta",c=new M(n),a=await this.buildPackage(n,this.rootSource,e,t);o&&(a.manifest.edition=o);let d=a.manifest.addresses[n];this.normalizeAddress(d||"")==="0x0000000000000000000000000000000000000000000000000000000000000000"&&a.manifest.originalId&&(a.manifest.addresses[n]=this.normalizeAddress(a.manifest.originalId)),c.addPackage(a),this.packageFiles.set(n,t);let l=await this.loadFromLockfile(c,a,t),f=Array.from(a.dependencies.keys()).filter(v=>!c.getPackage(v));(!l||f.length>0)&&await this.buildDependencyGraph(c,a);let g=c.detectCycle();if(g)throw new Error(`Dependency cycle detected: ${g.join(" \u2192 ")}`);let p=new D(c,{});await p.resolve();let m=new $(p);await m.compute(this.packageFiles);let y=this.reconstructMoveToml(i,p.getUnifiedAddressTable(),!0,s),h={...t};delete h["Move.lock"],h["Move.toml"]=y;let k=m.toPackageGroupedFormat(this.packageFiles);return{files:JSON.stringify(h),dependencies:JSON.stringify(k)}}async buildPackage(e,t,i,n){let o=b(i),s=n["Move.lock"],c=this.getChainIdForNetwork(this.network),a=this.resolvePublishedAt(i,s,c),d=a.latestId?this.normalizeAddress(a.latestId):void 0;a.error;let r={name:o.package?.name||e,version:o.package?.version||"0.0.0",edition:o.package?.edition,publishedAt:a.publishedAt,originalId:a.originalId,latestPublishedId:d,addresses:o.addresses||{},dependencies:o.dependencies||{},devDependencies:o["dev-dependencies"]},l=r.publishedAt&&r.publishedAt!=="0x0"?this.normalizeAddress(r.publishedAt):void 0,f=r.addresses[r.name],g=f?this.normalizeAddress(f):void 0;l?r.addresses[r.name]=l:g?r.addresses[r.name]=g:r.addresses[r.name]="0x0";let p=new Map;if(r.dependencies)for(let[y,h]of Object.entries(r.dependencies)){let k=this.parseDependencyInfo(h);k&&p.set(y,k)}return{id:{name:r.name,version:r.version,source:t||{type:"local"}},manifest:r,dependencies:p,devDependencies:new Map}}parseDependencyInfo(e){if(!e)return null;let t={source:{type:"local"}};if(e.git&&e.rev)t.source={type:"git",git:e.git,rev:e.rev,subdir:e.subdir};else if(e.local)t.source={type:"local",local:e.local};else return null;if(e["addr-subst"]||e.addr_subst){let i=e["addr-subst"]||e.addr_subst,n={};for(let[o,s]of Object.entries(i))typeof s=="string"&&(s.startsWith("0x")||/^[0-9a-fA-F]+$/.test(s)?n[o]={type:"assign",address:s}:n[o]={type:"renameFrom",name:s});Object.keys(n).length>0&&(t.subst=n)}return t}async buildDependencyGraph(e,t){for(let[i,n]of t.dependencies.entries()){if(n.source.type==="local")if(t.id.source.type==="git"&&n.source.local){let l=t.id.source.subdir||"",f=n.source.local,g=this.resolveRelativePath(l,f);n.source={type:"git",git:t.id.source.git,rev:t.id.source.rev,subdir:g}}else continue;if(n.source.type!=="git")continue;let o=`${n.source.git}|${n.source.rev}|${n.source.subdir||""}`;if(this.visited.has(o)){let l=this.findPackageBySource(e,n.source);l&&e.addDependency(t.id.name,l.id.name,n);continue}this.visited.add(o);let s=n.source.subdir;!s&&n.source.git&&this.isSuiRepo(n.source.git)&&(s=this.inferSuiFrameworkSubdir(i),s&&(n.source.subdir=s));let c=await this.fetcher.fetch(n.source.git,n.source.rev,s,`${t.id.name} -> ${i}`),a=null,d=`Move.${this.network}.toml`;for(let[l,f]of Object.entries(c))if(l.endsWith(d)){a=f;break}if(!a){for(let[l,f]of Object.entries(c))if(l.endsWith("Move.toml")){a=f;break}}if(!a)continue;let r=await this.buildPackage(i,n.source,a,c);if(!this.lockfileVersion||this.lockfileVersion<4){let l=this.packageNameCache.get(r.manifest.name);if(l){let f=g=>JSON.stringify(g);throw new Error([`Conflicting versions of package '${r.manifest.name}' found`,`Existing: ${f(l)}`,`New: ${f(n.source)}`,`When resolving dependencies for '${t.id.name}' -> '${i}'`].join(`
16
+ `))}this.packageNameCache.set(r.manifest.name,n.source)}r.manifest.publishedAt&&(r.manifest.addresses[r.manifest.name]=this.normalizeAddress(r.manifest.publishedAt)),r.manifest.edition||(r.manifest.edition="legacy"),e.addPackage(r),e.addDependency(t.id.name,r.id.name,n),this.packageFiles.set(r.id.name,c),await this.buildDependencyGraph(e,r)}}getChainIdForNetwork(e){return{mainnet:"35834a8a",testnet:"4c78adac",devnet:"2",localnet:"localnet"}[e]||e}resolvePublishedAt(e,t,i){let n=b(e),o=n.package?.published_at||n.package?.["published-at"],s=o&&o!=="0x0"?o:void 0,c=s?this.normalizeAddress(s):void 0,a=n.package?.["original-id"];if(!t||!i)return{publishedAt:c,originalId:a};let d=b(t),r,l,f;if(d.env)for(let[,g]of Object.entries(d.env)){let p=g["latest-published-id"],m=g["original-published-id"],y=g["chain-id"];if(y===i||!y){let h=p&&p!=="0x0"?this.normalizeAddress(p):void 0,k=m&&m!=="0x0"?this.normalizeAddress(m):void 0;l=h,f=k,r=h||k;break}}return!f&&r&&(f=r),r&&c&&r!==c?{error:`Conflicting 'published-at' addresses between Move.toml (${c}) and Move.lock (${r})`}:{publishedAt:f||c||r,originalId:f||a,latestId:l||r||c}}findPackageBySource(e,t){for(let i of e.getAllPackages()){let n=i.id.source;if(n.type===t.type&&n.git===t.git&&n.rev===t.rev&&n.subdir===t.subdir)return i}}resolveRelativePath(e,t){let i=e?e.split("/").filter(Boolean):[],n=t.split("/").filter(Boolean),o=[...i];for(let s of n)s===".."?o.length>0&&o.pop():s!=="."&&o.push(s);return o.join("/")}async computeManifestDigest(e){let i=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",i);return Array.from(new Uint8Array(n)).map(c=>c.toString(16).padStart(2,"0")).join("").toUpperCase()}async loadFromLockfile(e,t,i){let n=i["Move.lock"];if(!n)return!1;let o=b(n);this.lockfileVersion=o.move?.version;let s=o.move?.version;return s===3?await this.loadFromLockfileV3(e,o,t):s&&s>=4?await this.loadFromLockfileV4(e,o,i):await this.loadFromLockfileV0(e,o,t)}async loadFromLockfileV0(e,t,i){let n=t.move?.package;if(!n||!Array.isArray(n))return!1;let o=Array.isArray(t.move?.dependencies)?t.move.dependencies.map(r=>r.name||r.id||r).filter(Boolean):[],s=n.map(r=>r.name||r.id).filter(Boolean),c=[...o,...s.filter(r=>!o.includes(r))],a=new Map,d=new Map;for(let r of n){let l=r.id||r.name,f=r.source;if(!l||!f)continue;let g=null;if(f.git&&f.rev)g={type:"git",git:f.git,rev:f.rev,subdir:f.subdir};else if(f.local&&this.rootSource?.type==="git"){let h=this.resolveRelativePath(this.rootSource.subdir||"",f.local);g={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:h}}else continue;let p=await this.fetcher.fetch(g.git,g.rev,g.subdir,`lockfile:${l}`);if(Object.keys(p).length===0)continue;let m=p["Move.toml"];if(!m)continue;let y=await this.buildPackage(l,g,m,p);a.set(l,y),d.set(y.manifest.name,y),this.packageFiles.set(y.manifest.name,p),e.addPackage(y)}c.length&&e.setLockfileOrder(c);for(let r of n){let l=r.id||r.name,f=a.get(l);if(!f)continue;let g=r.dependencies;if(g&&Array.isArray(g))for(let p of g){let m=p.id||p.name,y=a.get(m)||d.get(m);if(y){let h={source:y.id.source};e.addDependency(f.id.name,y.id.name,h)}}}for(let r of i.dependencies.keys()){let l=d.get(r);if(l){let f=i.dependencies.get(r);e.addDependency(i.id.name,l.id.name,f)}}return a.size>0}async loadFromLockfileV3(e,t,i){let n=t.move?.package;if(!n||!Array.isArray(n))return!1;let o=new Map,s=new Map,c=[];for(let a of n)a.id&&s.set(a.id,a);for(let a of n){let d=a.id,r=a.source;c.push(d);let l=null;if(r?.git&&r.rev)l={type:"git",git:r.git,rev:r.rev,subdir:r.subdir};else if(r?.local&&this.rootSource?.type==="git"){let m=this.resolveRelativePath(this.rootSource.subdir||"",r.local);l={type:"git",git:this.rootSource.git,rev:this.rootSource.rev,subdir:m}}else continue;let f=await this.fetcher.fetch(r.git,r.rev,r.subdir,`lockfile:${d}`);if(Object.keys(f).length===0)continue;let g=f["Move.toml"];if(!g)continue;let p=await this.buildPackage(d,l,g,f);o.set(d,p),this.packageFiles.set(p.manifest.name,f),e.addPackage(p)}e.setLockfileOrder(c);for(let a of n){let d=a.id,r=o.get(d);if(!r)continue;let l=a.dependencies;if(!(!l||!Array.isArray(l)))for(let f of l){let g=f.id,p=o.get(g);if(!p){let m=s.get(g);if(m?.source?.local&&r.id.source.type==="git"){let y=this.resolveRelativePath(r.id.source.subdir||"",m.source.local),h={type:"git",git:r.id.source.git,rev:r.id.source.rev,subdir:y},k=await this.fetcher.fetch(h.git,h.rev,h.subdir,`lockfile:${g}`),v=k["Move.toml"];if(v){let w=await this.buildPackage(g,h,v,k);o.set(g,w),this.packageFiles.set(w.manifest.name,k),e.addPackage(w),p=w}}}if(p){let m={source:p.id.source};e.addDependency(r.id.name,p.id.name,m)}}}for(let a of i.dependencies.keys()){let d=o.get(a);if(d){let r=i.dependencies.get(a);e.addDependency(i.id.name,d.id.name,r)}}return!0}async loadFromLockfileV4(e,t,i){let n=t.pinned?.[this.network];if(!n)return!1;let o=rootFiles["Move.toml"];if(o&&t.move?.manifest_digest&&await this.computeManifestDigest(o)!==t.move.manifest_digest)return!1;let s=new Map,c=new Map,a=[];for(let[d,r]of Object.entries(n)){a.push(d);let l=this.lockfileSourceToDependencySource(r.source);if(!l)continue;let f=await this.fetchFromSource(l);if(!f)return!1;let g=f["Move.toml"];if(!g||r["manifest-digest"]&&await this.computeManifestDigest(g)!==r["manifest-digest"])return!1;let p=await this.buildPackage(d,l,g,f);s.set(d,p),c.set(p.manifest.name,p),this.packageFiles.set(p.manifest.name,f),(l.type!=="local"||!("root"in r.source))&&e.addPackage(p)}a.length>0&&e.setLockfileOrder(a);for(let[d,r]of Object.entries(n)){let l=s.get(d);if(l&&r.deps)for(let[f,g]of Object.entries(r.deps)){let p=s.get(g);if(p){let m=l.dependencies.get(f);m&&e.addDependency(l.id.name,p.id.name,m)}}}for(let d of rootPackage.dependencies.keys()){let r=c.get(d)||s.get(d);if(r){let l=rootPackage.dependencies.get(d);e.addDependency(rootPackage.id.name,r.id.name,l)}}return!0}lockfileSourceToDependencySource(e){return"git"in e?{type:"git",git:e.git,rev:e.rev,subdir:e.subdir}:"local"in e?{type:"local",local:e.local}:"root"in e?{type:"local"}:null}async fetchFromSource(e){if(e.type==="git"&&e.git&&e.rev)try{return await this.fetcher.fetch(e.git,e.rev,e.subdir,"lockfile:dependency")}catch{return null}return null}reconstructMoveToml(e,t,i,n){let s=`[package]
16
17
  name = "${e.package.name}"
17
18
  version = "${e.package.version}"
18
- `,c=n||e.package.edition;if(c&&(a+=`edition = "${c}"
19
- `),a+=`
19
+ `,c=n||e.package.edition;if(c&&(s+=`edition = "${c}"
20
+ `),s+=`
20
21
  [dependencies]
21
- `,e.dependencies)for(let[s,l]of Object.entries(e.dependencies)){let d=l;d.local?a+=`${s} = { local = "${d.local}" }
22
- `:d.git&&d.rev&&(d.subdir?a+=`${s} = { git = "${d.git}", subdir = "${d.subdir}", rev = "${d.rev}" }
23
- `:a+=`${s} = { git = "${d.git}", rev = "${d.rev}" }
24
- `)}a+=`
22
+ `,e.dependencies)for(let[a,d]of Object.entries(e.dependencies)){let r=d;r.local?s+=`${a} = { local = "${r.local}" }
23
+ `:r.git&&r.rev&&(r.subdir?s+=`${a} = { git = "${r.git}", subdir = "${r.subdir}", rev = "${r.rev}" }
24
+ `:s+=`${a} = { git = "${r.git}", rev = "${r.rev}" }
25
+ `)}s+=`
25
26
  [addresses]
26
- `;for(let[s,l]of Object.entries(t))a+=`${s} = "${l}"
27
- `;return a}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}isSuiRepo(e){return e.includes("github.com/MystenLabs/sui")}inferSuiFrameworkSubdir(e){let t={Sui:"crates/sui-framework/packages/sui-framework",MoveStdlib:"crates/sui-framework/packages/move-stdlib",SuiSystem:"crates/sui-framework/packages/sui-system",Bridge:"crates/sui-framework/packages/bridge",DeepBook:"crates/sui-framework/packages/deepbook",SuiFramework:"crates/sui-framework/packages/sui-framework"};return t[e]||t[e.toLowerCase()]}};async function A(o,e,t,i="mainnet"){return new R(t,i).resolve(o,e)}function N(o){try{let e=new URL(o);if(e.hostname!=="github.com")return null;let t=e.pathname.split("/").filter(Boolean);if(t.length<2)return null;let i=t[0],n=t[1],r="main",a;return t.length>=4&&t[2]==="tree"&&(r=t[3],t.length>4&&(a=t.slice(4).join("/"))),{owner:i,repo:n,ref:r,subdir:a}}catch{return null}}async function _(o,e){let t=N(o);if(!t)throw new Error(`Invalid GitHub URL: ${o}`);let i=e?.fetcher||new v,n=e?.includeLock!==!1,r=`https://github.com/${t.owner}/${t.repo}.git`,a=await i.fetch(r,t.ref,t.subdir);if(!n&&a["Move.lock"]){let{"Move.lock":c,...s}=a;return s}return a}async function W(o,e){let t=Array.isArray(o)?Object.fromEntries(o.map((n,r)=>[`package_${r}`,n])):o,i={};for(let[n,r]of Object.entries(t))i[n]=await _(r,e);return i}function E(o,e="main",t){let i=`https://github.com/${o}`;return(e||t)&&(i+=`/tree/${e}`),t&&(i+=`/${t}`),i}var T;async function b(o){return T||(T=import("./sui_move_wasm.js").then(async e=>(o?await e.default({module_or_path:o}):await e.default(),e))),T}function D(o){return JSON.stringify(o??{})}function F(o){return{success:!1,error:o instanceof Error?o.message:typeof o=="string"?o:"Unknown error"}}function I(o){if(typeof o!="object"||o===null)throw new Error("Unexpected compile result shape from wasm");let e=o;if(typeof e.success=="function"&&typeof e.output=="function")return e;if(typeof e.success=="boolean"&&typeof e.output=="string")return{success:()=>e.success,output:()=>e.output};throw new Error("Unexpected compile result shape from wasm")}function H(o){let e=t=>t.map(i=>i.toString(16).padStart(2,"0")).join("");try{let t=JSON.parse(o);if(!t.modules||!t.dependencies||!t.digest)throw new Error("missing fields in compiler output");let i=typeof t.digest=="string"?t.digest:e(t.digest);return{success:!0,modules:t.modules,dependencies:t.dependencies,digest:i}}catch(t){return F(t)}}function U(o){if(!o)return o;let e=o;return e.startsWith("0x")&&(e=e.slice(2)),/^[0-9a-fA-F]+$/.test(e)?"0x"+e.padStart(64,"0"):o}function z(o){let e={std:"0x1",sui:"0x2",sui_system:"0x3",bridge:"0xb"},t=o.split(/\r?\n/),i=/^\s*\[[^\]]+\]\s*$/,n=-1,r=t.length;for(let s=0;s<t.length;s++)if(/^\s*\[addresses\]\s*$/.test(t[s])){n=s;for(let l=s+1;l<t.length;l++)if(i.test(t[l])){r=l;break}break}let a=new Set;if(n>=0)for(let s=n+1;s<r;s++){let l=t[s].trim();if(!l||l.startsWith("#"))continue;let d=l.match(/^([A-Za-z0-9_.-]+)\s*=/);d&&a.add(d[1])}let c=Object.entries(e).filter(([s])=>!a.has(s)).map(([s,l])=>`${s} = "${U(l)}"`);return c.length===0?o:(n>=0?t.splice(r,0,...c):t.push("","[addresses]",...c),t.join(`
28
- `))}function V(o){let e=[{name:"Sui",git:"https://github.com/MystenLabs/sui.git",subdir:"crates/sui-framework/packages/sui-framework",rev:"framework/mainnet"},{name:"MoveStdlib",git:"https://github.com/MystenLabs/sui.git",subdir:"crates/sui-framework/packages/move-stdlib",rev:"framework/mainnet"}],t=o.split(/\r?\n/),i=/^\s*\[[^\]]+\]\s*$/,n=-1,r=t.length;for(let s=0;s<t.length;s++)if(/^\s*\[dependencies\]\s*$/.test(t[s])){n=s;for(let l=s+1;l<t.length;l++)if(i.test(t[l])){r=l;break}break}let a=new Set;if(n>=0)for(let s=n+1;s<r;s++){let l=t[s].trim();if(!l||l.startsWith("#"))continue;let d=l.match(/^([A-Za-z0-9_.-]+)\s*=/);d&&a.add(d[1])}let c=e.filter(s=>!a.has(s.name)).map(s=>`${s.name} = { git = "${s.git}", subdir = "${s.subdir}", rev = "${s.rev}" }`);return c.length===0?o:(n>=0?t.splice(r,0,...c):t.push("","[dependencies]",...c),t.join(`
29
- `))}function q(o){let e={...o??{}};if(e["dependencies/MoveStdlib/Move.toml"])return e;let t=[{name:"MoveStdlib",id:"0x1"},{name:"Sui",id:"0x2"},{name:"SuiSystem",id:"0x3"},{name:"Bridge",id:"0xb"}];for(let i of t){let n=`dependencies/${i.name}/Move.toml`;e[n]||(e[n]=["[package]",`name = "${i.name}"`,'version = "0.0.0"',`published-at = "${U(i.id)}"`,""].join(`
30
- `))}return e}function j(o){return!!(o?.["dependencies/MoveStdlib/Move.toml"]&&o?.["dependencies/Sui/Move.toml"])}function C(o){return typeof o=="string"?JSON.parse(o):o}async function me(o){await b(o?.wasm)}async function he(o){try{let e=o.dependencies??{},t={...o.files},i=typeof t["Move.toml"]=="string";if(o.autoSystemDeps&&i){let l=z(t["Move.toml"]);j(e)||(l=V(l)),t["Move.toml"]=l}if(o.autoSystemDeps&&!j(e)&&i){let l=await A(t["Move.toml"],t,new v,o.network);t=C(l.files),e=C(l.dependencies)}else o.autoSystemDeps&&(e=q(e));let n=await b(o.wasm),r=o.ansiColor&&typeof n.compile_with_color=="function"?n.compile_with_color(D(t),D(e),!0):n.compile(D(t),D(e)),a=I(r),c=a.success(),s=a.output();return c?H(s):F(s)}catch(e){return F(e)}}async function ke(o){return(await b(o?.wasm)).sui_move_version()}async function ve(o){return(await b(o?.wasm)).sui_version()}async function ye(o){return b(o?.wasm)}async function be(o,e,t){let i=await b(t?.wasm),n=t?.ansiColor&&typeof i.compile_with_color=="function"?i.compile_with_color(o,e,!0):i.compile(o,e),r=I(n);return{success:r.success(),output:r.output()}}export{w as Fetcher,v as GitHubFetcher,R as Resolver,he as buildMovePackage,be as compileRaw,_ as fetchPackageFromGitHub,W as fetchPackagesFromGitHub,ke as getSuiMoveVersion,ve as getSuiVersion,ye as getWasmBindings,E as githubUrl,me as initMoveCompiler,N as parseGitHubUrl,y as parseToml,A as resolve};
27
+ `;for(let[a,d]of Object.entries(t))s+=`${a} = "${d}"
28
+ `;return s}normalizeAddress(e){if(!e)return e;let t=e.trim();return t.startsWith("0x")&&(t=t.slice(2)),/^[0-9a-fA-F]+$/.test(t)?"0x"+t.padStart(64,"0"):e}isSuiRepo(e){return e.includes("github.com/MystenLabs/sui")}inferSuiFrameworkSubdir(e){let t={Sui:"crates/sui-framework/packages/sui-framework",MoveStdlib:"crates/sui-framework/packages/move-stdlib",SuiSystem:"crates/sui-framework/packages/sui-system",Bridge:"crates/sui-framework/packages/bridge",DeepBook:"crates/sui-framework/packages/deepbook",SuiFramework:"crates/sui-framework/packages/sui-framework"};return t[e]||t[e.toLowerCase()]}};async function G(u,e,t,i="mainnet",n){return new x(t,i,n||null).resolve(u,e)}function B(u){try{let e=new URL(u);if(e.hostname!=="github.com")return null;let t=e.pathname.split("/").filter(Boolean);if(t.length<2)return null;let i=t[0],n=t[1],o="main",s;return t.length>=4&&t[2]==="tree"&&(o=t[3],t.length>4&&(s=t.slice(4).join("/"))),{owner:i,repo:n,ref:o,subdir:s}}catch{return null}}async function _(u,e){let t=B(u);if(!t)throw new Error(`Invalid GitHub URL: ${u}`);let i=e?.fetcher||new P(e?.githubToken),n=e?.includeLock!==!1,o=`https://github.com/${t.owner}/${t.repo}.git`,s=await i.fetch(o,t.ref,t.subdir,`root:${t.owner}/${t.repo}`);if(Object.defineProperty(s,"__rootGit",{value:{git:o,rev:t.ref,subdir:t.subdir},enumerable:!1}),!n&&s["Move.lock"]){let{"Move.lock":c,...a}=s;return a}return s}var F;async function R(u){return F||(F=import("./sui_move_wasm.js").then(async e=>(u?await e.default({module_or_path:u}):await e.default(),e))),F}function O(u){return{error:u instanceof Error?u.message:typeof u=="string"?u:"Unknown error"}}function N(u){if(typeof u!="object"||u===null)throw new Error("Unexpected compile result shape from wasm");let e=u;if(typeof e.success=="function"&&typeof e.output=="function")return e;if(typeof e.success=="boolean"&&typeof e.output=="string")return{success:()=>e.success,output:()=>e.output};throw new Error("Unexpected compile result shape from wasm")}function j(u){let e=t=>{let i=t.startsWith("0x")?t.slice(2):t,n=i.length%2===0?i:`0${i}`,o=[];for(let s=0;s<n.length;s+=2){let c=parseInt(n.slice(s,s+2),16);if(Number.isNaN(c))throw new Error("invalid hex digest");o.push(c)}return o};try{let t=JSON.parse(u);if(!t.modules||!t.dependencies||!t.digest)throw new Error("missing fields in compiler output");let i=typeof t.digest=="string"?e(t.digest):Array.from(t.digest);return{modules:t.modules,dependencies:t.dependencies,digest:i}}catch(t){return O(t)}}function W(u){try{let e=JSON.parse(u);for(let t of e){let i=t.addressMapping?.[t.name]??(()=>{let n=Object.entries(t.files).find(([s])=>s.endsWith("Move.toml"));if(!n)return;let o=b(n[1]);return o.addresses&&o.addresses[t.name]||o.package?.published_at||o.package?.["published-at"]})()}}catch{}}async function le(u){await R(u?.wasm)}async function U(u){let e=u.files["Move.toml"]||"",t=u.rootGit||u.files.__rootGit,i=await G(e,{...u.files,"Move.toml":e},new P(u.githubToken),u.network,t?{type:"git",git:t.git,rev:t.rev,subdir:t.subdir}:void 0);return{files:i.files,dependencies:i.dependencies}}async function ge(u){try{let e=u.resolvedDependencies?u.resolvedDependencies:await U(u),t=await R(u.wasm);W(e.dependencies);let i=u.ansiColor&&typeof t.compile_with_color=="function"?t.compile_with_color(e.files,e.dependencies,!0):t.compile(e.files,e.dependencies),n=N(i),o=n.success(),s=n.output();return o?j(s):O(s)}catch(e){return O(e)}}async function ue(u){return(await R(u?.wasm)).sui_move_version()}async function pe(u){return(await R(u?.wasm)).sui_version()}async function fe(u){return R(u?.wasm)}async function he(u,e,t){let i=await R(t?.wasm),n=t?.ansiColor&&typeof i.compile_with_color=="function"?i.compile_with_color(u,e,!0):i.compile(u,e),o=N(n);return{success:o.success(),output:o.output()}}export{ge as buildMovePackage,he as compileRaw,_ as fetchPackageFromGitHub,ue as getSuiMoveVersion,pe as getSuiVersion,fe as getWasmBindings,le as initMoveCompiler,U as resolveDependencies};
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zktx.io/sui-move-builder",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Build Move packages in web or Node.js with dependency fetching and dump outputs.",
5
5
  "keywords": [
6
6
  "sui",