@utoo/web 1.2.6 → 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 +18 -19
- 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 +102 -90
- package/esm/utoo/index.js +1505 -1477
- 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() {
|
|
@@ -26,16 +26,15 @@ class InternalEndpoint {
|
|
|
26
26
|
return await ProjectInternal.deps((_a = options === null || options === void 0 ? void 0 : options.registry) !== null && _a !== void 0 ? _a : undefined, (_b = options === null || options === void 0 ? void 0 : options.concurrency) !== null && _b !== void 0 ? _b : undefined);
|
|
27
27
|
}
|
|
28
28
|
async install(packageLock, options) {
|
|
29
|
-
var _a;
|
|
30
29
|
await this.wasmInit;
|
|
31
|
-
await ProjectInternal.install(packageLock, options === null || options === void 0 ? void 0 : options.maxConcurrentDownloads
|
|
30
|
+
await ProjectInternal.install(packageLock, options === null || options === void 0 ? void 0 : options.maxConcurrentDownloads);
|
|
32
31
|
return;
|
|
33
32
|
}
|
|
34
33
|
async build() {
|
|
35
34
|
var _a, _b;
|
|
36
|
-
|
|
35
|
+
await this.wasmInit;
|
|
37
36
|
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.loaderWorkerUrl) && !this.loaderWorkerPoolInitialized) {
|
|
38
|
-
runLoaderWorkerPool(
|
|
37
|
+
runLoaderWorkerPool(this.options.cwd, this.options.loaderWorkerUrl, (_b = this.options) === null || _b === void 0 ? void 0 : _b.loadersImportMap);
|
|
39
38
|
this.loaderWorkerPoolInitialized = true;
|
|
40
39
|
}
|
|
41
40
|
return await ProjectInternal.build();
|
|
@@ -44,29 +43,29 @@ class InternalEndpoint {
|
|
|
44
43
|
await this.wasmInit;
|
|
45
44
|
let ret;
|
|
46
45
|
if (encoding === "utf8") {
|
|
47
|
-
ret = await
|
|
46
|
+
ret = await Fs.readToString(path);
|
|
48
47
|
}
|
|
49
48
|
else {
|
|
50
|
-
return await
|
|
49
|
+
return await Fs.read(path);
|
|
51
50
|
}
|
|
52
51
|
return ret;
|
|
53
52
|
}
|
|
54
53
|
async writeFile(path, content, _encoding) {
|
|
55
54
|
await this.wasmInit;
|
|
56
55
|
if (typeof content === "string") {
|
|
57
|
-
return await
|
|
56
|
+
return await Fs.writeString(path, content);
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
60
|
-
return await
|
|
59
|
+
return await Fs.write(path, content);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
async copyFile(src, dst) {
|
|
64
63
|
await this.wasmInit;
|
|
65
|
-
return await
|
|
64
|
+
return await Fs.copyFile(src, dst);
|
|
66
65
|
}
|
|
67
66
|
async stat(path) {
|
|
68
67
|
await this.wasmInit;
|
|
69
|
-
const metadata = await
|
|
68
|
+
const metadata = await Fs.metadata(path);
|
|
70
69
|
const json = metadata.toJSON();
|
|
71
70
|
const raw = {
|
|
72
71
|
type: json.type,
|
|
@@ -78,9 +77,9 @@ class InternalEndpoint {
|
|
|
78
77
|
async readdir(path, options) {
|
|
79
78
|
await this.wasmInit;
|
|
80
79
|
const dirEntries = (options === null || options === void 0 ? void 0 : options.recursive)
|
|
81
|
-
? await
|
|
80
|
+
? await Fs.readDir(path)
|
|
82
81
|
: // TODO: support recursive readDirAll
|
|
83
|
-
await
|
|
82
|
+
await Fs.readDir(path);
|
|
84
83
|
const rawDirents = dirEntries.map((e) => {
|
|
85
84
|
const dir = e.toJSON();
|
|
86
85
|
return {
|
|
@@ -94,20 +93,20 @@ class InternalEndpoint {
|
|
|
94
93
|
async mkdir(path, options) {
|
|
95
94
|
await this.wasmInit;
|
|
96
95
|
if (options === null || options === void 0 ? void 0 : options.recursive) {
|
|
97
|
-
return await
|
|
96
|
+
return await Fs.createDirAll(path);
|
|
98
97
|
}
|
|
99
98
|
else {
|
|
100
|
-
return await
|
|
99
|
+
return await Fs.createDir(path);
|
|
101
100
|
}
|
|
102
101
|
}
|
|
103
102
|
async rm(path, options) {
|
|
104
103
|
await this.wasmInit;
|
|
105
|
-
let metadata = (await
|
|
104
|
+
let metadata = (await Fs.metadata(path)).toJSON();
|
|
106
105
|
switch (metadata.type) {
|
|
107
106
|
case "file":
|
|
108
|
-
return await
|
|
107
|
+
return await Fs.removeFile(path);
|
|
109
108
|
case "directory":
|
|
110
|
-
return await
|
|
109
|
+
return await Fs.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
111
110
|
default:
|
|
112
111
|
// nothing to remove now
|
|
113
112
|
break;
|
|
@@ -115,7 +114,7 @@ class InternalEndpoint {
|
|
|
115
114
|
}
|
|
116
115
|
async rmdir(path, options) {
|
|
117
116
|
await this.wasmInit;
|
|
118
|
-
return await
|
|
117
|
+
return await Fs.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
|
|
119
118
|
}
|
|
120
119
|
async gzip(files) {
|
|
121
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,29 +234,13 @@ 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
|
|
206
|
-
* @param {number | null
|
|
207
|
-
* @param {string[]} omit
|
|
240
|
+
* @param {number | null} [max_concurrent_downloads]
|
|
208
241
|
* @returns {Promise<void>}
|
|
209
242
|
*/
|
|
210
|
-
static install(package_lock: string, max_concurrent_downloads
|
|
243
|
+
static install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
|
|
211
244
|
/**
|
|
212
245
|
* @param {string} path
|
|
213
246
|
*/
|
|
@@ -218,27 +251,6 @@ export class Project {
|
|
|
218
251
|
* @returns {Promise<string>}
|
|
219
252
|
*/
|
|
220
253
|
static sigMd5(content: Uint8Array): Promise<string>;
|
|
221
|
-
/**
|
|
222
|
-
* @param {string} path
|
|
223
|
-
* @returns {Promise<Metadata>}
|
|
224
|
-
*/
|
|
225
|
-
static metadata(path: string): Promise<Metadata>;
|
|
226
|
-
/**
|
|
227
|
-
* @param {string} path
|
|
228
|
-
* @returns {Promise<DirEntry[]>}
|
|
229
|
-
*/
|
|
230
|
-
static readDir(path: string): Promise<DirEntry[]>;
|
|
231
|
-
/**
|
|
232
|
-
* @param {string} src
|
|
233
|
-
* @param {string} dst
|
|
234
|
-
* @returns {Promise<void>}
|
|
235
|
-
*/
|
|
236
|
-
static copyFile(src: string, dst: string): Promise<void>;
|
|
237
|
-
/**
|
|
238
|
-
* @param {string} path
|
|
239
|
-
* @returns {Uint8Array}
|
|
240
|
-
*/
|
|
241
|
-
static readSync(path: string): Uint8Array;
|
|
242
254
|
__destroy_into_raw(): number | undefined;
|
|
243
255
|
__wbg_ptr: number | undefined;
|
|
244
256
|
free(): void;
|
|
@@ -248,10 +260,6 @@ export class WasmTaskMessage {
|
|
|
248
260
|
__destroy_into_raw(): number | undefined;
|
|
249
261
|
__wbg_ptr: number | undefined;
|
|
250
262
|
free(): void;
|
|
251
|
-
/**
|
|
252
|
-
* @returns {Uint8Array}
|
|
253
|
-
*/
|
|
254
|
-
get data(): Uint8Array;
|
|
255
263
|
/**
|
|
256
264
|
* @param {number} arg0
|
|
257
265
|
*/
|
|
@@ -260,6 +268,10 @@ export class WasmTaskMessage {
|
|
|
260
268
|
* @returns {number}
|
|
261
269
|
*/
|
|
262
270
|
get taskId(): number;
|
|
271
|
+
/**
|
|
272
|
+
* @returns {Uint8Array}
|
|
273
|
+
*/
|
|
274
|
+
get data(): Uint8Array;
|
|
263
275
|
}
|
|
264
276
|
export class WebWorkerCreation {
|
|
265
277
|
static __wrap(ptr: any): any;
|
|
@@ -283,19 +295,19 @@ export class WebWorkerOptions {
|
|
|
283
295
|
/**
|
|
284
296
|
* @param {string} arg0
|
|
285
297
|
*/
|
|
286
|
-
set
|
|
298
|
+
set cwd(arg0: string);
|
|
287
299
|
/**
|
|
288
300
|
* @returns {string}
|
|
289
301
|
*/
|
|
290
|
-
get
|
|
302
|
+
get cwd(): string;
|
|
291
303
|
/**
|
|
292
304
|
* @param {string} arg0
|
|
293
305
|
*/
|
|
294
|
-
set
|
|
306
|
+
set filename(arg0: string);
|
|
295
307
|
/**
|
|
296
308
|
* @returns {string}
|
|
297
309
|
*/
|
|
298
|
-
get
|
|
310
|
+
get filename(): string;
|
|
299
311
|
}
|
|
300
312
|
export class WebWorkerTermination {
|
|
301
313
|
static __wrap(ptr: any): any;
|
|
@@ -319,6 +331,6 @@ export class WebWorkerTermination {
|
|
|
319
331
|
*/
|
|
320
332
|
get workerId(): number;
|
|
321
333
|
}
|
|
322
|
-
export default __wbg_init;
|
|
323
334
|
export function initSync(module: any, memory: any): any;
|
|
324
335
|
declare function __wbg_init(module_or_path: any, memory: any): Promise<any>;
|
|
336
|
+
export { __wbg_init as default };
|