@utoo/web 1.1.0 → 1.2.0-rc.10
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/README.md +55 -0
- package/esm/a0a815481b4ff49f8961.wasm +0 -0
- package/esm/index.d.ts +3 -2
- package/esm/index.js +3 -2
- package/esm/loaderWorker.js +2 -0
- package/esm/loaderWorker.js.LICENSE.txt +23 -0
- package/esm/{forkedProject.d.ts → project/ForkedProject.d.ts} +5 -3
- package/esm/{forkedProject.js → project/ForkedProject.js} +8 -0
- package/esm/{internalProject.d.ts → project/InternalProject.d.ts} +5 -3
- package/esm/project/InternalProject.js +132 -0
- package/esm/{project.d.ts → project/Project.d.ts} +4 -1
- package/esm/{project.js → project/Project.js} +21 -6
- package/esm/serviceWorker.js +4 -3
- package/esm/{type.d.ts → types.d.ts} +44 -0
- package/esm/types.js +56 -0
- package/esm/utils/sabcom.d.ts +61 -0
- package/esm/utils/sabcom.js +203 -0
- package/esm/utoo/index.d.ts +126 -66
- package/esm/utoo/index.js +351 -235
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/cjs.js +299 -0
- package/esm/webpackLoaders/loaderWorkerPool.d.ts +2 -0
- package/esm/webpackLoaders/loaderWorkerPool.js +90 -0
- package/esm/webpackLoaders/polyfills/fsPolyfill.d.ts +78 -0
- package/esm/webpackLoaders/polyfills/fsPolyfill.js +279 -0
- package/esm/webpackLoaders/polyfills/fsPromisesPolyfill.d.ts +26 -0
- package/esm/webpackLoaders/polyfills/fsPromisesPolyfill.js +112 -0
- package/esm/webpackLoaders/polyfills/nodePolyFills.d.ts +92 -0
- package/esm/webpackLoaders/polyfills/nodePolyFills.js +230 -0
- package/esm/webpackLoaders/polyfills/workerThreadsPolyfill.d.ts +7 -0
- package/esm/webpackLoaders/polyfills/workerThreadsPolyfill.js +16 -0
- package/esm/webpackLoaders/{worker/type.d.ts → types.d.ts} +2 -1
- package/esm/webpackLoaders/worker.d.ts +2 -0
- package/esm/webpackLoaders/worker.js +46 -0
- package/esm/worker.js +2 -2
- package/package.json +19 -18
- package/esm/internalProject.js +0 -185
- package/esm/type.js +0 -12
- package/esm/webpackLoaders/loaders/less-loader/index.d.ts +0 -3
- package/esm/webpackLoaders/loaders/less-loader/index.js +0 -103
- package/esm/webpackLoaders/loaders/less-loader/options.json +0 -67
- package/esm/webpackLoaders/loaders/less-loader/utils.d.ts +0 -14
- package/esm/webpackLoaders/loaders/less-loader/utils.js +0 -217
- package/esm/webpackLoaders/worker/cjs.js +0 -80
- package/esm/webpackLoaders/worker/index.d.ts +0 -2
- package/esm/webpackLoaders/worker/index.js +0 -31
- package/esm/webpackLoaders/worker/nodePolyFills.d.ts +0 -14
- package/esm/webpackLoaders/worker/nodePolyFills.js +0 -24
- package/esm/webpackLoaders/workerContent.d.ts +0 -2
- package/esm/webpackLoaders/workerContent.js +0 -1
- /package/esm/{installServiceWorker.d.ts → utils/installServiceWorker.d.ts} +0 -0
- /package/esm/{installServiceWorker.js → utils/installServiceWorker.js} +0 -0
- /package/esm/{message.d.ts → utils/message.d.ts} +0 -0
- /package/esm/{message.js → utils/message.js} +0 -0
- /package/esm/webpackLoaders/{worker/cjs.d.ts → cjs.d.ts} +0 -0
- /package/esm/webpackLoaders/{worker/type.js → types.js} +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
export const SAB_STATE_IDLE = 0;
|
|
2
|
+
export const SAB_STATE_REQUEST = 1;
|
|
3
|
+
export const SAB_STATE_RESPONSE = 2;
|
|
4
|
+
export const SAB_STATE_ERROR = 3;
|
|
5
|
+
export const SAB_OP_READ_FILE = 1;
|
|
6
|
+
export const SAB_OP_READ_DIR = 2;
|
|
7
|
+
export const SAB_OP_WRITE_FILE = 3;
|
|
8
|
+
export const SAB_OP_MKDIR = 4;
|
|
9
|
+
export const SAB_OP_RM = 5;
|
|
10
|
+
export const SAB_OP_RMDIR = 6;
|
|
11
|
+
export const SAB_OP_COPY_FILE = 7;
|
|
12
|
+
export const SAB_OP_STAT = 8;
|
|
13
|
+
export const STAT_TYPE_FILE = 0;
|
|
14
|
+
export const STAT_TYPE_DIR = 1;
|
|
15
|
+
export const SAB_INDEX_STATE = 0;
|
|
16
|
+
export const SAB_INDEX_OP = 1;
|
|
17
|
+
export const SAB_INDEX_DATA_LEN = 2;
|
|
18
|
+
export const SAB_DATA_OFFSET = 12;
|
|
19
|
+
// Stat struct layout (starts at byte 12)
|
|
20
|
+
// type: Uint8 (1 byte) -> offset 0
|
|
21
|
+
// padding: 7 bytes
|
|
22
|
+
// size: BigUint64 (8 bytes) -> offset 8
|
|
23
|
+
// atimeMs: Float64 (8 bytes) -> offset 16
|
|
24
|
+
// mtimeMs: Float64 (8 bytes) -> offset 24
|
|
25
|
+
// ctimeMs: Float64 (8 bytes) -> offset 32
|
|
26
|
+
// birthtimeMs: Float64 (8 bytes) -> offset 40
|
|
27
|
+
const STAT_OFFSET_TYPE = 0;
|
|
28
|
+
const STAT_OFFSET_SIZE = 8;
|
|
29
|
+
const STAT_OFFSET_ATIME = 16;
|
|
30
|
+
const STAT_OFFSET_MTIME = 24;
|
|
31
|
+
const STAT_OFFSET_CTIME = 32;
|
|
32
|
+
const STAT_OFFSET_BIRTHTIME = 40;
|
|
33
|
+
// Layout:
|
|
34
|
+
// 0: State (Int32)
|
|
35
|
+
// 1: Op (Int32)
|
|
36
|
+
// 2: Data Length (Int32)
|
|
37
|
+
// 12...: Data (Uint8) - Start at byte 12 (3 * 4 bytes)
|
|
38
|
+
export class SabComHost {
|
|
39
|
+
constructor(sab) {
|
|
40
|
+
this.sab = sab;
|
|
41
|
+
this.int32 = new Int32Array(sab);
|
|
42
|
+
this.uint8 = new Uint8Array(sab);
|
|
43
|
+
this.dataView = new DataView(sab);
|
|
44
|
+
}
|
|
45
|
+
readRequest() {
|
|
46
|
+
const op = this.int32[SAB_INDEX_OP];
|
|
47
|
+
const len = this.int32[SAB_INDEX_DATA_LEN];
|
|
48
|
+
const data = new TextDecoder().decode(this.uint8.slice(SAB_DATA_OFFSET, SAB_DATA_OFFSET + len));
|
|
49
|
+
return { op, data };
|
|
50
|
+
}
|
|
51
|
+
writeResponse(data) {
|
|
52
|
+
if (typeof data === "string") {
|
|
53
|
+
data = new TextEncoder().encode(data);
|
|
54
|
+
}
|
|
55
|
+
// TODO: Check size overflow
|
|
56
|
+
this.int32[SAB_INDEX_DATA_LEN] = data.length;
|
|
57
|
+
this.uint8.set(data, SAB_DATA_OFFSET);
|
|
58
|
+
Atomics.store(this.int32, SAB_INDEX_STATE, SAB_STATE_RESPONSE);
|
|
59
|
+
Atomics.notify(this.int32, SAB_INDEX_STATE);
|
|
60
|
+
}
|
|
61
|
+
writeError(message) {
|
|
62
|
+
const data = new TextEncoder().encode(message);
|
|
63
|
+
this.int32[SAB_INDEX_DATA_LEN] = data.length;
|
|
64
|
+
this.uint8.set(data, SAB_DATA_OFFSET);
|
|
65
|
+
Atomics.store(this.int32, SAB_INDEX_STATE, SAB_STATE_ERROR);
|
|
66
|
+
Atomics.notify(this.int32, SAB_INDEX_STATE);
|
|
67
|
+
}
|
|
68
|
+
writeStat(type, size, atimeMs, mtimeMs, ctimeMs, birthtimeMs) {
|
|
69
|
+
const base = SAB_DATA_OFFSET;
|
|
70
|
+
this.dataView.setUint8(base + STAT_OFFSET_TYPE, type);
|
|
71
|
+
this.dataView.setBigUint64(base + STAT_OFFSET_SIZE, size, true);
|
|
72
|
+
this.dataView.setFloat64(base + STAT_OFFSET_ATIME, atimeMs, true);
|
|
73
|
+
this.dataView.setFloat64(base + STAT_OFFSET_MTIME, mtimeMs, true);
|
|
74
|
+
this.dataView.setFloat64(base + STAT_OFFSET_CTIME, ctimeMs, true);
|
|
75
|
+
this.dataView.setFloat64(base + STAT_OFFSET_BIRTHTIME, birthtimeMs, true);
|
|
76
|
+
Atomics.store(this.int32, SAB_INDEX_STATE, SAB_STATE_RESPONSE);
|
|
77
|
+
Atomics.notify(this.int32, SAB_INDEX_STATE);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export class SabComClient {
|
|
81
|
+
constructor(sab, notifyHost) {
|
|
82
|
+
this.sab = sab;
|
|
83
|
+
this.notifyHost = notifyHost;
|
|
84
|
+
this.int32 = new Int32Array(sab);
|
|
85
|
+
this.uint8 = new Uint8Array(sab);
|
|
86
|
+
this.dataView = new DataView(sab);
|
|
87
|
+
}
|
|
88
|
+
call(op, data) {
|
|
89
|
+
const encoded = new TextEncoder().encode(data);
|
|
90
|
+
this.int32[SAB_INDEX_OP] = op;
|
|
91
|
+
this.int32[SAB_INDEX_DATA_LEN] = encoded.length;
|
|
92
|
+
this.uint8.set(encoded, SAB_DATA_OFFSET);
|
|
93
|
+
Atomics.store(this.int32, SAB_INDEX_STATE, SAB_STATE_REQUEST);
|
|
94
|
+
this.notifyHost();
|
|
95
|
+
Atomics.wait(this.int32, SAB_INDEX_STATE, SAB_STATE_REQUEST);
|
|
96
|
+
const state = Atomics.load(this.int32, SAB_INDEX_STATE);
|
|
97
|
+
if (state === SAB_STATE_ERROR) {
|
|
98
|
+
const len = this.int32[SAB_INDEX_DATA_LEN];
|
|
99
|
+
const msg = new TextDecoder().decode(this.uint8.slice(SAB_DATA_OFFSET, SAB_DATA_OFFSET + len));
|
|
100
|
+
throw new Error(msg);
|
|
101
|
+
}
|
|
102
|
+
const len = this.int32[SAB_INDEX_DATA_LEN];
|
|
103
|
+
return this.uint8.slice(SAB_DATA_OFFSET, SAB_DATA_OFFSET + len);
|
|
104
|
+
}
|
|
105
|
+
callStat(path) {
|
|
106
|
+
const encoded = new TextEncoder().encode(path);
|
|
107
|
+
this.int32[SAB_INDEX_OP] = SAB_OP_STAT;
|
|
108
|
+
this.int32[SAB_INDEX_DATA_LEN] = encoded.length;
|
|
109
|
+
this.uint8.set(encoded, SAB_DATA_OFFSET);
|
|
110
|
+
Atomics.store(this.int32, SAB_INDEX_STATE, SAB_STATE_REQUEST);
|
|
111
|
+
this.notifyHost();
|
|
112
|
+
Atomics.wait(this.int32, SAB_INDEX_STATE, SAB_STATE_REQUEST);
|
|
113
|
+
const state = Atomics.load(this.int32, SAB_INDEX_STATE);
|
|
114
|
+
if (state === SAB_STATE_ERROR) {
|
|
115
|
+
const len = this.int32[SAB_INDEX_DATA_LEN];
|
|
116
|
+
const msg = new TextDecoder().decode(this.uint8.slice(SAB_DATA_OFFSET, SAB_DATA_OFFSET + len));
|
|
117
|
+
throw new Error(msg);
|
|
118
|
+
}
|
|
119
|
+
const base = SAB_DATA_OFFSET;
|
|
120
|
+
return {
|
|
121
|
+
type: this.dataView.getUint8(base + STAT_OFFSET_TYPE),
|
|
122
|
+
size: this.dataView.getBigUint64(base + STAT_OFFSET_SIZE, true),
|
|
123
|
+
atimeMs: this.dataView.getFloat64(base + STAT_OFFSET_ATIME, true),
|
|
124
|
+
mtimeMs: this.dataView.getFloat64(base + STAT_OFFSET_MTIME, true),
|
|
125
|
+
ctimeMs: this.dataView.getFloat64(base + STAT_OFFSET_CTIME, true),
|
|
126
|
+
birthtimeMs: this.dataView.getFloat64(base + STAT_OFFSET_BIRTHTIME, true),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export const handleSabRequest = async (sabHost, fs) => {
|
|
131
|
+
const { op, data: path } = sabHost.readRequest();
|
|
132
|
+
try {
|
|
133
|
+
if (op === SAB_OP_READ_FILE) {
|
|
134
|
+
const bytes = await fs.read(path);
|
|
135
|
+
sabHost.writeResponse(bytes);
|
|
136
|
+
}
|
|
137
|
+
else if (op === SAB_OP_READ_DIR) {
|
|
138
|
+
const entries = await fs.readDir(path);
|
|
139
|
+
sabHost.writeResponse(JSON.stringify(entries.map((e) => e.toJSON())));
|
|
140
|
+
}
|
|
141
|
+
else if (op === SAB_OP_WRITE_FILE) {
|
|
142
|
+
const { path: filePath, data: fileContent } = JSON.parse(path);
|
|
143
|
+
// TODO: handle binary content (base64?)
|
|
144
|
+
await fs.writeString(filePath, fileContent);
|
|
145
|
+
sabHost.writeResponse("ok");
|
|
146
|
+
}
|
|
147
|
+
else if (op === SAB_OP_MKDIR) {
|
|
148
|
+
const { path: dirPath, recursive } = JSON.parse(path);
|
|
149
|
+
if (recursive) {
|
|
150
|
+
await fs.createDirAll(dirPath);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
await fs.createDir(dirPath);
|
|
154
|
+
}
|
|
155
|
+
sabHost.writeResponse("ok");
|
|
156
|
+
}
|
|
157
|
+
else if (op === SAB_OP_RM) {
|
|
158
|
+
const { path: rmPath, recursive } = JSON.parse(path);
|
|
159
|
+
// Mimic internalProject.rm logic
|
|
160
|
+
const metadata = await fs.metadata(rmPath);
|
|
161
|
+
const json = metadata.toJSON
|
|
162
|
+
? metadata.toJSON()
|
|
163
|
+
: metadata;
|
|
164
|
+
const type = json.type;
|
|
165
|
+
if (type === "file") {
|
|
166
|
+
await fs.removeFile(rmPath);
|
|
167
|
+
}
|
|
168
|
+
else if (type === "directory") {
|
|
169
|
+
await fs.removeDir(rmPath, !!recursive);
|
|
170
|
+
}
|
|
171
|
+
sabHost.writeResponse("ok");
|
|
172
|
+
}
|
|
173
|
+
else if (op === SAB_OP_RMDIR) {
|
|
174
|
+
const { path: rmPath, recursive } = JSON.parse(path);
|
|
175
|
+
await fs.removeDir(rmPath, !!recursive);
|
|
176
|
+
sabHost.writeResponse("ok");
|
|
177
|
+
}
|
|
178
|
+
else if (op === SAB_OP_COPY_FILE) {
|
|
179
|
+
const { src, dst } = JSON.parse(path);
|
|
180
|
+
await fs.copyFile(src, dst);
|
|
181
|
+
sabHost.writeResponse("ok");
|
|
182
|
+
}
|
|
183
|
+
else if (op === SAB_OP_STAT) {
|
|
184
|
+
const metadata = await fs.metadata(path);
|
|
185
|
+
const json = metadata.toJSON
|
|
186
|
+
? metadata.toJSON()
|
|
187
|
+
: metadata;
|
|
188
|
+
const type = json.type === "directory" ? STAT_TYPE_DIR : STAT_TYPE_FILE;
|
|
189
|
+
const size = BigInt(json.file_size || 0);
|
|
190
|
+
const atimeMs = Number(json.atimeMs || 0);
|
|
191
|
+
const mtimeMs = Number(json.mtimeMs || 0);
|
|
192
|
+
const ctimeMs = Number(json.ctimeMs || 0);
|
|
193
|
+
const birthtimeMs = Number(json.birthtimeMs || 0);
|
|
194
|
+
sabHost.writeStat(type, size, atimeMs, mtimeMs, ctimeMs, birthtimeMs);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
sabHost.writeError("Unknown op");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
catch (e) {
|
|
201
|
+
sabHost.writeError(e.message);
|
|
202
|
+
}
|
|
203
|
+
};
|
package/esm/utoo/index.d.ts
CHANGED
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param {number} worker_id
|
|
3
|
-
* @returns {Promise<
|
|
3
|
+
* @returns {Promise<WasmTaskMessage>}
|
|
4
4
|
*/
|
|
5
|
-
export function
|
|
5
|
+
export function recvTaskMessageInWorker(worker_id: number): Promise<WasmTaskMessage>;
|
|
6
6
|
/**
|
|
7
|
-
* @
|
|
8
|
-
*/
|
|
9
|
-
export function recvWorkerTermination(): Promise<WorkerTermination>;
|
|
10
|
-
/**
|
|
11
|
-
* @param {number} task_id
|
|
12
|
-
* @param {number} worker_id
|
|
13
|
-
* @returns {Promise<void>}
|
|
14
|
-
*/
|
|
15
|
-
export function notifyWorkerAck(task_id: number, worker_id: number): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* @param {number} task_id
|
|
18
|
-
* @param {string} message
|
|
7
|
+
* @param {any} message
|
|
19
8
|
* @returns {Promise<void>}
|
|
20
9
|
*/
|
|
21
|
-
export function sendTaskMessage(
|
|
10
|
+
export function sendTaskMessage(message: any): Promise<void>;
|
|
11
|
+
export function init_pack(): void;
|
|
22
12
|
/**
|
|
23
|
-
* @param {string}
|
|
24
|
-
* @returns {Promise<number>}
|
|
13
|
+
* @param {string} filter
|
|
25
14
|
*/
|
|
26
|
-
export function
|
|
15
|
+
export function initLogFilter(filter: string): void;
|
|
27
16
|
/**
|
|
28
|
-
* @
|
|
17
|
+
* @param {Function} creator
|
|
18
|
+
* @param {Function} terminator
|
|
29
19
|
*/
|
|
30
|
-
export function
|
|
31
|
-
export function init_pack(): void;
|
|
20
|
+
export function registerWorkerScheduler(creator: Function, terminator: Function): void;
|
|
32
21
|
/**
|
|
33
|
-
* @param {
|
|
22
|
+
* @param {number} worker_id
|
|
34
23
|
*/
|
|
35
|
-
export function
|
|
24
|
+
export function workerCreated(worker_id: number): void;
|
|
36
25
|
/**
|
|
37
26
|
* Entry point for web workers
|
|
38
27
|
* @param {number} ptr
|
|
@@ -73,131 +62,180 @@ export class DirEntry {
|
|
|
73
62
|
}
|
|
74
63
|
export class Metadata {
|
|
75
64
|
static __wrap(ptr: any): any;
|
|
76
|
-
toJSON(): {
|
|
65
|
+
toJSON(): {
|
|
66
|
+
type: DirEntryType;
|
|
67
|
+
file_size: bigint;
|
|
68
|
+
};
|
|
77
69
|
toString(): string;
|
|
78
70
|
__destroy_into_raw(): number | undefined;
|
|
79
71
|
__wbg_ptr: number | undefined;
|
|
80
72
|
free(): void;
|
|
81
|
-
}
|
|
82
|
-
export class PoolOptions {
|
|
83
|
-
static __wrap(ptr: any): any;
|
|
84
|
-
__destroy_into_raw(): number | undefined;
|
|
85
|
-
__wbg_ptr: number | undefined;
|
|
86
|
-
free(): void;
|
|
87
73
|
/**
|
|
88
|
-
* @param {
|
|
74
|
+
* @param {DirEntryType} arg0
|
|
89
75
|
*/
|
|
90
|
-
set
|
|
76
|
+
set type(arg0: DirEntryType);
|
|
91
77
|
/**
|
|
92
|
-
* @returns {
|
|
78
|
+
* @returns {DirEntryType}
|
|
93
79
|
*/
|
|
94
|
-
get
|
|
80
|
+
get type(): DirEntryType;
|
|
95
81
|
/**
|
|
96
|
-
* @param {
|
|
82
|
+
* @param {bigint} arg0
|
|
97
83
|
*/
|
|
98
|
-
set
|
|
84
|
+
set file_size(arg0: bigint);
|
|
99
85
|
/**
|
|
100
|
-
* @returns {
|
|
86
|
+
* @returns {bigint}
|
|
101
87
|
*/
|
|
102
|
-
get
|
|
88
|
+
get file_size(): bigint;
|
|
103
89
|
}
|
|
104
90
|
export class Project {
|
|
105
|
-
/**
|
|
106
|
-
* @param {string} cwd
|
|
107
|
-
* @param {string} thread_url
|
|
108
|
-
*/
|
|
109
|
-
constructor(cwd: string, thread_url: string);
|
|
110
|
-
__destroy_into_raw(): number;
|
|
111
|
-
__wbg_ptr: number;
|
|
112
|
-
free(): void;
|
|
113
91
|
/**
|
|
114
92
|
* @param {string} path
|
|
115
93
|
* @returns {Promise<void>}
|
|
116
94
|
*/
|
|
117
|
-
createDir(path: string): Promise<void>;
|
|
95
|
+
static createDir(path: string): Promise<void>;
|
|
118
96
|
/**
|
|
119
97
|
* @param {string} path
|
|
120
98
|
* @param {boolean} recursive
|
|
121
99
|
* @returns {Promise<void>}
|
|
122
100
|
*/
|
|
123
|
-
removeDir(path: string, recursive: boolean): Promise<void>;
|
|
101
|
+
static removeDir(path: string, recursive: boolean): Promise<void>;
|
|
124
102
|
/**
|
|
125
103
|
* @param {string} path
|
|
126
104
|
* @returns {Promise<void>}
|
|
127
105
|
*/
|
|
128
|
-
removeFile(path: string): Promise<void>;
|
|
106
|
+
static removeFile(path: string): Promise<void>;
|
|
129
107
|
/**
|
|
130
108
|
* @param {string} path
|
|
131
109
|
* @param {string} content
|
|
132
110
|
* @returns {Promise<void>}
|
|
133
111
|
*/
|
|
134
|
-
writeString(path: string, content: string): Promise<void>;
|
|
112
|
+
static writeString(path: string, content: string): Promise<void>;
|
|
135
113
|
/**
|
|
136
114
|
* @param {string} path
|
|
137
115
|
* @returns {Promise<void>}
|
|
138
116
|
*/
|
|
139
|
-
createDirAll(path: string): Promise<void>;
|
|
117
|
+
static createDirAll(path: string): Promise<void>;
|
|
140
118
|
/**
|
|
141
119
|
* @param {string} path
|
|
142
120
|
* @returns {Promise<string>}
|
|
143
121
|
*/
|
|
144
|
-
readToString(path: string): Promise<string>;
|
|
122
|
+
static readToString(path: string): Promise<string>;
|
|
145
123
|
/**
|
|
146
124
|
* @returns {string}
|
|
147
125
|
*/
|
|
148
|
-
get cwd(): string;
|
|
126
|
+
static get cwd(): string;
|
|
127
|
+
/**
|
|
128
|
+
* Generate package-lock.json by resolving dependencies.
|
|
129
|
+
*
|
|
130
|
+
* # Arguments
|
|
131
|
+
* * `registry` - Optional registry URL. If None, uses npmmirror.
|
|
132
|
+
* - "https://registry.npmmirror.com" - supports semver queries (faster)
|
|
133
|
+
* - "https://registry.npmjs.org" - official npm registry (slower, fetches full manifest)
|
|
134
|
+
* * `concurrency` - Optional concurrency limit (defaults to 20)
|
|
135
|
+
* @param {string | null} [registry]
|
|
136
|
+
* @param {number | null} [concurrency]
|
|
137
|
+
* @returns {Promise<string>}
|
|
138
|
+
*/
|
|
139
|
+
static deps(registry?: string | null, concurrency?: number | null): Promise<string>;
|
|
149
140
|
/**
|
|
150
141
|
* Create a tar.gz archive and return bytes (no file I/O)
|
|
151
142
|
* This is useful for main thread execution without OPFS access
|
|
152
143
|
* @param {any} files
|
|
153
|
-
* @returns {Uint8Array}
|
|
144
|
+
* @returns {Promise<Uint8Array>}
|
|
145
|
+
*/
|
|
146
|
+
static gzip(files: any): Promise<Uint8Array>;
|
|
147
|
+
/**
|
|
148
|
+
* @param {string} thread_url
|
|
154
149
|
*/
|
|
155
|
-
|
|
150
|
+
static init(thread_url: string): void;
|
|
156
151
|
/**
|
|
157
152
|
* @param {string} path
|
|
158
153
|
* @returns {Promise<Uint8Array>}
|
|
159
154
|
*/
|
|
160
|
-
read(path: string): Promise<Uint8Array>;
|
|
155
|
+
static read(path: string): Promise<Uint8Array>;
|
|
161
156
|
/**
|
|
162
157
|
* @returns {Promise<any>}
|
|
163
158
|
*/
|
|
164
|
-
build(): Promise<any>;
|
|
159
|
+
static build(): Promise<any>;
|
|
165
160
|
/**
|
|
166
161
|
* @param {string} path
|
|
167
162
|
* @param {Uint8Array} content
|
|
168
163
|
* @returns {Promise<void>}
|
|
169
164
|
*/
|
|
170
|
-
write(path: string, content: Uint8Array): Promise<void>;
|
|
165
|
+
static write(path: string, content: Uint8Array): Promise<void>;
|
|
171
166
|
/**
|
|
172
167
|
* @param {string} package_lock
|
|
173
168
|
* @param {number | null} [max_concurrent_downloads]
|
|
174
169
|
* @returns {Promise<void>}
|
|
175
170
|
*/
|
|
176
|
-
install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
|
|
171
|
+
static install(package_lock: string, max_concurrent_downloads?: number | null): Promise<void>;
|
|
177
172
|
/**
|
|
178
|
-
*
|
|
173
|
+
* @param {string} path
|
|
174
|
+
*/
|
|
175
|
+
static setCwd(path: string): void;
|
|
176
|
+
/**
|
|
177
|
+
* Calculate MD5 hash of byte content (async for better thread scheduling)
|
|
179
178
|
* @param {Uint8Array} content
|
|
180
|
-
* @returns {string}
|
|
179
|
+
* @returns {Promise<string>}
|
|
181
180
|
*/
|
|
182
|
-
sigMd5(content: Uint8Array): string
|
|
181
|
+
static sigMd5(content: Uint8Array): Promise<string>;
|
|
183
182
|
/**
|
|
184
183
|
* @param {string} path
|
|
185
184
|
* @returns {Promise<Metadata>}
|
|
186
185
|
*/
|
|
187
|
-
metadata(path: string): Promise<Metadata>;
|
|
186
|
+
static metadata(path: string): Promise<Metadata>;
|
|
188
187
|
/**
|
|
189
188
|
* @param {string} path
|
|
190
189
|
* @returns {Promise<DirEntry[]>}
|
|
191
190
|
*/
|
|
192
|
-
readDir(path: string): Promise<DirEntry[]>;
|
|
191
|
+
static readDir(path: string): Promise<DirEntry[]>;
|
|
193
192
|
/**
|
|
194
193
|
* @param {string} src
|
|
195
194
|
* @param {string} dst
|
|
196
195
|
* @returns {Promise<void>}
|
|
197
196
|
*/
|
|
198
|
-
copyFile(src: string, dst: string): Promise<void>;
|
|
197
|
+
static copyFile(src: string, dst: string): Promise<void>;
|
|
198
|
+
__destroy_into_raw(): number | undefined;
|
|
199
|
+
__wbg_ptr: number | undefined;
|
|
200
|
+
free(): void;
|
|
199
201
|
}
|
|
200
|
-
export class
|
|
202
|
+
export class WasmTaskMessage {
|
|
203
|
+
static __wrap(ptr: any): any;
|
|
204
|
+
__destroy_into_raw(): number | undefined;
|
|
205
|
+
__wbg_ptr: number | undefined;
|
|
206
|
+
free(): void;
|
|
207
|
+
/**
|
|
208
|
+
* @param {number} arg0
|
|
209
|
+
*/
|
|
210
|
+
set taskId(arg0: number);
|
|
211
|
+
/**
|
|
212
|
+
* @returns {number}
|
|
213
|
+
*/
|
|
214
|
+
get taskId(): number;
|
|
215
|
+
/**
|
|
216
|
+
* @param {string} arg0
|
|
217
|
+
*/
|
|
218
|
+
set data(arg0: string);
|
|
219
|
+
/**
|
|
220
|
+
* @returns {string}
|
|
221
|
+
*/
|
|
222
|
+
get data(): string;
|
|
223
|
+
}
|
|
224
|
+
export class WebWorkerCreation {
|
|
225
|
+
static __wrap(ptr: any): any;
|
|
226
|
+
__destroy_into_raw(): number | undefined;
|
|
227
|
+
__wbg_ptr: number | undefined;
|
|
228
|
+
free(): void;
|
|
229
|
+
/**
|
|
230
|
+
* @param {WebWorkerOptions} arg0
|
|
231
|
+
*/
|
|
232
|
+
set options(arg0: WebWorkerOptions);
|
|
233
|
+
/**
|
|
234
|
+
* @returns {WebWorkerOptions}
|
|
235
|
+
*/
|
|
236
|
+
get options(): WebWorkerOptions;
|
|
237
|
+
}
|
|
238
|
+
export class WebWorkerOptions {
|
|
201
239
|
static __wrap(ptr: any): any;
|
|
202
240
|
__destroy_into_raw(): number | undefined;
|
|
203
241
|
__wbg_ptr: number | undefined;
|
|
@@ -210,6 +248,28 @@ export class WorkerTermination {
|
|
|
210
248
|
* @returns {string}
|
|
211
249
|
*/
|
|
212
250
|
get filename(): string;
|
|
251
|
+
/**
|
|
252
|
+
* @param {string} arg0
|
|
253
|
+
*/
|
|
254
|
+
set cwd(arg0: string);
|
|
255
|
+
/**
|
|
256
|
+
* @returns {string}
|
|
257
|
+
*/
|
|
258
|
+
get cwd(): string;
|
|
259
|
+
}
|
|
260
|
+
export class WebWorkerTermination {
|
|
261
|
+
static __wrap(ptr: any): any;
|
|
262
|
+
__destroy_into_raw(): number | undefined;
|
|
263
|
+
__wbg_ptr: number | undefined;
|
|
264
|
+
free(): void;
|
|
265
|
+
/**
|
|
266
|
+
* @param {WebWorkerOptions} arg0
|
|
267
|
+
*/
|
|
268
|
+
set options(arg0: WebWorkerOptions);
|
|
269
|
+
/**
|
|
270
|
+
* @returns {WebWorkerOptions}
|
|
271
|
+
*/
|
|
272
|
+
get options(): WebWorkerOptions;
|
|
213
273
|
/**
|
|
214
274
|
* @param {number} arg0
|
|
215
275
|
*/
|