Skip to content

Commit 55c6c02

Browse files
authored
chore: opfs-project (#2514)
1 parent 0aae6fb commit 55c6c02

File tree

5 files changed

+14
-38
lines changed

5 files changed

+14
-38
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/utoo-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ flate2 = "1.1.5"
2929
futures = { workspace = true }
3030
js-sys = "0.3.83"
3131
oneshot = "0.1.11"
32-
opfs-project = "0.2.3"
32+
opfs-project = "0.1.17"
3333
petgraph = "0.6"
3434
reqwest = { version = "0.12.22", default-features = false, features = ["json"] }
3535
rustc-hash = { workspace = true }

crates/utoo-wasm/src/project.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,29 +162,9 @@ impl Project {
162162
pub async fn install(
163163
package_lock: String,
164164
max_concurrent_downloads: Option<usize>,
165-
omit: Vec<String>,
166165
) -> Result<(), JsError> {
167-
use opfs_project::package_lock::PackageLock;
168-
use opfs_project::{InstallOptions, OmitType};
169-
170-
let lock = PackageLock::from_json(&package_lock)
171-
.map_err(|e| JsError::new(&format!("Failed to parse package-lock.json: {}", e)))?;
172-
173-
let omit = omit
174-
.into_iter()
175-
.filter_map(|s| match s.as_str() {
176-
"dev" => Some(OmitType::Dev),
177-
"optional" => Some(OmitType::Optional),
178-
_ => None,
179-
})
180-
.collect();
181-
182-
let options = Some(InstallOptions {
183-
max_concurrent_downloads,
184-
omit,
185-
});
186-
187-
opfs_project::install(&lock, options)
166+
let concurrency = max_concurrent_downloads.unwrap_or(20);
167+
opfs_project::package_manager::install_deps(&package_lock, concurrency)
188168
.await
189169
.map_err(to_js_error)
190170
}

packages/utoo-web/src/project/InternalProject.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ class InternalEndpoint implements ProjectEndpoint {
5050

5151
async install(packageLock: string, options?: InstallOptions) {
5252
await this.wasmInit!;
53-
await ProjectInternal.install(
54-
packageLock,
55-
options?.maxConcurrentDownloads,
56-
options?.omit ?? [],
57-
);
53+
await ProjectInternal.install(packageLock, options?.maxConcurrentDownloads);
5854
return;
5955
}
6056

packages/utoo-web/src/utoo/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class Project {
8181
/**
8282
* Install dependencies - downloads tgz files only, extracts on-demand when files are read
8383
*/
84-
static install(package_lock: string, max_concurrent_downloads: number | null | undefined, omit: string[]): Promise<void>;
84+
static install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
8585
static setCwd(path: string): void;
8686
/**
8787
* Calculate MD5 hash of byte content (async for better thread scheduling)
@@ -147,8 +147,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
147147
export interface InitOutput {
148148
readonly registerWorkerScheduler: (a: any, b: any) => void;
149149
readonly workerCreated: (a: number) => void;
150-
readonly initLogFilter: (a: number, b: number) => void;
151-
readonly init_pack: () => void;
152150
readonly __wbg_direntry_free: (a: number, b: number) => void;
153151
readonly __wbg_get_direntry_name: (a: number) => [number, number];
154152
readonly __wbg_get_direntry_type: (a: number) => number;
@@ -171,7 +169,7 @@ export interface InitOutput {
171169
readonly project_deps: (a: number, b: number, c: number) => any;
172170
readonly project_gzip: (a: any) => any;
173171
readonly project_init: (a: number, b: number) => void;
174-
readonly project_install: (a: number, b: number, c: number, d: number, e: number) => any;
172+
readonly project_install: (a: number, b: number, c: number) => any;
175173
readonly project_metadata: (a: number, b: number) => any;
176174
readonly project_metadataSync: (a: number, b: number) => [number, number, number];
177175
readonly project_read: (a: number, b: number) => any;
@@ -188,6 +186,8 @@ export interface InitOutput {
188186
readonly project_write: (a: number, b: number, c: any) => any;
189187
readonly project_writeString: (a: number, b: number, c: number, d: number) => any;
190188
readonly project_writeSync: (a: number, b: number, c: any) => [number, number];
189+
readonly initLogFilter: (a: number, b: number) => void;
190+
readonly init_pack: () => void;
191191
readonly rust_mi_get_default_heap: () => number;
192192
readonly rust_mi_get_thread_id: () => number;
193193
readonly rust_mi_set_default_heap: (a: number) => void;
@@ -214,14 +214,14 @@ export interface InitOutput {
214214
readonly wasm_thread_entry_point: (a: number) => void;
215215
readonly wasm_bindgen__convert__closures_____invoke__h56a508b165bb0698: (a: number, b: number) => void;
216216
readonly wasm_bindgen__closure__destroy__hb10b6a816b65033c: (a: number, b: number) => void;
217-
readonly wasm_bindgen__convert__closures_____invoke__hd01d906c585a4882: (a: number, b: number) => void;
218-
readonly wasm_bindgen__closure__destroy__h4f7407a77b90c2b4: (a: number, b: number) => void;
219-
readonly wasm_bindgen__convert__closures_____invoke__h0718aff2bbc4838f: (a: number, b: number, c: any) => void;
220-
readonly wasm_bindgen__closure__destroy__h421c3c7ae98d890c: (a: number, b: number) => void;
217+
readonly wasm_bindgen__convert__closures_____invoke__h1fc4d085249c5ea3: (a: number, b: number, c: any) => void;
218+
readonly wasm_bindgen__closure__destroy__hbc23ea6ab53be1d2: (a: number, b: number) => void;
221219
readonly wasm_bindgen__convert__closures_____invoke__h12ad3f2e11ef8f1f: (a: number, b: number, c: any) => void;
222220
readonly wasm_bindgen__closure__destroy__ha0c175f92395ef9a: (a: number, b: number) => void;
223221
readonly wasm_bindgen__convert__closures_____invoke__h05951ccee93604a9: (a: number, b: number, c: any) => void;
224222
readonly wasm_bindgen__closure__destroy__hc95bb6053e4d238d: (a: number, b: number) => void;
223+
readonly wasm_bindgen__convert__closures_____invoke__hd01d906c585a4882: (a: number, b: number) => void;
224+
readonly wasm_bindgen__closure__destroy__h4f7407a77b90c2b4: (a: number, b: number) => void;
225225
readonly wasm_bindgen__convert__closures________invoke__hc572a1bf691b2f02: (a: number, b: number, c: any) => void;
226226
readonly wasm_bindgen__closure__destroy__h79b136ee1664aaaa: (a: number, b: number) => void;
227227
readonly wasm_bindgen__convert__closures_____invoke__heb9448f3005917b6: (a: number, b: number, c: any, d: any) => void;

0 commit comments

Comments
 (0)