Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/utoo-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ flate2 = "1.1.5"
futures = { workspace = true }
js-sys = "0.3.83"
oneshot = "0.1.11"
opfs-project = "0.2.3"
opfs-project = "0.1.17"
petgraph = "0.6"
reqwest = { version = "0.12.22", default-features = false, features = ["json"] }
rustc-hash = { workspace = true }
Expand Down
24 changes: 2 additions & 22 deletions crates/utoo-wasm/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,29 +162,9 @@ impl Project {
pub async fn install(
package_lock: String,
max_concurrent_downloads: Option<usize>,
omit: Vec<String>,
) -> Result<(), JsError> {
use opfs_project::package_lock::PackageLock;
use opfs_project::{InstallOptions, OmitType};

let lock = PackageLock::from_json(&package_lock)
.map_err(|e| JsError::new(&format!("Failed to parse package-lock.json: {}", e)))?;

let omit = omit
.into_iter()
.filter_map(|s| match s.as_str() {
"dev" => Some(OmitType::Dev),
"optional" => Some(OmitType::Optional),
_ => None,
})
.collect();

let options = Some(InstallOptions {
max_concurrent_downloads,
omit,
});

opfs_project::install(&lock, options)
let concurrency = max_concurrent_downloads.unwrap_or(20);
opfs_project::package_manager::install_deps(&package_lock, concurrency)
.await
.map_err(to_js_error)
}
Comment thread
elrrrrrrr marked this conversation as resolved.
Expand Down
6 changes: 1 addition & 5 deletions packages/utoo-web/src/project/InternalProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class InternalEndpoint implements ProjectEndpoint {

async install(packageLock: string, options?: InstallOptions) {
await this.wasmInit!;
await ProjectInternal.install(
packageLock,
options?.maxConcurrentDownloads,
options?.omit ?? [],
);
await ProjectInternal.install(packageLock, options?.maxConcurrentDownloads);
return;
}

Expand Down
16 changes: 8 additions & 8 deletions packages/utoo-web/src/utoo/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class Project {
/**
* Install dependencies - downloads tgz files only, extracts on-demand when files are read
*/
static install(package_lock: string, max_concurrent_downloads: number | null | undefined, omit: string[]): Promise<void>;
static install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
static setCwd(path: string): void;
/**
* Calculate MD5 hash of byte content (async for better thread scheduling)
Expand Down Expand Up @@ -147,8 +147,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
export interface InitOutput {
readonly registerWorkerScheduler: (a: any, b: any) => void;
readonly workerCreated: (a: number) => void;
readonly initLogFilter: (a: number, b: number) => void;
readonly init_pack: () => void;
readonly __wbg_direntry_free: (a: number, b: number) => void;
readonly __wbg_get_direntry_name: (a: number) => [number, number];
readonly __wbg_get_direntry_type: (a: number) => number;
Expand All @@ -171,7 +169,7 @@ export interface InitOutput {
readonly project_deps: (a: number, b: number, c: number) => any;
readonly project_gzip: (a: any) => any;
readonly project_init: (a: number, b: number) => void;
readonly project_install: (a: number, b: number, c: number, d: number, e: number) => any;
readonly project_install: (a: number, b: number, c: number) => any;
readonly project_metadata: (a: number, b: number) => any;
readonly project_metadataSync: (a: number, b: number) => [number, number, number];
readonly project_read: (a: number, b: number) => any;
Expand All @@ -188,6 +186,8 @@ export interface InitOutput {
readonly project_write: (a: number, b: number, c: any) => any;
readonly project_writeString: (a: number, b: number, c: number, d: number) => any;
readonly project_writeSync: (a: number, b: number, c: any) => [number, number];
readonly initLogFilter: (a: number, b: number) => void;
readonly init_pack: () => void;
readonly rust_mi_get_default_heap: () => number;
readonly rust_mi_get_thread_id: () => number;
readonly rust_mi_set_default_heap: (a: number) => void;
Expand All @@ -214,14 +214,14 @@ export interface InitOutput {
readonly wasm_thread_entry_point: (a: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h56a508b165bb0698: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__hb10b6a816b65033c: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__hd01d906c585a4882: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h4f7407a77b90c2b4: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h0718aff2bbc4838f: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__closure__destroy__h421c3c7ae98d890c: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h1fc4d085249c5ea3: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__closure__destroy__hbc23ea6ab53be1d2: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h12ad3f2e11ef8f1f: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__closure__destroy__ha0c175f92395ef9a: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__h05951ccee93604a9: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__closure__destroy__hc95bb6053e4d238d: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__hd01d906c585a4882: (a: number, b: number) => void;
readonly wasm_bindgen__closure__destroy__h4f7407a77b90c2b4: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures________invoke__hc572a1bf691b2f02: (a: number, b: number, c: any) => void;
readonly wasm_bindgen__closure__destroy__h79b136ee1664aaaa: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures_____invoke__heb9448f3005917b6: (a: number, b: number, c: any, d: any) => void;
Expand Down
Loading