@utoo/web 1.2.0-rc.6 β 1.2.0-rc.7
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 +52 -0
- package/esm/{fe3ccd485f4eb7cd1a1e.wasm β b0afc1b3f31b4fb74f6b.wasm} +0 -0
- package/esm/internalProject.js +4 -1
- package/esm/loaderWorker.js +1 -1
- package/esm/project.js +6 -2
- package/esm/sabcom.d.ts +15 -4
- package/esm/sabcom.js +75 -56
- package/esm/utoo/index.js +6 -6
- package/esm/utoo/index_bg.wasm +0 -0
- package/package.json +5 -6
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
- π **Virtual File System**: Uses Origin Private File System (OPFS) for a Node.js-like file system experience.
|
|
14
|
+
|
|
15
|
+
## π§ Core Concepts
|
|
16
|
+
|
|
17
|
+
1. **Virtual 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. **Service Worker**: Acts as a local server to intercept requests and serve built files for preview.
|
|
21
|
+
|
|
22
|
+
## π¦ Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @utoo/web
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## π οΈ Development
|
|
29
|
+
|
|
30
|
+
### Prerequisites
|
|
31
|
+
|
|
32
|
+
- Rust toolchain (nightly)
|
|
33
|
+
- `wasm-bindgen-cli`
|
|
34
|
+
- `binaryen` (for `wasm-opt`)
|
|
35
|
+
|
|
36
|
+
### Build
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Install toolchain
|
|
40
|
+
npm run install-toolchain
|
|
41
|
+
|
|
42
|
+
# Build WASM and TypeScript
|
|
43
|
+
npm run build
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## π Documentation
|
|
47
|
+
|
|
48
|
+
For detailed API usage and examples, please refer to the [API Documentation](./API.md) ([δΈζη](./API_zh-CN.md)).
|
|
49
|
+
|
|
50
|
+
## οΏ½π License
|
|
51
|
+
|
|
52
|
+
[MIT](./LICENSE)
|
|
Binary file
|
package/esm/internalProject.js
CHANGED
|
@@ -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
|
-
|
|
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;
|