@utoo/web 1.2.7 → 1.2.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/esm/loaderWorker.js +1 -1
- package/esm/message.d.ts +19 -0
- package/esm/message.js +21 -0
- package/esm/project/InternalProject.js +17 -17
- package/esm/project/Project.js +6 -6
- package/esm/{serviceWorker.js → serviceWorker/index.js} +49 -5
- package/esm/{utils/installServiceWorker.js → serviceWorker/install.js} +20 -2
- package/esm/utoo/index.d.ts +100 -87
- package/esm/utoo/index.js +1506 -1464
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/loaderWorkerPool.d.ts +1 -2
- package/esm/webpackLoaders/loaderWorkerPool.js +5 -6
- package/esm/webpackLoaders/worker.js +2 -6
- package/esm/worker.js +3 -2
- package/package.json +2 -2
- package/esm/utils/message.d.ts +0 -3
- package/esm/utils/message.js +0 -3
- /package/esm/{serviceWorker.d.ts → serviceWorker/index.d.ts} +0 -0
- /package/esm/{utils/installServiceWorker.d.ts → serviceWorker/install.d.ts} +0 -0
package/esm/message.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum WorkerMessageType {
|
|
2
|
+
InitConnection = 1464664064,// "WM" in hex
|
|
3
|
+
RequestFork = 1464664065
|
|
4
|
+
}
|
|
5
|
+
/** @deprecated use WorkerMessageType.InitConnection */
|
|
6
|
+
export declare const HandShake = WorkerMessageType.InitConnection;
|
|
7
|
+
/** @deprecated use WorkerMessageType.RequestFork */
|
|
8
|
+
export declare const Fork = WorkerMessageType.RequestFork;
|
|
9
|
+
export declare enum SWMessageType {
|
|
10
|
+
HandShake = 1398210560,// "SW" in hex
|
|
11
|
+
HeartbeatPing = 1398210561,
|
|
12
|
+
HeartbeatPong = 1398210562
|
|
13
|
+
}
|
|
14
|
+
/** @deprecated use SWMessageType */
|
|
15
|
+
export declare const ServiceWorkerHandShake = SWMessageType.HandShake;
|
|
16
|
+
/** @deprecated use SWMessageType */
|
|
17
|
+
export declare const ServiceWorkerHeartbeatPing = SWMessageType.HeartbeatPing;
|
|
18
|
+
/** @deprecated use SWMessageType */
|
|
19
|
+
export declare const ServiceWorkerHeartbeatPong = SWMessageType.HeartbeatPong;
|
package/esm/message.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export var WorkerMessageType;
|
|
2
|
+
(function (WorkerMessageType) {
|
|
3
|
+
WorkerMessageType[WorkerMessageType["InitConnection"] = 1464664064] = "InitConnection";
|
|
4
|
+
WorkerMessageType[WorkerMessageType["RequestFork"] = 1464664065] = "RequestFork";
|
|
5
|
+
})(WorkerMessageType || (WorkerMessageType = {}));
|
|
6
|
+
/** @deprecated use WorkerMessageType.InitConnection */
|
|
7
|
+
export const HandShake = WorkerMessageType.InitConnection;
|
|
8
|
+
/** @deprecated use WorkerMessageType.RequestFork */
|
|
9
|
+
export const Fork = WorkerMessageType.RequestFork;
|
|
10
|
+
export var SWMessageType;
|
|
11
|
+
(function (SWMessageType) {
|
|
12
|
+
SWMessageType[SWMessageType["HandShake"] = 1398210560] = "HandShake";
|
|
13
|
+
SWMessageType[SWMessageType["HeartbeatPing"] = 1398210561] = "HeartbeatPing";
|
|
14
|
+
SWMessageType[SWMessageType["HeartbeatPong"] = 1398210562] = "HeartbeatPong";
|
|
15
|
+
})(SWMessageType || (SWMessageType = {}));
|
|
16
|
+
/** @deprecated use SWMessageType */
|
|
17
|
+
export const ServiceWorkerHandShake = SWMessageType.HandShake;
|
|
18
|
+
/** @deprecated use SWMessageType */
|
|
19
|
+
export const ServiceWorkerHeartbeatPing = SWMessageType.HeartbeatPing;
|
|
20
|
+
/** @deprecated use SWMessageType */
|
|
21
|
+
export const ServiceWorkerHeartbeatPong = SWMessageType.HeartbeatPong;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import initWasm, { initLogFilter, Project as ProjectInternal, } from "../utoo";
|
|
1
|
+
import initWasm, { Fs, initLogFilter, Project as ProjectInternal, } from "../utoo";
|
|
2
2
|
import { runLoaderWorkerPool } from "../webpackLoaders/loaderWorkerPool";
|
|
3
3
|
class InternalEndpoint {
|
|
4
4
|
constructor() {
|
|
@@ -32,9 +32,9 @@ class InternalEndpoint {
|
|
|
32
32
|
}
|
|
33
33
|
async build() {
|
|
34
34
|
var _a, _b;
|
|
35
|
-
|
|
35
|
+
await this.wasmInit;
|
|
36
36
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.loaderWorkerUrl) && !this.loaderWorkerPoolInitialized) {
|
|
37
|
-
runLoaderWorkerPool(
|
|
37
|
+
runLoaderWorkerPool(this.options.cwd, this.options.loaderWorkerUrl, (_b = this.options) === null || _b === void 0 ? void 0 : _b.loadersImportMap);
|
|
38
38
|
this.loaderWorkerPoolInitialized = true;
|
|
39
39
|
}
|
|
40
40
|
return await ProjectInternal.build();
|
|
@@ -43,29 +43,29 @@ class InternalEndpoint {
|
|
|
43
43
|
await this.wasmInit;
|
|
44
44
|
let ret;
|
|
45
45
|
if (encoding === "utf8") {
|
|
46
|
-
ret = await
|
|
46
|
+
ret = await Fs.readToString(path);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
return await
|
|
49
|
+
return await Fs.read(path);
|
|
50
50
|
}
|
|
51
51
|
return ret;
|
|
52
52
|
}
|
|
53
53
|
async writeFile(path, content, _encoding) {
|
|
54
54
|
await this.wasmInit;
|
|
55
55
|
if (typeof content === "string") {
|
|
56
|
-
return await
|
|
56
|
+
return await Fs.writeString(path, content);
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
return await
|
|
59
|
+
return await Fs.write(path, content);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
async copyFile(src, dst) {
|
|
63
63
|
await this.wasmInit;
|
|
64
|
-
return await
|
|
64
|
+
return await Fs.copyFile(src, dst);
|
|
65
65
|
}
|
|
66
66
|
async stat(path) {
|
|
67
67
|
await this.wasmInit;
|
|
68
|
-
const metadata = await
|
|
68
|
+
const metadata = await Fs.metadata(path);
|
|
69
69
|
const json = metadata.toJSON();
|
|
70
70
|
const raw = {
|
|
71
71
|
type: json.type,
|
|
@@ -77,9 +77,9 @@ class InternalEndpoint {
|
|
|
77
77
|
async readdir(path, options) {
|
|
78
78
|
await this.wasmInit;
|
|
79
79
|
const dirEntries = (options === null || options === void 0 ? void 0 : options.recursive)
|
|
80
|
-
? await
|
|
80
|
+
? await Fs.readDir(path)
|
|
81
81
|
: // TODO: support recursive readDirAll
|
|
82
|
-
await
|
|
82
|
+
await Fs.readDir(path);
|
|
83
83
|
const rawDirents = dirEntries.map((e) => {
|
|
84
84
|
const dir = e.toJSON();
|
|
85
85
|
return {
|
|
@@ -93,20 +93,20 @@ class InternalEndpoint {
|
|
|
93
93
|
async mkdir(path, options) {
|
|
94
94
|
await this.wasmInit;
|
|
95
95
|
if (options === null || options === void 0 ? void 0 : options.recursive) {
|
|
96
|
-
return await
|
|
96
|
+
return await Fs.createDirAll(path);
|
|
97
97
|
}
|
|
98
98
|
else {
|
|
99
|
-
return await
|
|
99
|
+
return await Fs.createDir(path);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
async rm(path, options) {
|
|
103
103
|
await this.wasmInit;
|
|
104
|
-
let metadata = (await
|
|
104
|
+
let metadata = (await Fs.metadata(path)).toJSON();
|
|
105
105
|
switch (metadata.type) {
|
|
106
106
|
case "file":
|
|
107
|
-
return await
|
|
107
|
+
return await Fs.removeFile(path);
|
|
108
108
|
case "directory":
|
|
109
|
-
return await
|
|
109
|
+
return await Fs.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
110
110
|
default:
|
|
111
111
|
// nothing to remove now
|
|
112
112
|
break;
|
|
@@ -114,7 +114,7 @@ class InternalEndpoint {
|
|
|
114
114
|
}
|
|
115
115
|
async rmdir(path, options) {
|
|
116
116
|
await this.wasmInit;
|
|
117
|
-
return await
|
|
117
|
+
return await Fs.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
118
118
|
}
|
|
119
119
|
async gzip(files) {
|
|
120
120
|
await this.wasmInit;
|
package/esm/project/Project.js
CHANGED
|
@@ -12,9 +12,9 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
12
12
|
var _Project_mount;
|
|
13
13
|
import { handleIssues } from "@utoo/pack-shared";
|
|
14
14
|
import * as comlink from "comlink";
|
|
15
|
+
import { WorkerMessageType } from "../message";
|
|
16
|
+
import { installServiceWorker } from "../serviceWorker/install";
|
|
15
17
|
import { Dirent, Stats, } from "../types";
|
|
16
|
-
import { installServiceWorker } from "../utils/installServiceWorker";
|
|
17
|
-
import { Fork, HandShake } from "../utils/message";
|
|
18
18
|
import { ForkedProject } from "./ForkedProject";
|
|
19
19
|
let ProjectWorker;
|
|
20
20
|
const ConnectedPorts = new Set();
|
|
@@ -39,7 +39,7 @@ export class Project {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
ProjectWorker.postMessage(
|
|
42
|
+
ProjectWorker.postMessage(WorkerMessageType.InitConnection, [port2]);
|
|
43
43
|
__classPrivateFieldSet(this, _Project_mount, (_b = __classPrivateFieldGet(this, _Project_mount, "f")) !== null && _b !== void 0 ? _b : this.remote.mount({
|
|
44
44
|
cwd,
|
|
45
45
|
wasmUrl,
|
|
@@ -51,8 +51,8 @@ export class Project {
|
|
|
51
51
|
}
|
|
52
52
|
connectWorker(e) {
|
|
53
53
|
const port = e.ports[0];
|
|
54
|
-
if (e.data ===
|
|
55
|
-
ProjectWorker.postMessage(
|
|
54
|
+
if (e.data === WorkerMessageType.RequestFork && !ConnectedPorts.has(port)) {
|
|
55
|
+
ProjectWorker.postMessage(WorkerMessageType.InitConnection, [port]);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
async installServiceWorker() {
|
|
@@ -125,7 +125,7 @@ export class Project {
|
|
|
125
125
|
return await this.remote.sigMd5(content);
|
|
126
126
|
}
|
|
127
127
|
static fork(channel, eventSource) {
|
|
128
|
-
(eventSource || self).postMessage(
|
|
128
|
+
(eventSource || self).postMessage(WorkerMessageType.RequestFork, {
|
|
129
129
|
transfer: [channel.port2],
|
|
130
130
|
});
|
|
131
131
|
return new ForkedProject(channel.port1);
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { SWMessageType } from "../message";
|
|
2
|
+
import { Project } from "../project/Project";
|
|
3
|
+
const HANDSHAKE_TIMEOUT = 10000; // 10 seconds
|
|
4
|
+
const HANDSHAKE_WARNING_INTERVAL = 3000; // 3 seconds
|
|
3
5
|
let _resolve;
|
|
6
|
+
let _handshakeCompleted = false;
|
|
4
7
|
let _promise = new Promise((resolve) => {
|
|
5
|
-
_resolve =
|
|
8
|
+
_resolve = () => {
|
|
9
|
+
_handshakeCompleted = true;
|
|
10
|
+
resolve();
|
|
11
|
+
};
|
|
6
12
|
});
|
|
7
13
|
let _projectEndpoint;
|
|
8
14
|
const params = new URLSearchParams(self.location.search);
|
|
@@ -15,18 +21,56 @@ self.addEventListener("activate", (event) => {
|
|
|
15
21
|
event.waitUntil(self.clients.claim());
|
|
16
22
|
});
|
|
17
23
|
self.addEventListener("message", (event) => {
|
|
18
|
-
if (event.data && event.data[
|
|
24
|
+
if (event.data && event.data[SWMessageType.HandShake] === true) {
|
|
25
|
+
console.log("[ServiceWorker] Handshake message received");
|
|
19
26
|
_projectEndpoint = Project.fork(new MessageChannel(), event.source);
|
|
20
27
|
_resolve();
|
|
28
|
+
console.log("[ServiceWorker] Handshake completed, ProjectEndpoint ready");
|
|
29
|
+
}
|
|
30
|
+
else if (event.data && event.data[SWMessageType.HeartbeatPing] === true) {
|
|
31
|
+
event.source.postMessage({
|
|
32
|
+
[SWMessageType.HeartbeatPong]: true,
|
|
33
|
+
});
|
|
21
34
|
}
|
|
22
35
|
});
|
|
36
|
+
async function waitForHandshake(requestUrl) {
|
|
37
|
+
if (_handshakeCompleted)
|
|
38
|
+
return;
|
|
39
|
+
const startTime = Date.now();
|
|
40
|
+
const warningTimer = setInterval(() => {
|
|
41
|
+
const elapsed = Date.now() - startTime;
|
|
42
|
+
console.warn(`[ServiceWorker] Still waiting for handshake... (${elapsed}ms elapsed, request: ${requestUrl})`);
|
|
43
|
+
}, HANDSHAKE_WARNING_INTERVAL);
|
|
44
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
reject(new Error(`[ServiceWorker] Handshake timeout after ${HANDSHAKE_TIMEOUT}ms. ` +
|
|
47
|
+
`Make sure the main thread calls installServiceWorker() and sends the handshake message. ` +
|
|
48
|
+
`Request: ${requestUrl}`));
|
|
49
|
+
}, HANDSHAKE_TIMEOUT);
|
|
50
|
+
});
|
|
51
|
+
try {
|
|
52
|
+
await Promise.race([_promise, timeoutPromise]);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
clearInterval(warningTimer);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
23
58
|
self.addEventListener("fetch", (event) => {
|
|
24
59
|
let { url: urlStr } = event.request;
|
|
25
60
|
let url = new URL(urlStr);
|
|
26
61
|
if (typeof _serviceWorkerScope === "string") {
|
|
27
62
|
if (url.pathname.startsWith(_serviceWorkerScope)) {
|
|
28
63
|
event.respondWith((async () => {
|
|
29
|
-
|
|
64
|
+
try {
|
|
65
|
+
await waitForHandshake(urlStr);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
console.error(e.message);
|
|
69
|
+
return new Response(e.message, {
|
|
70
|
+
status: 503,
|
|
71
|
+
statusText: "Service Unavailable",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
30
74
|
const relativePathToCwd = (_targetDirToCwd !== null && _targetDirToCwd !== void 0 ? _targetDirToCwd : ".") +
|
|
31
75
|
url.pathname.replace(_serviceWorkerScope, "");
|
|
32
76
|
return readFileFromProject(relativePathToCwd);
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SWMessageType } from "../message";
|
|
2
|
+
const HEARTBEAT_INTERVAL = 10000;
|
|
3
|
+
function startHeartbeat(sw) {
|
|
4
|
+
let lastHeartbeat = Date.now();
|
|
5
|
+
navigator.serviceWorker.addEventListener("message", (event) => {
|
|
6
|
+
if (event.data && event.data[SWMessageType.HeartbeatPong] === true) {
|
|
7
|
+
lastHeartbeat = Date.now();
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
setInterval(() => {
|
|
11
|
+
sw.postMessage({
|
|
12
|
+
[SWMessageType.HeartbeatPing]: true,
|
|
13
|
+
});
|
|
14
|
+
if (Date.now() - lastHeartbeat > HEARTBEAT_INTERVAL * 2) {
|
|
15
|
+
console.error("Service Worker Heartbeat Timeout");
|
|
16
|
+
}
|
|
17
|
+
}, HEARTBEAT_INTERVAL);
|
|
18
|
+
}
|
|
2
19
|
export async function installServiceWorker(url, scope, targetDirToCwd) {
|
|
3
20
|
const swUrl = new URL(url, window.location.href);
|
|
4
21
|
swUrl.searchParams.set("scope", scope);
|
|
@@ -11,8 +28,9 @@ export async function installServiceWorker(url, scope, targetDirToCwd) {
|
|
|
11
28
|
return new Promise((resolve) => {
|
|
12
29
|
function sendMessage(sw) {
|
|
13
30
|
sw.postMessage({
|
|
14
|
-
[
|
|
31
|
+
[SWMessageType.HandShake]: true,
|
|
15
32
|
});
|
|
33
|
+
startHeartbeat(sw);
|
|
16
34
|
resolve();
|
|
17
35
|
}
|
|
18
36
|
function listenForActivation(sw) {
|
package/esm/utoo/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @returns {any}
|
|
3
|
+
*/
|
|
4
|
+
export function getWasmMemory(): any;
|
|
5
|
+
/**
|
|
6
|
+
* @returns {any}
|
|
7
|
+
*/
|
|
8
|
+
export function getWasmModule(): any;
|
|
1
9
|
/**
|
|
2
10
|
* @param {string} filter
|
|
3
11
|
*/
|
|
@@ -60,34 +68,18 @@ export class DirEntry {
|
|
|
60
68
|
*/
|
|
61
69
|
get type(): DirEntryType;
|
|
62
70
|
}
|
|
63
|
-
export class
|
|
64
|
-
static __wrap(ptr: any): any;
|
|
65
|
-
toJSON(): {
|
|
66
|
-
type: DirEntryType;
|
|
67
|
-
file_size: bigint;
|
|
68
|
-
};
|
|
69
|
-
toString(): string;
|
|
70
|
-
__destroy_into_raw(): number | undefined;
|
|
71
|
-
__wbg_ptr: number | undefined;
|
|
72
|
-
free(): void;
|
|
73
|
-
/**
|
|
74
|
-
* @param {DirEntryType} arg0
|
|
75
|
-
*/
|
|
76
|
-
set type(arg0: DirEntryType);
|
|
71
|
+
export class Fs {
|
|
77
72
|
/**
|
|
78
|
-
* @
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param {bigint} arg0
|
|
73
|
+
* @param {string} src
|
|
74
|
+
* @param {string} dst
|
|
75
|
+
* @returns {Promise<void>}
|
|
83
76
|
*/
|
|
84
|
-
|
|
77
|
+
static copyFile(src: string, dst: string): Promise<void>;
|
|
85
78
|
/**
|
|
86
|
-
* @
|
|
79
|
+
* @param {string} src
|
|
80
|
+
* @param {string} dst
|
|
87
81
|
*/
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
export class Project {
|
|
82
|
+
static copyFileSync(src: string, dst: string): void;
|
|
91
83
|
/**
|
|
92
84
|
* @param {string} path
|
|
93
85
|
* @returns {Promise<void>}
|
|
@@ -95,26 +87,22 @@ export class Project {
|
|
|
95
87
|
static createDir(path: string): Promise<void>;
|
|
96
88
|
/**
|
|
97
89
|
* @param {string} path
|
|
98
|
-
* @param {boolean} recursive
|
|
99
90
|
* @returns {Promise<void>}
|
|
100
91
|
*/
|
|
101
|
-
static
|
|
92
|
+
static createDirAll(path: string): Promise<void>;
|
|
102
93
|
/**
|
|
103
94
|
* @param {string} path
|
|
104
|
-
* @param {Uint8Array} content
|
|
105
95
|
*/
|
|
106
|
-
static
|
|
96
|
+
static createDirAllSync(path: string): void;
|
|
107
97
|
/**
|
|
108
98
|
* @param {string} path
|
|
109
|
-
* @returns {Promise<void>}
|
|
110
99
|
*/
|
|
111
|
-
static
|
|
100
|
+
static createDirSync(path: string): void;
|
|
112
101
|
/**
|
|
113
102
|
* @param {string} path
|
|
114
|
-
* @
|
|
115
|
-
* @returns {Promise<void>}
|
|
103
|
+
* @returns {Promise<Metadata>}
|
|
116
104
|
*/
|
|
117
|
-
static
|
|
105
|
+
static metadata(path: string): Promise<Metadata>;
|
|
118
106
|
/**
|
|
119
107
|
* @param {string} path
|
|
120
108
|
* @returns {Metadata}
|
|
@@ -122,19 +110,24 @@ export class Project {
|
|
|
122
110
|
static metadataSync(path: string): Metadata;
|
|
123
111
|
/**
|
|
124
112
|
* @param {string} path
|
|
125
|
-
* @returns {
|
|
113
|
+
* @returns {Promise<Uint8Array>}
|
|
126
114
|
*/
|
|
127
|
-
static
|
|
115
|
+
static read(path: string): Promise<Uint8Array>;
|
|
128
116
|
/**
|
|
129
|
-
* @param {string}
|
|
130
|
-
* @
|
|
117
|
+
* @param {string} path
|
|
118
|
+
* @returns {Promise<DirEntry[]>}
|
|
131
119
|
*/
|
|
132
|
-
static
|
|
120
|
+
static readDir(path: string): Promise<DirEntry[]>;
|
|
133
121
|
/**
|
|
134
122
|
* @param {string} path
|
|
135
|
-
* @returns {
|
|
123
|
+
* @returns {DirEntry[]}
|
|
136
124
|
*/
|
|
137
|
-
static
|
|
125
|
+
static readDirSync(path: string): DirEntry[];
|
|
126
|
+
/**
|
|
127
|
+
* @param {string} path
|
|
128
|
+
* @returns {Uint8Array}
|
|
129
|
+
*/
|
|
130
|
+
static readSync(path: string): Uint8Array;
|
|
138
131
|
/**
|
|
139
132
|
* @param {string} path
|
|
140
133
|
* @returns {Promise<string>}
|
|
@@ -142,21 +135,77 @@ export class Project {
|
|
|
142
135
|
static readToString(path: string): Promise<string>;
|
|
143
136
|
/**
|
|
144
137
|
* @param {string} path
|
|
138
|
+
* @param {boolean} recursive
|
|
139
|
+
* @returns {Promise<void>}
|
|
145
140
|
*/
|
|
146
|
-
static
|
|
141
|
+
static removeDir(path: string, recursive: boolean): Promise<void>;
|
|
147
142
|
/**
|
|
148
143
|
* @param {string} path
|
|
149
144
|
* @param {boolean} recursive
|
|
150
145
|
*/
|
|
151
146
|
static removeDirSync(path: string, recursive: boolean): void;
|
|
147
|
+
/**
|
|
148
|
+
* @param {string} path
|
|
149
|
+
* @returns {Promise<void>}
|
|
150
|
+
*/
|
|
151
|
+
static removeFile(path: string): Promise<void>;
|
|
152
152
|
/**
|
|
153
153
|
* @param {string} path
|
|
154
154
|
*/
|
|
155
155
|
static removeFileSync(path: string): void;
|
|
156
156
|
/**
|
|
157
157
|
* @param {string} path
|
|
158
|
+
* @param {Uint8Array} content
|
|
159
|
+
* @returns {Promise<void>}
|
|
160
|
+
*/
|
|
161
|
+
static write(path: string, content: Uint8Array): Promise<void>;
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} path
|
|
164
|
+
* @param {string} content
|
|
165
|
+
* @returns {Promise<void>}
|
|
158
166
|
*/
|
|
159
|
-
static
|
|
167
|
+
static writeString(path: string, content: string): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* @param {string} path
|
|
170
|
+
* @param {Uint8Array} content
|
|
171
|
+
*/
|
|
172
|
+
static writeSync(path: string, content: Uint8Array): void;
|
|
173
|
+
__destroy_into_raw(): number | undefined;
|
|
174
|
+
__wbg_ptr: number | undefined;
|
|
175
|
+
free(): void;
|
|
176
|
+
}
|
|
177
|
+
export class Metadata {
|
|
178
|
+
static __wrap(ptr: any): any;
|
|
179
|
+
toJSON(): {
|
|
180
|
+
file_size: bigint;
|
|
181
|
+
type: DirEntryType;
|
|
182
|
+
};
|
|
183
|
+
toString(): string;
|
|
184
|
+
__destroy_into_raw(): number | undefined;
|
|
185
|
+
__wbg_ptr: number | undefined;
|
|
186
|
+
free(): void;
|
|
187
|
+
/**
|
|
188
|
+
* @param {bigint} arg0
|
|
189
|
+
*/
|
|
190
|
+
set file_size(arg0: bigint);
|
|
191
|
+
/**
|
|
192
|
+
* @returns {bigint}
|
|
193
|
+
*/
|
|
194
|
+
get file_size(): bigint;
|
|
195
|
+
/**
|
|
196
|
+
* @param {DirEntryType} arg0
|
|
197
|
+
*/
|
|
198
|
+
set type(arg0: DirEntryType);
|
|
199
|
+
/**
|
|
200
|
+
* @returns {DirEntryType}
|
|
201
|
+
*/
|
|
202
|
+
get type(): DirEntryType;
|
|
203
|
+
}
|
|
204
|
+
export class Project {
|
|
205
|
+
/**
|
|
206
|
+
* @returns {Promise<any>}
|
|
207
|
+
*/
|
|
208
|
+
static build(): Promise<any>;
|
|
160
209
|
/**
|
|
161
210
|
* @returns {string}
|
|
162
211
|
*/
|
|
@@ -185,21 +234,6 @@ export class Project {
|
|
|
185
234
|
* @param {string} thread_url
|
|
186
235
|
*/
|
|
187
236
|
static init(thread_url: string): void;
|
|
188
|
-
/**
|
|
189
|
-
* @param {string} path
|
|
190
|
-
* @returns {Promise<Uint8Array>}
|
|
191
|
-
*/
|
|
192
|
-
static read(path: string): Promise<Uint8Array>;
|
|
193
|
-
/**
|
|
194
|
-
* @returns {Promise<any>}
|
|
195
|
-
*/
|
|
196
|
-
static build(): Promise<any>;
|
|
197
|
-
/**
|
|
198
|
-
* @param {string} path
|
|
199
|
-
* @param {Uint8Array} content
|
|
200
|
-
* @returns {Promise<void>}
|
|
201
|
-
*/
|
|
202
|
-
static write(path: string, content: Uint8Array): Promise<void>;
|
|
203
237
|
/**
|
|
204
238
|
* Install dependencies - downloads tgz files only, extracts on-demand when files are read
|
|
205
239
|
* @param {string} package_lock
|
|
@@ -217,27 +251,6 @@ export class Project {
|
|
|
217
251
|
* @returns {Promise<string>}
|
|
218
252
|
*/
|
|
219
253
|
static sigMd5(content: Uint8Array): Promise<string>;
|
|
220
|
-
/**
|
|
221
|
-
* @param {string} path
|
|
222
|
-
* @returns {Promise<Metadata>}
|
|
223
|
-
*/
|
|
224
|
-
static metadata(path: string): Promise<Metadata>;
|
|
225
|
-
/**
|
|
226
|
-
* @param {string} path
|
|
227
|
-
* @returns {Promise<DirEntry[]>}
|
|
228
|
-
*/
|
|
229
|
-
static readDir(path: string): Promise<DirEntry[]>;
|
|
230
|
-
/**
|
|
231
|
-
* @param {string} src
|
|
232
|
-
* @param {string} dst
|
|
233
|
-
* @returns {Promise<void>}
|
|
234
|
-
*/
|
|
235
|
-
static copyFile(src: string, dst: string): Promise<void>;
|
|
236
|
-
/**
|
|
237
|
-
* @param {string} path
|
|
238
|
-
* @returns {Uint8Array}
|
|
239
|
-
*/
|
|
240
|
-
static readSync(path: string): Uint8Array;
|
|
241
254
|
__destroy_into_raw(): number | undefined;
|
|
242
255
|
__wbg_ptr: number | undefined;
|
|
243
256
|
free(): void;
|
|
@@ -247,10 +260,6 @@ export class WasmTaskMessage {
|
|
|
247
260
|
__destroy_into_raw(): number | undefined;
|
|
248
261
|
__wbg_ptr: number | undefined;
|
|
249
262
|
free(): void;
|
|
250
|
-
/**
|
|
251
|
-
* @returns {Uint8Array}
|
|
252
|
-
*/
|
|
253
|
-
get data(): Uint8Array;
|
|
254
263
|
/**
|
|
255
264
|
* @param {number} arg0
|
|
256
265
|
*/
|
|
@@ -259,6 +268,10 @@ export class WasmTaskMessage {
|
|
|
259
268
|
* @returns {number}
|
|
260
269
|
*/
|
|
261
270
|
get taskId(): number;
|
|
271
|
+
/**
|
|
272
|
+
* @returns {Uint8Array}
|
|
273
|
+
*/
|
|
274
|
+
get data(): Uint8Array;
|
|
262
275
|
}
|
|
263
276
|
export class WebWorkerCreation {
|
|
264
277
|
static __wrap(ptr: any): any;
|
|
@@ -282,19 +295,19 @@ export class WebWorkerOptions {
|
|
|
282
295
|
/**
|
|
283
296
|
* @param {string} arg0
|
|
284
297
|
*/
|
|
285
|
-
set
|
|
298
|
+
set cwd(arg0: string);
|
|
286
299
|
/**
|
|
287
300
|
* @returns {string}
|
|
288
301
|
*/
|
|
289
|
-
get
|
|
302
|
+
get cwd(): string;
|
|
290
303
|
/**
|
|
291
304
|
* @param {string} arg0
|
|
292
305
|
*/
|
|
293
|
-
set
|
|
306
|
+
set filename(arg0: string);
|
|
294
307
|
/**
|
|
295
308
|
* @returns {string}
|
|
296
309
|
*/
|
|
297
|
-
get
|
|
310
|
+
get filename(): string;
|
|
298
311
|
}
|
|
299
312
|
export class WebWorkerTermination {
|
|
300
313
|
static __wrap(ptr: any): any;
|
|
@@ -318,6 +331,6 @@ export class WebWorkerTermination {
|
|
|
318
331
|
*/
|
|
319
332
|
get workerId(): number;
|
|
320
333
|
}
|
|
321
|
-
export default __wbg_init;
|
|
322
334
|
export function initSync(module: any, memory: any): any;
|
|
323
335
|
declare function __wbg_init(module_or_path: any, memory: any): Promise<any>;
|
|
336
|
+
export { __wbg_init as default };
|