@utoo/web 0.0.1-alpha.3 → 0.0.1-alpha.9
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/esm/index.d.ts +14 -9
- package/esm/index.js +29 -31
- package/esm/type.d.ts +20 -7
- package/esm/type.js +12 -1
- package/esm/utoo/index.d.ts +21 -34
- package/esm/utoo/index.js +452 -174
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/worker.d.ts +4 -1
- package/esm/worker.js +52 -14
- package/package.json +11 -5
package/esm/utoo/index_bg.wasm
CHANGED
|
Binary file
|
package/esm/worker.d.ts
CHANGED
package/esm/worker.js
CHANGED
|
@@ -3,33 +3,71 @@ import { HandShake } from "./message";
|
|
|
3
3
|
import initWasm, { Project as ProjectInternal } from "./utoo";
|
|
4
4
|
const projectEndpoint = {
|
|
5
5
|
projectInternal: undefined,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
wasmInit: undefined,
|
|
7
|
+
// This should be called only once
|
|
8
|
+
async mount(opt) {
|
|
9
|
+
const { cwd, wasmUrl } = opt;
|
|
10
|
+
this.wasmInit = initWasm(wasmUrl);
|
|
8
11
|
this.projectInternal = new ProjectInternal(cwd);
|
|
12
|
+
return;
|
|
9
13
|
},
|
|
10
14
|
async install(packageLock) {
|
|
15
|
+
await this.wasmInit;
|
|
11
16
|
await this.projectInternal.install(packageLock);
|
|
17
|
+
return;
|
|
12
18
|
},
|
|
13
19
|
async build() {
|
|
14
|
-
await this.
|
|
20
|
+
await this.wasmInit;
|
|
21
|
+
return await this.projectInternal.build();
|
|
15
22
|
},
|
|
16
|
-
async readFile(path) {
|
|
17
|
-
|
|
23
|
+
async readFile(path, encoding) {
|
|
24
|
+
await this.wasmInit;
|
|
25
|
+
let ret;
|
|
26
|
+
if (encoding === "utf8") {
|
|
27
|
+
ret = await this.projectInternal.readToString(path);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
ret = await this.projectInternal.read(path);
|
|
31
|
+
}
|
|
32
|
+
return ret;
|
|
18
33
|
},
|
|
19
|
-
async writeFile(path, content) {
|
|
20
|
-
|
|
34
|
+
async writeFile(path, content, _encoding) {
|
|
35
|
+
await this.wasmInit;
|
|
36
|
+
if (typeof content === "string") {
|
|
37
|
+
return await this.projectInternal.writeString(path, content);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return await this.projectInternal.write(path, content);
|
|
41
|
+
}
|
|
21
42
|
},
|
|
22
43
|
async copyFile(src, dst) {
|
|
44
|
+
await this.wasmInit;
|
|
23
45
|
return await this.projectInternal.copyFile(src, dst);
|
|
24
46
|
},
|
|
25
|
-
async
|
|
26
|
-
|
|
47
|
+
async readdir(path, options) {
|
|
48
|
+
await this.wasmInit;
|
|
49
|
+
const dirEntries = (options === null || options === void 0 ? void 0 : options.recursive)
|
|
50
|
+
? await this.projectInternal.readDir(path)
|
|
51
|
+
: // TODO: support recursive readDirAll
|
|
52
|
+
await this.projectInternal.readDir(path);
|
|
53
|
+
const rawDirents = dirEntries.map((e) => {
|
|
54
|
+
const dir = e.toJSON();
|
|
55
|
+
return {
|
|
56
|
+
name: dir.name,
|
|
57
|
+
type: dir.type,
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
// WARN: This is a hack, functions can not be structurally cloned
|
|
61
|
+
return rawDirents;
|
|
27
62
|
},
|
|
28
|
-
async
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
63
|
+
async mkdir(path, options) {
|
|
64
|
+
await this.wasmInit;
|
|
65
|
+
if (options === null || options === void 0 ? void 0 : options.recursive) {
|
|
66
|
+
return await this.projectInternal.createDirAll(path);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
return await this.projectInternal.createDir(path);
|
|
70
|
+
}
|
|
33
71
|
},
|
|
34
72
|
};
|
|
35
73
|
const ConnectedPorts = new Set();
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/web",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.9",
|
|
4
4
|
"module": "esm/index.js",
|
|
5
5
|
"types": "esm/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"esm/*"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
10
|
+
"install-toolchain": "cargo install wasm-bindgen-cli && brew install binaryen",
|
|
11
|
+
"build-wasm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown -Z build-std=panic_abort,std",
|
|
12
|
+
"build-wasm:pm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown --no-default-features -Z build-std=panic_abort,std",
|
|
13
|
+
"bindgen-dev": "wasm-bindgen ../../target/wasm32-unknown-unknown/wasm-dev/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web --debug --keep-debug --no-demangle",
|
|
14
|
+
"bindgen-build": "wasm-bindgen ../../target/wasm32-unknown-unknown/wasm-release/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web",
|
|
11
15
|
"tsx": "rm -rf esm && tsc -p ./tsconfig.json",
|
|
12
|
-
"dev": "npm run
|
|
13
|
-
"
|
|
16
|
+
"dev": "npm run build-wasm -- --profile wasm-dev && npm run bindgen-dev && npm run tsx && cp src/utoo/index_bg.wasm esm/utoo",
|
|
17
|
+
"dev:pm": "npm run build-wasm:pm -- --profile wasm-dev && npm run bindgen-dev && npm run tsx && cp src/utoo/index_bg.wasm esm/utoo",
|
|
18
|
+
"build": "npm run build-wasm -- --profile wasm-release && npm run bindgen-build && npm run tsx && wasm-opt src/utoo/index_bg.wasm -o esm/utoo/index_bg.wasm --enable-threads --enable-bulk-memory --enable-nontrapping-float-to-int -O4",
|
|
14
19
|
"prepublishOnly": "npm run build"
|
|
15
20
|
},
|
|
16
21
|
"dependencies": {
|
|
@@ -23,5 +28,6 @@
|
|
|
23
28
|
"node": ">= 20"
|
|
24
29
|
},
|
|
25
30
|
"author": "xusd320",
|
|
26
|
-
"license": "MIT"
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": "git@github.com:umijs/mako.git"
|
|
27
33
|
}
|