@utoo/web 1.2.0-rc.6 β†’ 1.2.0-rc.8

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 ADDED
@@ -0,0 +1,53 @@
1
+ # @utoo/web
2
+
3
+ > πŸŒ– Web-compatible version of the Utoo toolchain, powered by [Turbopack](https://turbo.build/pack) and WebAssembly.
4
+
5
+ `@utoo/web` brings the power of the Utoo bundler to the browser, leveraging WebAssembly to provide high-performance bundling in non-native environments. It enables a complete web development environment, including a virtual file system and dependency management, entirely within the browser.
6
+
7
+ ## ✨ Features
8
+
9
+ - 🌐 **Browser-based Bundling**: Run the Utoo bundler directly in the browser.
10
+ - ⚑ **WASM Powered**: High performance via WebAssembly bindings of the Turbopack-based core.
11
+ - πŸ› οΈ **Web Worker Support**: Offloads heavy bundling tasks to background workers to keep the UI responsive.
12
+ - πŸ”Œ **Webpack Compatibility**: Supports a subset of Webpack configurations in the browser.
13
+ - πŸ“‚ **Real File System**: Uses Origin Private File System (OPFS) for a Node.js-like file system experience.
14
+
15
+ ## 🧠 Core Concepts
16
+
17
+ 1. **Real File System**: The project lives in the browser's OPFS.
18
+ 2. **Project Main Worker**: Core logic runs in a dedicated worker to keep the UI responsive.
19
+ 3. **Thread Worker**: Heavy bundling tasks are offloaded to a worker powered by a ported `tokio` runtime.
20
+ 4. **Loader Worker**: Executes Webpack loaders in a dedicated worker with Node.js polyfills.
21
+ 5. **Service Worker**: Acts as a local server to intercept requests and serve built files for preview.
22
+
23
+ ## πŸ“¦ Installation
24
+
25
+ ```bash
26
+ npm install @utoo/web
27
+ ```
28
+
29
+ ## πŸ› οΈ Development
30
+
31
+ ### Prerequisites
32
+
33
+ - Rust toolchain (nightly)
34
+ - `wasm-bindgen-cli`
35
+ - `binaryen` (for `wasm-opt`)
36
+
37
+ ### Build
38
+
39
+ ```bash
40
+ # Install toolchain
41
+ npm run install-toolchain
42
+
43
+ # Build WASM and TypeScript
44
+ npm run build
45
+ ```
46
+
47
+ ## πŸ“š Documentation
48
+
49
+ For detailed API usage and examples, please refer to the [API Documentation](./API.md) ([δΈ­ζ–‡η‰ˆ](./API_zh-CN.md)).
50
+
51
+ ## οΏ½πŸ“„ License
52
+
53
+ [MIT](./LICENSE)
@@ -1,3 +1,4 @@
1
+ import * as comlink from "comlink";
1
2
  import initWasm, { init_log_filter, Project as ProjectInternal, } from "./utoo";
2
3
  import { runLoaderWorkerPool } from "./webpackLoaders/loaderWorkerPool";
3
4
  class InternalEndpoint {
@@ -41,6 +42,7 @@ class InternalEndpoint {
41
42
  }
42
43
  else {
43
44
  ret = await ProjectInternal.read(path);
45
+ return comlink.transfer(ret, [ret.buffer]);
44
46
  }
45
47
  return ret;
46
48
  }
@@ -112,7 +114,8 @@ class InternalEndpoint {
112
114
  }
113
115
  async gzip(files) {
114
116
  await this.wasmInit;
115
- return await ProjectInternal.gzip(files);
117
+ const ret = await ProjectInternal.gzip(files);
118
+ return comlink.transfer(ret, [ret.buffer]);
116
119
  }
117
120
  async sigMd5(content) {
118
121
  await this.wasmInit;