Skip to content

Commit 42877b1

Browse files
authored
fix(wasm): bump deps & gate turbo-tasks no-restore fast path behind wasm cfg (#2699)
1 parent 7740052 commit 42877b1

10 files changed

Lines changed: 58 additions & 51 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ simd-json = "0.17.0"
5858
tempfile = "3"
5959
thiserror = "1.0"
6060
tokio = { version = "1.47.1" }
61-
tokio-fs-ext = "0.7.7"
61+
tokio-fs-ext = "0.7.8"
6262
toml = "0.8"
6363
tracing = "0.1.41"
6464
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "fmt"] }

crates/utoo-wasm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ flate2 = "1.1.5"
1616
futures = { workspace = true }
1717
js-sys = "0.3.83"
1818
oneshot = "0.1.11"
19-
opfs-project = "0.2.4"
19+
opfs-project = "0.2.5"
2020
petgraph = "0.6"
2121
reqwest = { version = "0.12.22", default-features = false, features = ["json"] }
2222
rustc-hash = { workspace = true }

crates/utoo-wasm/src/fs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use utoo_ruborist::service::Glob;
1111
use wasm_bindgen::prelude::*;
1212

1313
use crate::errors::to_js_error;
14-
use crate::project::OPFS_PROJECT;
14+
use crate::pm::OPFS_PROJECT;
1515
use crate::tokio_runtime::runtime;
1616

1717
/// OPFS-backed glob implementation.

crates/utoo-wasm/src/opfs_offload.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{io, path::Path};
22
use tokio_fs_ext::{offload, watch, Metadata, ReadDir};
33

4-
use crate::project::{with_project, OPFS_PROJECT};
4+
use crate::pm::{with_project, OPFS_PROJECT};
55

66
pub struct OpfsOffload;
77

@@ -51,7 +51,11 @@ impl offload::FsOffload for OpfsOffload {
5151
}
5252

5353
async fn metadata(&self, path: impl AsRef<Path>) -> io::Result<Metadata> {
54-
tokio_fs_ext::metadata(path).await
54+
let guard = OPFS_PROJECT.read();
55+
let project = guard
56+
.as_ref()
57+
.ok_or_else(|| io::Error::other("OpfsProject not initialised"))?;
58+
project.metadata(path).await
5559
}
5660

5761
async fn watch_dir(

crates/utoo-wasm/src/pack.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub async fn init_pack_project(dev: bool) -> Result<()> {
242242
// Drop the old project
243243
GLOBAL_PACK_PROJECT.write().take();
244244

245-
let cwd = crate::project::with_project(|p| p.cwd().to_string_lossy().to_string());
245+
let cwd = crate::pm::with_project(|p| p.cwd().to_string_lossy().to_string());
246246
let project_root = if cwd.starts_with('/') {
247247
cwd
248248
} else {
@@ -276,6 +276,7 @@ pub async fn init_pack_project(dev: bool) -> Result<()> {
276276
build_id: project_path.clone(),
277277
watch: WatchOptions {
278278
enable: true,
279+
ignored: vec![],
279280
..Default::default()
280281
},
281282
dev,

crates/utoo-wasm/src/pm.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,39 @@
55
//! - Gzip archive creation
66
//! - Dependency resolution
77
//! - Package installation
8+
//! - Global OpfsProject instance management
89
910
use anyhow::{anyhow, Result};
1011
use opfs_project::archive::PackFile;
12+
use parking_lot::RwLock;
1113
use std::path::Path;
1214
use wasm_bindgen::JsCast;
1315

14-
use crate::project::{with_project, OPFS_PROJECT};
1516
use crate::tokio_runtime::{runtime, TOKIO_RUNTIME};
1617

18+
/// Global OpfsProject instance, initialised the first time `Project::init` is called.
19+
pub(crate) static OPFS_PROJECT: RwLock<Option<opfs_project::OpfsProject>> = RwLock::new(None);
20+
21+
/// Get a reference to the global OpfsProject for reading.
22+
///
23+
/// Panics if the project has not been initialised via `Project::init`.
24+
pub(crate) fn with_project<R>(f: impl FnOnce(&opfs_project::OpfsProject) -> R) -> R {
25+
let guard = OPFS_PROJECT.read();
26+
let project = guard
27+
.as_ref()
28+
.expect("OpfsProject not initialised — call Project.init() first");
29+
f(project)
30+
}
31+
32+
/// Get a mutable reference to the global OpfsProject.
33+
pub(crate) fn with_project_mut<R>(f: impl FnOnce(&mut opfs_project::OpfsProject) -> R) -> R {
34+
let mut guard = OPFS_PROJECT.write();
35+
let project = guard
36+
.as_mut()
37+
.expect("OpfsProject not initialised — call Project.init() first");
38+
f(project)
39+
}
40+
1741
/// Calculate MD5 hash of byte content
1842
pub async fn sig_md5(content: Vec<u8>) -> Result<String> {
1943
let result = runtime()
@@ -59,6 +83,7 @@ pub async fn gzip(files: wasm_bindgen::JsValue) -> Result<Vec<u8>> {
5983
/// Generate package-lock.json by resolving dependencies
6084
pub async fn deps(registry: Option<&str>, concurrency: Option<usize>) -> Result<String> {
6185
let cwd = with_project(|p| p.cwd().to_path_buf());
86+
6287
let package_lock =
6388
crate::deps::build_deps_from_file(Path::new(&cwd), registry, concurrency).await?;
6489

crates/utoo-wasm/src/project.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,14 @@ use parking_lot::RwLock;
99
use wasm_bindgen::prelude::*;
1010

1111
use crate::errors::to_js_error;
12-
use crate::pm;
12+
use crate::pm::{self, with_project, OPFS_PROJECT};
1313
use crate::tokio_runtime::init_tokio_runtime;
1414

1515
#[cfg(feature = "utoopack")]
1616
use crate::pack::{self, RootTask};
1717

1818
static GLOBAL_THREAD_URL: RwLock<Option<String>> = RwLock::new(None);
1919

20-
/// Global OpfsProject instance, initialised the first time `Project::init` is called.
21-
pub(crate) static OPFS_PROJECT: RwLock<Option<opfs_project::OpfsProject>> = RwLock::new(None);
22-
23-
/// Get a reference to the global OpfsProject for reading.
24-
///
25-
/// Panics if the project has not been initialised via `Project::init`.
26-
pub(crate) fn with_project<R>(f: impl FnOnce(&opfs_project::OpfsProject) -> R) -> R {
27-
let guard = OPFS_PROJECT.read();
28-
let project = guard
29-
.as_ref()
30-
.expect("OpfsProject not initialised — call Project.init() first");
31-
f(project)
32-
}
33-
34-
/// Get a mutable reference to the global OpfsProject.
35-
pub(crate) fn with_project_mut<R>(f: impl FnOnce(&mut opfs_project::OpfsProject) -> R) -> R {
36-
let mut guard = OPFS_PROJECT.write();
37-
let project = guard
38-
.as_mut()
39-
.expect("OpfsProject not initialised — call Project.init() first");
40-
f(project)
41-
}
42-
4320
#[wasm_bindgen]
4421
pub struct Project;
4522

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,13 @@ export function workerCreated(worker_id: number): void;
194194
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
195195

196196
export interface InitOutput {
197-
readonly ERR_ABORT: () => [number, number];
198-
readonly ERR_INVALID_STATE: () => [number, number];
199-
readonly ERR_KEY_ALREADY_EXISTS: () => [number, number];
200-
readonly ERR_NOT_ALLOWED: () => [number, number];
201-
readonly ERR_NOT_FOUND: () => [number, number];
202-
readonly ERR_NO_MODIFICATION_ALLOWED: () => [number, number];
203-
readonly ERR_QUOTA_EXCEEDED: () => [number, number];
204-
readonly ERR_TYPE_MISMATCH: () => [number, number];
205-
readonly getWasmMemory: () => any;
206-
readonly getWasmModule: () => any;
207197
readonly initLogFilter: (a: number, b: number) => void;
208198
readonly init_pack: () => void;
199+
readonly getWasmMemory: () => any;
200+
readonly getWasmModule: () => any;
201+
readonly __wbg_roottask_free: (a: number, b: number) => void;
202+
readonly registerWorkerScheduler: (a: any, b: any) => void;
203+
readonly workerCreated: (a: number) => void;
209204
readonly __wbg_project_free: (a: number, b: number) => void;
210205
readonly project_build: () => any;
211206
readonly project_cwd: () => [number, number];
@@ -219,6 +214,14 @@ export interface InitOutput {
219214
readonly project_sigMd5: (a: any) => any;
220215
readonly project_updateInfoSubscribe: (a: number, b: any) => void;
221216
readonly project_writeAllToDisk: (a: any) => void;
217+
readonly ERR_ABORT: () => [number, number];
218+
readonly ERR_INVALID_STATE: () => [number, number];
219+
readonly ERR_KEY_ALREADY_EXISTS: () => [number, number];
220+
readonly ERR_NOT_ALLOWED: () => [number, number];
221+
readonly ERR_NOT_FOUND: () => [number, number];
222+
readonly ERR_NO_MODIFICATION_ALLOWED: () => [number, number];
223+
readonly ERR_QUOTA_EXCEEDED: () => [number, number];
224+
readonly ERR_TYPE_MISMATCH: () => [number, number];
222225
readonly __wbg_direntry_free: (a: number, b: number) => void;
223226
readonly __wbg_fs_free: (a: number, b: number) => void;
224227
readonly __wbg_get_direntry_name: (a: number) => [number, number];
@@ -250,9 +253,6 @@ export interface InitOutput {
250253
readonly fs_write: (a: number, b: number, c: any) => any;
251254
readonly fs_writeString: (a: number, b: number, c: number, d: number) => any;
252255
readonly fs_writeSync: (a: number, b: number, c: any) => [number, number];
253-
readonly __wbg_roottask_free: (a: number, b: number) => void;
254-
readonly registerWorkerScheduler: (a: any, b: any) => void;
255-
readonly workerCreated: (a: number) => void;
256256
readonly rust_mi_get_default_heap: () => number;
257257
readonly rust_mi_get_thread_id: () => number;
258258
readonly rust_mi_set_default_heap: (a: number) => void;
@@ -278,16 +278,16 @@ export interface InitOutput {
278278
readonly __wbg_createsyncaccesshandleoptions_free: (a: number, b: number) => void;
279279
readonly wasm_thread_entry_point: (a: number) => void;
280280
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__FnMut_____Output_______: (a: number, b: number) => void;
281-
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__Fn__js_sys_d20acbc549183cf6___Array____Output_______: (a: number, b: number) => void;
282281
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__FnMut__wasm_bindgen_f95c71b28f29bc9d___JsValue____Output_______: (a: number, b: number) => void;
283282
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__FnMut__web_sys_27d1e2f4b4c95162___features__gen_MessageEvent__MessageEvent____Output_______: (a: number, b: number) => void;
284283
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__FnMut_____Output________1_: (a: number, b: number) => void;
285284
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_for__a__core_e1885f5e8fe25124___ops__function__FnMut____a_web_sys_27d1e2f4b4c95162___features__gen_MessageEvent__MessageEvent____Output_______: (a: number, b: number) => void;
285+
readonly wasm_bindgen_f95c71b28f29bc9d___closure__destroy___dyn_core_e1885f5e8fe25124___ops__function__Fn__js_sys_d20acbc549183cf6___Array____Output_______: (a: number, b: number) => void;
286286
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke___js_sys_d20acbc549183cf6___Function__js_sys_d20acbc549183cf6___Function_____: (a: number, b: number, c: any, d: any) => void;
287-
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke___js_sys_d20acbc549183cf6___Array_____: (a: number, b: number, c: any) => void;
288287
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke___wasm_bindgen_f95c71b28f29bc9d___JsValue_____: (a: number, b: number, c: any) => void;
289288
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke___web_sys_27d1e2f4b4c95162___features__gen_MessageEvent__MessageEvent_____: (a: number, b: number, c: any) => void;
290289
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures________invoke___web_sys_27d1e2f4b4c95162___features__gen_MessageEvent__MessageEvent_____: (a: number, b: number, c: any) => void;
290+
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke___js_sys_d20acbc549183cf6___Array_____: (a: number, b: number, c: any) => void;
291291
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke______: (a: number, b: number) => void;
292292
readonly wasm_bindgen_f95c71b28f29bc9d___convert__closures_____invoke_______1_: (a: number, b: number) => void;
293293
readonly memory: WebAssembly.Memory;

0 commit comments

Comments
 (0)