@utoo/web 1.2.0-rc.3 → 1.2.0-rc.5
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/{72c61d34e5927ff08d5d.wasm → 8df7dc7828270e8a8ece.wasm} +0 -0
- package/esm/loaderWorker.js +1 -1
- package/esm/loaderWorkerPool.d.ts +1 -1
- package/esm/loaderWorkerPool.js +15 -62
- package/esm/sabcom.d.ts +13 -0
- package/esm/sabcom.js +65 -0
- package/esm/serviceWorker.js +1 -1
- package/esm/utoo/index.d.ts +20 -1
- package/esm/utoo/index.js +91 -62
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/worker/cjs.js +41 -27
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.js +8 -8
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import
|
|
3
|
+
import * as sabcom from "../../../sabcom";
|
|
4
4
|
function resolvePath(p) {
|
|
5
5
|
var _a, _b, _c;
|
|
6
6
|
// @ts-ignore
|
|
@@ -48,7 +48,7 @@ export function readFile(path, options, cb) {
|
|
|
48
48
|
}
|
|
49
49
|
export function readFileSync(path, options) {
|
|
50
50
|
const client = getSabClient();
|
|
51
|
-
const result = client.call(SAB_OP_READ_FILE, resolvePath(path));
|
|
51
|
+
const result = client.call(sabcom.SAB_OP_READ_FILE, resolvePath(path));
|
|
52
52
|
if (options === "utf8" ||
|
|
53
53
|
options === "utf-8" ||
|
|
54
54
|
(options && (options.encoding === "utf8" || options.encoding === "utf-8"))) {
|
|
@@ -58,7 +58,7 @@ export function readFileSync(path, options) {
|
|
|
58
58
|
}
|
|
59
59
|
export function readdirSync(path, options) {
|
|
60
60
|
const client = getSabClient();
|
|
61
|
-
const result = client.call(SAB_OP_READ_DIR, resolvePath(path));
|
|
61
|
+
const result = client.call(sabcom.SAB_OP_READ_DIR, resolvePath(path));
|
|
62
62
|
const json = new TextDecoder().decode(result);
|
|
63
63
|
const entries = JSON.parse(json);
|
|
64
64
|
if (options === null || options === void 0 ? void 0 : options.withFileTypes) {
|
|
@@ -89,7 +89,7 @@ export function writeFileSync(path, data, options) {
|
|
|
89
89
|
// TODO: handle binary data properly
|
|
90
90
|
const content = typeof data === "string" ? data : new TextDecoder().decode(data);
|
|
91
91
|
const payload = JSON.stringify({ path: resolvePath(path), data: content });
|
|
92
|
-
client.call(SAB_OP_WRITE_FILE, payload);
|
|
92
|
+
client.call(sabcom.SAB_OP_WRITE_FILE, payload);
|
|
93
93
|
}
|
|
94
94
|
export function writeFile(path, data, options, cb) {
|
|
95
95
|
if (typeof options === "function") {
|
|
@@ -108,7 +108,7 @@ export function mkdirSync(path, options) {
|
|
|
108
108
|
const client = getSabClient();
|
|
109
109
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
110
110
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
111
|
-
client.call(SAB_OP_MKDIR, payload);
|
|
111
|
+
client.call(sabcom.SAB_OP_MKDIR, payload);
|
|
112
112
|
}
|
|
113
113
|
export function mkdir(path, options, cb) {
|
|
114
114
|
if (typeof options === "function") {
|
|
@@ -127,7 +127,7 @@ export function rmSync(path, options) {
|
|
|
127
127
|
const client = getSabClient();
|
|
128
128
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
129
129
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
130
|
-
client.call(SAB_OP_RM, payload);
|
|
130
|
+
client.call(sabcom.SAB_OP_RM, payload);
|
|
131
131
|
}
|
|
132
132
|
export function rm(path, options, cb) {
|
|
133
133
|
if (typeof options === "function") {
|
|
@@ -146,7 +146,7 @@ export function rmdirSync(path, options) {
|
|
|
146
146
|
const client = getSabClient();
|
|
147
147
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
148
148
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
149
|
-
client.call(SAB_OP_RMDIR, payload);
|
|
149
|
+
client.call(sabcom.SAB_OP_RMDIR, payload);
|
|
150
150
|
}
|
|
151
151
|
export function rmdir(path, options, cb) {
|
|
152
152
|
if (typeof options === "function") {
|
|
@@ -167,7 +167,7 @@ export function copyFileSync(src, dst) {
|
|
|
167
167
|
src: resolvePath(src),
|
|
168
168
|
dst: resolvePath(dst),
|
|
169
169
|
});
|
|
170
|
-
client.call(SAB_OP_COPY_FILE, payload);
|
|
170
|
+
client.call(sabcom.SAB_OP_COPY_FILE, payload);
|
|
171
171
|
}
|
|
172
172
|
export function copyFile(src, dst, cb) {
|
|
173
173
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/web",
|
|
3
|
-
"version": "1.2.0-rc.
|
|
3
|
+
"version": "1.2.0-rc.5",
|
|
4
4
|
"module": "esm/index.js",
|
|
5
5
|
"types": "esm/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"bindgen-build:local": "wasm-bindgen ../../target/wasm32-unknown-unknown/release-local/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web",
|
|
16
16
|
"pretsc": "npm run build --workspace @utoo/pack-shared",
|
|
17
17
|
"tsc": "rm -rf esm && tsc -p ./tsconfig.json",
|
|
18
|
-
"dev": "npm run build-wasm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && cp src/utoo/index_bg.wasm esm/utoo",
|
|
18
|
+
"dev": "npm run build-wasm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && npm run build-loaderWorker && cp src/utoo/index_bg.wasm esm/utoo",
|
|
19
19
|
"dev:pm": "npm run build-wasm:pm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && cp src/utoo/index_bg.wasm esm/utoo",
|
|
20
20
|
"wasm-opt": "wasm-opt src/utoo/index_bg.wasm -o esm/utoo/index_bg.wasm --enable-threads --enable-bulk-memory --enable-nontrapping-float-to-int -Oz",
|
|
21
21
|
"build": "npm run build-wasm -- --release && npm run bindgen-build && npm run tsc && npm run build-loaderWorker && npm run wasm-opt",
|