@utoo/web 0.0.1-alpha.15 → 0.0.1-alpha.17
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/forkedProject.d.ts +22 -0
- package/esm/forkedProject.js +34 -0
- package/esm/index.d.ts +1 -21
- package/esm/index.js +1 -127
- package/esm/project.d.ts +27 -0
- package/esm/project.js +109 -0
- package/esm/serviceWorker.js +6 -0
- package/esm/type.d.ts +6 -0
- package/esm/utoo/index.d.ts +24 -0
- package/esm/utoo/index.js +90 -15
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/worker.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProjectEndpoint } from "./type";
|
|
2
|
+
export declare class ForkedProject implements ProjectEndpoint {
|
|
3
|
+
private endpoint;
|
|
4
|
+
constructor(port: MessagePort);
|
|
5
|
+
install(packageLock: string): Promise<void>;
|
|
6
|
+
build(): Promise<void>;
|
|
7
|
+
readFile(path: string, encoding?: "utf8"): Promise<any>;
|
|
8
|
+
writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
|
|
9
|
+
copyFile(src: string, dst: string): Promise<void>;
|
|
10
|
+
readdir(path: string, options?: {
|
|
11
|
+
recursive?: boolean;
|
|
12
|
+
}): Promise<import("./type").Dirent[]>;
|
|
13
|
+
mkdir(path: string, options?: {
|
|
14
|
+
recursive?: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
rm(path: string, options?: {
|
|
17
|
+
recursive?: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
rmdir(path: string, options?: {
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as comlink from "comlink";
|
|
2
|
+
export class ForkedProject {
|
|
3
|
+
constructor(port) {
|
|
4
|
+
var _a;
|
|
5
|
+
(_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
|
|
6
|
+
}
|
|
7
|
+
async install(packageLock) {
|
|
8
|
+
return await this.endpoint.install(packageLock);
|
|
9
|
+
}
|
|
10
|
+
async build() {
|
|
11
|
+
return await this.endpoint.build();
|
|
12
|
+
}
|
|
13
|
+
async readFile(path, encoding) {
|
|
14
|
+
return (await this.endpoint.readFile(path, encoding));
|
|
15
|
+
}
|
|
16
|
+
async writeFile(path, content, encoding) {
|
|
17
|
+
return await this.endpoint.writeFile(path, content, encoding);
|
|
18
|
+
}
|
|
19
|
+
async copyFile(src, dst) {
|
|
20
|
+
return await this.endpoint.copyFile(src, dst);
|
|
21
|
+
}
|
|
22
|
+
async readdir(path, options) {
|
|
23
|
+
return await this.endpoint.readdir(path, options);
|
|
24
|
+
}
|
|
25
|
+
async mkdir(path, options) {
|
|
26
|
+
return await this.endpoint.mkdir(path, options);
|
|
27
|
+
}
|
|
28
|
+
async rm(path, options) {
|
|
29
|
+
return await this.endpoint.rm(path, options);
|
|
30
|
+
}
|
|
31
|
+
async rmdir(path, options) {
|
|
32
|
+
return await this.endpoint.rmdir(path, options);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,22 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class Project implements ProjectEndpoint {
|
|
3
|
-
#private;
|
|
4
|
-
private serviceWorkerOptions?;
|
|
5
|
-
private remote;
|
|
6
|
-
constructor(options: ProjectOptions);
|
|
7
|
-
private connectWorker;
|
|
8
|
-
installServiceWorker(): Promise<void>;
|
|
9
|
-
install(packageLock: string): Promise<void>;
|
|
10
|
-
build(): Promise<void>;
|
|
11
|
-
readFile(path: string, encoding?: "utf8"): Promise<any>;
|
|
12
|
-
writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
|
|
13
|
-
copyFile(src: string, dst: string): Promise<void>;
|
|
14
|
-
readdir(path: string, options?: {
|
|
15
|
-
recursive?: boolean;
|
|
16
|
-
}): Promise<Dirent[]>;
|
|
17
|
-
mkdir(path: string, options?: {
|
|
18
|
-
recursive?: boolean;
|
|
19
|
-
}): Promise<void>;
|
|
20
|
-
static fork(channel: MessageChannel, eventSource: Client | DedicatedWorkerGlobalScope): ProjectEndpoint;
|
|
21
|
-
}
|
|
1
|
+
export { Project } from "./project";
|
|
22
2
|
export * from "./type";
|
package/esm/index.js
CHANGED
|
@@ -1,128 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _Project_tunnel;
|
|
13
|
-
import * as comlink from "comlink";
|
|
14
|
-
import { Fork, HandShake, ServiceWorkerHandShake } from "./message";
|
|
15
|
-
import { Dirent, } from "./type";
|
|
16
|
-
let ProjectWorker;
|
|
17
|
-
const ConnectedPorts = new Set();
|
|
18
|
-
export class Project {
|
|
19
|
-
constructor(options) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
_Project_tunnel.set(this, void 0);
|
|
22
|
-
const { cwd, workerUrl, wasmUrl, threadWorkerUrl, serviceWorker } = options;
|
|
23
|
-
this.serviceWorkerOptions = serviceWorker;
|
|
24
|
-
const { port1, port2 } = new MessageChannel();
|
|
25
|
-
(_a = this.remote) !== null && _a !== void 0 ? _a : (this.remote = comlink.wrap(port1));
|
|
26
|
-
if (!ProjectWorker) {
|
|
27
|
-
ProjectWorker = workerUrl
|
|
28
|
-
? new Worker(workerUrl)
|
|
29
|
-
: new Worker(new URL("./worker", import.meta.url));
|
|
30
|
-
window.addEventListener("message", (e) => {
|
|
31
|
-
this.connectWorker(e);
|
|
32
|
-
});
|
|
33
|
-
if (this.serviceWorkerOptions) {
|
|
34
|
-
navigator.serviceWorker.addEventListener("message", (e) => {
|
|
35
|
-
this.connectWorker(e);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
ProjectWorker.postMessage(HandShake, [port2]);
|
|
40
|
-
__classPrivateFieldSet(this, _Project_tunnel, (_b = __classPrivateFieldGet(this, _Project_tunnel, "f")) !== null && _b !== void 0 ? _b : this.remote.mount({
|
|
41
|
-
cwd,
|
|
42
|
-
wasmUrl,
|
|
43
|
-
threadWorkerUrl,
|
|
44
|
-
}), "f");
|
|
45
|
-
}
|
|
46
|
-
connectWorker(e) {
|
|
47
|
-
const port = e.ports[0];
|
|
48
|
-
if (e.data === Fork && !ConnectedPorts.has(port)) {
|
|
49
|
-
ProjectWorker.postMessage(HandShake, [port]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async installServiceWorker() {
|
|
53
|
-
var _a;
|
|
54
|
-
if (this.serviceWorkerOptions) {
|
|
55
|
-
const { url, scope } = this.serviceWorkerOptions;
|
|
56
|
-
// Should add "Service-Worker-Allowed": "/" in page root response,
|
|
57
|
-
await navigator.serviceWorker.register(url, { scope: "/" });
|
|
58
|
-
(_a = navigator.serviceWorker.controller) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
59
|
-
[ServiceWorkerHandShake]: true,
|
|
60
|
-
scope,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async install(packageLock) {
|
|
65
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
66
|
-
return await this.remote.install(packageLock);
|
|
67
|
-
}
|
|
68
|
-
async build() {
|
|
69
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
70
|
-
return await this.remote.build();
|
|
71
|
-
}
|
|
72
|
-
async readFile(path, encoding) {
|
|
73
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
74
|
-
return (await this.remote.readFile(path, encoding));
|
|
75
|
-
}
|
|
76
|
-
async writeFile(path, content, encoding) {
|
|
77
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
78
|
-
return await this.remote.writeFile(path, content, encoding);
|
|
79
|
-
}
|
|
80
|
-
async copyFile(src, dst) {
|
|
81
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
82
|
-
return await this.remote.copyFile(src, dst);
|
|
83
|
-
}
|
|
84
|
-
async readdir(path, options) {
|
|
85
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
86
|
-
const dirEntry = (await this.remote.readdir(path, options));
|
|
87
|
-
return dirEntry.map((e) => new Dirent(e));
|
|
88
|
-
}
|
|
89
|
-
async mkdir(path, options) {
|
|
90
|
-
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
91
|
-
return await this.remote.mkdir(path, options);
|
|
92
|
-
}
|
|
93
|
-
static fork(channel, eventSource) {
|
|
94
|
-
eventSource.postMessage(Fork, {
|
|
95
|
-
transfer: [channel.port2],
|
|
96
|
-
});
|
|
97
|
-
return new ForkedProject(channel.port1);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
_Project_tunnel = new WeakMap();
|
|
101
|
-
class ForkedProject {
|
|
102
|
-
constructor(port) {
|
|
103
|
-
var _a;
|
|
104
|
-
(_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
|
|
105
|
-
}
|
|
106
|
-
async install(packageLock) {
|
|
107
|
-
return await this.endpoint.install(packageLock);
|
|
108
|
-
}
|
|
109
|
-
async build() {
|
|
110
|
-
return await this.endpoint.build();
|
|
111
|
-
}
|
|
112
|
-
async readFile(path, encoding) {
|
|
113
|
-
return (await this.endpoint.readFile(path, encoding));
|
|
114
|
-
}
|
|
115
|
-
async writeFile(path, content, encoding) {
|
|
116
|
-
return await this.endpoint.writeFile(path, content, encoding);
|
|
117
|
-
}
|
|
118
|
-
async copyFile(src, dst) {
|
|
119
|
-
return await this.endpoint.copyFile(src, dst);
|
|
120
|
-
}
|
|
121
|
-
async readdir(path, options) {
|
|
122
|
-
return await this.endpoint.readdir(path, options);
|
|
123
|
-
}
|
|
124
|
-
async mkdir(path, options) {
|
|
125
|
-
return await this.endpoint.mkdir(path, options);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
1
|
+
export { Project } from "./project";
|
|
128
2
|
export * from "./type";
|
package/esm/project.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dirent, ProjectEndpoint, ProjectOptions } from "./type";
|
|
2
|
+
export declare class Project implements ProjectEndpoint {
|
|
3
|
+
#private;
|
|
4
|
+
private serviceWorkerOptions?;
|
|
5
|
+
private remote;
|
|
6
|
+
constructor(options: ProjectOptions);
|
|
7
|
+
private connectWorker;
|
|
8
|
+
installServiceWorker(): Promise<void>;
|
|
9
|
+
install(packageLock: string): Promise<void>;
|
|
10
|
+
build(): Promise<void>;
|
|
11
|
+
readFile(path: string, encoding?: "utf8"): Promise<any>;
|
|
12
|
+
writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
|
|
13
|
+
copyFile(src: string, dst: string): Promise<void>;
|
|
14
|
+
readdir(path: string, options?: {
|
|
15
|
+
recursive?: boolean;
|
|
16
|
+
}): Promise<Dirent[]>;
|
|
17
|
+
mkdir(path: string, options?: {
|
|
18
|
+
recursive?: boolean;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
rm(path: string, options?: {
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
rmdir(path: string, options?: {
|
|
24
|
+
recursive?: boolean;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
static fork(channel: MessageChannel, eventSource: Client | DedicatedWorkerGlobalScope): ProjectEndpoint;
|
|
27
|
+
}
|
package/esm/project.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
+
};
|
|
12
|
+
var _Project_tunnel;
|
|
13
|
+
import * as comlink from "comlink";
|
|
14
|
+
import { ForkedProject } from "./forkedProject";
|
|
15
|
+
import { Fork, HandShake, ServiceWorkerHandShake } from "./message";
|
|
16
|
+
import { Dirent, } from "./type";
|
|
17
|
+
let ProjectWorker;
|
|
18
|
+
const ConnectedPorts = new Set();
|
|
19
|
+
export class Project {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
_Project_tunnel.set(this, void 0);
|
|
23
|
+
const { cwd, workerUrl, wasmUrl, threadWorkerUrl, serviceWorker } = options;
|
|
24
|
+
this.serviceWorkerOptions = serviceWorker;
|
|
25
|
+
const { port1, port2 } = new MessageChannel();
|
|
26
|
+
(_a = this.remote) !== null && _a !== void 0 ? _a : (this.remote = comlink.wrap(port1));
|
|
27
|
+
if (!ProjectWorker) {
|
|
28
|
+
ProjectWorker = workerUrl
|
|
29
|
+
? new Worker(workerUrl)
|
|
30
|
+
: new Worker(new URL("./worker", import.meta.url));
|
|
31
|
+
window.addEventListener("message", (e) => {
|
|
32
|
+
this.connectWorker(e);
|
|
33
|
+
});
|
|
34
|
+
if (this.serviceWorkerOptions) {
|
|
35
|
+
navigator.serviceWorker.addEventListener("message", (e) => {
|
|
36
|
+
this.connectWorker(e);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
ProjectWorker.postMessage(HandShake, [port2]);
|
|
41
|
+
__classPrivateFieldSet(this, _Project_tunnel, (_b = __classPrivateFieldGet(this, _Project_tunnel, "f")) !== null && _b !== void 0 ? _b : this.remote.mount({
|
|
42
|
+
cwd,
|
|
43
|
+
wasmUrl,
|
|
44
|
+
threadWorkerUrl,
|
|
45
|
+
}), "f");
|
|
46
|
+
}
|
|
47
|
+
connectWorker(e) {
|
|
48
|
+
const port = e.ports[0];
|
|
49
|
+
if (e.data === Fork && !ConnectedPorts.has(port)) {
|
|
50
|
+
ProjectWorker.postMessage(HandShake, [port]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async installServiceWorker() {
|
|
54
|
+
var _a;
|
|
55
|
+
if (this.serviceWorkerOptions) {
|
|
56
|
+
const { url, scope } = this.serviceWorkerOptions;
|
|
57
|
+
// Should add "Service-Worker-Allowed": "/" in page root response headers,
|
|
58
|
+
await navigator.serviceWorker.register(url, { scope: "/" });
|
|
59
|
+
(_a = navigator.serviceWorker.controller) === null || _a === void 0 ? void 0 : _a.postMessage({
|
|
60
|
+
[ServiceWorkerHandShake]: true,
|
|
61
|
+
scope,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async install(packageLock) {
|
|
66
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
67
|
+
return await this.remote.install(packageLock);
|
|
68
|
+
}
|
|
69
|
+
async build() {
|
|
70
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
71
|
+
return await this.remote.build();
|
|
72
|
+
}
|
|
73
|
+
async readFile(path, encoding) {
|
|
74
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
75
|
+
return (await this.remote.readFile(path, encoding));
|
|
76
|
+
}
|
|
77
|
+
async writeFile(path, content, encoding) {
|
|
78
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
79
|
+
return await this.remote.writeFile(path, content, encoding);
|
|
80
|
+
}
|
|
81
|
+
async copyFile(src, dst) {
|
|
82
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
83
|
+
return await this.remote.copyFile(src, dst);
|
|
84
|
+
}
|
|
85
|
+
async readdir(path, options) {
|
|
86
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
87
|
+
const dirEntry = (await this.remote.readdir(path, options));
|
|
88
|
+
return dirEntry.map((e) => new Dirent(e));
|
|
89
|
+
}
|
|
90
|
+
async mkdir(path, options) {
|
|
91
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
92
|
+
return await this.remote.mkdir(path, options);
|
|
93
|
+
}
|
|
94
|
+
async rm(path, options) {
|
|
95
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
96
|
+
return await this.remote.rm(path, options);
|
|
97
|
+
}
|
|
98
|
+
async rmdir(path, options) {
|
|
99
|
+
await __classPrivateFieldGet(this, _Project_tunnel, "f");
|
|
100
|
+
return await this.remote.rmdir(path, options);
|
|
101
|
+
}
|
|
102
|
+
static fork(channel, eventSource) {
|
|
103
|
+
eventSource.postMessage(Fork, {
|
|
104
|
+
transfer: [channel.port2],
|
|
105
|
+
});
|
|
106
|
+
return new ForkedProject(channel.port1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
_Project_tunnel = new WeakMap();
|
package/esm/serviceWorker.js
CHANGED
|
@@ -6,6 +6,12 @@ let _promise = new Promise((resolve) => {
|
|
|
6
6
|
});
|
|
7
7
|
let _projectEndpoint;
|
|
8
8
|
let _serviceWorkerScope;
|
|
9
|
+
self.addEventListener("install", (event) => {
|
|
10
|
+
event.waitUntil(self.skipWaiting());
|
|
11
|
+
});
|
|
12
|
+
self.addEventListener("activate", (event) => {
|
|
13
|
+
event.waitUntil(self.clients.claim());
|
|
14
|
+
});
|
|
9
15
|
self.addEventListener("message", (event) => {
|
|
10
16
|
if (event.data && event.data[ServiceWorkerHandShake] === true) {
|
|
11
17
|
_serviceWorkerScope = event.data.scope;
|
package/esm/type.d.ts
CHANGED
|
@@ -22,6 +22,12 @@ export interface ProjectEndpoint {
|
|
|
22
22
|
mkdir(path: string, options?: {
|
|
23
23
|
recursive?: boolean;
|
|
24
24
|
}): Promise<void>;
|
|
25
|
+
rm(path: string, options?: {
|
|
26
|
+
recursive?: boolean;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
rmdir(path: string, options?: {
|
|
29
|
+
recursive?: boolean;
|
|
30
|
+
}): Promise<void>;
|
|
25
31
|
copyFile(src: string, dst: string): Promise<void>;
|
|
26
32
|
}
|
|
27
33
|
export interface ProjectOptions {
|
package/esm/utoo/index.d.ts
CHANGED
|
@@ -37,6 +37,14 @@ export class DirEntry {
|
|
|
37
37
|
*/
|
|
38
38
|
get type(): DirEntryType;
|
|
39
39
|
}
|
|
40
|
+
export class Metadata {
|
|
41
|
+
static __wrap(ptr: any): any;
|
|
42
|
+
toJSON(): {};
|
|
43
|
+
toString(): string;
|
|
44
|
+
__destroy_into_raw(): number | undefined;
|
|
45
|
+
__wbg_ptr: number | undefined;
|
|
46
|
+
free(): void;
|
|
47
|
+
}
|
|
40
48
|
export class Project {
|
|
41
49
|
/**
|
|
42
50
|
* @param {string} cwd
|
|
@@ -102,6 +110,22 @@ export class Project {
|
|
|
102
110
|
* @returns {Promise<void>}
|
|
103
111
|
*/
|
|
104
112
|
copyFile(src: string, dst: string): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* @param {string} path
|
|
115
|
+
* @returns {Promise<void>}
|
|
116
|
+
*/
|
|
117
|
+
removeFile(path: string): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* @param {string} path
|
|
120
|
+
* @param {boolean} recursive
|
|
121
|
+
* @returns {Promise<void>}
|
|
122
|
+
*/
|
|
123
|
+
removeDir(path: string, recursive: boolean): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* @param {string} path
|
|
126
|
+
* @returns {Promise<Metadata>}
|
|
127
|
+
*/
|
|
128
|
+
metadata(path: string): Promise<Metadata>;
|
|
105
129
|
}
|
|
106
130
|
export default __wbg_init;
|
|
107
131
|
export function initSync(module: any, memory: any): any;
|
package/esm/utoo/index.js
CHANGED
|
@@ -200,15 +200,15 @@ function debugString(val) {
|
|
|
200
200
|
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
201
201
|
return className;
|
|
202
202
|
}
|
|
203
|
-
export function init_pack() {
|
|
204
|
-
wasm.init_pack();
|
|
205
|
-
}
|
|
206
203
|
function passArray8ToWasm0(arg, malloc) {
|
|
207
204
|
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
208
205
|
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
209
206
|
WASM_VECTOR_LEN = arg.length;
|
|
210
207
|
return ptr;
|
|
211
208
|
}
|
|
209
|
+
export function init_pack() {
|
|
210
|
+
wasm.init_pack();
|
|
211
|
+
}
|
|
212
212
|
/**
|
|
213
213
|
* Entry point for web workers
|
|
214
214
|
* @param {number} ptr
|
|
@@ -339,6 +339,34 @@ export class DirEntry {
|
|
|
339
339
|
wasm.__wbg_set_direntry_type(this.__wbg_ptr, (__wbindgen_enum_DirEntryType.indexOf(arg0) + 1 || 3) - 1);
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
|
+
const MetadataFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
343
|
+
? { register: () => { }, unregister: () => { } }
|
|
344
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_metadata_free(ptr >>> 0, 1));
|
|
345
|
+
export class Metadata {
|
|
346
|
+
static __wrap(ptr) {
|
|
347
|
+
ptr = ptr >>> 0;
|
|
348
|
+
const obj = Object.create(Metadata.prototype);
|
|
349
|
+
obj.__wbg_ptr = ptr;
|
|
350
|
+
MetadataFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
351
|
+
return obj;
|
|
352
|
+
}
|
|
353
|
+
toJSON() {
|
|
354
|
+
return {};
|
|
355
|
+
}
|
|
356
|
+
toString() {
|
|
357
|
+
return JSON.stringify(this);
|
|
358
|
+
}
|
|
359
|
+
__destroy_into_raw() {
|
|
360
|
+
const ptr = this.__wbg_ptr;
|
|
361
|
+
this.__wbg_ptr = 0;
|
|
362
|
+
MetadataFinalization.unregister(this);
|
|
363
|
+
return ptr;
|
|
364
|
+
}
|
|
365
|
+
free() {
|
|
366
|
+
const ptr = this.__destroy_into_raw();
|
|
367
|
+
wasm.__wbg_metadata_free(ptr, 0);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
342
370
|
const ProjectFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
343
371
|
? { register: () => { }, unregister: () => { } }
|
|
344
372
|
: new FinalizationRegistry(ptr => wasm.__wbg_project_free(ptr >>> 0, 1));
|
|
@@ -493,6 +521,37 @@ export class Project {
|
|
|
493
521
|
const ret = wasm.project_copyFile(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
494
522
|
return takeObject(ret);
|
|
495
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* @param {string} path
|
|
526
|
+
* @returns {Promise<void>}
|
|
527
|
+
*/
|
|
528
|
+
removeFile(path) {
|
|
529
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
530
|
+
const len0 = WASM_VECTOR_LEN;
|
|
531
|
+
const ret = wasm.project_removeFile(this.__wbg_ptr, ptr0, len0);
|
|
532
|
+
return takeObject(ret);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* @param {string} path
|
|
536
|
+
* @param {boolean} recursive
|
|
537
|
+
* @returns {Promise<void>}
|
|
538
|
+
*/
|
|
539
|
+
removeDir(path, recursive) {
|
|
540
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
541
|
+
const len0 = WASM_VECTOR_LEN;
|
|
542
|
+
const ret = wasm.project_removeDir(this.__wbg_ptr, ptr0, len0, recursive);
|
|
543
|
+
return takeObject(ret);
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* @param {string} path
|
|
547
|
+
* @returns {Promise<Metadata>}
|
|
548
|
+
*/
|
|
549
|
+
metadata(path) {
|
|
550
|
+
const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
551
|
+
const len0 = WASM_VECTOR_LEN;
|
|
552
|
+
const ret = wasm.project_metadata(this.__wbg_ptr, ptr0, len0);
|
|
553
|
+
return takeObject(ret);
|
|
554
|
+
}
|
|
496
555
|
}
|
|
497
556
|
async function __wbg_load(module, imports) {
|
|
498
557
|
if (typeof Response === 'function' && module instanceof Response) {
|
|
@@ -770,6 +829,10 @@ function __wbg_get_imports() {
|
|
|
770
829
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
771
830
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
772
831
|
};
|
|
832
|
+
imports.wbg.__wbg_metadata_new = function (arg0) {
|
|
833
|
+
const ret = Metadata.__wrap(arg0);
|
|
834
|
+
return addHeapObject(ret);
|
|
835
|
+
};
|
|
773
836
|
imports.wbg.__wbg_name_f2d27098bfd843e7 = function (arg0, arg1) {
|
|
774
837
|
const ret = getObject(arg1).name;
|
|
775
838
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
|
|
@@ -932,6 +995,12 @@ function __wbg_get_imports() {
|
|
|
932
995
|
const ret = Math.random();
|
|
933
996
|
return ret;
|
|
934
997
|
};
|
|
998
|
+
imports.wbg.__wbg_read_b863f640f1437745 = function () {
|
|
999
|
+
return handleError(function (arg0, arg1, arg2) {
|
|
1000
|
+
const ret = getObject(arg0).read(getArrayU8FromWasm0(arg1, arg2));
|
|
1001
|
+
return ret;
|
|
1002
|
+
}, arguments);
|
|
1003
|
+
};
|
|
935
1004
|
imports.wbg.__wbg_read_f8fdd4b410209222 = function () {
|
|
936
1005
|
return handleError(function (arg0, arg1, arg2, arg3) {
|
|
937
1006
|
const ret = getObject(arg0).read(getArrayU8FromWasm0(arg1, arg2), getObject(arg3));
|
|
@@ -1126,6 +1195,12 @@ function __wbg_get_imports() {
|
|
|
1126
1195
|
return ret;
|
|
1127
1196
|
}, arguments);
|
|
1128
1197
|
};
|
|
1198
|
+
imports.wbg.__wbg_write_978b8e385470e7a9 = function () {
|
|
1199
|
+
return handleError(function (arg0, arg1, arg2) {
|
|
1200
|
+
const ret = getObject(arg0).write(getArrayU8FromWasm0(arg1, arg2));
|
|
1201
|
+
return ret;
|
|
1202
|
+
}, arguments);
|
|
1203
|
+
};
|
|
1129
1204
|
imports.wbg.__wbindgen_array_new = function () {
|
|
1130
1205
|
const ret = [];
|
|
1131
1206
|
return addHeapObject(ret);
|
|
@@ -1150,28 +1225,28 @@ function __wbg_get_imports() {
|
|
|
1150
1225
|
const ret = false;
|
|
1151
1226
|
return ret;
|
|
1152
1227
|
};
|
|
1153
|
-
imports.wbg.
|
|
1154
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1228
|
+
imports.wbg.__wbindgen_closure_wrapper163189 = function (arg0, arg1, arg2) {
|
|
1229
|
+
const ret = makeMutClosure(arg0, arg1, 9520, __wbg_adapter_49);
|
|
1155
1230
|
return addHeapObject(ret);
|
|
1156
1231
|
};
|
|
1157
|
-
imports.wbg.
|
|
1158
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1232
|
+
imports.wbg.__wbindgen_closure_wrapper163191 = function (arg0, arg1, arg2) {
|
|
1233
|
+
const ret = makeMutClosure(arg0, arg1, 2008, __wbg_adapter_49);
|
|
1159
1234
|
return addHeapObject(ret);
|
|
1160
1235
|
};
|
|
1161
|
-
imports.wbg.
|
|
1162
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1236
|
+
imports.wbg.__wbindgen_closure_wrapper168988 = function (arg0, arg1, arg2) {
|
|
1237
|
+
const ret = makeMutClosure(arg0, arg1, 9520, __wbg_adapter_49);
|
|
1163
1238
|
return addHeapObject(ret);
|
|
1164
1239
|
};
|
|
1165
|
-
imports.wbg.
|
|
1166
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1240
|
+
imports.wbg.__wbindgen_closure_wrapper169042 = function (arg0, arg1, arg2) {
|
|
1241
|
+
const ret = makeMutClosure(arg0, arg1, 9523, __wbg_adapter_56);
|
|
1167
1242
|
return addHeapObject(ret);
|
|
1168
1243
|
};
|
|
1169
|
-
imports.wbg.
|
|
1170
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1244
|
+
imports.wbg.__wbindgen_closure_wrapper169065 = function (arg0, arg1, arg2) {
|
|
1245
|
+
const ret = makeMutClosure(arg0, arg1, 9527, __wbg_adapter_46);
|
|
1171
1246
|
return addHeapObject(ret);
|
|
1172
1247
|
};
|
|
1173
|
-
imports.wbg.
|
|
1174
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1248
|
+
imports.wbg.__wbindgen_closure_wrapper30132 = function (arg0, arg1, arg2) {
|
|
1249
|
+
const ret = makeMutClosure(arg0, arg1, 2008, __wbg_adapter_46);
|
|
1175
1250
|
return addHeapObject(ret);
|
|
1176
1251
|
};
|
|
1177
1252
|
imports.wbg.__wbindgen_debug_string = function (arg0, arg1) {
|
package/esm/utoo/index_bg.wasm
CHANGED
|
Binary file
|
package/esm/worker.js
CHANGED
|
@@ -71,6 +71,23 @@ const projectEndpoint = {
|
|
|
71
71
|
return await this.projectInternal.createDir(path);
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
+
async rm(path, options) {
|
|
75
|
+
await this.wasmInit;
|
|
76
|
+
let metadata = (await this.projectInternal.metadata(path)).toJSON();
|
|
77
|
+
switch (metadata.type) {
|
|
78
|
+
case "file":
|
|
79
|
+
return await this.projectInternal.removeFile(path);
|
|
80
|
+
case "directory":
|
|
81
|
+
return await this.projectInternal.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
82
|
+
default:
|
|
83
|
+
// nothing to remove now
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
async rmdir(path, options) {
|
|
88
|
+
await this.wasmInit;
|
|
89
|
+
return await this.projectInternal.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
90
|
+
},
|
|
74
91
|
};
|
|
75
92
|
const ConnectedPorts = new Set();
|
|
76
93
|
self.addEventListener("message", (e) => {
|