@utoo/web 1.1.0 → 1.2.0-rc.2
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/f4423b245e72d3fa009d.wasm +0 -0
- package/esm/internalProject.d.ts +1 -0
- package/esm/internalProject.js +10 -85
- package/esm/loaderWorker.js +2 -0
- package/esm/loaderWorker.js.LICENSE.txt +44 -0
- package/esm/loaderWorkerPool.d.ts +3 -0
- package/esm/loaderWorkerPool.js +125 -0
- package/esm/project.d.ts +1 -0
- package/esm/project.js +2 -0
- package/esm/sabcom.d.ts +31 -0
- package/esm/sabcom.js +71 -0
- package/esm/type.d.ts +1 -0
- package/esm/utoo/index.d.ts +72 -47
- package/esm/utoo/index.js +257 -165
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/worker/cjs.js +253 -58
- package/esm/webpackLoaders/worker/index.d.ts +2 -2
- package/esm/webpackLoaders/worker/index.js +36 -26
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.d.ts +2 -0
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.js +48 -0
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.d.ts +124 -0
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.js +316 -0
- package/esm/webpackLoaders/worker/polyfills/fsPromisesPolyfill.d.ts +9 -0
- package/esm/webpackLoaders/worker/polyfills/fsPromisesPolyfill.js +9 -0
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.d.ts +94 -0
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.js +229 -0
- package/esm/webpackLoaders/worker/polyfills/workerThreadsPolyfill.d.ts +7 -0
- package/esm/webpackLoaders/worker/polyfills/workerThreadsPolyfill.js +16 -0
- package/esm/webpackLoaders/worker/type.d.ts +1 -1
- package/package.json +11 -11
- 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
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { SAB_OP_COPY_FILE, SAB_OP_MKDIR, SAB_OP_READ_DIR, SAB_OP_READ_FILE, SAB_OP_RM, SAB_OP_RMDIR, SAB_OP_WRITE_FILE, } from "../../../sabcom";
|
|
4
|
+
function resolvePath(p) {
|
|
5
|
+
var _a, _b, _c;
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
const cwd = ((_b = (_a = self.process) === null || _a === void 0 ? void 0 : _a.cwd) === null || _b === void 0 ? void 0 : _b.call(_a)) || ((_c = self.workerData) === null || _c === void 0 ? void 0 : _c.cwd) || "/";
|
|
8
|
+
if (cwd === "/") {
|
|
9
|
+
if (p.startsWith("/")) {
|
|
10
|
+
return p.slice(1);
|
|
11
|
+
}
|
|
12
|
+
return p;
|
|
13
|
+
}
|
|
14
|
+
if (p.startsWith(cwd)) {
|
|
15
|
+
// Check if it's an exact match or followed by separator
|
|
16
|
+
if (p.length === cwd.length) {
|
|
17
|
+
return ".";
|
|
18
|
+
}
|
|
19
|
+
if (p[cwd.length] === path.sep || p[cwd.length] === "/") {
|
|
20
|
+
let relative = p.slice(cwd.length);
|
|
21
|
+
if (relative.startsWith("/"))
|
|
22
|
+
relative = relative.slice(1);
|
|
23
|
+
return relative || ".";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return p;
|
|
27
|
+
}
|
|
28
|
+
function getSabClient() {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
const client = self.workerData.sabClient;
|
|
31
|
+
if (!client) {
|
|
32
|
+
throw new Error("Sync fs not supported (no sabClient)");
|
|
33
|
+
}
|
|
34
|
+
return client;
|
|
35
|
+
}
|
|
36
|
+
export function readFile(path, options, cb) {
|
|
37
|
+
if (typeof options === "function") {
|
|
38
|
+
cb = options;
|
|
39
|
+
options = {};
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const data = readFileSync(path, options);
|
|
43
|
+
cb(null, data);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
cb(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function readFileSync(path, options) {
|
|
50
|
+
const client = getSabClient();
|
|
51
|
+
const result = client.call(SAB_OP_READ_FILE, resolvePath(path));
|
|
52
|
+
if (options === "utf8" ||
|
|
53
|
+
options === "utf-8" ||
|
|
54
|
+
(options && (options.encoding === "utf8" || options.encoding === "utf-8"))) {
|
|
55
|
+
return new TextDecoder().decode(result);
|
|
56
|
+
}
|
|
57
|
+
return Buffer.from(result);
|
|
58
|
+
}
|
|
59
|
+
export function readdirSync(path, options) {
|
|
60
|
+
const client = getSabClient();
|
|
61
|
+
const result = client.call(SAB_OP_READ_DIR, resolvePath(path));
|
|
62
|
+
const json = new TextDecoder().decode(result);
|
|
63
|
+
const entries = JSON.parse(json);
|
|
64
|
+
if (options === null || options === void 0 ? void 0 : options.withFileTypes) {
|
|
65
|
+
return entries.map((e) => ({
|
|
66
|
+
name: e.name,
|
|
67
|
+
isFile: () => e.type === "file",
|
|
68
|
+
isDirectory: () => e.type === "directory",
|
|
69
|
+
isSymbolicLink: () => false,
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
return entries.map((e) => e.name);
|
|
73
|
+
}
|
|
74
|
+
export function readdir(path, options, cb) {
|
|
75
|
+
if (typeof options === "function") {
|
|
76
|
+
cb = options;
|
|
77
|
+
options = {};
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const files = readdirSync(path, options);
|
|
81
|
+
cb(null, files);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
cb(e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function writeFileSync(path, data, options) {
|
|
88
|
+
const client = getSabClient();
|
|
89
|
+
// TODO: handle binary data properly
|
|
90
|
+
const content = typeof data === "string" ? data : new TextDecoder().decode(data);
|
|
91
|
+
const payload = JSON.stringify({ path: resolvePath(path), data: content });
|
|
92
|
+
client.call(SAB_OP_WRITE_FILE, payload);
|
|
93
|
+
}
|
|
94
|
+
export function writeFile(path, data, options, cb) {
|
|
95
|
+
if (typeof options === "function") {
|
|
96
|
+
cb = options;
|
|
97
|
+
options = {};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
writeFileSync(path, data, options);
|
|
101
|
+
cb(null);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
cb(e);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export function mkdirSync(path, options) {
|
|
108
|
+
const client = getSabClient();
|
|
109
|
+
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
110
|
+
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
111
|
+
client.call(SAB_OP_MKDIR, payload);
|
|
112
|
+
}
|
|
113
|
+
export function mkdir(path, options, cb) {
|
|
114
|
+
if (typeof options === "function") {
|
|
115
|
+
cb = options;
|
|
116
|
+
options = {};
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
mkdirSync(path, options);
|
|
120
|
+
cb(null);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
cb(e);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function rmSync(path, options) {
|
|
127
|
+
const client = getSabClient();
|
|
128
|
+
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
129
|
+
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
130
|
+
client.call(SAB_OP_RM, payload);
|
|
131
|
+
}
|
|
132
|
+
export function rm(path, options, cb) {
|
|
133
|
+
if (typeof options === "function") {
|
|
134
|
+
cb = options;
|
|
135
|
+
options = {};
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
rmSync(path, options);
|
|
139
|
+
cb(null);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
cb(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
export function rmdirSync(path, options) {
|
|
146
|
+
const client = getSabClient();
|
|
147
|
+
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
148
|
+
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
149
|
+
client.call(SAB_OP_RMDIR, payload);
|
|
150
|
+
}
|
|
151
|
+
export function rmdir(path, options, cb) {
|
|
152
|
+
if (typeof options === "function") {
|
|
153
|
+
cb = options;
|
|
154
|
+
options = {};
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
rmdirSync(path, options);
|
|
158
|
+
cb(null);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
cb(e);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export function copyFileSync(src, dst) {
|
|
165
|
+
const client = getSabClient();
|
|
166
|
+
const payload = JSON.stringify({
|
|
167
|
+
src: resolvePath(src),
|
|
168
|
+
dst: resolvePath(dst),
|
|
169
|
+
});
|
|
170
|
+
client.call(SAB_OP_COPY_FILE, payload);
|
|
171
|
+
}
|
|
172
|
+
export function copyFile(src, dst, cb) {
|
|
173
|
+
try {
|
|
174
|
+
copyFileSync(src, dst);
|
|
175
|
+
cb(null);
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
cb(e);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
export function statSync(p) {
|
|
182
|
+
const parent = path.dirname(p);
|
|
183
|
+
const name = path.basename(p);
|
|
184
|
+
// Root check
|
|
185
|
+
if (p === "/" || p === ".") {
|
|
186
|
+
return {
|
|
187
|
+
isDirectory: () => true,
|
|
188
|
+
isFile: () => false,
|
|
189
|
+
isSymbolicLink: () => false,
|
|
190
|
+
size: 0,
|
|
191
|
+
mtime: new Date(),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const entries = readdirSync(parent, { withFileTypes: true });
|
|
196
|
+
const entry = entries.find((e) => e.name === name);
|
|
197
|
+
if (!entry) {
|
|
198
|
+
throw new Error(`ENOENT: no such file or directory, stat '${p}'`);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
isDirectory: () => entry.isDirectory(),
|
|
202
|
+
isFile: () => entry.isFile(),
|
|
203
|
+
isSymbolicLink: () => entry.isSymbolicLink(),
|
|
204
|
+
size: 0,
|
|
205
|
+
mtime: new Date(),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
throw e;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
export function lstatSync(p) {
|
|
213
|
+
return statSync(p);
|
|
214
|
+
}
|
|
215
|
+
export function stat(path, cb) {
|
|
216
|
+
try {
|
|
217
|
+
const stats = statSync(path);
|
|
218
|
+
cb(null, stats);
|
|
219
|
+
}
|
|
220
|
+
catch (e) {
|
|
221
|
+
cb(e);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
export function lstat(path, cb) {
|
|
225
|
+
try {
|
|
226
|
+
const stats = lstatSync(path);
|
|
227
|
+
cb(null, stats);
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
cb(e);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export function realpathSync(p) {
|
|
234
|
+
return p;
|
|
235
|
+
}
|
|
236
|
+
export function realpath(p, cb) {
|
|
237
|
+
cb(null, p);
|
|
238
|
+
}
|
|
239
|
+
export function accessSync(path, mode) {
|
|
240
|
+
try {
|
|
241
|
+
statSync(path);
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
throw e;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
export function access(path, mode, cb) {
|
|
248
|
+
if (typeof mode === "function") {
|
|
249
|
+
cb = mode;
|
|
250
|
+
mode = 0;
|
|
251
|
+
}
|
|
252
|
+
try {
|
|
253
|
+
accessSync(path, mode);
|
|
254
|
+
if (cb)
|
|
255
|
+
cb(null);
|
|
256
|
+
}
|
|
257
|
+
catch (e) {
|
|
258
|
+
if (cb)
|
|
259
|
+
cb(e);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
export function existsSync(path) {
|
|
263
|
+
try {
|
|
264
|
+
statSync(path);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
export const promises = {
|
|
272
|
+
readFile: async (path, options) => readFileSync(path, options),
|
|
273
|
+
writeFile: async (path, data, options) => writeFileSync(path, data, options),
|
|
274
|
+
readdir: async (path, options) => readdirSync(path, options),
|
|
275
|
+
mkdir: async (path, options) => mkdirSync(path, options),
|
|
276
|
+
rm: async (path, options) => rmSync(path, options),
|
|
277
|
+
rmdir: async (path, options) => rmdirSync(path, options),
|
|
278
|
+
copyFile: async (src, dst) => copyFileSync(src, dst),
|
|
279
|
+
stat: async (p) => statSync(p),
|
|
280
|
+
lstat: async (p) => lstatSync(p),
|
|
281
|
+
realpath: async (p) => realpathSync(p),
|
|
282
|
+
access: async (path, mode) => accessSync(path, mode),
|
|
283
|
+
};
|
|
284
|
+
export const constants = {
|
|
285
|
+
F_OK: 0,
|
|
286
|
+
R_OK: 4,
|
|
287
|
+
W_OK: 2,
|
|
288
|
+
X_OK: 1,
|
|
289
|
+
};
|
|
290
|
+
export default {
|
|
291
|
+
readFile,
|
|
292
|
+
readFileSync,
|
|
293
|
+
readdir,
|
|
294
|
+
readdirSync,
|
|
295
|
+
writeFile,
|
|
296
|
+
writeFileSync,
|
|
297
|
+
mkdir,
|
|
298
|
+
mkdirSync,
|
|
299
|
+
rm,
|
|
300
|
+
rmSync,
|
|
301
|
+
rmdir,
|
|
302
|
+
rmdirSync,
|
|
303
|
+
copyFile,
|
|
304
|
+
copyFileSync,
|
|
305
|
+
stat,
|
|
306
|
+
statSync,
|
|
307
|
+
lstat,
|
|
308
|
+
lstatSync,
|
|
309
|
+
realpath,
|
|
310
|
+
realpathSync,
|
|
311
|
+
access,
|
|
312
|
+
accessSync,
|
|
313
|
+
existsSync,
|
|
314
|
+
promises,
|
|
315
|
+
constants,
|
|
316
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { promises } from "./fsPolyfill";
|
|
2
|
+
export declare const readFile: (path: string, options?: any) => Promise<string | Buffer<any>>;
|
|
3
|
+
export declare const writeFile: (path: string, data: string | Uint8Array, options?: any) => Promise<void>;
|
|
4
|
+
export declare const readdir: (path: string, options?: any) => Promise<any>;
|
|
5
|
+
export declare const mkdir: (path: string, options?: any) => Promise<void>;
|
|
6
|
+
export declare const rm: (path: string, options?: any) => Promise<void>;
|
|
7
|
+
export declare const rmdir: (path: string, options?: any) => Promise<void>;
|
|
8
|
+
export declare const copyFile: (src: string, dst: string) => Promise<void>;
|
|
9
|
+
export default promises;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { promises } from "./fsPolyfill";
|
|
2
|
+
export const readFile = promises.readFile;
|
|
3
|
+
export const writeFile = promises.writeFile;
|
|
4
|
+
export const readdir = promises.readdir;
|
|
5
|
+
export const mkdir = promises.mkdir;
|
|
6
|
+
export const rm = promises.rm;
|
|
7
|
+
export const rmdir = promises.rmdir;
|
|
8
|
+
export const copyFile = promises.copyFile;
|
|
9
|
+
export default promises;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as fs from "./fsPolyfill";
|
|
2
|
+
declare const _default: {
|
|
3
|
+
readonly assert: any;
|
|
4
|
+
readonly "node:assert": any;
|
|
5
|
+
buffer: any;
|
|
6
|
+
"node:buffer": any;
|
|
7
|
+
readonly child_process: any;
|
|
8
|
+
readonly "node:child_process": any;
|
|
9
|
+
readonly cluster: any;
|
|
10
|
+
readonly "node:cluster": any;
|
|
11
|
+
readonly console: any;
|
|
12
|
+
readonly "node:console": any;
|
|
13
|
+
readonly constants: any;
|
|
14
|
+
readonly "node:constants": any;
|
|
15
|
+
readonly crypto: any;
|
|
16
|
+
readonly "node:crypto": any;
|
|
17
|
+
readonly dgram: any;
|
|
18
|
+
readonly "node:dgram": any;
|
|
19
|
+
readonly dns: any;
|
|
20
|
+
readonly "node:dns": any;
|
|
21
|
+
readonly domain: any;
|
|
22
|
+
readonly "node:domain": any;
|
|
23
|
+
readonly events: any;
|
|
24
|
+
readonly "node:events": any;
|
|
25
|
+
"fast-glob": any;
|
|
26
|
+
readonly http: any;
|
|
27
|
+
readonly "node:http": any;
|
|
28
|
+
readonly http2: any;
|
|
29
|
+
readonly "node:http2": any;
|
|
30
|
+
readonly https: any;
|
|
31
|
+
readonly "node:https": any;
|
|
32
|
+
readonly module: any;
|
|
33
|
+
readonly "node:module": any;
|
|
34
|
+
readonly net: any;
|
|
35
|
+
readonly "node:net": any;
|
|
36
|
+
readonly os: any;
|
|
37
|
+
readonly "node:os": any;
|
|
38
|
+
readonly punycode: any;
|
|
39
|
+
readonly "node:punycode": any;
|
|
40
|
+
readonly querystring: any;
|
|
41
|
+
readonly "node:querystring": any;
|
|
42
|
+
readonly readline: any;
|
|
43
|
+
readonly "node:readline": any;
|
|
44
|
+
readonly repl: any;
|
|
45
|
+
readonly "node:repl": any;
|
|
46
|
+
readonly stream: any;
|
|
47
|
+
readonly "node:stream": any;
|
|
48
|
+
readonly string_decoder: any;
|
|
49
|
+
readonly "node:string_decoder": any;
|
|
50
|
+
readonly sys: any;
|
|
51
|
+
readonly "node:sys": any;
|
|
52
|
+
readonly timers: any;
|
|
53
|
+
readonly "node:timers": any;
|
|
54
|
+
readonly tls: any;
|
|
55
|
+
readonly "node:tls": any;
|
|
56
|
+
readonly tty: any;
|
|
57
|
+
readonly "node:tty": any;
|
|
58
|
+
readonly vm: any;
|
|
59
|
+
readonly "node:vm": any;
|
|
60
|
+
readonly zlib: any;
|
|
61
|
+
readonly "node:zlib": any;
|
|
62
|
+
fs: typeof fs;
|
|
63
|
+
"node:fs": typeof fs;
|
|
64
|
+
"graceful-fs": typeof fs;
|
|
65
|
+
path: any;
|
|
66
|
+
"node:path": any;
|
|
67
|
+
process: any;
|
|
68
|
+
"node:process": any;
|
|
69
|
+
readonly url: any;
|
|
70
|
+
readonly "node:url": any;
|
|
71
|
+
readonly util: any;
|
|
72
|
+
readonly "node:util": any;
|
|
73
|
+
worker_threads: {
|
|
74
|
+
workerData: any;
|
|
75
|
+
threadId: any;
|
|
76
|
+
isMainThread: false;
|
|
77
|
+
parentPort: {
|
|
78
|
+
postMessage: (message: any) => void;
|
|
79
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
80
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
"node:worker_threads": {
|
|
84
|
+
workerData: any;
|
|
85
|
+
threadId: any;
|
|
86
|
+
isMainThread: false;
|
|
87
|
+
parentPort: {
|
|
88
|
+
postMessage: (message: any) => void;
|
|
89
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
90
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export default _default;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
const buffer = require("buffer");
|
|
2
|
+
self.Buffer = buffer.Buffer;
|
|
3
|
+
const process = require("process");
|
|
4
|
+
const originalCwd = process.cwd;
|
|
5
|
+
process.cwd = () => {
|
|
6
|
+
var _a;
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
return ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || (originalCwd === null || originalCwd === void 0 ? void 0 : originalCwd()) || "/";
|
|
9
|
+
};
|
|
10
|
+
self.process = process;
|
|
11
|
+
self.global = self;
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const originalResolve = path.resolve;
|
|
14
|
+
path.resolve = (...args) => {
|
|
15
|
+
var _a;
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const cwd = ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || "/";
|
|
18
|
+
return originalResolve(cwd, ...args);
|
|
19
|
+
};
|
|
20
|
+
import fastGlob from "./fastGlobPolyfill";
|
|
21
|
+
import * as fs from "./fsPolyfill";
|
|
22
|
+
import * as workerThreads from "./workerThreadsPolyfill";
|
|
23
|
+
const workerThreadsWithLiveWorkerData = {
|
|
24
|
+
...workerThreads,
|
|
25
|
+
get workerData() {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
return self.workerData;
|
|
28
|
+
},
|
|
29
|
+
get threadId() {
|
|
30
|
+
var _a;
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
return ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.workerId) || 0;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
// Used to directly inject polyfill instance into systemjs
|
|
36
|
+
export default {
|
|
37
|
+
get assert() {
|
|
38
|
+
return require("assert");
|
|
39
|
+
},
|
|
40
|
+
get "node:assert"() {
|
|
41
|
+
return require("assert");
|
|
42
|
+
},
|
|
43
|
+
buffer,
|
|
44
|
+
"node:buffer": buffer,
|
|
45
|
+
get child_process() {
|
|
46
|
+
return require("child_process");
|
|
47
|
+
},
|
|
48
|
+
get "node:child_process"() {
|
|
49
|
+
return require("child_process");
|
|
50
|
+
},
|
|
51
|
+
get cluster() {
|
|
52
|
+
return require("cluster");
|
|
53
|
+
},
|
|
54
|
+
get "node:cluster"() {
|
|
55
|
+
return require("cluster");
|
|
56
|
+
},
|
|
57
|
+
get console() {
|
|
58
|
+
return require("console");
|
|
59
|
+
},
|
|
60
|
+
get "node:console"() {
|
|
61
|
+
return require("console");
|
|
62
|
+
},
|
|
63
|
+
get constants() {
|
|
64
|
+
return require("constants");
|
|
65
|
+
},
|
|
66
|
+
get "node:constants"() {
|
|
67
|
+
return require("constants");
|
|
68
|
+
},
|
|
69
|
+
get crypto() {
|
|
70
|
+
return require("crypto");
|
|
71
|
+
},
|
|
72
|
+
get "node:crypto"() {
|
|
73
|
+
return require("crypto");
|
|
74
|
+
},
|
|
75
|
+
get dgram() {
|
|
76
|
+
return require("dgram");
|
|
77
|
+
},
|
|
78
|
+
get "node:dgram"() {
|
|
79
|
+
return require("dgram");
|
|
80
|
+
},
|
|
81
|
+
get dns() {
|
|
82
|
+
return require("dns");
|
|
83
|
+
},
|
|
84
|
+
get "node:dns"() {
|
|
85
|
+
return require("dns");
|
|
86
|
+
},
|
|
87
|
+
get domain() {
|
|
88
|
+
return require("domain");
|
|
89
|
+
},
|
|
90
|
+
get "node:domain"() {
|
|
91
|
+
return require("domain");
|
|
92
|
+
},
|
|
93
|
+
get events() {
|
|
94
|
+
return require("events");
|
|
95
|
+
},
|
|
96
|
+
get "node:events"() {
|
|
97
|
+
return require("events");
|
|
98
|
+
},
|
|
99
|
+
"fast-glob": fastGlob,
|
|
100
|
+
get http() {
|
|
101
|
+
return require("http");
|
|
102
|
+
},
|
|
103
|
+
get "node:http"() {
|
|
104
|
+
return require("http");
|
|
105
|
+
},
|
|
106
|
+
get http2() {
|
|
107
|
+
return require("http2");
|
|
108
|
+
},
|
|
109
|
+
get "node:http2"() {
|
|
110
|
+
return require("http2");
|
|
111
|
+
},
|
|
112
|
+
get https() {
|
|
113
|
+
return require("https");
|
|
114
|
+
},
|
|
115
|
+
get "node:https"() {
|
|
116
|
+
return require("https");
|
|
117
|
+
},
|
|
118
|
+
get module() {
|
|
119
|
+
return require("module");
|
|
120
|
+
},
|
|
121
|
+
get "node:module"() {
|
|
122
|
+
return require("module");
|
|
123
|
+
},
|
|
124
|
+
get net() {
|
|
125
|
+
return require("net");
|
|
126
|
+
},
|
|
127
|
+
get "node:net"() {
|
|
128
|
+
return require("net");
|
|
129
|
+
},
|
|
130
|
+
get os() {
|
|
131
|
+
return require("os");
|
|
132
|
+
},
|
|
133
|
+
get "node:os"() {
|
|
134
|
+
return require("os");
|
|
135
|
+
},
|
|
136
|
+
get punycode() {
|
|
137
|
+
return require("punycode");
|
|
138
|
+
},
|
|
139
|
+
get "node:punycode"() {
|
|
140
|
+
return require("punycode");
|
|
141
|
+
},
|
|
142
|
+
get querystring() {
|
|
143
|
+
return require("querystring");
|
|
144
|
+
},
|
|
145
|
+
get "node:querystring"() {
|
|
146
|
+
return require("querystring");
|
|
147
|
+
},
|
|
148
|
+
get readline() {
|
|
149
|
+
return require("readline");
|
|
150
|
+
},
|
|
151
|
+
get "node:readline"() {
|
|
152
|
+
return require("readline");
|
|
153
|
+
},
|
|
154
|
+
get repl() {
|
|
155
|
+
return require("repl");
|
|
156
|
+
},
|
|
157
|
+
get "node:repl"() {
|
|
158
|
+
return require("repl");
|
|
159
|
+
},
|
|
160
|
+
get stream() {
|
|
161
|
+
return require("stream");
|
|
162
|
+
},
|
|
163
|
+
get "node:stream"() {
|
|
164
|
+
return require("stream");
|
|
165
|
+
},
|
|
166
|
+
get string_decoder() {
|
|
167
|
+
return require("string_decoder");
|
|
168
|
+
},
|
|
169
|
+
get "node:string_decoder"() {
|
|
170
|
+
return require("string_decoder");
|
|
171
|
+
},
|
|
172
|
+
get sys() {
|
|
173
|
+
return require("util");
|
|
174
|
+
},
|
|
175
|
+
get "node:sys"() {
|
|
176
|
+
return require("util");
|
|
177
|
+
},
|
|
178
|
+
get timers() {
|
|
179
|
+
return require("timers");
|
|
180
|
+
},
|
|
181
|
+
get "node:timers"() {
|
|
182
|
+
return require("timers");
|
|
183
|
+
},
|
|
184
|
+
get tls() {
|
|
185
|
+
return require("tls");
|
|
186
|
+
},
|
|
187
|
+
get "node:tls"() {
|
|
188
|
+
return require("tls");
|
|
189
|
+
},
|
|
190
|
+
get tty() {
|
|
191
|
+
return require("tty");
|
|
192
|
+
},
|
|
193
|
+
get "node:tty"() {
|
|
194
|
+
return require("tty");
|
|
195
|
+
},
|
|
196
|
+
get vm() {
|
|
197
|
+
return require("vm");
|
|
198
|
+
},
|
|
199
|
+
get "node:vm"() {
|
|
200
|
+
return require("vm");
|
|
201
|
+
},
|
|
202
|
+
get zlib() {
|
|
203
|
+
return require("zlib");
|
|
204
|
+
},
|
|
205
|
+
get "node:zlib"() {
|
|
206
|
+
return require("zlib");
|
|
207
|
+
},
|
|
208
|
+
fs,
|
|
209
|
+
"node:fs": fs,
|
|
210
|
+
"graceful-fs": fs,
|
|
211
|
+
path,
|
|
212
|
+
"node:path": path,
|
|
213
|
+
process,
|
|
214
|
+
"node:process": process,
|
|
215
|
+
get url() {
|
|
216
|
+
return require("url");
|
|
217
|
+
},
|
|
218
|
+
get "node:url"() {
|
|
219
|
+
return require("url");
|
|
220
|
+
},
|
|
221
|
+
get util() {
|
|
222
|
+
return require("util");
|
|
223
|
+
},
|
|
224
|
+
get "node:util"() {
|
|
225
|
+
return require("util");
|
|
226
|
+
},
|
|
227
|
+
worker_threads: workerThreadsWithLiveWorkerData,
|
|
228
|
+
"node:worker_threads": workerThreadsWithLiveWorkerData,
|
|
229
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const workerData: any;
|
|
2
|
+
export declare const isMainThread = false;
|
|
3
|
+
export declare const parentPort: {
|
|
4
|
+
postMessage: (message: any) => void;
|
|
5
|
+
on: (event: string, listener: (...args: any[]) => void) => void;
|
|
6
|
+
off: (event: string, listener: (...args: any[]) => void) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
export const workerData = self.workerData;
|
|
3
|
+
export const isMainThread = false;
|
|
4
|
+
export const parentPort = {
|
|
5
|
+
postMessage: (message) => self.postMessage(message),
|
|
6
|
+
on: (event, listener) => {
|
|
7
|
+
if (event === "message") {
|
|
8
|
+
self.onmessage = (e) => listener(e.data);
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
off: (event, listener) => {
|
|
12
|
+
if (event === "message") {
|
|
13
|
+
self.onmessage = null;
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export interface LoaderRunnerMeta {
|
|
2
2
|
workerData: {
|
|
3
|
-
poolId: string;
|
|
4
3
|
workerId: number;
|
|
5
4
|
cwd: string;
|
|
6
5
|
};
|
|
@@ -8,4 +7,5 @@ export interface LoaderRunnerMeta {
|
|
|
8
7
|
importMaps: Record<string, string>;
|
|
9
8
|
entrypoint: string;
|
|
10
9
|
};
|
|
10
|
+
sab?: SharedArrayBuffer;
|
|
11
11
|
}
|