@utoo/web 1.5.3-rc.3 → 1.5.3
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/loaderWorkerInline.js +1 -1
- package/esm/project/InternalProject.js +5 -5
- package/esm/project/Project.js +1 -2
- package/esm/serviceWorkerBundle.js +1 -1
- package/esm/threadWorkerInline.js +1 -1
- package/esm/types.d.ts +0 -1
- package/esm/utoo/index.js +24 -24
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/cjs.d.ts +1 -1
- package/esm/webpackLoaders/cjs.js +12 -47
- package/esm/webpackLoaders/loaderWorkerPool.d.ts +1 -1
- package/esm/webpackLoaders/loaderWorkerPool.js +3 -3
- package/esm/webpackLoaders/polyfills/fsPolyfill/utils.js +7 -12
- package/esm/webpackLoaders/polyfills/nodePolyFills.js +14 -14
- package/esm/webpackLoaders/types.d.ts +0 -1
- package/esm/webpackLoaders/worker.js +19 -69
- package/esm/workerInline.js +1 -1
- package/package.json +4 -9
|
@@ -15,11 +15,6 @@ export function getFs() {
|
|
|
15
15
|
}
|
|
16
16
|
return fs;
|
|
17
17
|
}
|
|
18
|
-
const preserveOriginalError = (fsError, error, message) => {
|
|
19
|
-
fsError.originalMessage = message;
|
|
20
|
-
fsError.cause = error;
|
|
21
|
-
return fsError;
|
|
22
|
-
};
|
|
23
18
|
export function translateError(error, path, syscall) {
|
|
24
19
|
const message = error.message || String(error);
|
|
25
20
|
// 1. NotFound (ENOENT)
|
|
@@ -30,7 +25,7 @@ export function translateError(error, path, syscall) {
|
|
|
30
25
|
e.code = "ENOENT";
|
|
31
26
|
e.syscall = syscall;
|
|
32
27
|
e.path = path;
|
|
33
|
-
return
|
|
28
|
+
return e;
|
|
34
29
|
}
|
|
35
30
|
// 2. Directory error (Mapped to EISDIR)
|
|
36
31
|
// Mapping "TypeMismatchError" or "type mismatch" from tokio-fs-ext
|
|
@@ -40,7 +35,7 @@ export function translateError(error, path, syscall) {
|
|
|
40
35
|
e.code = "EISDIR";
|
|
41
36
|
e.syscall = syscall;
|
|
42
37
|
e.path = path;
|
|
43
|
-
return
|
|
38
|
+
return e;
|
|
44
39
|
}
|
|
45
40
|
// 3. Locking/Concurrency (Mapped to EAGAIN/EBUSY)
|
|
46
41
|
// Mapping "NoModificationAllowedError" from tokio-fs-ext
|
|
@@ -50,7 +45,7 @@ export function translateError(error, path, syscall) {
|
|
|
50
45
|
e.code = "EAGAIN";
|
|
51
46
|
e.syscall = syscall;
|
|
52
47
|
e.path = path;
|
|
53
|
-
return
|
|
48
|
+
return e;
|
|
54
49
|
}
|
|
55
50
|
// 4. Permission Denied (EACCES)
|
|
56
51
|
// Mapping "NotAllowedError" from tokio-fs-ext
|
|
@@ -60,7 +55,7 @@ export function translateError(error, path, syscall) {
|
|
|
60
55
|
e.code = "EACCES";
|
|
61
56
|
e.syscall = syscall;
|
|
62
57
|
e.path = path;
|
|
63
|
-
return
|
|
58
|
+
return e;
|
|
64
59
|
}
|
|
65
60
|
// 5. Storage Full (ENOSPC)
|
|
66
61
|
// Mapping "QuotaExceededError" from tokio-fs-ext
|
|
@@ -70,7 +65,7 @@ export function translateError(error, path, syscall) {
|
|
|
70
65
|
e.code = "ENOSPC";
|
|
71
66
|
e.syscall = syscall;
|
|
72
67
|
e.path = path;
|
|
73
|
-
return
|
|
68
|
+
return e;
|
|
74
69
|
}
|
|
75
70
|
// 6. Invalid Argument (EINVAL)
|
|
76
71
|
// Mapping "InvalidStateError" from tokio-fs-ext
|
|
@@ -80,7 +75,7 @@ export function translateError(error, path, syscall) {
|
|
|
80
75
|
e.code = "EINVAL";
|
|
81
76
|
e.syscall = syscall;
|
|
82
77
|
e.path = path;
|
|
83
|
-
return
|
|
78
|
+
return e;
|
|
84
79
|
}
|
|
85
80
|
// 7. Interrupted (EINTR)
|
|
86
81
|
// Mapping "AbortError" from tokio-fs-ext
|
|
@@ -90,7 +85,7 @@ export function translateError(error, path, syscall) {
|
|
|
90
85
|
e.code = "EINTR";
|
|
91
86
|
e.syscall = syscall;
|
|
92
87
|
e.path = path;
|
|
93
|
-
return
|
|
88
|
+
return e;
|
|
94
89
|
}
|
|
95
90
|
return error;
|
|
96
91
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as fs from "./fsPolyfill";
|
|
2
2
|
import * as workerThreads from "./workerThreadsPolyfill";
|
|
3
|
-
const
|
|
4
|
-
self.Buffer =
|
|
5
|
-
const
|
|
6
|
-
const originalCwd =
|
|
7
|
-
|
|
3
|
+
const bufferPolyfilled = require("buffer");
|
|
4
|
+
self.Buffer = bufferPolyfilled.Buffer;
|
|
5
|
+
const processPolyfilled = require("process");
|
|
6
|
+
const originalCwd = processPolyfilled.cwd;
|
|
7
|
+
processPolyfilled.cwd = () => {
|
|
8
8
|
var _a;
|
|
9
9
|
// @ts-ignore
|
|
10
10
|
return ((_a = workerThreads.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || (originalCwd === null || originalCwd === void 0 ? void 0 : originalCwd()) || "/";
|
|
11
11
|
};
|
|
12
|
-
if (!
|
|
13
|
-
|
|
14
|
-
if (!
|
|
15
|
-
|
|
16
|
-
self.process =
|
|
12
|
+
if (!processPolyfilled.versions)
|
|
13
|
+
processPolyfilled.versions = {};
|
|
14
|
+
if (!processPolyfilled.versions.node)
|
|
15
|
+
processPolyfilled.versions.node = "24.0.0";
|
|
16
|
+
self.process = processPolyfilled;
|
|
17
17
|
self.global = self;
|
|
18
18
|
const path = require("path");
|
|
19
19
|
const originalResolve = path.resolve;
|
|
@@ -41,8 +41,8 @@ export default {
|
|
|
41
41
|
get "node:assert"() {
|
|
42
42
|
return require("assert");
|
|
43
43
|
},
|
|
44
|
-
buffer,
|
|
45
|
-
"node:buffer":
|
|
44
|
+
buffer: bufferPolyfilled,
|
|
45
|
+
"node:buffer": bufferPolyfilled,
|
|
46
46
|
get child_process() {
|
|
47
47
|
return require("child_process");
|
|
48
48
|
},
|
|
@@ -213,8 +213,8 @@ export default {
|
|
|
213
213
|
"node:fs": fs,
|
|
214
214
|
path,
|
|
215
215
|
"node:path": path,
|
|
216
|
-
process,
|
|
217
|
-
"node:process":
|
|
216
|
+
process: processPolyfilled,
|
|
217
|
+
"node:process": processPolyfilled,
|
|
218
218
|
get url() {
|
|
219
219
|
return require("url");
|
|
220
220
|
},
|
|
@@ -5,78 +5,28 @@ const binding = {
|
|
|
5
5
|
sendTaskMessage,
|
|
6
6
|
workerCreated,
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (error && typeof error === "object") {
|
|
12
|
-
const { code, message } = error;
|
|
13
|
-
return [code, message].filter(Boolean).join(": ");
|
|
14
|
-
}
|
|
15
|
-
return String(error);
|
|
16
|
-
};
|
|
17
|
-
const isMissingEntrypointError = (error) => {
|
|
18
|
-
if (error && typeof error === "object") {
|
|
19
|
-
const { code, message } = error;
|
|
20
|
-
if (code === "ENOENT")
|
|
21
|
-
return true;
|
|
22
|
-
return Boolean((message === null || message === void 0 ? void 0 : message.includes("NotFoundError")) || (message === null || message === void 0 ? void 0 : message.includes("ENOENT")));
|
|
23
|
-
}
|
|
24
|
-
return String(error).includes("NotFoundError");
|
|
25
|
-
};
|
|
26
|
-
const waitForEntrypointReadable = async (entrypoint) => {
|
|
27
|
-
let lastError;
|
|
28
|
-
for (let attempt = 0;; attempt += 1) {
|
|
8
|
+
export function startLoaderWorker() {
|
|
9
|
+
self.onmessage = (event) => {
|
|
10
|
+
let [module, memory, meta] = event.data;
|
|
29
11
|
try {
|
|
30
|
-
|
|
31
|
-
return;
|
|
12
|
+
initSync({ module, memory });
|
|
32
13
|
}
|
|
33
|
-
catch (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
attempt >= ENTRYPOINT_READ_RETRY_DELAYS_MS.length) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
await delay(ENTRYPOINT_READ_RETRY_DELAYS_MS[attempt]);
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error(err);
|
|
16
|
+
throw err;
|
|
40
17
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
initSync({ module, memory });
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
console.error(err);
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
59
|
-
self.workerData = {
|
|
60
|
-
threadId: meta.workerData.threadId,
|
|
61
|
-
cwd: meta.workerData.cwd,
|
|
62
|
-
projectRoot: meta.workerData.projectRoot,
|
|
63
|
-
binding,
|
|
64
|
-
fs: Fs,
|
|
65
|
-
};
|
|
66
|
-
self.process = {
|
|
67
|
-
env: {},
|
|
68
|
-
cwd: () => self.workerData.cwd,
|
|
69
|
-
};
|
|
70
|
-
await waitForEntrypointReadable(meta.loaderAssets.entrypoint);
|
|
71
|
-
await cjs(meta.loaderAssets.entrypoint, meta.loaderAssets.importMaps, meta.loaderAssets.loadersImportMapFetchCache);
|
|
72
|
-
};
|
|
73
|
-
export function startLoaderWorker() {
|
|
74
|
-
self.onmessage = (event) => {
|
|
75
|
-
void handleLoaderWorkerMessage(event).catch((error) => {
|
|
76
|
-
setTimeout(() => {
|
|
77
|
-
throw error;
|
|
78
|
-
});
|
|
79
|
-
});
|
|
18
|
+
self.workerData = {
|
|
19
|
+
threadId: meta.workerData.threadId,
|
|
20
|
+
cwd: meta.workerData.cwd,
|
|
21
|
+
projectRoot: meta.workerData.projectRoot,
|
|
22
|
+
binding,
|
|
23
|
+
fs: Fs,
|
|
24
|
+
};
|
|
25
|
+
self.process = {
|
|
26
|
+
env: {},
|
|
27
|
+
cwd: () => self.workerData.cwd,
|
|
28
|
+
};
|
|
29
|
+
cjs(meta.loaderAssets.entrypoint, meta.loaderAssets.importMaps);
|
|
80
30
|
};
|
|
81
31
|
}
|
|
82
32
|
// @ts-ignore
|