@qds.dev/code 0.8.2 → 0.8.5
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/lib/preview/bundler/repl-bundler-worker.qwik.mjs +2747 -378
- package/lib/preview/bundler/wasi-worker-browser.mjs +2962 -1632
- package/package.json +1 -1
- package/lib-types/src/debug.d.ts +0 -1
- package/lib-types/src/preview/bundler/index.d.ts +0 -34
- package/lib-types/src/preview/bundler/repl-ssr-worker.d.ts +0 -27
- package/lib-types/src/preview/index.d.ts +0 -19
- package/lib-types/src/preview/preview-sw.d.ts +0 -20
- package/lib-types/src/preview/preview-sw.unit.d.ts +0 -1
- package/lib-types/src/preview/repl-helpers-node.d.ts +0 -4
- package/lib-types/src/preview/repl-helpers.d.ts +0 -16
- package/lib-types/src/preview/repl-helpers.unit.d.ts +0 -1
|
@@ -1,42 +1,626 @@
|
|
|
1
|
-
import { ThreadManager, ThreadMessageHandler, WASIThreads } from "@emnapi/wasi-threads";
|
|
2
|
-
|
|
3
1
|
//#region rolldown:runtime
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region ../../node_modules/.pnpm/@emnapi+wasi-threads@1.1.0/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js
|
|
9
|
+
var _WebAssembly$2 = typeof WebAssembly !== "undefined" ? WebAssembly : typeof WXWebAssembly !== "undefined" ? WXWebAssembly : void 0;
|
|
10
|
+
var ENVIRONMENT_IS_NODE = typeof process === "object" && process !== null && typeof process.versions === "object" && process.versions !== null && typeof process.versions.node === "string";
|
|
11
|
+
function getPostMessage(options$1) {
|
|
12
|
+
return typeof (options$1 === null || options$1 === void 0 ? void 0 : options$1.postMessage) === "function" ? options$1.postMessage : typeof postMessage === "function" ? postMessage : void 0;
|
|
13
|
+
}
|
|
14
|
+
function deserizeErrorFromBuffer(sab) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
var i32array = new Int32Array(sab);
|
|
17
|
+
if (Atomics.load(i32array, 0) <= 1) return null;
|
|
18
|
+
var nameLength = Atomics.load(i32array, 1);
|
|
19
|
+
var messageLength = Atomics.load(i32array, 2);
|
|
20
|
+
var stackLength = Atomics.load(i32array, 3);
|
|
21
|
+
var buffer = new Uint8Array(sab);
|
|
22
|
+
var nameBuffer = buffer.slice(16, 16 + nameLength);
|
|
23
|
+
var messageBuffer = buffer.slice(16 + nameLength, 16 + nameLength + messageLength);
|
|
24
|
+
var stackBuffer = buffer.slice(16 + nameLength + messageLength, 16 + nameLength + messageLength + stackLength);
|
|
25
|
+
var name = new TextDecoder().decode(nameBuffer);
|
|
26
|
+
var message = new TextDecoder().decode(messageBuffer);
|
|
27
|
+
var stack = new TextDecoder().decode(stackBuffer);
|
|
28
|
+
var error$1 = new ((_a = globalThis[name]) !== null && _a !== void 0 ? _a : name === "RuntimeError" ? (_b = _WebAssembly$2.RuntimeError) !== null && _b !== void 0 ? _b : Error : Error)(message);
|
|
29
|
+
Object.defineProperty(error$1, "stack", {
|
|
30
|
+
value: stack,
|
|
31
|
+
writable: true,
|
|
32
|
+
enumerable: false,
|
|
33
|
+
configurable: true
|
|
34
|
+
});
|
|
35
|
+
return error$1;
|
|
36
|
+
}
|
|
37
|
+
/** @public */
|
|
38
|
+
function isSharedArrayBuffer(value) {
|
|
39
|
+
return typeof SharedArrayBuffer === "function" && value instanceof SharedArrayBuffer || Object.prototype.toString.call(value) === "[object SharedArrayBuffer]";
|
|
40
|
+
}
|
|
41
|
+
/** @public */
|
|
42
|
+
function isTrapError(e$1) {
|
|
43
|
+
try {
|
|
44
|
+
return e$1 instanceof _WebAssembly$2.RuntimeError;
|
|
45
|
+
} catch (_) {
|
|
46
|
+
return false;
|
|
15
47
|
}
|
|
16
|
-
|
|
17
|
-
|
|
48
|
+
}
|
|
49
|
+
function createMessage(type$1, payload) {
|
|
50
|
+
return { __emnapi__: {
|
|
51
|
+
type: type$1,
|
|
52
|
+
payload
|
|
53
|
+
} };
|
|
54
|
+
}
|
|
55
|
+
var WASI_THREADS_MAX_TID = 536870911;
|
|
56
|
+
function checkSharedWasmMemory(wasmMemory) {
|
|
57
|
+
if (wasmMemory) {
|
|
58
|
+
if (!isSharedArrayBuffer(wasmMemory.buffer)) throw new Error("Multithread features require shared wasm memory. Try to compile with `-matomics -mbulk-memory` and use `--import-memory --shared-memory` during linking, then create WebAssembly.Memory with `shared: true` option");
|
|
59
|
+
} else if (typeof SharedArrayBuffer === "undefined") throw new Error("Current environment does not support SharedArrayBuffer, threads are not available!");
|
|
60
|
+
}
|
|
61
|
+
function getReuseWorker(value) {
|
|
62
|
+
var _a;
|
|
63
|
+
if (typeof value === "boolean") return value ? {
|
|
64
|
+
size: 0,
|
|
65
|
+
strict: false
|
|
66
|
+
} : false;
|
|
67
|
+
if (typeof value === "number") {
|
|
68
|
+
if (!(value >= 0)) throw new RangeError("reuseWorker: size must be a non-negative integer");
|
|
69
|
+
return {
|
|
70
|
+
size: value,
|
|
71
|
+
strict: false
|
|
72
|
+
};
|
|
18
73
|
}
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
74
|
+
if (!value) return false;
|
|
75
|
+
var size = (_a = Number(value.size)) !== null && _a !== void 0 ? _a : 0;
|
|
76
|
+
var strict = Boolean(value.strict);
|
|
77
|
+
if (!(size > 0) && strict) throw new RangeError("reuseWorker: size must be set to positive integer if strict is set to true");
|
|
78
|
+
return {
|
|
79
|
+
size,
|
|
80
|
+
strict
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
var nextWorkerID = 0;
|
|
84
|
+
/** @public */
|
|
85
|
+
var ThreadManager = /* @__PURE__ */ function() {
|
|
86
|
+
function ThreadManager$1(options$1) {
|
|
87
|
+
var _a;
|
|
88
|
+
this.unusedWorkers = [];
|
|
89
|
+
this.runningWorkers = [];
|
|
90
|
+
this.pthreads = Object.create(null);
|
|
91
|
+
this.wasmModule = null;
|
|
92
|
+
this.wasmMemory = null;
|
|
93
|
+
this.messageEvents = /* @__PURE__ */ new WeakMap();
|
|
94
|
+
if (!options$1) throw new TypeError("ThreadManager(): options is not provided");
|
|
95
|
+
if ("childThread" in options$1) this._childThread = Boolean(options$1.childThread);
|
|
96
|
+
else this._childThread = false;
|
|
97
|
+
if (this._childThread) {
|
|
98
|
+
this._onCreateWorker = void 0;
|
|
99
|
+
this._reuseWorker = false;
|
|
100
|
+
this._beforeLoad = void 0;
|
|
101
|
+
} else {
|
|
102
|
+
this._onCreateWorker = options$1.onCreateWorker;
|
|
103
|
+
this._reuseWorker = getReuseWorker(options$1.reuseWorker);
|
|
104
|
+
this._beforeLoad = options$1.beforeLoad;
|
|
105
|
+
}
|
|
106
|
+
this.printErr = (_a = options$1.printErr) !== null && _a !== void 0 ? _a : console.error.bind(console);
|
|
107
|
+
}
|
|
108
|
+
Object.defineProperty(ThreadManager$1.prototype, "nextWorkerID", {
|
|
109
|
+
get: function() {
|
|
110
|
+
return nextWorkerID;
|
|
111
|
+
},
|
|
112
|
+
enumerable: false,
|
|
113
|
+
configurable: true
|
|
114
|
+
});
|
|
115
|
+
ThreadManager$1.prototype.init = function() {
|
|
116
|
+
if (!this._childThread) this.initMainThread();
|
|
117
|
+
};
|
|
118
|
+
ThreadManager$1.prototype.initMainThread = function() {
|
|
119
|
+
this.preparePool();
|
|
120
|
+
};
|
|
121
|
+
ThreadManager$1.prototype.preparePool = function() {
|
|
122
|
+
if (this._reuseWorker) {
|
|
123
|
+
if (this._reuseWorker.size) {
|
|
124
|
+
var pthreadPoolSize = this._reuseWorker.size;
|
|
125
|
+
while (pthreadPoolSize--) {
|
|
126
|
+
var worker = this.allocateUnusedWorker();
|
|
127
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
128
|
+
worker.once("message", function() {});
|
|
129
|
+
worker.unref();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
ThreadManager$1.prototype.shouldPreloadWorkers = function() {
|
|
136
|
+
return !this._childThread && this._reuseWorker && this._reuseWorker.size > 0;
|
|
137
|
+
};
|
|
138
|
+
ThreadManager$1.prototype.loadWasmModuleToAllWorkers = function() {
|
|
139
|
+
var _this_1 = this;
|
|
140
|
+
var promises$1 = Array(this.unusedWorkers.length);
|
|
141
|
+
var _loop_1 = function(i$1) {
|
|
142
|
+
var worker = this_1.unusedWorkers[i$1];
|
|
143
|
+
if (ENVIRONMENT_IS_NODE) worker.ref();
|
|
144
|
+
promises$1[i$1] = this_1.loadWasmModuleToWorker(worker).then(function(w) {
|
|
145
|
+
if (ENVIRONMENT_IS_NODE) worker.unref();
|
|
146
|
+
return w;
|
|
147
|
+
}, function(e$1) {
|
|
148
|
+
if (ENVIRONMENT_IS_NODE) worker.unref();
|
|
149
|
+
throw e$1;
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
var this_1 = this;
|
|
153
|
+
for (var i = 0; i < this.unusedWorkers.length; ++i) _loop_1(i);
|
|
154
|
+
return Promise.all(promises$1).catch(function(err) {
|
|
155
|
+
_this_1.terminateAllThreads();
|
|
156
|
+
throw err;
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
ThreadManager$1.prototype.preloadWorkers = function() {
|
|
160
|
+
if (this.shouldPreloadWorkers()) return this.loadWasmModuleToAllWorkers();
|
|
161
|
+
return Promise.resolve([]);
|
|
162
|
+
};
|
|
163
|
+
ThreadManager$1.prototype.setup = function(wasmModule, wasmMemory) {
|
|
164
|
+
this.wasmModule = wasmModule;
|
|
165
|
+
this.wasmMemory = wasmMemory;
|
|
166
|
+
};
|
|
167
|
+
ThreadManager$1.prototype.markId = function(worker) {
|
|
168
|
+
if (worker.__emnapi_tid) return worker.__emnapi_tid;
|
|
169
|
+
var tid = nextWorkerID + 43;
|
|
170
|
+
nextWorkerID = (nextWorkerID + 1) % (WASI_THREADS_MAX_TID - 42);
|
|
171
|
+
this.pthreads[tid] = worker;
|
|
172
|
+
worker.__emnapi_tid = tid;
|
|
173
|
+
return tid;
|
|
174
|
+
};
|
|
175
|
+
ThreadManager$1.prototype.returnWorkerToPool = function(worker) {
|
|
176
|
+
var tid = worker.__emnapi_tid;
|
|
177
|
+
if (tid !== void 0) delete this.pthreads[tid];
|
|
178
|
+
this.unusedWorkers.push(worker);
|
|
179
|
+
this.runningWorkers.splice(this.runningWorkers.indexOf(worker), 1);
|
|
180
|
+
delete worker.__emnapi_tid;
|
|
181
|
+
if (ENVIRONMENT_IS_NODE) worker.unref();
|
|
182
|
+
};
|
|
183
|
+
ThreadManager$1.prototype.loadWasmModuleToWorker = function(worker, sab) {
|
|
184
|
+
var _this_1 = this;
|
|
185
|
+
if (worker.whenLoaded) return worker.whenLoaded;
|
|
186
|
+
var err = this.printErr;
|
|
187
|
+
var beforeLoad = this._beforeLoad;
|
|
188
|
+
var _this = this;
|
|
189
|
+
worker.whenLoaded = new Promise(function(resolve$2, reject) {
|
|
190
|
+
var handleError$1 = function(e$1) {
|
|
191
|
+
var message = "worker sent an error!";
|
|
192
|
+
if (worker.__emnapi_tid !== void 0) message = "worker (tid = " + worker.__emnapi_tid + ") sent an error!";
|
|
193
|
+
if ("message" in e$1) {
|
|
194
|
+
err(message + " " + e$1.message);
|
|
195
|
+
if (e$1.message.indexOf("RuntimeError") !== -1 || e$1.message.indexOf("unreachable") !== -1) try {
|
|
196
|
+
_this.terminateAllThreads();
|
|
197
|
+
} catch (_) {}
|
|
198
|
+
} else err(message);
|
|
199
|
+
reject(e$1);
|
|
200
|
+
throw e$1;
|
|
201
|
+
};
|
|
202
|
+
var handleMessage$1 = function(data) {
|
|
203
|
+
if (data.__emnapi__) {
|
|
204
|
+
var type$1 = data.__emnapi__.type;
|
|
205
|
+
var payload = data.__emnapi__.payload;
|
|
206
|
+
if (type$1 === "loaded") {
|
|
207
|
+
worker.loaded = true;
|
|
208
|
+
if (ENVIRONMENT_IS_NODE && !worker.__emnapi_tid) worker.unref();
|
|
209
|
+
resolve$2(worker);
|
|
210
|
+
} else if (type$1 === "cleanup-thread") {
|
|
211
|
+
if (payload.tid in _this_1.pthreads) _this_1.cleanThread(worker, payload.tid);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
worker.onmessage = function(e$1) {
|
|
216
|
+
handleMessage$1(e$1.data);
|
|
217
|
+
_this_1.fireMessageEvent(worker, e$1);
|
|
218
|
+
};
|
|
219
|
+
worker.onerror = handleError$1;
|
|
220
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
221
|
+
worker.on("message", function(data) {
|
|
222
|
+
var _a, _b;
|
|
223
|
+
(_b = (_a = worker).onmessage) === null || _b === void 0 || _b.call(_a, { data });
|
|
29
224
|
});
|
|
225
|
+
worker.on("error", function(e$1) {
|
|
226
|
+
var _a, _b;
|
|
227
|
+
(_b = (_a = worker).onerror) === null || _b === void 0 || _b.call(_a, e$1);
|
|
228
|
+
});
|
|
229
|
+
worker.on("detachedExit", function() {});
|
|
230
|
+
}
|
|
231
|
+
if (typeof beforeLoad === "function") beforeLoad(worker);
|
|
232
|
+
try {
|
|
233
|
+
worker.postMessage(createMessage("load", {
|
|
234
|
+
wasmModule: _this_1.wasmModule,
|
|
235
|
+
wasmMemory: _this_1.wasmMemory,
|
|
236
|
+
sab
|
|
237
|
+
}));
|
|
238
|
+
} catch (err$1) {
|
|
239
|
+
checkSharedWasmMemory(_this_1.wasmMemory);
|
|
240
|
+
throw err$1;
|
|
30
241
|
}
|
|
242
|
+
});
|
|
243
|
+
return worker.whenLoaded;
|
|
244
|
+
};
|
|
245
|
+
ThreadManager$1.prototype.allocateUnusedWorker = function() {
|
|
246
|
+
var _onCreateWorker = this._onCreateWorker;
|
|
247
|
+
if (typeof _onCreateWorker !== "function") throw new TypeError("`options.onCreateWorker` is not provided");
|
|
248
|
+
var worker = _onCreateWorker({
|
|
249
|
+
type: "thread",
|
|
250
|
+
name: "emnapi-pthread"
|
|
251
|
+
});
|
|
252
|
+
this.unusedWorkers.push(worker);
|
|
253
|
+
return worker;
|
|
254
|
+
};
|
|
255
|
+
ThreadManager$1.prototype.getNewWorker = function(sab) {
|
|
256
|
+
if (this._reuseWorker) {
|
|
257
|
+
if (this.unusedWorkers.length === 0) {
|
|
258
|
+
if (this._reuseWorker.strict) {
|
|
259
|
+
if (!ENVIRONMENT_IS_NODE) {
|
|
260
|
+
var err = this.printErr;
|
|
261
|
+
err("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
var worker_1 = this.allocateUnusedWorker();
|
|
266
|
+
this.loadWasmModuleToWorker(worker_1, sab);
|
|
267
|
+
}
|
|
268
|
+
return this.unusedWorkers.pop();
|
|
31
269
|
}
|
|
270
|
+
var worker = this.allocateUnusedWorker();
|
|
271
|
+
this.loadWasmModuleToWorker(worker, sab);
|
|
272
|
+
return this.unusedWorkers.pop();
|
|
273
|
+
};
|
|
274
|
+
ThreadManager$1.prototype.cleanThread = function(worker, tid, force) {
|
|
275
|
+
if (!force && this._reuseWorker) this.returnWorkerToPool(worker);
|
|
276
|
+
else {
|
|
277
|
+
delete this.pthreads[tid];
|
|
278
|
+
var index = this.runningWorkers.indexOf(worker);
|
|
279
|
+
if (index !== -1) this.runningWorkers.splice(index, 1);
|
|
280
|
+
this.terminateWorker(worker);
|
|
281
|
+
delete worker.__emnapi_tid;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
ThreadManager$1.prototype.terminateWorker = function(worker) {
|
|
285
|
+
var _this_1 = this;
|
|
286
|
+
var _a;
|
|
287
|
+
var tid = worker.__emnapi_tid;
|
|
288
|
+
worker.terminate();
|
|
289
|
+
(_a = this.messageEvents.get(worker)) === null || _a === void 0 || _a.clear();
|
|
290
|
+
this.messageEvents.delete(worker);
|
|
291
|
+
worker.onmessage = function(e$1) {
|
|
292
|
+
if (e$1.data.__emnapi__) {
|
|
293
|
+
var err = _this_1.printErr;
|
|
294
|
+
err("received \"" + e$1.data.__emnapi__.type + "\" command from terminated worker: " + tid);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
ThreadManager$1.prototype.terminateAllThreads = function() {
|
|
299
|
+
for (var i = 0; i < this.runningWorkers.length; ++i) this.terminateWorker(this.runningWorkers[i]);
|
|
300
|
+
for (var i = 0; i < this.unusedWorkers.length; ++i) this.terminateWorker(this.unusedWorkers[i]);
|
|
301
|
+
this.unusedWorkers = [];
|
|
302
|
+
this.runningWorkers = [];
|
|
303
|
+
this.pthreads = Object.create(null);
|
|
304
|
+
this.preparePool();
|
|
305
|
+
};
|
|
306
|
+
ThreadManager$1.prototype.addMessageEventListener = function(worker, onMessage) {
|
|
307
|
+
var listeners = this.messageEvents.get(worker);
|
|
308
|
+
if (!listeners) {
|
|
309
|
+
listeners = /* @__PURE__ */ new Set();
|
|
310
|
+
this.messageEvents.set(worker, listeners);
|
|
311
|
+
}
|
|
312
|
+
listeners.add(onMessage);
|
|
313
|
+
return function() {
|
|
314
|
+
listeners === null || listeners === void 0 || listeners.delete(onMessage);
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
ThreadManager$1.prototype.fireMessageEvent = function(worker, e$1) {
|
|
318
|
+
var listeners = this.messageEvents.get(worker);
|
|
319
|
+
if (!listeners) return;
|
|
320
|
+
var err = this.printErr;
|
|
321
|
+
listeners.forEach(function(listener) {
|
|
322
|
+
try {
|
|
323
|
+
listener(e$1);
|
|
324
|
+
} catch (e$2) {
|
|
325
|
+
err(e$2.stack);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
return ThreadManager$1;
|
|
330
|
+
}();
|
|
331
|
+
var kIsProxy = Symbol("kIsProxy");
|
|
332
|
+
/** @public */
|
|
333
|
+
function createInstanceProxy(instance$1, memory) {
|
|
334
|
+
if (instance$1[kIsProxy]) return instance$1;
|
|
335
|
+
var originalExports = instance$1.exports;
|
|
336
|
+
var createHandler = function(target) {
|
|
337
|
+
var handlers = [
|
|
338
|
+
"apply",
|
|
339
|
+
"construct",
|
|
340
|
+
"defineProperty",
|
|
341
|
+
"deleteProperty",
|
|
342
|
+
"get",
|
|
343
|
+
"getOwnPropertyDescriptor",
|
|
344
|
+
"getPrototypeOf",
|
|
345
|
+
"has",
|
|
346
|
+
"isExtensible",
|
|
347
|
+
"ownKeys",
|
|
348
|
+
"preventExtensions",
|
|
349
|
+
"set",
|
|
350
|
+
"setPrototypeOf"
|
|
351
|
+
];
|
|
352
|
+
var handler$1 = {};
|
|
353
|
+
var _loop_1 = function(i$1) {
|
|
354
|
+
var name_1 = handlers[i$1];
|
|
355
|
+
handler$1[name_1] = function() {
|
|
356
|
+
var args$1 = Array.prototype.slice.call(arguments, 1);
|
|
357
|
+
args$1.unshift(target);
|
|
358
|
+
return Reflect[name_1].apply(Reflect, args$1);
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
for (var i = 0; i < handlers.length; i++) _loop_1(i);
|
|
362
|
+
return handler$1;
|
|
363
|
+
};
|
|
364
|
+
var handler = createHandler(originalExports);
|
|
365
|
+
var _initialize = function() {};
|
|
366
|
+
var _start = function() {
|
|
367
|
+
return 0;
|
|
368
|
+
};
|
|
369
|
+
handler.get = function(_target, p, receiver) {
|
|
370
|
+
var _a;
|
|
371
|
+
if (p === "memory") return (_a = typeof memory === "function" ? memory() : memory) !== null && _a !== void 0 ? _a : Reflect.get(originalExports, p, receiver);
|
|
372
|
+
if (p === "_initialize") return p in originalExports ? _initialize : void 0;
|
|
373
|
+
if (p === "_start") return p in originalExports ? _start : void 0;
|
|
374
|
+
return Reflect.get(originalExports, p, receiver);
|
|
375
|
+
};
|
|
376
|
+
handler.has = function(_target, p) {
|
|
377
|
+
if (p === "memory") return true;
|
|
378
|
+
return Reflect.has(originalExports, p);
|
|
379
|
+
};
|
|
380
|
+
var exportsProxy = new Proxy(Object.create(null), handler);
|
|
381
|
+
return new Proxy(instance$1, { get: function(target, p, receiver) {
|
|
382
|
+
if (p === "exports") return exportsProxy;
|
|
383
|
+
if (p === kIsProxy) return true;
|
|
384
|
+
return Reflect.get(target, p, receiver);
|
|
385
|
+
} });
|
|
386
|
+
}
|
|
387
|
+
var patchedWasiInstances = /* @__PURE__ */ new WeakMap();
|
|
388
|
+
/** @public */
|
|
389
|
+
var WASIThreads = /* @__PURE__ */ function() {
|
|
390
|
+
function WASIThreads$1(options$1) {
|
|
391
|
+
var _this_1 = this;
|
|
392
|
+
if (!options$1) throw new TypeError("WASIThreads(): options is not provided");
|
|
393
|
+
if (!options$1.wasi) throw new TypeError("WASIThreads(): options.wasi is not provided");
|
|
394
|
+
patchedWasiInstances.set(this, /* @__PURE__ */ new WeakSet());
|
|
395
|
+
var wasi = options$1.wasi;
|
|
396
|
+
patchWasiInstance(this, wasi);
|
|
397
|
+
this.wasi = wasi;
|
|
398
|
+
if ("childThread" in options$1) this.childThread = Boolean(options$1.childThread);
|
|
399
|
+
else this.childThread = false;
|
|
400
|
+
this.PThread = void 0;
|
|
401
|
+
if ("threadManager" in options$1) if (typeof options$1.threadManager === "function") this.PThread = options$1.threadManager();
|
|
402
|
+
else this.PThread = options$1.threadManager;
|
|
403
|
+
else if (!this.childThread) {
|
|
404
|
+
this.PThread = new ThreadManager(options$1);
|
|
405
|
+
this.PThread.init();
|
|
406
|
+
}
|
|
407
|
+
var waitThreadStart = false;
|
|
408
|
+
if ("waitThreadStart" in options$1) waitThreadStart = typeof options$1.waitThreadStart === "number" ? options$1.waitThreadStart : Boolean(options$1.waitThreadStart);
|
|
409
|
+
var postMessage$2 = getPostMessage(options$1);
|
|
410
|
+
if (this.childThread && typeof postMessage$2 !== "function") throw new TypeError("options.postMessage is not a function");
|
|
411
|
+
this.postMessage = postMessage$2;
|
|
412
|
+
var wasm64 = Boolean(options$1.wasm64);
|
|
413
|
+
var onMessage = function(e$1) {
|
|
414
|
+
if (e$1.data.__emnapi__) {
|
|
415
|
+
var type$1 = e$1.data.__emnapi__.type;
|
|
416
|
+
var payload = e$1.data.__emnapi__.payload;
|
|
417
|
+
if (type$1 === "spawn-thread") threadSpawn(payload.startArg, payload.errorOrTid);
|
|
418
|
+
else if (type$1 === "terminate-all-threads") _this_1.terminateAllThreads();
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
var threadSpawn = function(startArg, errorOrTid) {
|
|
422
|
+
var _a;
|
|
423
|
+
var EAGAIN = 6;
|
|
424
|
+
var isNewABI = errorOrTid !== void 0;
|
|
425
|
+
try {
|
|
426
|
+
checkSharedWasmMemory(_this_1.wasmMemory);
|
|
427
|
+
} catch (err) {
|
|
428
|
+
(_a = _this_1.PThread) === null || _a === void 0 || _a.printErr(err.stack);
|
|
429
|
+
if (isNewABI) {
|
|
430
|
+
var struct_1 = new Int32Array(_this_1.wasmMemory.buffer, errorOrTid, 2);
|
|
431
|
+
Atomics.store(struct_1, 0, 1);
|
|
432
|
+
Atomics.store(struct_1, 1, EAGAIN);
|
|
433
|
+
Atomics.notify(struct_1, 1);
|
|
434
|
+
return 1;
|
|
435
|
+
} else return -EAGAIN;
|
|
436
|
+
}
|
|
437
|
+
if (!isNewABI) {
|
|
438
|
+
var malloc = _this_1.wasmInstance.exports.malloc;
|
|
439
|
+
errorOrTid = wasm64 ? Number(malloc(BigInt(8))) : malloc(8);
|
|
440
|
+
if (!errorOrTid) return -48;
|
|
441
|
+
}
|
|
442
|
+
var _free = _this_1.wasmInstance.exports.free;
|
|
443
|
+
var free = wasm64 ? function(ptr) {
|
|
444
|
+
_free(BigInt(ptr));
|
|
445
|
+
} : _free;
|
|
446
|
+
var struct = new Int32Array(_this_1.wasmMemory.buffer, errorOrTid, 2);
|
|
447
|
+
Atomics.store(struct, 0, 0);
|
|
448
|
+
Atomics.store(struct, 1, 0);
|
|
449
|
+
if (_this_1.childThread) {
|
|
450
|
+
postMessage$2(createMessage("spawn-thread", {
|
|
451
|
+
startArg,
|
|
452
|
+
errorOrTid
|
|
453
|
+
}));
|
|
454
|
+
Atomics.wait(struct, 1, 0);
|
|
455
|
+
var isError = Atomics.load(struct, 0);
|
|
456
|
+
var result = Atomics.load(struct, 1);
|
|
457
|
+
if (isNewABI) return isError;
|
|
458
|
+
free(errorOrTid);
|
|
459
|
+
return isError ? -result : result;
|
|
460
|
+
}
|
|
461
|
+
var shouldWait = waitThreadStart || waitThreadStart === 0;
|
|
462
|
+
var sab;
|
|
463
|
+
if (shouldWait) {
|
|
464
|
+
sab = new Int32Array(new SharedArrayBuffer(8208));
|
|
465
|
+
Atomics.store(sab, 0, 0);
|
|
466
|
+
}
|
|
467
|
+
var worker;
|
|
468
|
+
var tid;
|
|
469
|
+
var PThread = _this_1.PThread;
|
|
470
|
+
try {
|
|
471
|
+
worker = PThread.getNewWorker(sab);
|
|
472
|
+
if (!worker) throw new Error("failed to get new worker");
|
|
473
|
+
PThread.addMessageEventListener(worker, onMessage);
|
|
474
|
+
tid = PThread.markId(worker);
|
|
475
|
+
if (ENVIRONMENT_IS_NODE) worker.ref();
|
|
476
|
+
worker.postMessage(createMessage("start", {
|
|
477
|
+
tid,
|
|
478
|
+
arg: startArg,
|
|
479
|
+
sab
|
|
480
|
+
}));
|
|
481
|
+
if (shouldWait) {
|
|
482
|
+
if (typeof waitThreadStart === "number") {
|
|
483
|
+
if (Atomics.wait(sab, 0, 0, waitThreadStart) === "timed-out") {
|
|
484
|
+
try {
|
|
485
|
+
PThread.cleanThread(worker, tid, true);
|
|
486
|
+
} catch (_) {}
|
|
487
|
+
throw new Error("Spawning thread timed out. Please check if the worker is created successfully and if message is handled properly in the worker.");
|
|
488
|
+
}
|
|
489
|
+
} else Atomics.wait(sab, 0, 0);
|
|
490
|
+
if (Atomics.load(sab, 0) > 1) {
|
|
491
|
+
try {
|
|
492
|
+
PThread.cleanThread(worker, tid, true);
|
|
493
|
+
} catch (_) {}
|
|
494
|
+
throw deserizeErrorFromBuffer(sab.buffer);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
} catch (e$1) {
|
|
498
|
+
Atomics.store(struct, 0, 1);
|
|
499
|
+
Atomics.store(struct, 1, EAGAIN);
|
|
500
|
+
Atomics.notify(struct, 1);
|
|
501
|
+
PThread === null || PThread === void 0 || PThread.printErr(e$1.stack);
|
|
502
|
+
if (isNewABI) return 1;
|
|
503
|
+
free(errorOrTid);
|
|
504
|
+
return -EAGAIN;
|
|
505
|
+
}
|
|
506
|
+
Atomics.store(struct, 0, 0);
|
|
507
|
+
Atomics.store(struct, 1, tid);
|
|
508
|
+
Atomics.notify(struct, 1);
|
|
509
|
+
PThread.runningWorkers.push(worker);
|
|
510
|
+
if (!shouldWait) worker.whenLoaded.catch(function(err) {
|
|
511
|
+
delete worker.whenLoaded;
|
|
512
|
+
PThread.cleanThread(worker, tid, true);
|
|
513
|
+
throw err;
|
|
514
|
+
});
|
|
515
|
+
if (isNewABI) return 0;
|
|
516
|
+
free(errorOrTid);
|
|
517
|
+
return tid;
|
|
518
|
+
};
|
|
519
|
+
this.threadSpawn = threadSpawn;
|
|
32
520
|
}
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
521
|
+
WASIThreads$1.prototype.getImportObject = function() {
|
|
522
|
+
return { wasi: { "thread-spawn": this.threadSpawn } };
|
|
523
|
+
};
|
|
524
|
+
WASIThreads$1.prototype.setup = function(wasmInstance, wasmModule, wasmMemory) {
|
|
525
|
+
wasmMemory !== null && wasmMemory !== void 0 || (wasmMemory = wasmInstance.exports.memory);
|
|
526
|
+
this.wasmInstance = wasmInstance;
|
|
527
|
+
this.wasmMemory = wasmMemory;
|
|
528
|
+
if (this.PThread) this.PThread.setup(wasmModule, wasmMemory);
|
|
529
|
+
};
|
|
530
|
+
WASIThreads$1.prototype.preloadWorkers = function() {
|
|
531
|
+
if (this.PThread) return this.PThread.preloadWorkers();
|
|
532
|
+
return Promise.resolve([]);
|
|
533
|
+
};
|
|
534
|
+
/**
|
|
535
|
+
* It's ok to call this method to a WASI command module.
|
|
536
|
+
*
|
|
537
|
+
* in child thread, must call this method instead of {@link WASIThreads.start} even if it's a WASI command module
|
|
538
|
+
*
|
|
539
|
+
* @returns A proxied WebAssembly instance if in child thread, other wise the original instance
|
|
540
|
+
*/
|
|
541
|
+
WASIThreads$1.prototype.initialize = function(instance$1, module, memory) {
|
|
542
|
+
var exports = instance$1.exports;
|
|
543
|
+
memory !== null && memory !== void 0 || (memory = exports.memory);
|
|
544
|
+
if (this.childThread) instance$1 = createInstanceProxy(instance$1, memory);
|
|
545
|
+
this.setup(instance$1, module, memory);
|
|
546
|
+
var wasi = this.wasi;
|
|
547
|
+
if ("_start" in exports && typeof exports._start === "function") if (this.childThread) {
|
|
548
|
+
wasi.start(instance$1);
|
|
549
|
+
try {
|
|
550
|
+
var kStarted$1 = getWasiSymbol(wasi, "kStarted");
|
|
551
|
+
wasi[kStarted$1] = false;
|
|
552
|
+
} catch (_) {}
|
|
553
|
+
} else setupInstance(wasi, instance$1);
|
|
554
|
+
else wasi.initialize(instance$1);
|
|
555
|
+
return instance$1;
|
|
556
|
+
};
|
|
557
|
+
/**
|
|
558
|
+
* Equivalent to calling {@link WASIThreads.initialize} and then calling {@link WASIInstance.start}
|
|
559
|
+
* ```js
|
|
560
|
+
* this.initialize(instance, module, memory)
|
|
561
|
+
* this.wasi.start(instance)
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
WASIThreads$1.prototype.start = function(instance$1, module, memory) {
|
|
565
|
+
var exports = instance$1.exports;
|
|
566
|
+
memory !== null && memory !== void 0 || (memory = exports.memory);
|
|
567
|
+
if (this.childThread) instance$1 = createInstanceProxy(instance$1, memory);
|
|
568
|
+
this.setup(instance$1, module, memory);
|
|
569
|
+
return {
|
|
570
|
+
exitCode: this.wasi.start(instance$1),
|
|
571
|
+
instance: instance$1
|
|
572
|
+
};
|
|
573
|
+
};
|
|
574
|
+
WASIThreads$1.prototype.terminateAllThreads = function() {
|
|
575
|
+
var _a;
|
|
576
|
+
if (!this.childThread) (_a = this.PThread) === null || _a === void 0 || _a.terminateAllThreads();
|
|
577
|
+
else this.postMessage(createMessage("terminate-all-threads", {}));
|
|
578
|
+
};
|
|
579
|
+
return WASIThreads$1;
|
|
580
|
+
}();
|
|
581
|
+
function patchWasiInstance(wasiThreads, wasi) {
|
|
582
|
+
var patched = patchedWasiInstances.get(wasiThreads);
|
|
583
|
+
if (patched.has(wasi)) return;
|
|
584
|
+
var _this = wasiThreads;
|
|
585
|
+
var wasiImport = wasi.wasiImport;
|
|
586
|
+
if (wasiImport) {
|
|
587
|
+
var proc_exit_1 = wasiImport.proc_exit;
|
|
588
|
+
wasiImport.proc_exit = function(code$1) {
|
|
589
|
+
_this.terminateAllThreads();
|
|
590
|
+
return proc_exit_1.call(this, code$1);
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (!_this.childThread) {
|
|
594
|
+
var start_1 = wasi.start;
|
|
595
|
+
if (typeof start_1 === "function") wasi.start = function(instance$1) {
|
|
596
|
+
try {
|
|
597
|
+
return start_1.call(this, instance$1);
|
|
598
|
+
} catch (err) {
|
|
599
|
+
if (isTrapError(err)) _this.terminateAllThreads();
|
|
600
|
+
throw err;
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
patched.add(wasi);
|
|
605
|
+
}
|
|
606
|
+
function getWasiSymbol(wasi, description$1) {
|
|
607
|
+
var symbols = Object.getOwnPropertySymbols(wasi);
|
|
608
|
+
var selectDescription = function(description$2) {
|
|
609
|
+
return function(s) {
|
|
610
|
+
if (s.description) return s.description === description$2;
|
|
611
|
+
return s.toString() === "Symbol(".concat(description$2, ")");
|
|
612
|
+
};
|
|
613
|
+
};
|
|
614
|
+
if (Array.isArray(description$1)) return description$1.map(function(d) {
|
|
615
|
+
return symbols.filter(selectDescription(d))[0];
|
|
616
|
+
});
|
|
617
|
+
return symbols.filter(selectDescription(description$1))[0];
|
|
618
|
+
}
|
|
619
|
+
function setupInstance(wasi, instance$1) {
|
|
620
|
+
var _a = getWasiSymbol(wasi, ["kInstance", "kSetMemory"]), kInstance$1 = _a[0], kSetMemory$1 = _a[1];
|
|
621
|
+
wasi[kInstance$1] = instance$1;
|
|
622
|
+
wasi[kSetMemory$1](instance$1.exports.memory);
|
|
623
|
+
}
|
|
40
624
|
|
|
41
625
|
//#endregion
|
|
42
626
|
//#region ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
@@ -70,20 +654,10 @@ function __extends$1(d, b) {
|
|
|
70
654
|
}
|
|
71
655
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
72
656
|
}
|
|
73
|
-
var __assign$1 = function() {
|
|
74
|
-
__assign$1 = Object.assign || function __assign$2(t$2) {
|
|
75
|
-
for (var s, i = 1, n$1 = arguments.length; i < n$1; i++) {
|
|
76
|
-
s = arguments[i];
|
|
77
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t$2[p] = s[p];
|
|
78
|
-
}
|
|
79
|
-
return t$2;
|
|
80
|
-
};
|
|
81
|
-
return __assign$1.apply(this, arguments);
|
|
82
|
-
};
|
|
83
657
|
|
|
84
658
|
//#endregion
|
|
85
659
|
//#region ../../node_modules/.pnpm/@emnapi+core@1.8.1/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js
|
|
86
|
-
var _WebAssembly = typeof WebAssembly !== "undefined" ? WebAssembly : typeof WXWebAssembly !== "undefined" ? WXWebAssembly : void 0;
|
|
660
|
+
var _WebAssembly$1 = typeof WebAssembly !== "undefined" ? WebAssembly : typeof WXWebAssembly !== "undefined" ? WXWebAssembly : void 0;
|
|
87
661
|
function validateImports(imports) {
|
|
88
662
|
if (imports && typeof imports !== "object") throw new TypeError("imports must be an object or undefined");
|
|
89
663
|
return true;
|
|
@@ -98,22 +672,22 @@ function load(wasmInput, imports) {
|
|
|
98
672
|
return load(input, imports);
|
|
99
673
|
});
|
|
100
674
|
} catch (_) {}
|
|
101
|
-
if (wasmInput instanceof ArrayBuffer || ArrayBuffer.isView(wasmInput)) return _WebAssembly.instantiate(wasmInput, imports);
|
|
102
|
-
if (wasmInput instanceof _WebAssembly.Module) return _WebAssembly.instantiate(wasmInput, imports).then(function(instance$1) {
|
|
675
|
+
if (wasmInput instanceof ArrayBuffer || ArrayBuffer.isView(wasmInput)) return _WebAssembly$1.instantiate(wasmInput, imports);
|
|
676
|
+
if (wasmInput instanceof _WebAssembly$1.Module) return _WebAssembly$1.instantiate(wasmInput, imports).then(function(instance$1) {
|
|
103
677
|
return {
|
|
104
678
|
instance: instance$1,
|
|
105
679
|
module: wasmInput
|
|
106
680
|
};
|
|
107
681
|
});
|
|
108
682
|
if (typeof Response !== "undefined" && wasmInput instanceof Response) return wasmInput.arrayBuffer().then(function(buffer) {
|
|
109
|
-
return _WebAssembly.instantiate(buffer, imports);
|
|
683
|
+
return _WebAssembly$1.instantiate(buffer, imports);
|
|
110
684
|
});
|
|
111
685
|
var inputIsString = typeof wasmInput === "string";
|
|
112
686
|
if (inputIsString || typeof URL !== "undefined" && wasmInput instanceof URL) {
|
|
113
|
-
if (inputIsString && typeof wx !== "undefined" && typeof __wxConfig !== "undefined") return _WebAssembly.instantiate(wasmInput, imports);
|
|
687
|
+
if (inputIsString && typeof wx !== "undefined" && typeof __wxConfig !== "undefined") return _WebAssembly$1.instantiate(wasmInput, imports);
|
|
114
688
|
if (typeof fetch !== "function") throw new TypeError("wasm source can not be a string or URL in this environment");
|
|
115
|
-
if (typeof _WebAssembly.instantiateStreaming === "function") try {
|
|
116
|
-
return _WebAssembly.instantiateStreaming(fetch(wasmInput), imports).catch(function() {
|
|
689
|
+
if (typeof _WebAssembly$1.instantiateStreaming === "function") try {
|
|
690
|
+
return _WebAssembly$1.instantiateStreaming(fetch(wasmInput), imports).catch(function() {
|
|
117
691
|
return load(fetch(wasmInput), imports);
|
|
118
692
|
});
|
|
119
693
|
} catch (_) {
|
|
@@ -123,22 +697,9 @@ function load(wasmInput, imports) {
|
|
|
123
697
|
}
|
|
124
698
|
throw new TypeError("Invalid wasm source");
|
|
125
699
|
}
|
|
126
|
-
function loadSync(wasmInput, imports) {
|
|
127
|
-
if (!wasmInput) throw new TypeError("Invalid wasm source");
|
|
128
|
-
validateImports(imports);
|
|
129
|
-
imports = imports !== null && imports !== void 0 ? imports : {};
|
|
130
|
-
var module;
|
|
131
|
-
if (wasmInput instanceof ArrayBuffer || ArrayBuffer.isView(wasmInput)) module = new _WebAssembly.Module(wasmInput);
|
|
132
|
-
else if (wasmInput instanceof WebAssembly.Module) module = wasmInput;
|
|
133
|
-
else throw new TypeError("Invalid wasm source");
|
|
134
|
-
return {
|
|
135
|
-
instance: new _WebAssembly.Instance(module, imports),
|
|
136
|
-
module
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
700
|
function createNapiModule(options$1) {
|
|
140
701
|
return (function() {
|
|
141
|
-
var ENVIRONMENT_IS_NODE = typeof process === "object" && process !== null && typeof process.versions === "object" && process.versions !== null && typeof process.versions.node === "string";
|
|
702
|
+
var ENVIRONMENT_IS_NODE$1 = typeof process === "object" && process !== null && typeof process.versions === "object" && process.versions !== null && typeof process.versions.node === "string";
|
|
142
703
|
var ENVIRONMENT_IS_PTHREAD = Boolean(options$1.childThread);
|
|
143
704
|
var waitThreadStart = typeof options$1.waitThreadStart === "number" ? options$1.waitThreadStart : Boolean(options$1.waitThreadStart);
|
|
144
705
|
var wasmInstance;
|
|
@@ -147,7 +708,7 @@ function createNapiModule(options$1) {
|
|
|
147
708
|
var _malloc;
|
|
148
709
|
var _free;
|
|
149
710
|
function abort(msg) {
|
|
150
|
-
if (typeof _WebAssembly.RuntimeError === "function") throw new _WebAssembly.RuntimeError(msg);
|
|
711
|
+
if (typeof _WebAssembly$1.RuntimeError === "function") throw new _WebAssembly$1.RuntimeError(msg);
|
|
151
712
|
throw Error(msg);
|
|
152
713
|
}
|
|
153
714
|
var napiModule = {
|
|
@@ -175,9 +736,9 @@ function createNapiModule(options$1) {
|
|
|
175
736
|
var module = options$2.module;
|
|
176
737
|
var memory = options$2.memory || exports$1.memory;
|
|
177
738
|
var table = options$2.table || exports$1.__indirect_function_table;
|
|
178
|
-
if (!(module instanceof _WebAssembly.Module)) throw new TypeError("Invalid wasm module");
|
|
179
|
-
if (!(memory instanceof _WebAssembly.Memory)) throw new TypeError("Invalid wasm memory");
|
|
180
|
-
if (!(table instanceof _WebAssembly.Table)) throw new TypeError("Invalid wasm table");
|
|
739
|
+
if (!(module instanceof _WebAssembly$1.Module)) throw new TypeError("Invalid wasm module");
|
|
740
|
+
if (!(memory instanceof _WebAssembly$1.Memory)) throw new TypeError("Invalid wasm memory");
|
|
741
|
+
if (!(table instanceof _WebAssembly$1.Table)) throw new TypeError("Invalid wasm table");
|
|
181
742
|
wasmMemory = memory;
|
|
182
743
|
wasmTable = table;
|
|
183
744
|
if (typeof exports$1.malloc !== "function") throw new TypeError("malloc is not exported");
|
|
@@ -254,7 +815,7 @@ function createNapiModule(options$1) {
|
|
|
254
815
|
if (!worker) return false;
|
|
255
816
|
if (worker._emnapiSendListener) return true;
|
|
256
817
|
var handler = function(e$1) {
|
|
257
|
-
var __emnapi__ = (ENVIRONMENT_IS_NODE ? e$1 : e$1.data).__emnapi__;
|
|
818
|
+
var __emnapi__ = (ENVIRONMENT_IS_NODE$1 ? e$1 : e$1.data).__emnapi__;
|
|
258
819
|
if (__emnapi__ && __emnapi__.type === "async-send") if (ENVIRONMENT_IS_PTHREAD) {
|
|
259
820
|
var postMessage_1 = napiModule.postMessage;
|
|
260
821
|
postMessage_1({ __emnapi__ });
|
|
@@ -264,7 +825,7 @@ function createNapiModule(options$1) {
|
|
|
264
825
|
}
|
|
265
826
|
};
|
|
266
827
|
var dispose = function() {
|
|
267
|
-
if (ENVIRONMENT_IS_NODE) worker.off("message", handler);
|
|
828
|
+
if (ENVIRONMENT_IS_NODE$1) worker.off("message", handler);
|
|
268
829
|
else worker.removeEventListener("message", handler, false);
|
|
269
830
|
delete worker._emnapiSendListener;
|
|
270
831
|
};
|
|
@@ -272,7 +833,7 @@ function createNapiModule(options$1) {
|
|
|
272
833
|
handler,
|
|
273
834
|
dispose
|
|
274
835
|
};
|
|
275
|
-
if (ENVIRONMENT_IS_NODE) worker.on("message", handler);
|
|
836
|
+
if (ENVIRONMENT_IS_NODE$1) worker.on("message", handler);
|
|
276
837
|
else worker.addEventListener("message", handler, false);
|
|
277
838
|
return true;
|
|
278
839
|
}
|
|
@@ -388,7 +949,7 @@ function createNapiModule(options$1) {
|
|
|
388
949
|
* @__sig i
|
|
389
950
|
*/
|
|
390
951
|
function _emnapi_is_main_browser_thread() {
|
|
391
|
-
return typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE ? 1 : 0;
|
|
952
|
+
return typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE$1 ? 1 : 0;
|
|
392
953
|
}
|
|
393
954
|
/**
|
|
394
955
|
* @__sig v
|
|
@@ -475,10 +1036,10 @@ function createNapiModule(options$1) {
|
|
|
475
1036
|
}
|
|
476
1037
|
}
|
|
477
1038
|
var uvThreadpoolReadyResolve;
|
|
478
|
-
var uvThreadpoolReady = new Promise(function(resolve$
|
|
1039
|
+
var uvThreadpoolReady = new Promise(function(resolve$2) {
|
|
479
1040
|
uvThreadpoolReadyResolve = function() {
|
|
480
1041
|
uvThreadpoolReady.ready = true;
|
|
481
|
-
resolve$
|
|
1042
|
+
resolve$2();
|
|
482
1043
|
};
|
|
483
1044
|
});
|
|
484
1045
|
uvThreadpoolReady.ready = false;
|
|
@@ -495,17 +1056,17 @@ function createNapiModule(options$1) {
|
|
|
495
1056
|
var HEAP_DATA_VIEW = new DataView(wasmMemory.buffer);
|
|
496
1057
|
var _loop_1 = function(i$1) {
|
|
497
1058
|
var worker = emnapiGetWorkerByPthreadPtr(HEAP_DATA_VIEW.getUint32(threads + i$1 * 4, true));
|
|
498
|
-
p.push(new Promise(function(resolve$
|
|
1059
|
+
p.push(new Promise(function(resolve$2) {
|
|
499
1060
|
var handler = function(e$1) {
|
|
500
|
-
var __emnapi__ = (ENVIRONMENT_IS_NODE ? e$1 : e$1.data).__emnapi__;
|
|
1061
|
+
var __emnapi__ = (ENVIRONMENT_IS_NODE$1 ? e$1 : e$1.data).__emnapi__;
|
|
501
1062
|
if (__emnapi__ && __emnapi__.type === "async-thread-ready") {
|
|
502
|
-
resolve$
|
|
1063
|
+
resolve$2();
|
|
503
1064
|
if (worker && typeof worker.unref === "function") worker.unref();
|
|
504
|
-
if (ENVIRONMENT_IS_NODE) worker.off("message", handler);
|
|
1065
|
+
if (ENVIRONMENT_IS_NODE$1) worker.off("message", handler);
|
|
505
1066
|
else worker.removeEventListener("message", handler);
|
|
506
1067
|
}
|
|
507
1068
|
};
|
|
508
|
-
if (ENVIRONMENT_IS_NODE) worker.on("message", handler);
|
|
1069
|
+
if (ENVIRONMENT_IS_NODE$1) worker.on("message", handler);
|
|
509
1070
|
else worker.addEventListener("message", handler);
|
|
510
1071
|
}));
|
|
511
1072
|
};
|
|
@@ -869,7 +1430,7 @@ function createNapiModule(options$1) {
|
|
|
869
1430
|
if (!worker) return false;
|
|
870
1431
|
if (worker._emnapiTSFNListener) return true;
|
|
871
1432
|
var handler = function(e$1) {
|
|
872
|
-
var __emnapi__ = (ENVIRONMENT_IS_NODE ? e$1 : e$1.data).__emnapi__;
|
|
1433
|
+
var __emnapi__ = (ENVIRONMENT_IS_NODE$1 ? e$1 : e$1.data).__emnapi__;
|
|
873
1434
|
if (__emnapi__) {
|
|
874
1435
|
var type$1 = __emnapi__.type;
|
|
875
1436
|
var payload = __emnapi__.payload;
|
|
@@ -877,7 +1438,7 @@ function createNapiModule(options$1) {
|
|
|
877
1438
|
}
|
|
878
1439
|
};
|
|
879
1440
|
var dispose = function() {
|
|
880
|
-
if (ENVIRONMENT_IS_NODE) worker.off("message", handler);
|
|
1441
|
+
if (ENVIRONMENT_IS_NODE$1) worker.off("message", handler);
|
|
881
1442
|
else worker.removeEventListener("message", handler, false);
|
|
882
1443
|
delete worker._emnapiTSFNListener;
|
|
883
1444
|
};
|
|
@@ -885,7 +1446,7 @@ function createNapiModule(options$1) {
|
|
|
885
1446
|
handler,
|
|
886
1447
|
dispose
|
|
887
1448
|
};
|
|
888
|
-
if (ENVIRONMENT_IS_NODE) worker.on("message", handler);
|
|
1449
|
+
if (ENVIRONMENT_IS_NODE$1) worker.on("message", handler);
|
|
889
1450
|
else worker.addEventListener("message", handler, false);
|
|
890
1451
|
return true;
|
|
891
1452
|
},
|
|
@@ -941,7 +1502,7 @@ function createNapiModule(options$1) {
|
|
|
941
1502
|
var isClosing = emnapiTSFN.getIsClosing(func);
|
|
942
1503
|
return queueSize >= maxSize && maxSize > 0 && !isClosing;
|
|
943
1504
|
};
|
|
944
|
-
var isBrowserMain = typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE;
|
|
1505
|
+
var isBrowserMain = typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE$1;
|
|
945
1506
|
return mutex.execute(function() {
|
|
946
1507
|
while (waitCondition()) {
|
|
947
1508
|
if (mode === 0) return 15;
|
|
@@ -971,7 +1532,7 @@ function createNapiModule(options$1) {
|
|
|
971
1532
|
var index = func + emnapiTSFN.offset.mutex;
|
|
972
1533
|
var mutex = {
|
|
973
1534
|
lock: function() {
|
|
974
|
-
var isBrowserMain = typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE;
|
|
1535
|
+
var isBrowserMain = typeof window !== "undefined" && typeof document !== "undefined" && !ENVIRONMENT_IS_NODE$1;
|
|
975
1536
|
var i32a = new Int32Array(wasmMemory.buffer, index, 1);
|
|
976
1537
|
if (isBrowserMain) while (true) {
|
|
977
1538
|
var oldValue = Atomics.compareExchange(i32a, 0, 0, 1);
|
|
@@ -1434,7 +1995,7 @@ function createNapiModule(options$1) {
|
|
|
1434
1995
|
if (!worker) return false;
|
|
1435
1996
|
if (worker._emnapiAWMTListener) return true;
|
|
1436
1997
|
var handler = function(e$1) {
|
|
1437
|
-
var __emnapi__ = (ENVIRONMENT_IS_NODE ? e$1 : e$1.data).__emnapi__;
|
|
1998
|
+
var __emnapi__ = (ENVIRONMENT_IS_NODE$1 ? e$1 : e$1.data).__emnapi__;
|
|
1438
1999
|
if (__emnapi__) {
|
|
1439
2000
|
var type$1 = __emnapi__.type;
|
|
1440
2001
|
var payload = __emnapi__.payload;
|
|
@@ -1449,7 +2010,7 @@ function createNapiModule(options$1) {
|
|
|
1449
2010
|
}
|
|
1450
2011
|
};
|
|
1451
2012
|
var dispose = function() {
|
|
1452
|
-
if (ENVIRONMENT_IS_NODE) worker.off("message", handler);
|
|
2013
|
+
if (ENVIRONMENT_IS_NODE$1) worker.off("message", handler);
|
|
1453
2014
|
else worker.removeEventListener("message", handler, false);
|
|
1454
2015
|
delete worker._emnapiAWMTListener;
|
|
1455
2016
|
};
|
|
@@ -1457,7 +2018,7 @@ function createNapiModule(options$1) {
|
|
|
1457
2018
|
handler,
|
|
1458
2019
|
dispose
|
|
1459
2020
|
};
|
|
1460
|
-
if (ENVIRONMENT_IS_NODE) worker.on("message", handler);
|
|
2021
|
+
if (ENVIRONMENT_IS_NODE$1) worker.on("message", handler);
|
|
1461
2022
|
else worker.addEventListener("message", handler, false);
|
|
1462
2023
|
return true;
|
|
1463
2024
|
},
|
|
@@ -4579,9 +5140,9 @@ function createNapiModule(options$1) {
|
|
|
4579
5140
|
if (!deferred) return envObject.setLastError(1);
|
|
4580
5141
|
if (!promise$1) return envObject.setLastError(1);
|
|
4581
5142
|
var HEAP_DATA_VIEW = new DataView(wasmMemory.buffer);
|
|
4582
|
-
var p = new Promise(function(resolve$
|
|
5143
|
+
var p = new Promise(function(resolve$2, reject) {
|
|
4583
5144
|
deferredObjectId = emnapiCtx.createDeferred({
|
|
4584
|
-
resolve: resolve$
|
|
5145
|
+
resolve: resolve$2,
|
|
4585
5146
|
reject
|
|
4586
5147
|
}).id;
|
|
4587
5148
|
HEAP_DATA_VIEW.setUint32(deferred, deferredObjectId, true);
|
|
@@ -5574,10 +6135,10 @@ function createNapiModule(options$1) {
|
|
|
5574
6135
|
}
|
|
5575
6136
|
function loadNapiModuleImpl(loadFn, userNapiModule, wasmInput, options$1) {
|
|
5576
6137
|
options$1 = options$1 !== null && options$1 !== void 0 ? options$1 : {};
|
|
5577
|
-
var getMemory = options$1.getMemory;
|
|
6138
|
+
var getMemory$1 = options$1.getMemory;
|
|
5578
6139
|
var getTable = options$1.getTable;
|
|
5579
6140
|
var beforeInit = options$1.beforeInit;
|
|
5580
|
-
if (getMemory != null && typeof getMemory !== "function") throw new TypeError("options.getMemory is not a function");
|
|
6141
|
+
if (getMemory$1 != null && typeof getMemory$1 !== "function") throw new TypeError("options.getMemory is not a function");
|
|
5581
6142
|
if (getTable != null && typeof getTable !== "function") throw new TypeError("options.getTable is not a function");
|
|
5582
6143
|
if (beforeInit != null && typeof beforeInit !== "function") throw new TypeError("options.beforeInit is not a function");
|
|
5583
6144
|
var napiModule;
|
|
@@ -5618,7 +6179,7 @@ function loadNapiModuleImpl(loadFn, userNapiModule, wasmInput, options$1) {
|
|
|
5618
6179
|
var originalExports = originalInstance.exports;
|
|
5619
6180
|
var exportMemory = "memory" in originalExports;
|
|
5620
6181
|
var importMemory = "memory" in importObject.env;
|
|
5621
|
-
var memory = getMemory ? getMemory(originalExports) : exportMemory ? originalExports.memory : importMemory ? importObject.env.memory : void 0;
|
|
6182
|
+
var memory = getMemory$1 ? getMemory$1(originalExports) : exportMemory ? originalExports.memory : importMemory ? importObject.env.memory : void 0;
|
|
5622
6183
|
if (!memory) throw new Error("memory is neither exported nor imported");
|
|
5623
6184
|
var table = getTable ? getTable(originalExports) : originalExports.__indirect_function_table;
|
|
5624
6185
|
if (wasi && !exportMemory) {
|
|
@@ -5663,71 +6224,10 @@ function loadCallback(wasmInput, importObject, callback) {
|
|
|
5663
6224
|
return callback(err);
|
|
5664
6225
|
});
|
|
5665
6226
|
}
|
|
5666
|
-
function loadSyncCallback(wasmInput, importObject, callback) {
|
|
5667
|
-
var source;
|
|
5668
|
-
try {
|
|
5669
|
-
source = loadSync(wasmInput, importObject);
|
|
5670
|
-
} catch (err) {
|
|
5671
|
-
return callback(err);
|
|
5672
|
-
}
|
|
5673
|
-
return callback(null, source);
|
|
5674
|
-
}
|
|
5675
6227
|
/** @public */
|
|
5676
6228
|
function instantiateNapiModule(wasmInput, options$1) {
|
|
5677
6229
|
return loadNapiModuleImpl(loadCallback, void 0, wasmInput, options$1);
|
|
5678
6230
|
}
|
|
5679
|
-
/** @public */
|
|
5680
|
-
function instantiateNapiModuleSync(wasmInput, options$1) {
|
|
5681
|
-
return loadNapiModuleImpl(loadSyncCallback, void 0, wasmInput, options$1);
|
|
5682
|
-
}
|
|
5683
|
-
/** @public */
|
|
5684
|
-
var MessageHandler = /* @__PURE__ */ function(_super) {
|
|
5685
|
-
__extends$1(MessageHandler$1, _super);
|
|
5686
|
-
function MessageHandler$1(options$1) {
|
|
5687
|
-
var _this = this;
|
|
5688
|
-
if (typeof options$1.onLoad !== "function") throw new TypeError("options.onLoad is not a function");
|
|
5689
|
-
var userOnError = options$1.onError;
|
|
5690
|
-
_this = _super.call(this, __assign$1(__assign$1({}, options$1), { onError: function(err, type$1) {
|
|
5691
|
-
var _a;
|
|
5692
|
-
var emnapi_thread_crashed = (_a = _this.instance) === null || _a === void 0 ? void 0 : _a.exports.emnapi_thread_crashed;
|
|
5693
|
-
if (typeof emnapi_thread_crashed === "function") emnapi_thread_crashed();
|
|
5694
|
-
if (typeof userOnError === "function") userOnError(err, type$1);
|
|
5695
|
-
else throw err;
|
|
5696
|
-
} })) || this;
|
|
5697
|
-
_this.napiModule = void 0;
|
|
5698
|
-
return _this;
|
|
5699
|
-
}
|
|
5700
|
-
MessageHandler$1.prototype.instantiate = function(data) {
|
|
5701
|
-
var _this = this;
|
|
5702
|
-
var source = this.onLoad(data);
|
|
5703
|
-
if (typeof source.then === "function") return source.then(function(result) {
|
|
5704
|
-
_this.napiModule = result.napiModule;
|
|
5705
|
-
return result;
|
|
5706
|
-
});
|
|
5707
|
-
this.napiModule = source.napiModule;
|
|
5708
|
-
return source;
|
|
5709
|
-
};
|
|
5710
|
-
MessageHandler$1.prototype.handle = function(e$1) {
|
|
5711
|
-
var _this = this;
|
|
5712
|
-
var _a;
|
|
5713
|
-
_super.prototype.handle.call(this, e$1);
|
|
5714
|
-
if ((_a = e$1 === null || e$1 === void 0 ? void 0 : e$1.data) === null || _a === void 0 ? void 0 : _a.__emnapi__) {
|
|
5715
|
-
var type$1 = e$1.data.__emnapi__.type;
|
|
5716
|
-
var payload_1 = e$1.data.__emnapi__.payload;
|
|
5717
|
-
try {
|
|
5718
|
-
if (type$1 === "async-worker-init") this.handleAfterLoad(e$1, function() {
|
|
5719
|
-
_this.napiModule.initWorker(payload_1.arg);
|
|
5720
|
-
});
|
|
5721
|
-
else if (type$1 === "async-work-execute") this.handleAfterLoad(e$1, function() {
|
|
5722
|
-
_this.napiModule.executeAsyncWork(payload_1.work);
|
|
5723
|
-
});
|
|
5724
|
-
} catch (err) {
|
|
5725
|
-
this.onError(err, type$1);
|
|
5726
|
-
}
|
|
5727
|
-
}
|
|
5728
|
-
};
|
|
5729
|
-
return MessageHandler$1;
|
|
5730
|
-
}(ThreadMessageHandler);
|
|
5731
6231
|
|
|
5732
6232
|
//#endregion
|
|
5733
6233
|
//#region ../../node_modules/.pnpm/@emnapi+runtime@1.8.1/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js
|
|
@@ -6951,24 +7451,1991 @@ function getDefaultContext() {
|
|
|
6951
7451
|
}
|
|
6952
7452
|
|
|
6953
7453
|
//#endregion
|
|
6954
|
-
//#region ../../node_modules/.pnpm/@
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6962
|
-
|
|
6963
|
-
|
|
6964
|
-
if (
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
|
|
7454
|
+
//#region ../../node_modules/.pnpm/@tybys+wasm-util@0.10.1/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js
|
|
7455
|
+
const _WebAssembly = typeof WebAssembly !== "undefined" ? WebAssembly : typeof WXWebAssembly !== "undefined" ? WXWebAssembly : void 0;
|
|
7456
|
+
if (!_WebAssembly) throw new Error("WebAssembly is not supported in this environment");
|
|
7457
|
+
function validateObject(value, name) {
|
|
7458
|
+
if (value === null || typeof value !== "object") throw new TypeError(`${name} must be an object. Received ${value === null ? "null" : typeof value}`);
|
|
7459
|
+
}
|
|
7460
|
+
function validateArray(value, name) {
|
|
7461
|
+
if (!Array.isArray(value)) throw new TypeError(`${name} must be an array. Received ${value === null ? "null" : typeof value}`);
|
|
7462
|
+
}
|
|
7463
|
+
function validateBoolean(value, name) {
|
|
7464
|
+
if (typeof value !== "boolean") throw new TypeError(`${name} must be a boolean. Received ${value === null ? "null" : typeof value}`);
|
|
7465
|
+
}
|
|
7466
|
+
function validateString(value, name) {
|
|
7467
|
+
if (typeof value !== "string") throw new TypeError(`${name} must be a string. Received ${value === null ? "null" : typeof value}`);
|
|
7468
|
+
}
|
|
7469
|
+
function validateFunction(value, name) {
|
|
7470
|
+
if (typeof value !== "function") throw new TypeError(`${name} must be a function. Received ${value === null ? "null" : typeof value}`);
|
|
7471
|
+
}
|
|
7472
|
+
function validateUndefined(value, name) {
|
|
7473
|
+
if (value !== void 0) throw new TypeError(`${name} must be undefined. Received ${value === null ? "null" : typeof value}`);
|
|
7474
|
+
}
|
|
7475
|
+
function isPromiseLike(obj) {
|
|
7476
|
+
return !!(obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function");
|
|
7477
|
+
}
|
|
7478
|
+
function sleepBreakIf(delay, breakIf) {
|
|
7479
|
+
const end = Date.now() + delay;
|
|
7480
|
+
let ret = false;
|
|
7481
|
+
while (Date.now() < end) if (breakIf()) {
|
|
7482
|
+
ret = true;
|
|
7483
|
+
break;
|
|
7484
|
+
}
|
|
7485
|
+
return ret;
|
|
7486
|
+
}
|
|
7487
|
+
function unsharedSlice(view, start, end) {
|
|
7488
|
+
return typeof SharedArrayBuffer === "function" && view.buffer instanceof SharedArrayBuffer || Object.prototype.toString.call(view.buffer.constructor) === "[object SharedArrayBuffer]" ? view.slice(start, end) : view.subarray(start, end);
|
|
7489
|
+
}
|
|
7490
|
+
const CHAR_DOT = 46;
|
|
7491
|
+
const CHAR_FORWARD_SLASH = 47;
|
|
7492
|
+
function isPosixPathSeparator(code$1) {
|
|
7493
|
+
return code$1 === CHAR_FORWARD_SLASH;
|
|
7494
|
+
}
|
|
7495
|
+
function normalizeString$1(path$1, allowAboveRoot, separator, isPathSeparator) {
|
|
7496
|
+
let res = "";
|
|
7497
|
+
let lastSegmentLength = 0;
|
|
7498
|
+
let lastSlash = -1;
|
|
7499
|
+
let dots = 0;
|
|
7500
|
+
let code$1 = 0;
|
|
7501
|
+
for (let i = 0; i <= path$1.length; ++i) {
|
|
7502
|
+
if (i < path$1.length) code$1 = path$1.charCodeAt(i);
|
|
7503
|
+
else if (isPathSeparator(code$1)) break;
|
|
7504
|
+
else code$1 = CHAR_FORWARD_SLASH;
|
|
7505
|
+
if (isPathSeparator(code$1)) {
|
|
7506
|
+
if (lastSlash === i - 1 || dots === 1);
|
|
7507
|
+
else if (dots === 2) {
|
|
7508
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
|
7509
|
+
if (res.length > 2) {
|
|
7510
|
+
const lastSlashIndex = res.indexOf(separator);
|
|
7511
|
+
if (lastSlashIndex === -1) {
|
|
7512
|
+
res = "";
|
|
7513
|
+
lastSegmentLength = 0;
|
|
7514
|
+
} else {
|
|
7515
|
+
res = res.slice(0, lastSlashIndex);
|
|
7516
|
+
lastSegmentLength = res.length - 1 - res.indexOf(separator);
|
|
7517
|
+
}
|
|
7518
|
+
lastSlash = i;
|
|
7519
|
+
dots = 0;
|
|
7520
|
+
continue;
|
|
7521
|
+
} else if (res.length !== 0) {
|
|
7522
|
+
res = "";
|
|
7523
|
+
lastSegmentLength = 0;
|
|
7524
|
+
lastSlash = i;
|
|
7525
|
+
dots = 0;
|
|
7526
|
+
continue;
|
|
7527
|
+
}
|
|
7528
|
+
}
|
|
7529
|
+
if (allowAboveRoot) {
|
|
7530
|
+
res += res.length > 0 ? `${separator}..` : "..";
|
|
7531
|
+
lastSegmentLength = 2;
|
|
7532
|
+
}
|
|
7533
|
+
} else {
|
|
7534
|
+
if (res.length > 0) res += `${separator}${path$1.slice(lastSlash + 1, i)}`;
|
|
7535
|
+
else res = path$1.slice(lastSlash + 1, i);
|
|
7536
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
7537
|
+
}
|
|
7538
|
+
lastSlash = i;
|
|
7539
|
+
dots = 0;
|
|
7540
|
+
} else if (code$1 === CHAR_DOT && dots !== -1) ++dots;
|
|
7541
|
+
else dots = -1;
|
|
7542
|
+
}
|
|
7543
|
+
return res;
|
|
7544
|
+
}
|
|
7545
|
+
function resolve$1(...args$1) {
|
|
7546
|
+
let resolvedPath = "";
|
|
7547
|
+
let resolvedAbsolute = false;
|
|
7548
|
+
for (let i = args$1.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
7549
|
+
const path$1 = i >= 0 ? args$1[i] : "/";
|
|
7550
|
+
validateString(path$1, "path");
|
|
7551
|
+
if (path$1.length === 0) continue;
|
|
7552
|
+
resolvedPath = `${path$1}/${resolvedPath}`;
|
|
7553
|
+
resolvedAbsolute = path$1.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
7554
|
+
}
|
|
7555
|
+
resolvedPath = normalizeString$1(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);
|
|
7556
|
+
if (resolvedAbsolute) return `/${resolvedPath}`;
|
|
7557
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
7558
|
+
}
|
|
7559
|
+
const WasiRights = {
|
|
7560
|
+
FD_DATASYNC: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(0),
|
|
7561
|
+
FD_READ: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(1),
|
|
7562
|
+
FD_SEEK: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(2),
|
|
7563
|
+
FD_FDSTAT_SET_FLAGS: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(3),
|
|
7564
|
+
FD_SYNC: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(4),
|
|
7565
|
+
FD_TELL: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(5),
|
|
7566
|
+
FD_WRITE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(6),
|
|
7567
|
+
FD_ADVISE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(7),
|
|
7568
|
+
FD_ALLOCATE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(8),
|
|
7569
|
+
PATH_CREATE_DIRECTORY: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(9),
|
|
7570
|
+
PATH_CREATE_FILE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(10),
|
|
7571
|
+
PATH_LINK_SOURCE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(11),
|
|
7572
|
+
PATH_LINK_TARGET: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(12),
|
|
7573
|
+
PATH_OPEN: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(13),
|
|
7574
|
+
FD_READDIR: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(14),
|
|
7575
|
+
PATH_READLINK: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(15),
|
|
7576
|
+
PATH_RENAME_SOURCE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(16),
|
|
7577
|
+
PATH_RENAME_TARGET: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(17),
|
|
7578
|
+
PATH_FILESTAT_GET: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(18),
|
|
7579
|
+
PATH_FILESTAT_SET_SIZE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(19),
|
|
7580
|
+
PATH_FILESTAT_SET_TIMES: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(20),
|
|
7581
|
+
FD_FILESTAT_GET: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(21),
|
|
7582
|
+
FD_FILESTAT_SET_SIZE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(22),
|
|
7583
|
+
FD_FILESTAT_SET_TIMES: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(23),
|
|
7584
|
+
PATH_SYMLINK: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(24),
|
|
7585
|
+
PATH_REMOVE_DIRECTORY: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(25),
|
|
7586
|
+
PATH_UNLINK_FILE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(26),
|
|
7587
|
+
POLL_FD_READWRITE: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(27),
|
|
7588
|
+
SOCK_SHUTDOWN: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(28),
|
|
7589
|
+
SOCK_ACCEPT: /* @__PURE__ */ BigInt(1) << /* @__PURE__ */ BigInt(29)
|
|
6968
7590
|
};
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
7591
|
+
function strerror(errno) {
|
|
7592
|
+
switch (errno) {
|
|
7593
|
+
case 0: return "Success";
|
|
7594
|
+
case 1: return "Argument list too long";
|
|
7595
|
+
case 2: return "Permission denied";
|
|
7596
|
+
case 3: return "Address in use";
|
|
7597
|
+
case 4: return "Address not available";
|
|
7598
|
+
case 5: return "Address family not supported by protocol";
|
|
7599
|
+
case 6: return "Resource temporarily unavailable";
|
|
7600
|
+
case 7: return "Operation already in progress";
|
|
7601
|
+
case 8: return "Bad file descriptor";
|
|
7602
|
+
case 9: return "Bad message";
|
|
7603
|
+
case 10: return "Resource busy";
|
|
7604
|
+
case 11: return "Operation canceled";
|
|
7605
|
+
case 12: return "No child process";
|
|
7606
|
+
case 13: return "Connection aborted";
|
|
7607
|
+
case 14: return "Connection refused";
|
|
7608
|
+
case 15: return "Connection reset by peer";
|
|
7609
|
+
case 16: return "Resource deadlock would occur";
|
|
7610
|
+
case 17: return "Destination address required";
|
|
7611
|
+
case 18: return "Domain error";
|
|
7612
|
+
case 19: return "Quota exceeded";
|
|
7613
|
+
case 20: return "File exists";
|
|
7614
|
+
case 21: return "Bad address";
|
|
7615
|
+
case 22: return "File too large";
|
|
7616
|
+
case 23: return "Host is unreachable";
|
|
7617
|
+
case 24: return "Identifier removed";
|
|
7618
|
+
case 25: return "Illegal byte sequence";
|
|
7619
|
+
case 26: return "Operation in progress";
|
|
7620
|
+
case 27: return "Interrupted system call";
|
|
7621
|
+
case 28: return "Invalid argument";
|
|
7622
|
+
case 29: return "I/O error";
|
|
7623
|
+
case 30: return "Socket is connected";
|
|
7624
|
+
case 31: return "Is a directory";
|
|
7625
|
+
case 32: return "Symbolic link loop";
|
|
7626
|
+
case 33: return "No file descriptors available";
|
|
7627
|
+
case 34: return "Too many links";
|
|
7628
|
+
case 35: return "Message too large";
|
|
7629
|
+
case 36: return "Multihop attempted";
|
|
7630
|
+
case 37: return "Filename too long";
|
|
7631
|
+
case 38: return "Network is down";
|
|
7632
|
+
case 39: return "Connection reset by network";
|
|
7633
|
+
case 40: return "Network unreachable";
|
|
7634
|
+
case 41: return "Too many files open in system";
|
|
7635
|
+
case 42: return "No buffer space available";
|
|
7636
|
+
case 43: return "No such device";
|
|
7637
|
+
case 44: return "No such file or directory";
|
|
7638
|
+
case 45: return "Exec format error";
|
|
7639
|
+
case 46: return "No locks available";
|
|
7640
|
+
case 47: return "Link has been severed";
|
|
7641
|
+
case 48: return "Out of memory";
|
|
7642
|
+
case 49: return "No message of the desired type";
|
|
7643
|
+
case 50: return "Protocol not available";
|
|
7644
|
+
case 51: return "No space left on device";
|
|
7645
|
+
case 52: return "Function not implemented";
|
|
7646
|
+
case 53: return "Socket not connected";
|
|
7647
|
+
case 54: return "Not a directory";
|
|
7648
|
+
case 55: return "Directory not empty";
|
|
7649
|
+
case 56: return "State not recoverable";
|
|
7650
|
+
case 57: return "Not a socket";
|
|
7651
|
+
case 58: return "Not supported";
|
|
7652
|
+
case 59: return "Not a tty";
|
|
7653
|
+
case 60: return "No such device or address";
|
|
7654
|
+
case 61: return "Value too large for data type";
|
|
7655
|
+
case 62: return "Previous owner died";
|
|
7656
|
+
case 63: return "Operation not permitted";
|
|
7657
|
+
case 64: return "Broken pipe";
|
|
7658
|
+
case 65: return "Protocol error";
|
|
7659
|
+
case 66: return "Protocol not supported";
|
|
7660
|
+
case 67: return "Protocol wrong type for socket";
|
|
7661
|
+
case 68: return "Result not representable";
|
|
7662
|
+
case 69: return "Read-only file system";
|
|
7663
|
+
case 70: return "Invalid seek";
|
|
7664
|
+
case 71: return "No such process";
|
|
7665
|
+
case 72: return "Stale file handle";
|
|
7666
|
+
case 73: return "Operation timed out";
|
|
7667
|
+
case 74: return "Text file busy";
|
|
7668
|
+
case 75: return "Cross-device link";
|
|
7669
|
+
case 76: return "Capabilities insufficient";
|
|
7670
|
+
default: return "Unknown error";
|
|
7671
|
+
}
|
|
7672
|
+
}
|
|
7673
|
+
var WasiError = class extends Error {
|
|
7674
|
+
constructor(message, errno) {
|
|
7675
|
+
super(message);
|
|
7676
|
+
this.errno = errno;
|
|
7677
|
+
}
|
|
7678
|
+
getErrorMessage() {
|
|
7679
|
+
return strerror(this.errno);
|
|
7680
|
+
}
|
|
7681
|
+
};
|
|
7682
|
+
Object.defineProperty(WasiError.prototype, "name", {
|
|
7683
|
+
configurable: true,
|
|
7684
|
+
writable: true,
|
|
7685
|
+
value: "WasiError"
|
|
7686
|
+
});
|
|
7687
|
+
const RIGHTS_ALL = WasiRights.FD_DATASYNC | WasiRights.FD_READ | WasiRights.FD_SEEK | WasiRights.FD_FDSTAT_SET_FLAGS | WasiRights.FD_SYNC | WasiRights.FD_TELL | WasiRights.FD_WRITE | WasiRights.FD_ADVISE | WasiRights.FD_ALLOCATE | WasiRights.PATH_CREATE_DIRECTORY | WasiRights.PATH_CREATE_FILE | WasiRights.PATH_LINK_SOURCE | WasiRights.PATH_LINK_TARGET | WasiRights.PATH_OPEN | WasiRights.FD_READDIR | WasiRights.PATH_READLINK | WasiRights.PATH_RENAME_SOURCE | WasiRights.PATH_RENAME_TARGET | WasiRights.PATH_FILESTAT_GET | WasiRights.PATH_FILESTAT_SET_SIZE | WasiRights.PATH_FILESTAT_SET_TIMES | WasiRights.FD_FILESTAT_GET | WasiRights.FD_FILESTAT_SET_TIMES | WasiRights.FD_FILESTAT_SET_SIZE | WasiRights.PATH_SYMLINK | WasiRights.PATH_UNLINK_FILE | WasiRights.PATH_REMOVE_DIRECTORY | WasiRights.POLL_FD_READWRITE | WasiRights.SOCK_SHUTDOWN | WasiRights.SOCK_ACCEPT;
|
|
7688
|
+
const BLOCK_DEVICE_BASE = RIGHTS_ALL;
|
|
7689
|
+
const BLOCK_DEVICE_INHERITING = RIGHTS_ALL;
|
|
7690
|
+
const CHARACTER_DEVICE_BASE = RIGHTS_ALL;
|
|
7691
|
+
const CHARACTER_DEVICE_INHERITING = RIGHTS_ALL;
|
|
7692
|
+
const REGULAR_FILE_BASE = WasiRights.FD_DATASYNC | WasiRights.FD_READ | WasiRights.FD_SEEK | WasiRights.FD_FDSTAT_SET_FLAGS | WasiRights.FD_SYNC | WasiRights.FD_TELL | WasiRights.FD_WRITE | WasiRights.FD_ADVISE | WasiRights.FD_ALLOCATE | WasiRights.FD_FILESTAT_GET | WasiRights.FD_FILESTAT_SET_SIZE | WasiRights.FD_FILESTAT_SET_TIMES | WasiRights.POLL_FD_READWRITE;
|
|
7693
|
+
const REGULAR_FILE_INHERITING = /* @__PURE__ */ BigInt(0);
|
|
7694
|
+
const DIRECTORY_BASE = WasiRights.FD_FDSTAT_SET_FLAGS | WasiRights.FD_SYNC | WasiRights.FD_ADVISE | WasiRights.PATH_CREATE_DIRECTORY | WasiRights.PATH_CREATE_FILE | WasiRights.PATH_LINK_SOURCE | WasiRights.PATH_LINK_TARGET | WasiRights.PATH_OPEN | WasiRights.FD_READDIR | WasiRights.PATH_READLINK | WasiRights.PATH_RENAME_SOURCE | WasiRights.PATH_RENAME_TARGET | WasiRights.PATH_FILESTAT_GET | WasiRights.PATH_FILESTAT_SET_SIZE | WasiRights.PATH_FILESTAT_SET_TIMES | WasiRights.FD_FILESTAT_GET | WasiRights.FD_FILESTAT_SET_TIMES | WasiRights.PATH_SYMLINK | WasiRights.PATH_UNLINK_FILE | WasiRights.PATH_REMOVE_DIRECTORY | WasiRights.POLL_FD_READWRITE;
|
|
7695
|
+
const DIRECTORY_INHERITING = DIRECTORY_BASE | REGULAR_FILE_BASE;
|
|
7696
|
+
const SOCKET_BASE = WasiRights.FD_READ | WasiRights.FD_FDSTAT_SET_FLAGS | WasiRights.FD_WRITE | WasiRights.FD_FILESTAT_GET | WasiRights.POLL_FD_READWRITE | WasiRights.SOCK_SHUTDOWN;
|
|
7697
|
+
const SOCKET_INHERITING = RIGHTS_ALL;
|
|
7698
|
+
const TTY_BASE = WasiRights.FD_READ | WasiRights.FD_FDSTAT_SET_FLAGS | WasiRights.FD_WRITE | WasiRights.FD_FILESTAT_GET | WasiRights.POLL_FD_READWRITE;
|
|
7699
|
+
const TTY_INHERITING = /* @__PURE__ */ BigInt(0);
|
|
7700
|
+
function getRights(stdio, fd, flags, type$1) {
|
|
7701
|
+
const ret = {
|
|
7702
|
+
base: BigInt(0),
|
|
7703
|
+
inheriting: BigInt(0)
|
|
7704
|
+
};
|
|
7705
|
+
if (type$1 === 0) throw new WasiError("Unknown file type", 28);
|
|
7706
|
+
switch (type$1) {
|
|
7707
|
+
case 4:
|
|
7708
|
+
ret.base = REGULAR_FILE_BASE;
|
|
7709
|
+
ret.inheriting = REGULAR_FILE_INHERITING;
|
|
7710
|
+
break;
|
|
7711
|
+
case 3:
|
|
7712
|
+
ret.base = DIRECTORY_BASE;
|
|
7713
|
+
ret.inheriting = DIRECTORY_INHERITING;
|
|
7714
|
+
break;
|
|
7715
|
+
case 6:
|
|
7716
|
+
case 5:
|
|
7717
|
+
ret.base = SOCKET_BASE;
|
|
7718
|
+
ret.inheriting = SOCKET_INHERITING;
|
|
7719
|
+
break;
|
|
7720
|
+
case 2:
|
|
7721
|
+
if (stdio.indexOf(fd) !== -1) {
|
|
7722
|
+
ret.base = TTY_BASE;
|
|
7723
|
+
ret.inheriting = TTY_INHERITING;
|
|
7724
|
+
} else {
|
|
7725
|
+
ret.base = CHARACTER_DEVICE_BASE;
|
|
7726
|
+
ret.inheriting = CHARACTER_DEVICE_INHERITING;
|
|
7727
|
+
}
|
|
7728
|
+
break;
|
|
7729
|
+
case 1:
|
|
7730
|
+
ret.base = BLOCK_DEVICE_BASE;
|
|
7731
|
+
ret.inheriting = BLOCK_DEVICE_INHERITING;
|
|
7732
|
+
break;
|
|
7733
|
+
default:
|
|
7734
|
+
ret.base = BigInt(0);
|
|
7735
|
+
ret.inheriting = BigInt(0);
|
|
7736
|
+
}
|
|
7737
|
+
const read_or_write_only = flags & 3;
|
|
7738
|
+
if (read_or_write_only === 0) ret.base &= ~WasiRights.FD_WRITE;
|
|
7739
|
+
else if (read_or_write_only === 1) ret.base &= ~WasiRights.FD_READ;
|
|
7740
|
+
return ret;
|
|
7741
|
+
}
|
|
7742
|
+
function concatBuffer(buffers, size) {
|
|
7743
|
+
let total = 0;
|
|
7744
|
+
if (typeof size === "number" && size >= 0) total = size;
|
|
7745
|
+
else for (let i = 0; i < buffers.length; i++) {
|
|
7746
|
+
const buffer = buffers[i];
|
|
7747
|
+
total += buffer.length;
|
|
7748
|
+
}
|
|
7749
|
+
let pos = 0;
|
|
7750
|
+
const ret = new Uint8Array(total);
|
|
7751
|
+
for (let i = 0; i < buffers.length; i++) {
|
|
7752
|
+
const buffer = buffers[i];
|
|
7753
|
+
ret.set(buffer, pos);
|
|
7754
|
+
pos += buffer.length;
|
|
7755
|
+
}
|
|
7756
|
+
return ret;
|
|
7757
|
+
}
|
|
7758
|
+
var FileDescriptor = class {
|
|
7759
|
+
constructor(id$1, fd, path$1, realPath, type$1, rightsBase, rightsInheriting, preopen) {
|
|
7760
|
+
this.id = id$1;
|
|
7761
|
+
this.fd = fd;
|
|
7762
|
+
this.path = path$1;
|
|
7763
|
+
this.realPath = realPath;
|
|
7764
|
+
this.type = type$1;
|
|
7765
|
+
this.rightsBase = rightsBase;
|
|
7766
|
+
this.rightsInheriting = rightsInheriting;
|
|
7767
|
+
this.preopen = preopen;
|
|
7768
|
+
this.pos = BigInt(0);
|
|
7769
|
+
this.size = BigInt(0);
|
|
7770
|
+
}
|
|
7771
|
+
seek(offset, whence) {
|
|
7772
|
+
if (whence === 0) this.pos = BigInt(offset);
|
|
7773
|
+
else if (whence === 1) this.pos += BigInt(offset);
|
|
7774
|
+
else if (whence === 2) this.pos = BigInt(this.size) - BigInt(offset);
|
|
7775
|
+
else throw new WasiError("Unknown whence", 29);
|
|
7776
|
+
return this.pos;
|
|
7777
|
+
}
|
|
7778
|
+
};
|
|
7779
|
+
var StandardOutput = class extends FileDescriptor {
|
|
7780
|
+
constructor(log, id$1, fd, path$1, realPath, type$1, rightsBase, rightsInheriting, preopen) {
|
|
7781
|
+
super(id$1, fd, path$1, realPath, type$1, rightsBase, rightsInheriting, preopen);
|
|
7782
|
+
this._log = log;
|
|
7783
|
+
this._buf = null;
|
|
7784
|
+
}
|
|
7785
|
+
write(buffer) {
|
|
7786
|
+
const originalBuffer = buffer;
|
|
7787
|
+
if (this._buf) {
|
|
7788
|
+
buffer = concatBuffer([this._buf, buffer]);
|
|
7789
|
+
this._buf = null;
|
|
7790
|
+
}
|
|
7791
|
+
if (buffer.indexOf(10) === -1) {
|
|
7792
|
+
this._buf = buffer;
|
|
7793
|
+
return originalBuffer.byteLength;
|
|
7794
|
+
}
|
|
7795
|
+
let written = 0;
|
|
7796
|
+
let lastBegin = 0;
|
|
7797
|
+
let index;
|
|
7798
|
+
while ((index = buffer.indexOf(10, written)) !== -1) {
|
|
7799
|
+
const str = new TextDecoder().decode(buffer.subarray(lastBegin, index));
|
|
7800
|
+
this._log(str);
|
|
7801
|
+
written += index - lastBegin + 1;
|
|
7802
|
+
lastBegin = index + 1;
|
|
7803
|
+
}
|
|
7804
|
+
if (written < buffer.length) this._buf = buffer.slice(written);
|
|
7805
|
+
return originalBuffer.byteLength;
|
|
7806
|
+
}
|
|
7807
|
+
};
|
|
7808
|
+
function toFileType(stat) {
|
|
7809
|
+
if (stat.isBlockDevice()) return 1;
|
|
7810
|
+
if (stat.isCharacterDevice()) return 2;
|
|
7811
|
+
if (stat.isDirectory()) return 3;
|
|
7812
|
+
if (stat.isSocket()) return 6;
|
|
7813
|
+
if (stat.isFile()) return 4;
|
|
7814
|
+
if (stat.isSymbolicLink()) return 7;
|
|
7815
|
+
return 0;
|
|
7816
|
+
}
|
|
7817
|
+
function toFileStat(view, buf, stat) {
|
|
7818
|
+
view.setBigUint64(buf, stat.dev, true);
|
|
7819
|
+
view.setBigUint64(buf + 8, stat.ino, true);
|
|
7820
|
+
view.setBigUint64(buf + 16, BigInt(toFileType(stat)), true);
|
|
7821
|
+
view.setBigUint64(buf + 24, stat.nlink, true);
|
|
7822
|
+
view.setBigUint64(buf + 32, stat.size, true);
|
|
7823
|
+
view.setBigUint64(buf + 40, stat.atimeMs * BigInt(1e6), true);
|
|
7824
|
+
view.setBigUint64(buf + 48, stat.mtimeMs * BigInt(1e6), true);
|
|
7825
|
+
view.setBigUint64(buf + 56, stat.ctimeMs * BigInt(1e6), true);
|
|
7826
|
+
}
|
|
7827
|
+
var FileDescriptorTable = class {
|
|
7828
|
+
constructor(options$1) {
|
|
7829
|
+
this.used = 0;
|
|
7830
|
+
this.size = options$1.size;
|
|
7831
|
+
this.fds = Array(options$1.size);
|
|
7832
|
+
this.stdio = [
|
|
7833
|
+
options$1.in,
|
|
7834
|
+
options$1.out,
|
|
7835
|
+
options$1.err
|
|
7836
|
+
];
|
|
7837
|
+
this.print = options$1.print;
|
|
7838
|
+
this.printErr = options$1.printErr;
|
|
7839
|
+
this.insertStdio(options$1.in, 0, "<stdin>");
|
|
7840
|
+
this.insertStdio(options$1.out, 1, "<stdout>");
|
|
7841
|
+
this.insertStdio(options$1.err, 2, "<stderr>");
|
|
7842
|
+
}
|
|
7843
|
+
insertStdio(fd, expected, name) {
|
|
7844
|
+
const type$1 = 2;
|
|
7845
|
+
const { base, inheriting } = getRights(this.stdio, fd, 2, type$1);
|
|
7846
|
+
const wrap$3 = this.insert(fd, name, name, type$1, base, inheriting, 0);
|
|
7847
|
+
if (wrap$3.id !== expected) throw new WasiError(`id: ${wrap$3.id} !== expected: ${expected}`, 8);
|
|
7848
|
+
return wrap$3;
|
|
7849
|
+
}
|
|
7850
|
+
insert(fd, mappedPath, realPath, type$1, rightsBase, rightsInheriting, preopen) {
|
|
7851
|
+
var _a, _b;
|
|
7852
|
+
let index = -1;
|
|
7853
|
+
if (this.used >= this.size) {
|
|
7854
|
+
const newSize = this.size * 2;
|
|
7855
|
+
this.fds.length = newSize;
|
|
7856
|
+
index = this.size;
|
|
7857
|
+
this.size = newSize;
|
|
7858
|
+
} else for (let i = 0; i < this.size; ++i) if (this.fds[i] == null) {
|
|
7859
|
+
index = i;
|
|
7860
|
+
break;
|
|
7861
|
+
}
|
|
7862
|
+
let entry;
|
|
7863
|
+
if (mappedPath === "<stdout>") entry = new StandardOutput((_a = this.print) !== null && _a !== void 0 ? _a : console.log, index, fd, mappedPath, realPath, type$1, rightsBase, rightsInheriting, preopen);
|
|
7864
|
+
else if (mappedPath === "<stderr>") entry = new StandardOutput((_b = this.printErr) !== null && _b !== void 0 ? _b : console.error, index, fd, mappedPath, realPath, type$1, rightsBase, rightsInheriting, preopen);
|
|
7865
|
+
else entry = new FileDescriptor(index, fd, mappedPath, realPath, type$1, rightsBase, rightsInheriting, preopen);
|
|
7866
|
+
this.fds[index] = entry;
|
|
7867
|
+
this.used++;
|
|
7868
|
+
return entry;
|
|
7869
|
+
}
|
|
7870
|
+
get(id$1, base, inheriting) {
|
|
7871
|
+
if (id$1 >= this.size) throw new WasiError("Invalid fd", 8);
|
|
7872
|
+
const entry = this.fds[id$1];
|
|
7873
|
+
if (!entry || entry.id !== id$1) throw new WasiError("Bad file descriptor", 8);
|
|
7874
|
+
if ((~entry.rightsBase & base) !== BigInt(0) || (~entry.rightsInheriting & inheriting) !== BigInt(0)) throw new WasiError("Capabilities insufficient", 76);
|
|
7875
|
+
return entry;
|
|
7876
|
+
}
|
|
7877
|
+
remove(id$1) {
|
|
7878
|
+
if (id$1 >= this.size) throw new WasiError("Invalid fd", 8);
|
|
7879
|
+
const entry = this.fds[id$1];
|
|
7880
|
+
if (!entry || entry.id !== id$1) throw new WasiError("Bad file descriptor", 8);
|
|
7881
|
+
this.fds[id$1] = void 0;
|
|
7882
|
+
this.used--;
|
|
7883
|
+
}
|
|
7884
|
+
};
|
|
7885
|
+
var SyncTable = class extends FileDescriptorTable {
|
|
7886
|
+
constructor(options$1) {
|
|
7887
|
+
super(options$1);
|
|
7888
|
+
this.fs = options$1.fs;
|
|
7889
|
+
}
|
|
7890
|
+
getFileTypeByFd(fd) {
|
|
7891
|
+
return toFileType(this.fs.fstatSync(fd, { bigint: true }));
|
|
7892
|
+
}
|
|
7893
|
+
insertPreopen(fd, mappedPath, realPath) {
|
|
7894
|
+
const type$1 = this.getFileTypeByFd(fd);
|
|
7895
|
+
if (type$1 !== 3) throw new WasiError(`Preopen not dir: ["${mappedPath}", "${realPath}"]`, 54);
|
|
7896
|
+
const result = getRights(this.stdio, fd, 0, type$1);
|
|
7897
|
+
return this.insert(fd, mappedPath, realPath, type$1, result.base, result.inheriting, 1);
|
|
7898
|
+
}
|
|
7899
|
+
renumber(dst, src) {
|
|
7900
|
+
if (dst === src) return;
|
|
7901
|
+
if (dst >= this.size || src >= this.size) throw new WasiError("Invalid fd", 8);
|
|
7902
|
+
const dstEntry = this.fds[dst];
|
|
7903
|
+
const srcEntry = this.fds[src];
|
|
7904
|
+
if (!dstEntry || !srcEntry || dstEntry.id !== dst || srcEntry.id !== src) throw new WasiError("Invalid fd", 8);
|
|
7905
|
+
this.fs.closeSync(dstEntry.fd);
|
|
7906
|
+
this.fds[dst] = this.fds[src];
|
|
7907
|
+
this.fds[dst].id = dst;
|
|
7908
|
+
this.fds[src] = void 0;
|
|
7909
|
+
this.used--;
|
|
7910
|
+
}
|
|
7911
|
+
};
|
|
7912
|
+
var AsyncTable = class extends FileDescriptorTable {
|
|
7913
|
+
constructor(options$1) {
|
|
7914
|
+
super(options$1);
|
|
7915
|
+
}
|
|
7916
|
+
async getFileTypeByFd(fd) {
|
|
7917
|
+
return toFileType(await fd.stat({ bigint: true }));
|
|
7918
|
+
}
|
|
7919
|
+
async insertPreopen(fd, mappedPath, realPath) {
|
|
7920
|
+
const type$1 = await this.getFileTypeByFd(fd);
|
|
7921
|
+
if (type$1 !== 3) throw new WasiError(`Preopen not dir: ["${mappedPath}", "${realPath}"]`, 54);
|
|
7922
|
+
const result = getRights(this.stdio, fd.fd, 0, type$1);
|
|
7923
|
+
return this.insert(fd, mappedPath, realPath, type$1, result.base, result.inheriting, 1);
|
|
7924
|
+
}
|
|
7925
|
+
async renumber(dst, src) {
|
|
7926
|
+
if (dst === src) return;
|
|
7927
|
+
if (dst >= this.size || src >= this.size) throw new WasiError("Invalid fd", 8);
|
|
7928
|
+
const dstEntry = this.fds[dst];
|
|
7929
|
+
const srcEntry = this.fds[src];
|
|
7930
|
+
if (!dstEntry || !srcEntry || dstEntry.id !== dst || srcEntry.id !== src) throw new WasiError("Invalid fd", 8);
|
|
7931
|
+
await dstEntry.fd.close();
|
|
7932
|
+
this.fds[dst] = this.fds[src];
|
|
7933
|
+
this.fds[dst].id = dst;
|
|
7934
|
+
this.fds[src] = void 0;
|
|
7935
|
+
this.used--;
|
|
7936
|
+
}
|
|
7937
|
+
};
|
|
7938
|
+
/** @public */
|
|
7939
|
+
const WebAssemblyMemory = /* @__PURE__ */ (function() {
|
|
7940
|
+
return _WebAssembly.Memory;
|
|
7941
|
+
})();
|
|
7942
|
+
/** @public */
|
|
7943
|
+
var Memory = class extends WebAssemblyMemory {
|
|
7944
|
+
constructor(descriptor) {
|
|
7945
|
+
super(descriptor);
|
|
7946
|
+
}
|
|
7947
|
+
get HEAP8() {
|
|
7948
|
+
return new Int8Array(super.buffer);
|
|
7949
|
+
}
|
|
7950
|
+
get HEAPU8() {
|
|
7951
|
+
return new Uint8Array(super.buffer);
|
|
7952
|
+
}
|
|
7953
|
+
get HEAP16() {
|
|
7954
|
+
return new Int16Array(super.buffer);
|
|
7955
|
+
}
|
|
7956
|
+
get HEAPU16() {
|
|
7957
|
+
return new Uint16Array(super.buffer);
|
|
7958
|
+
}
|
|
7959
|
+
get HEAP32() {
|
|
7960
|
+
return new Int32Array(super.buffer);
|
|
7961
|
+
}
|
|
7962
|
+
get HEAPU32() {
|
|
7963
|
+
return new Uint32Array(super.buffer);
|
|
7964
|
+
}
|
|
7965
|
+
get HEAP64() {
|
|
7966
|
+
return new BigInt64Array(super.buffer);
|
|
7967
|
+
}
|
|
7968
|
+
get HEAPU64() {
|
|
7969
|
+
return new BigUint64Array(super.buffer);
|
|
7970
|
+
}
|
|
7971
|
+
get HEAPF32() {
|
|
7972
|
+
return new Float32Array(super.buffer);
|
|
7973
|
+
}
|
|
7974
|
+
get HEAPF64() {
|
|
7975
|
+
return new Float64Array(super.buffer);
|
|
7976
|
+
}
|
|
7977
|
+
get view() {
|
|
7978
|
+
return new DataView(super.buffer);
|
|
7979
|
+
}
|
|
7980
|
+
};
|
|
7981
|
+
/** @public */
|
|
7982
|
+
function extendMemory(memory) {
|
|
7983
|
+
if (Object.getPrototypeOf(memory) === _WebAssembly.Memory.prototype) Object.setPrototypeOf(memory, Memory.prototype);
|
|
7984
|
+
return memory;
|
|
7985
|
+
}
|
|
7986
|
+
function checkWebAssemblyFunction() {
|
|
7987
|
+
const WebAssemblyFunction = _WebAssembly.Function;
|
|
7988
|
+
if (typeof WebAssemblyFunction !== "function") throw new Error("WebAssembly.Function is not supported in this environment. If you are using V8 based browser like Chrome, try to specify --js-flags=\"--wasm-staging --experimental-wasm-stack-switching\"");
|
|
7989
|
+
return WebAssemblyFunction;
|
|
7990
|
+
}
|
|
7991
|
+
/** @public */
|
|
7992
|
+
function wrapAsyncImport(f, parameterType, returnType) {
|
|
7993
|
+
const WebAssemblyFunction = checkWebAssemblyFunction();
|
|
7994
|
+
if (typeof f !== "function") throw new TypeError("Function required");
|
|
7995
|
+
const parameters = parameterType.slice(0);
|
|
7996
|
+
parameters.unshift("externref");
|
|
7997
|
+
return new WebAssemblyFunction({
|
|
7998
|
+
parameters,
|
|
7999
|
+
results: returnType
|
|
8000
|
+
}, f, { suspending: "first" });
|
|
8001
|
+
}
|
|
8002
|
+
function copyMemory(targets, src) {
|
|
8003
|
+
if (targets.length === 0 || src.length === 0) return 0;
|
|
8004
|
+
let copied = 0;
|
|
8005
|
+
let left = src.length - copied;
|
|
8006
|
+
for (let i = 0; i < targets.length; ++i) {
|
|
8007
|
+
const target = targets[i];
|
|
8008
|
+
if (left < target.length) {
|
|
8009
|
+
target.set(src.subarray(copied, copied + left), 0);
|
|
8010
|
+
copied += left;
|
|
8011
|
+
left = 0;
|
|
8012
|
+
return copied;
|
|
8013
|
+
}
|
|
8014
|
+
target.set(src.subarray(copied, copied + target.length), 0);
|
|
8015
|
+
copied += target.length;
|
|
8016
|
+
left -= target.length;
|
|
8017
|
+
}
|
|
8018
|
+
return copied;
|
|
8019
|
+
}
|
|
8020
|
+
const _memory = /* @__PURE__ */ new WeakMap();
|
|
8021
|
+
const _wasi = /* @__PURE__ */ new WeakMap();
|
|
8022
|
+
const _fs = /* @__PURE__ */ new WeakMap();
|
|
8023
|
+
function getMemory(wasi) {
|
|
8024
|
+
return _memory.get(wasi);
|
|
8025
|
+
}
|
|
8026
|
+
function getFs(wasi) {
|
|
8027
|
+
const fs$1 = _fs.get(wasi);
|
|
8028
|
+
if (!fs$1) throw new Error("filesystem is unavailable");
|
|
8029
|
+
return fs$1;
|
|
8030
|
+
}
|
|
8031
|
+
function handleError(err) {
|
|
8032
|
+
if (err instanceof WasiError) {
|
|
8033
|
+
console.warn(err);
|
|
8034
|
+
return err.errno;
|
|
8035
|
+
}
|
|
8036
|
+
switch (err.code) {
|
|
8037
|
+
case "ENOENT": return 44;
|
|
8038
|
+
case "EBADF": return 8;
|
|
8039
|
+
case "EINVAL": return 28;
|
|
8040
|
+
case "EPERM": return 63;
|
|
8041
|
+
case "EPROTO": return 65;
|
|
8042
|
+
case "EEXIST": return 20;
|
|
8043
|
+
case "ENOTDIR": return 54;
|
|
8044
|
+
case "EMFILE": return 33;
|
|
8045
|
+
case "EACCES": return 2;
|
|
8046
|
+
case "EISDIR": return 31;
|
|
8047
|
+
case "ENOTEMPTY": return 55;
|
|
8048
|
+
case "ENOSYS": return 52;
|
|
8049
|
+
}
|
|
8050
|
+
throw err;
|
|
8051
|
+
}
|
|
8052
|
+
function defineName(name, f) {
|
|
8053
|
+
Object.defineProperty(f, "name", { value: name });
|
|
8054
|
+
return f;
|
|
8055
|
+
}
|
|
8056
|
+
function tryCall(f, wasi, args$1) {
|
|
8057
|
+
let r;
|
|
8058
|
+
try {
|
|
8059
|
+
r = f.apply(wasi, args$1);
|
|
8060
|
+
} catch (err) {
|
|
8061
|
+
return handleError(err);
|
|
8062
|
+
}
|
|
8063
|
+
if (isPromiseLike(r)) return r.then((_) => _, handleError);
|
|
8064
|
+
return r;
|
|
8065
|
+
}
|
|
8066
|
+
function syscallWrap(self$1, name, f) {
|
|
8067
|
+
let debug$1 = false;
|
|
8068
|
+
const NODE_DEBUG_NATIVE = (() => {
|
|
8069
|
+
try {
|
|
8070
|
+
return process.env.NODE_DEBUG_NATIVE;
|
|
8071
|
+
} catch (_) {
|
|
8072
|
+
return;
|
|
8073
|
+
}
|
|
8074
|
+
})();
|
|
8075
|
+
if (typeof NODE_DEBUG_NATIVE === "string" && NODE_DEBUG_NATIVE.split(",").includes("wasi")) debug$1 = true;
|
|
8076
|
+
return debug$1 ? defineName(name, function() {
|
|
8077
|
+
const args$1 = Array.prototype.slice.call(arguments);
|
|
8078
|
+
let debugArgs = [`${name}(${Array.from({ length: arguments.length }).map(() => "%d").join(", ")})`];
|
|
8079
|
+
debugArgs = debugArgs.concat(args$1);
|
|
8080
|
+
console.debug.apply(console, debugArgs);
|
|
8081
|
+
return tryCall(f, self$1, args$1);
|
|
8082
|
+
}) : defineName(name, function() {
|
|
8083
|
+
return tryCall(f, self$1, arguments);
|
|
8084
|
+
});
|
|
8085
|
+
}
|
|
8086
|
+
function resolvePathSync(fs$1, fileDescriptor, path$1, flags) {
|
|
8087
|
+
let resolvedPath = resolve$1(fileDescriptor.realPath, path$1);
|
|
8088
|
+
if ((flags & 1) === 1) try {
|
|
8089
|
+
resolvedPath = fs$1.readlinkSync(resolvedPath);
|
|
8090
|
+
} catch (err) {
|
|
8091
|
+
if (err.code !== "EINVAL" && err.code !== "ENOENT") throw err;
|
|
8092
|
+
}
|
|
8093
|
+
return resolvedPath;
|
|
8094
|
+
}
|
|
8095
|
+
async function resolvePathAsync(fs$1, fileDescriptor, path$1, flags) {
|
|
8096
|
+
let resolvedPath = resolve$1(fileDescriptor.realPath, path$1);
|
|
8097
|
+
if ((flags & 1) === 1) try {
|
|
8098
|
+
resolvedPath = await fs$1.promises.readlink(resolvedPath);
|
|
8099
|
+
} catch (err) {
|
|
8100
|
+
if (err.code !== "EINVAL" && err.code !== "ENOENT") throw err;
|
|
8101
|
+
}
|
|
8102
|
+
return resolvedPath;
|
|
8103
|
+
}
|
|
8104
|
+
const encoder = /* @__PURE__ */ new TextEncoder();
|
|
8105
|
+
const decoder = /* @__PURE__ */ new TextDecoder();
|
|
8106
|
+
const INT64_MAX = (BigInt(1) << BigInt(63)) - BigInt(1);
|
|
8107
|
+
function readStdin() {
|
|
8108
|
+
const value = window.prompt();
|
|
8109
|
+
if (value === null) return new Uint8Array();
|
|
8110
|
+
return new TextEncoder().encode(value + "\n");
|
|
8111
|
+
}
|
|
8112
|
+
function validateFstFlagsOrReturn(flags) {
|
|
8113
|
+
return Boolean(flags & -16) || (flags & 3) === 3 || (flags & 12) === 12;
|
|
8114
|
+
}
|
|
8115
|
+
var WASI$1 = class WASI$1 {
|
|
8116
|
+
constructor(args$1, env, fds, asyncFs, fs$1, asyncify) {
|
|
8117
|
+
this.args_get = syscallWrap(this, "args_get", function(argv, argv_buf) {
|
|
8118
|
+
argv = Number(argv);
|
|
8119
|
+
argv_buf = Number(argv_buf);
|
|
8120
|
+
if (argv === 0 || argv_buf === 0) return 28;
|
|
8121
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8122
|
+
const args$2 = _wasi.get(this).args;
|
|
8123
|
+
for (let i = 0; i < args$2.length; ++i) {
|
|
8124
|
+
const arg = args$2[i];
|
|
8125
|
+
view.setInt32(argv, argv_buf, true);
|
|
8126
|
+
argv += 4;
|
|
8127
|
+
const data = encoder.encode(arg + "\0");
|
|
8128
|
+
HEAPU8.set(data, argv_buf);
|
|
8129
|
+
argv_buf += data.length;
|
|
8130
|
+
}
|
|
8131
|
+
return 0;
|
|
8132
|
+
});
|
|
8133
|
+
this.args_sizes_get = syscallWrap(this, "args_sizes_get", function(argc, argv_buf_size) {
|
|
8134
|
+
argc = Number(argc);
|
|
8135
|
+
argv_buf_size = Number(argv_buf_size);
|
|
8136
|
+
if (argc === 0 || argv_buf_size === 0) return 28;
|
|
8137
|
+
const { view } = getMemory(this);
|
|
8138
|
+
const args$2 = _wasi.get(this).args;
|
|
8139
|
+
view.setUint32(argc, args$2.length, true);
|
|
8140
|
+
view.setUint32(argv_buf_size, encoder.encode(args$2.join("\0") + "\0").length, true);
|
|
8141
|
+
return 0;
|
|
8142
|
+
});
|
|
8143
|
+
this.environ_get = syscallWrap(this, "environ_get", function(environ, environ_buf) {
|
|
8144
|
+
environ = Number(environ);
|
|
8145
|
+
environ_buf = Number(environ_buf);
|
|
8146
|
+
if (environ === 0 || environ_buf === 0) return 28;
|
|
8147
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8148
|
+
const env$1 = _wasi.get(this).env;
|
|
8149
|
+
for (let i = 0; i < env$1.length; ++i) {
|
|
8150
|
+
const pair = env$1[i];
|
|
8151
|
+
view.setInt32(environ, environ_buf, true);
|
|
8152
|
+
environ += 4;
|
|
8153
|
+
const data = encoder.encode(pair + "\0");
|
|
8154
|
+
HEAPU8.set(data, environ_buf);
|
|
8155
|
+
environ_buf += data.length;
|
|
8156
|
+
}
|
|
8157
|
+
return 0;
|
|
8158
|
+
});
|
|
8159
|
+
this.environ_sizes_get = syscallWrap(this, "environ_sizes_get", function(len, buflen) {
|
|
8160
|
+
len = Number(len);
|
|
8161
|
+
buflen = Number(buflen);
|
|
8162
|
+
if (len === 0 || buflen === 0) return 28;
|
|
8163
|
+
const { view } = getMemory(this);
|
|
8164
|
+
const wasi = _wasi.get(this);
|
|
8165
|
+
view.setUint32(len, wasi.env.length, true);
|
|
8166
|
+
view.setUint32(buflen, encoder.encode(wasi.env.join("\0") + "\0").length, true);
|
|
8167
|
+
return 0;
|
|
8168
|
+
});
|
|
8169
|
+
this.clock_res_get = syscallWrap(this, "clock_res_get", function(id$1, resolution) {
|
|
8170
|
+
resolution = Number(resolution);
|
|
8171
|
+
if (resolution === 0) return 28;
|
|
8172
|
+
const { view } = getMemory(this);
|
|
8173
|
+
switch (id$1) {
|
|
8174
|
+
case 0:
|
|
8175
|
+
view.setBigUint64(resolution, BigInt(1e6), true);
|
|
8176
|
+
return 0;
|
|
8177
|
+
case 1:
|
|
8178
|
+
case 2:
|
|
8179
|
+
case 3:
|
|
8180
|
+
view.setBigUint64(resolution, BigInt(1e3), true);
|
|
8181
|
+
return 0;
|
|
8182
|
+
default: return 28;
|
|
8183
|
+
}
|
|
8184
|
+
});
|
|
8185
|
+
this.clock_time_get = syscallWrap(this, "clock_time_get", function(id$1, _percision, time) {
|
|
8186
|
+
time = Number(time);
|
|
8187
|
+
if (time === 0) return 28;
|
|
8188
|
+
const { view } = getMemory(this);
|
|
8189
|
+
switch (id$1) {
|
|
8190
|
+
case 0:
|
|
8191
|
+
view.setBigUint64(time, BigInt(Date.now()) * BigInt(1e6), true);
|
|
8192
|
+
return 0;
|
|
8193
|
+
case 1:
|
|
8194
|
+
case 2:
|
|
8195
|
+
case 3: {
|
|
8196
|
+
const t$2 = performance.now() / 1e3;
|
|
8197
|
+
const s = Math.trunc(t$2);
|
|
8198
|
+
const ms = Math.floor((t$2 - s) * 1e3);
|
|
8199
|
+
const result = BigInt(s) * BigInt(1e9) + BigInt(ms) * BigInt(1e6);
|
|
8200
|
+
view.setBigUint64(time, result, true);
|
|
8201
|
+
return 0;
|
|
8202
|
+
}
|
|
8203
|
+
default: return 28;
|
|
8204
|
+
}
|
|
8205
|
+
});
|
|
8206
|
+
this.fd_advise = syscallWrap(this, "fd_advise", function(_fd, _offset, _len, _advice) {
|
|
8207
|
+
return 52;
|
|
8208
|
+
});
|
|
8209
|
+
this.fd_fdstat_get = syscallWrap(this, "fd_fdstat_get", function(fd, fdstat) {
|
|
8210
|
+
fdstat = Number(fdstat);
|
|
8211
|
+
if (fdstat === 0) return 28;
|
|
8212
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, BigInt(0), BigInt(0));
|
|
8213
|
+
const { view } = getMemory(this);
|
|
8214
|
+
view.setUint16(fdstat, fileDescriptor.type, true);
|
|
8215
|
+
view.setUint16(fdstat + 2, 0, true);
|
|
8216
|
+
view.setBigUint64(fdstat + 8, fileDescriptor.rightsBase, true);
|
|
8217
|
+
view.setBigUint64(fdstat + 16, fileDescriptor.rightsInheriting, true);
|
|
8218
|
+
return 0;
|
|
8219
|
+
});
|
|
8220
|
+
this.fd_fdstat_set_flags = syscallWrap(this, "fd_fdstat_set_flags", function(_fd, _flags) {
|
|
8221
|
+
return 52;
|
|
8222
|
+
});
|
|
8223
|
+
this.fd_fdstat_set_rights = syscallWrap(this, "fd_fdstat_set_rights", function(fd, rightsBase, rightsInheriting) {
|
|
8224
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, BigInt(0), BigInt(0));
|
|
8225
|
+
if ((rightsBase | fileDescriptor.rightsBase) > fileDescriptor.rightsBase) return 76;
|
|
8226
|
+
if ((rightsInheriting | fileDescriptor.rightsInheriting) > fileDescriptor.rightsInheriting) return 76;
|
|
8227
|
+
fileDescriptor.rightsBase = rightsBase;
|
|
8228
|
+
fileDescriptor.rightsInheriting = rightsInheriting;
|
|
8229
|
+
return 0;
|
|
8230
|
+
});
|
|
8231
|
+
this.fd_prestat_get = syscallWrap(this, "fd_prestat_get", function(fd, prestat) {
|
|
8232
|
+
prestat = Number(prestat);
|
|
8233
|
+
if (prestat === 0) return 28;
|
|
8234
|
+
const wasi = _wasi.get(this);
|
|
8235
|
+
let fileDescriptor;
|
|
8236
|
+
try {
|
|
8237
|
+
fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
8238
|
+
} catch (err) {
|
|
8239
|
+
if (err instanceof WasiError) return err.errno;
|
|
8240
|
+
throw err;
|
|
8241
|
+
}
|
|
8242
|
+
if (fileDescriptor.preopen !== 1) return 28;
|
|
8243
|
+
const { view } = getMemory(this);
|
|
8244
|
+
view.setUint32(prestat, 0, true);
|
|
8245
|
+
view.setUint32(prestat + 4, encoder.encode(fileDescriptor.path).length, true);
|
|
8246
|
+
return 0;
|
|
8247
|
+
});
|
|
8248
|
+
this.fd_prestat_dir_name = syscallWrap(this, "fd_prestat_dir_name", function(fd, path$1, path_len) {
|
|
8249
|
+
path$1 = Number(path$1);
|
|
8250
|
+
path_len = Number(path_len);
|
|
8251
|
+
if (path$1 === 0) return 28;
|
|
8252
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, BigInt(0), BigInt(0));
|
|
8253
|
+
if (fileDescriptor.preopen !== 1) return 8;
|
|
8254
|
+
const buffer = encoder.encode(fileDescriptor.path);
|
|
8255
|
+
if (buffer.length > path_len) return 42;
|
|
8256
|
+
const { HEAPU8 } = getMemory(this);
|
|
8257
|
+
HEAPU8.set(buffer, path$1);
|
|
8258
|
+
return 0;
|
|
8259
|
+
});
|
|
8260
|
+
this.fd_seek = syscallWrap(this, "fd_seek", function(fd, offset, whence, newOffset) {
|
|
8261
|
+
newOffset = Number(newOffset);
|
|
8262
|
+
if (newOffset === 0) return 28;
|
|
8263
|
+
if (fd === 0 || fd === 1 || fd === 2) return 0;
|
|
8264
|
+
const r = _wasi.get(this).fds.get(fd, WasiRights.FD_SEEK, BigInt(0)).seek(offset, whence);
|
|
8265
|
+
const { view } = getMemory(this);
|
|
8266
|
+
view.setBigUint64(newOffset, r, true);
|
|
8267
|
+
return 0;
|
|
8268
|
+
});
|
|
8269
|
+
this.fd_tell = syscallWrap(this, "fd_tell", function(fd, offset) {
|
|
8270
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_TELL, BigInt(0));
|
|
8271
|
+
const pos = BigInt(fileDescriptor.pos);
|
|
8272
|
+
const { view } = getMemory(this);
|
|
8273
|
+
view.setBigUint64(Number(offset), pos, true);
|
|
8274
|
+
return 0;
|
|
8275
|
+
});
|
|
8276
|
+
this.poll_oneoff = syscallWrap(this, "poll_oneoff", function(in_ptr, out_ptr, nsubscriptions, nevents) {
|
|
8277
|
+
in_ptr = Number(in_ptr);
|
|
8278
|
+
out_ptr = Number(out_ptr);
|
|
8279
|
+
nevents = Number(nevents);
|
|
8280
|
+
nsubscriptions = Number(nsubscriptions);
|
|
8281
|
+
nsubscriptions = nsubscriptions >>> 0;
|
|
8282
|
+
if (in_ptr === 0 || out_ptr === 0 || nsubscriptions === 0 || nevents === 0) return 28;
|
|
8283
|
+
const { view } = getMemory(this);
|
|
8284
|
+
view.setUint32(nevents, 0, true);
|
|
8285
|
+
let i = 0;
|
|
8286
|
+
let timer_userdata = BigInt(0);
|
|
8287
|
+
let cur_timeout = BigInt(0);
|
|
8288
|
+
let has_timeout = 0;
|
|
8289
|
+
let min_timeout = BigInt(0);
|
|
8290
|
+
let sub;
|
|
8291
|
+
const subscriptions = Array(nsubscriptions);
|
|
8292
|
+
for (i = 0; i < nsubscriptions; i++) {
|
|
8293
|
+
sub = in_ptr + i * 48;
|
|
8294
|
+
const userdata = view.getBigUint64(sub, true);
|
|
8295
|
+
const type$1 = view.getUint8(sub + 8);
|
|
8296
|
+
const clockIdOrFd = view.getUint32(sub + 16, true);
|
|
8297
|
+
subscriptions[i] = {
|
|
8298
|
+
userdata,
|
|
8299
|
+
type: type$1,
|
|
8300
|
+
u: {
|
|
8301
|
+
clock: {
|
|
8302
|
+
clock_id: clockIdOrFd,
|
|
8303
|
+
timeout: view.getBigUint64(sub + 24, true),
|
|
8304
|
+
precision: view.getBigUint64(sub + 32, true),
|
|
8305
|
+
flags: view.getUint16(sub + 40, true)
|
|
8306
|
+
},
|
|
8307
|
+
fd_readwrite: { fd: clockIdOrFd }
|
|
8308
|
+
}
|
|
8309
|
+
};
|
|
8310
|
+
}
|
|
8311
|
+
const fdevents = [];
|
|
8312
|
+
for (i = 0; i < nsubscriptions; i++) {
|
|
8313
|
+
sub = subscriptions[i];
|
|
8314
|
+
switch (sub.type) {
|
|
8315
|
+
case 0:
|
|
8316
|
+
if (sub.u.clock.flags === 1) {
|
|
8317
|
+
const now = BigInt(Date.now()) * BigInt(1e6);
|
|
8318
|
+
cur_timeout = sub.u.clock.timeout - now;
|
|
8319
|
+
} else cur_timeout = sub.u.clock.timeout;
|
|
8320
|
+
if (has_timeout === 0 || cur_timeout < min_timeout) {
|
|
8321
|
+
min_timeout = cur_timeout;
|
|
8322
|
+
timer_userdata = sub.userdata;
|
|
8323
|
+
has_timeout = 1;
|
|
8324
|
+
}
|
|
8325
|
+
break;
|
|
8326
|
+
case 1:
|
|
8327
|
+
case 2:
|
|
8328
|
+
fdevents.push(sub);
|
|
8329
|
+
break;
|
|
8330
|
+
default: return 28;
|
|
8331
|
+
}
|
|
8332
|
+
}
|
|
8333
|
+
if (fdevents.length > 0) {
|
|
8334
|
+
for (i = 0; i < fdevents.length; i++) {
|
|
8335
|
+
const fdevent = fdevents[i];
|
|
8336
|
+
const event = out_ptr + 32 * i;
|
|
8337
|
+
view.setBigUint64(event, fdevent.userdata, true);
|
|
8338
|
+
view.setUint32(event + 8, 52, true);
|
|
8339
|
+
view.setUint32(event + 12, fdevent.type, true);
|
|
8340
|
+
view.setBigUint64(event + 16, BigInt(0), true);
|
|
8341
|
+
view.setUint16(event + 24, 0, true);
|
|
8342
|
+
view.setUint32(nevents, 1, true);
|
|
8343
|
+
}
|
|
8344
|
+
view.setUint32(nevents, fdevents.length, true);
|
|
8345
|
+
return 0;
|
|
8346
|
+
}
|
|
8347
|
+
if (has_timeout) {
|
|
8348
|
+
sleepBreakIf(Number(min_timeout / BigInt(1e6)), () => false);
|
|
8349
|
+
const event = out_ptr;
|
|
8350
|
+
view.setBigUint64(event, timer_userdata, true);
|
|
8351
|
+
view.setUint32(event + 8, 0, true);
|
|
8352
|
+
view.setUint32(event + 12, 0, true);
|
|
8353
|
+
view.setUint32(nevents, 1, true);
|
|
8354
|
+
}
|
|
8355
|
+
return 0;
|
|
8356
|
+
});
|
|
8357
|
+
this.proc_exit = syscallWrap(this, "proc_exit", function(rval) {
|
|
8358
|
+
if (typeof process === "object" && process !== null && typeof process.exit === "function") process.exit(rval);
|
|
8359
|
+
return 0;
|
|
8360
|
+
});
|
|
8361
|
+
this.proc_raise = syscallWrap(this, "proc_raise", function(_sig) {
|
|
8362
|
+
return 52;
|
|
8363
|
+
});
|
|
8364
|
+
this.sched_yield = syscallWrap(this, "sched_yield", function() {
|
|
8365
|
+
return 0;
|
|
8366
|
+
});
|
|
8367
|
+
this.random_get = typeof crypto !== "undefined" && typeof crypto.getRandomValues === "function" ? syscallWrap(this, "random_get", function(buf, buf_len) {
|
|
8368
|
+
buf = Number(buf);
|
|
8369
|
+
if (buf === 0) return 28;
|
|
8370
|
+
buf_len = Number(buf_len);
|
|
8371
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8372
|
+
if (typeof SharedArrayBuffer === "function" && HEAPU8.buffer instanceof SharedArrayBuffer || Object.prototype.toString.call(HEAPU8.buffer) === "[object SharedArrayBuffer]") {
|
|
8373
|
+
for (let i = buf; i < buf + buf_len; ++i) view.setUint8(i, Math.floor(Math.random() * 256));
|
|
8374
|
+
return 0;
|
|
8375
|
+
}
|
|
8376
|
+
let pos;
|
|
8377
|
+
const stride = 65536;
|
|
8378
|
+
for (pos = 0; pos + stride < buf_len; pos += stride) crypto.getRandomValues(HEAPU8.subarray(buf + pos, buf + pos + stride));
|
|
8379
|
+
crypto.getRandomValues(HEAPU8.subarray(buf + pos, buf + buf_len));
|
|
8380
|
+
return 0;
|
|
8381
|
+
}) : syscallWrap(this, "random_get", function(buf, buf_len) {
|
|
8382
|
+
buf = Number(buf);
|
|
8383
|
+
if (buf === 0) return 28;
|
|
8384
|
+
buf_len = Number(buf_len);
|
|
8385
|
+
const { view } = getMemory(this);
|
|
8386
|
+
for (let i = buf; i < buf + buf_len; ++i) view.setUint8(i, Math.floor(Math.random() * 256));
|
|
8387
|
+
return 0;
|
|
8388
|
+
});
|
|
8389
|
+
this.sock_recv = syscallWrap(this, "sock_recv", function() {
|
|
8390
|
+
return 58;
|
|
8391
|
+
});
|
|
8392
|
+
this.sock_send = syscallWrap(this, "sock_send", function() {
|
|
8393
|
+
return 58;
|
|
8394
|
+
});
|
|
8395
|
+
this.sock_shutdown = syscallWrap(this, "sock_shutdown", function() {
|
|
8396
|
+
return 58;
|
|
8397
|
+
});
|
|
8398
|
+
this.sock_accept = syscallWrap(this, "sock_accept", function() {
|
|
8399
|
+
return 58;
|
|
8400
|
+
});
|
|
8401
|
+
_wasi.set(this, {
|
|
8402
|
+
fds,
|
|
8403
|
+
args: args$1,
|
|
8404
|
+
env
|
|
8405
|
+
});
|
|
8406
|
+
if (fs$1) _fs.set(this, fs$1);
|
|
8407
|
+
const _this = this;
|
|
8408
|
+
function defineImport(name, syncVersion, asyncVersion, parameterType, returnType) {
|
|
8409
|
+
if (asyncFs) if (asyncify) _this[name] = asyncify.wrapImportFunction(syscallWrap(_this, name, asyncVersion));
|
|
8410
|
+
else _this[name] = wrapAsyncImport(syscallWrap(_this, name, asyncVersion), parameterType, returnType);
|
|
8411
|
+
else _this[name] = syscallWrap(_this, name, syncVersion);
|
|
8412
|
+
}
|
|
8413
|
+
defineImport("fd_allocate", function fd_allocate(fd, offset, len) {
|
|
8414
|
+
const wasi = _wasi.get(this);
|
|
8415
|
+
const fs$2 = getFs(this);
|
|
8416
|
+
const fileDescriptor = wasi.fds.get(fd, WasiRights.FD_ALLOCATE, BigInt(0));
|
|
8417
|
+
if (fs$2.fstatSync(fileDescriptor.fd, { bigint: true }).size < offset + len) fs$2.ftruncateSync(fileDescriptor.fd, Number(offset + len));
|
|
8418
|
+
return 0;
|
|
8419
|
+
}, async function fd_allocate(fd, offset, len) {
|
|
8420
|
+
const h = _wasi.get(this).fds.get(fd, WasiRights.FD_ALLOCATE, BigInt(0)).fd;
|
|
8421
|
+
if ((await h.stat({ bigint: true })).size < offset + len) await h.truncate(Number(offset + len));
|
|
8422
|
+
return 0;
|
|
8423
|
+
}, [
|
|
8424
|
+
"i32",
|
|
8425
|
+
"i64",
|
|
8426
|
+
"f64"
|
|
8427
|
+
], ["i32"]);
|
|
8428
|
+
defineImport("fd_close", function fd_close(fd) {
|
|
8429
|
+
const wasi = _wasi.get(this);
|
|
8430
|
+
const fileDescriptor = wasi.fds.get(fd, BigInt(0), BigInt(0));
|
|
8431
|
+
getFs(this).closeSync(fileDescriptor.fd);
|
|
8432
|
+
wasi.fds.remove(fd);
|
|
8433
|
+
return 0;
|
|
8434
|
+
}, async function fd_close(fd) {
|
|
8435
|
+
const wasi = _wasi.get(this);
|
|
8436
|
+
await wasi.fds.get(fd, BigInt(0), BigInt(0)).fd.close();
|
|
8437
|
+
wasi.fds.remove(fd);
|
|
8438
|
+
return 0;
|
|
8439
|
+
}, ["i32"], ["i32"]);
|
|
8440
|
+
defineImport("fd_datasync", function fd_datasync(fd) {
|
|
8441
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_DATASYNC, BigInt(0));
|
|
8442
|
+
getFs(this).fdatasyncSync(fileDescriptor.fd);
|
|
8443
|
+
return 0;
|
|
8444
|
+
}, async function fd_datasync(fd) {
|
|
8445
|
+
await _wasi.get(this).fds.get(fd, WasiRights.FD_DATASYNC, BigInt(0)).fd.datasync();
|
|
8446
|
+
return 0;
|
|
8447
|
+
}, ["i32"], ["i32"]);
|
|
8448
|
+
defineImport("fd_filestat_get", function fd_filestat_get(fd, buf) {
|
|
8449
|
+
buf = Number(buf);
|
|
8450
|
+
if (buf === 0) return 28;
|
|
8451
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_FILESTAT_GET, BigInt(0));
|
|
8452
|
+
const stat = getFs(this).fstatSync(fileDescriptor.fd, { bigint: true });
|
|
8453
|
+
const { view } = getMemory(this);
|
|
8454
|
+
toFileStat(view, buf, stat);
|
|
8455
|
+
return 0;
|
|
8456
|
+
}, async function fd_filestat_get(fd, buf) {
|
|
8457
|
+
buf = Number(buf);
|
|
8458
|
+
if (buf === 0) return 28;
|
|
8459
|
+
const stat = await _wasi.get(this).fds.get(fd, WasiRights.FD_FILESTAT_GET, BigInt(0)).fd.stat({ bigint: true });
|
|
8460
|
+
const { view } = getMemory(this);
|
|
8461
|
+
toFileStat(view, buf, stat);
|
|
8462
|
+
return 0;
|
|
8463
|
+
}, ["i32", "i32"], ["i32"]);
|
|
8464
|
+
defineImport("fd_filestat_set_size", function fd_filestat_set_size(fd, size) {
|
|
8465
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_FILESTAT_SET_SIZE, BigInt(0));
|
|
8466
|
+
getFs(this).ftruncateSync(fileDescriptor.fd, Number(size));
|
|
8467
|
+
return 0;
|
|
8468
|
+
}, async function fd_filestat_set_size(fd, size) {
|
|
8469
|
+
await _wasi.get(this).fds.get(fd, WasiRights.FD_FILESTAT_SET_SIZE, BigInt(0)).fd.truncate(Number(size));
|
|
8470
|
+
return 0;
|
|
8471
|
+
}, ["i32", "i64"], ["i32"]);
|
|
8472
|
+
function fdFilestatGetTimes(fd, atim, mtim, flags) {
|
|
8473
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_FILESTAT_SET_TIMES, BigInt(0));
|
|
8474
|
+
if ((flags & 2) === 2) atim = BigInt(Date.now() * 1e6);
|
|
8475
|
+
if ((flags & 8) === 8) mtim = BigInt(Date.now() * 1e6);
|
|
8476
|
+
return {
|
|
8477
|
+
fileDescriptor,
|
|
8478
|
+
atim,
|
|
8479
|
+
mtim
|
|
8480
|
+
};
|
|
8481
|
+
}
|
|
8482
|
+
defineImport("fd_filestat_set_times", function fd_filestat_set_times(fd, atim, mtim, flags) {
|
|
8483
|
+
if (validateFstFlagsOrReturn(flags)) return 28;
|
|
8484
|
+
const { fileDescriptor, atim: atimRes, mtim: mtimRes } = fdFilestatGetTimes.call(this, fd, atim, mtim, flags);
|
|
8485
|
+
getFs(this).futimesSync(fileDescriptor.fd, Number(atimRes), Number(mtimRes));
|
|
8486
|
+
return 0;
|
|
8487
|
+
}, async function fd_filestat_set_times(fd, atim, mtim, flags) {
|
|
8488
|
+
if (validateFstFlagsOrReturn(flags)) return 28;
|
|
8489
|
+
const { fileDescriptor, atim: atimRes, mtim: mtimRes } = fdFilestatGetTimes.call(this, fd, atim, mtim, flags);
|
|
8490
|
+
await fileDescriptor.fd.utimes(Number(atimRes), Number(mtimRes));
|
|
8491
|
+
return 0;
|
|
8492
|
+
}, [
|
|
8493
|
+
"i32",
|
|
8494
|
+
"i64",
|
|
8495
|
+
"i64",
|
|
8496
|
+
"i32"
|
|
8497
|
+
], ["i32"]);
|
|
8498
|
+
defineImport("fd_pread", function fd_pread(fd, iovs, iovslen, offset, size) {
|
|
8499
|
+
iovs = Number(iovs);
|
|
8500
|
+
size = Number(size);
|
|
8501
|
+
if (iovs === 0 && iovslen || size === 0 || offset > INT64_MAX) return 28;
|
|
8502
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8503
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READ | WasiRights.FD_SEEK, BigInt(0));
|
|
8504
|
+
if (!iovslen) {
|
|
8505
|
+
view.setUint32(size, 0, true);
|
|
8506
|
+
return 0;
|
|
8507
|
+
}
|
|
8508
|
+
let totalSize = 0;
|
|
8509
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8510
|
+
const offset$1 = iovs + i * 8;
|
|
8511
|
+
const buf = view.getInt32(offset$1, true);
|
|
8512
|
+
const bufLen = view.getUint32(offset$1 + 4, true);
|
|
8513
|
+
totalSize += bufLen;
|
|
8514
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8515
|
+
});
|
|
8516
|
+
let nread = 0;
|
|
8517
|
+
const buffer = (() => {
|
|
8518
|
+
try {
|
|
8519
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
8520
|
+
} catch (_) {
|
|
8521
|
+
return new Uint8Array(totalSize);
|
|
8522
|
+
}
|
|
8523
|
+
})();
|
|
8524
|
+
buffer._isBuffer = true;
|
|
8525
|
+
const bytesRead = getFs(this).readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
8526
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
8527
|
+
view.setUint32(size, nread, true);
|
|
8528
|
+
return 0;
|
|
8529
|
+
}, async function(fd, iovs, iovslen, offset, size) {
|
|
8530
|
+
iovs = Number(iovs);
|
|
8531
|
+
size = Number(size);
|
|
8532
|
+
if (iovs === 0 && iovslen || size === 0 || offset > INT64_MAX) return 28;
|
|
8533
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8534
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READ | WasiRights.FD_SEEK, BigInt(0));
|
|
8535
|
+
if (!iovslen) {
|
|
8536
|
+
view.setUint32(size, 0, true);
|
|
8537
|
+
return 0;
|
|
8538
|
+
}
|
|
8539
|
+
let totalSize = 0;
|
|
8540
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8541
|
+
const offset$1 = iovs + i * 8;
|
|
8542
|
+
const buf = view.getInt32(offset$1, true);
|
|
8543
|
+
const bufLen = view.getUint32(offset$1 + 4, true);
|
|
8544
|
+
totalSize += bufLen;
|
|
8545
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8546
|
+
});
|
|
8547
|
+
let nread = 0;
|
|
8548
|
+
const buffer = new Uint8Array(totalSize);
|
|
8549
|
+
buffer._isBuffer = true;
|
|
8550
|
+
const { bytesRead } = await fileDescriptor.fd.read(buffer, 0, buffer.length, Number(offset));
|
|
8551
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
8552
|
+
view.setUint32(size, nread, true);
|
|
8553
|
+
return 0;
|
|
8554
|
+
}, [
|
|
8555
|
+
"i32",
|
|
8556
|
+
"i32",
|
|
8557
|
+
"i32",
|
|
8558
|
+
"i64",
|
|
8559
|
+
"i32"
|
|
8560
|
+
], ["i32"]);
|
|
8561
|
+
defineImport("fd_pwrite", function fd_pwrite(fd, iovs, iovslen, offset, size) {
|
|
8562
|
+
iovs = Number(iovs);
|
|
8563
|
+
size = Number(size);
|
|
8564
|
+
if (iovs === 0 && iovslen || size === 0 || offset > INT64_MAX) return 28;
|
|
8565
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8566
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_WRITE | WasiRights.FD_SEEK, BigInt(0));
|
|
8567
|
+
if (!iovslen) {
|
|
8568
|
+
view.setUint32(size, 0, true);
|
|
8569
|
+
return 0;
|
|
8570
|
+
}
|
|
8571
|
+
const buffer = concatBuffer(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8572
|
+
const offset$1 = iovs + i * 8;
|
|
8573
|
+
const buf = view.getInt32(offset$1, true);
|
|
8574
|
+
const bufLen = view.getUint32(offset$1 + 4, true);
|
|
8575
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8576
|
+
}));
|
|
8577
|
+
const nwritten = getFs(this).writeSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(offset));
|
|
8578
|
+
view.setUint32(size, nwritten, true);
|
|
8579
|
+
return 0;
|
|
8580
|
+
}, async function fd_pwrite(fd, iovs, iovslen, offset, size) {
|
|
8581
|
+
iovs = Number(iovs);
|
|
8582
|
+
size = Number(size);
|
|
8583
|
+
if (iovs === 0 && iovslen || size === 0 || offset > INT64_MAX) return 28;
|
|
8584
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8585
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_WRITE | WasiRights.FD_SEEK, BigInt(0));
|
|
8586
|
+
if (!iovslen) {
|
|
8587
|
+
view.setUint32(size, 0, true);
|
|
8588
|
+
return 0;
|
|
8589
|
+
}
|
|
8590
|
+
const buffer = concatBuffer(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8591
|
+
const offset$1 = iovs + i * 8;
|
|
8592
|
+
const buf = view.getInt32(offset$1, true);
|
|
8593
|
+
const bufLen = view.getUint32(offset$1 + 4, true);
|
|
8594
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8595
|
+
}));
|
|
8596
|
+
const { bytesWritten } = await fileDescriptor.fd.write(buffer, 0, buffer.length, Number(offset));
|
|
8597
|
+
view.setUint32(size, bytesWritten, true);
|
|
8598
|
+
return 0;
|
|
8599
|
+
}, [
|
|
8600
|
+
"i32",
|
|
8601
|
+
"i32",
|
|
8602
|
+
"i32",
|
|
8603
|
+
"i64",
|
|
8604
|
+
"i32"
|
|
8605
|
+
], ["i32"]);
|
|
8606
|
+
defineImport("fd_read", function fd_read(fd, iovs, iovslen, size) {
|
|
8607
|
+
iovs = Number(iovs);
|
|
8608
|
+
size = Number(size);
|
|
8609
|
+
if (iovs === 0 && iovslen || size === 0) return 28;
|
|
8610
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8611
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READ, BigInt(0));
|
|
8612
|
+
if (!iovslen) {
|
|
8613
|
+
view.setUint32(size, 0, true);
|
|
8614
|
+
return 0;
|
|
8615
|
+
}
|
|
8616
|
+
let totalSize = 0;
|
|
8617
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8618
|
+
const offset = iovs + i * 8;
|
|
8619
|
+
const buf = view.getInt32(offset, true);
|
|
8620
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
8621
|
+
totalSize += bufLen;
|
|
8622
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8623
|
+
});
|
|
8624
|
+
let buffer;
|
|
8625
|
+
let nread = 0;
|
|
8626
|
+
if (fd === 0) {
|
|
8627
|
+
if (typeof window === "undefined" || typeof window.prompt !== "function") return 58;
|
|
8628
|
+
buffer = readStdin();
|
|
8629
|
+
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
8630
|
+
} else {
|
|
8631
|
+
buffer = (() => {
|
|
8632
|
+
try {
|
|
8633
|
+
return new Uint8Array(new SharedArrayBuffer(totalSize));
|
|
8634
|
+
} catch (_) {
|
|
8635
|
+
return new Uint8Array(totalSize);
|
|
8636
|
+
}
|
|
8637
|
+
})();
|
|
8638
|
+
buffer._isBuffer = true;
|
|
8639
|
+
const bytesRead = getFs(this).readSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
8640
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
8641
|
+
fileDescriptor.pos += BigInt(nread);
|
|
8642
|
+
}
|
|
8643
|
+
view.setUint32(size, nread, true);
|
|
8644
|
+
return 0;
|
|
8645
|
+
}, async function fd_read(fd, iovs, iovslen, size) {
|
|
8646
|
+
iovs = Number(iovs);
|
|
8647
|
+
size = Number(size);
|
|
8648
|
+
if (iovs === 0 && iovslen || size === 0) return 28;
|
|
8649
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8650
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READ, BigInt(0));
|
|
8651
|
+
if (!iovslen) {
|
|
8652
|
+
view.setUint32(size, 0, true);
|
|
8653
|
+
return 0;
|
|
8654
|
+
}
|
|
8655
|
+
let totalSize = 0;
|
|
8656
|
+
const ioVecs = Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8657
|
+
const offset = iovs + i * 8;
|
|
8658
|
+
const buf = view.getInt32(offset, true);
|
|
8659
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
8660
|
+
totalSize += bufLen;
|
|
8661
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8662
|
+
});
|
|
8663
|
+
let buffer;
|
|
8664
|
+
let nread = 0;
|
|
8665
|
+
if (fd === 0) {
|
|
8666
|
+
if (typeof window === "undefined" || typeof window.prompt !== "function") return 58;
|
|
8667
|
+
buffer = readStdin();
|
|
8668
|
+
nread = buffer ? copyMemory(ioVecs, buffer) : 0;
|
|
8669
|
+
} else {
|
|
8670
|
+
buffer = new Uint8Array(totalSize);
|
|
8671
|
+
buffer._isBuffer = true;
|
|
8672
|
+
const { bytesRead } = await fileDescriptor.fd.read(buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
8673
|
+
nread = buffer ? copyMemory(ioVecs, buffer.subarray(0, bytesRead)) : 0;
|
|
8674
|
+
fileDescriptor.pos += BigInt(nread);
|
|
8675
|
+
}
|
|
8676
|
+
view.setUint32(size, nread, true);
|
|
8677
|
+
return 0;
|
|
8678
|
+
}, [
|
|
8679
|
+
"i32",
|
|
8680
|
+
"i32",
|
|
8681
|
+
"i32",
|
|
8682
|
+
"i32"
|
|
8683
|
+
], ["i32"]);
|
|
8684
|
+
defineImport("fd_readdir", function fd_readdir(fd, buf, buf_len, cookie, bufused) {
|
|
8685
|
+
buf = Number(buf);
|
|
8686
|
+
buf_len = Number(buf_len);
|
|
8687
|
+
bufused = Number(bufused);
|
|
8688
|
+
if (buf === 0 || bufused === 0) return 0;
|
|
8689
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READDIR, BigInt(0));
|
|
8690
|
+
const fs$2 = getFs(this);
|
|
8691
|
+
const entries = fs$2.readdirSync(fileDescriptor.realPath, { withFileTypes: true });
|
|
8692
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8693
|
+
let bufferUsed = 0;
|
|
8694
|
+
for (let i = Number(cookie); i < entries.length; i++) {
|
|
8695
|
+
const nameData = encoder.encode(entries[i].name);
|
|
8696
|
+
const entryInfo = fs$2.statSync(resolve$1(fileDescriptor.realPath, entries[i].name), { bigint: true });
|
|
8697
|
+
const entryData = new Uint8Array(24 + nameData.byteLength);
|
|
8698
|
+
const entryView = new DataView(entryData.buffer);
|
|
8699
|
+
entryView.setBigUint64(0, BigInt(i + 1), true);
|
|
8700
|
+
entryView.setBigUint64(8, BigInt(entryInfo.ino ? entryInfo.ino : 0), true);
|
|
8701
|
+
entryView.setUint32(16, nameData.byteLength, true);
|
|
8702
|
+
let type$1;
|
|
8703
|
+
if (entries[i].isFile()) type$1 = 4;
|
|
8704
|
+
else if (entries[i].isDirectory()) type$1 = 3;
|
|
8705
|
+
else if (entries[i].isSymbolicLink()) type$1 = 7;
|
|
8706
|
+
else if (entries[i].isCharacterDevice()) type$1 = 2;
|
|
8707
|
+
else if (entries[i].isBlockDevice()) type$1 = 1;
|
|
8708
|
+
else if (entries[i].isSocket()) type$1 = 6;
|
|
8709
|
+
else type$1 = 0;
|
|
8710
|
+
entryView.setUint8(20, type$1);
|
|
8711
|
+
entryData.set(nameData, 24);
|
|
8712
|
+
const data = entryData.slice(0, Math.min(entryData.length, buf_len - bufferUsed));
|
|
8713
|
+
HEAPU8.set(data, buf + bufferUsed);
|
|
8714
|
+
bufferUsed += data.byteLength;
|
|
8715
|
+
}
|
|
8716
|
+
view.setUint32(bufused, bufferUsed, true);
|
|
8717
|
+
return 0;
|
|
8718
|
+
}, async function fd_readdir(fd, buf, buf_len, cookie, bufused) {
|
|
8719
|
+
buf = Number(buf);
|
|
8720
|
+
buf_len = Number(buf_len);
|
|
8721
|
+
bufused = Number(bufused);
|
|
8722
|
+
if (buf === 0 || bufused === 0) return 0;
|
|
8723
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_READDIR, BigInt(0));
|
|
8724
|
+
const fs$2 = getFs(this);
|
|
8725
|
+
const entries = await fs$2.promises.readdir(fileDescriptor.realPath, { withFileTypes: true });
|
|
8726
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8727
|
+
let bufferUsed = 0;
|
|
8728
|
+
for (let i = Number(cookie); i < entries.length; i++) {
|
|
8729
|
+
const nameData = encoder.encode(entries[i].name);
|
|
8730
|
+
const entryInfo = await fs$2.promises.stat(resolve$1(fileDescriptor.realPath, entries[i].name), { bigint: true });
|
|
8731
|
+
const entryData = new Uint8Array(24 + nameData.byteLength);
|
|
8732
|
+
const entryView = new DataView(entryData.buffer);
|
|
8733
|
+
entryView.setBigUint64(0, BigInt(i + 1), true);
|
|
8734
|
+
entryView.setBigUint64(8, BigInt(entryInfo.ino ? entryInfo.ino : 0), true);
|
|
8735
|
+
entryView.setUint32(16, nameData.byteLength, true);
|
|
8736
|
+
let type$1;
|
|
8737
|
+
if (entries[i].isFile()) type$1 = 4;
|
|
8738
|
+
else if (entries[i].isDirectory()) type$1 = 3;
|
|
8739
|
+
else if (entries[i].isSymbolicLink()) type$1 = 7;
|
|
8740
|
+
else if (entries[i].isCharacterDevice()) type$1 = 2;
|
|
8741
|
+
else if (entries[i].isBlockDevice()) type$1 = 1;
|
|
8742
|
+
else if (entries[i].isSocket()) type$1 = 6;
|
|
8743
|
+
else type$1 = 0;
|
|
8744
|
+
entryView.setUint8(20, type$1);
|
|
8745
|
+
entryData.set(nameData, 24);
|
|
8746
|
+
const data = entryData.slice(0, Math.min(entryData.length, buf_len - bufferUsed));
|
|
8747
|
+
HEAPU8.set(data, buf + bufferUsed);
|
|
8748
|
+
bufferUsed += data.byteLength;
|
|
8749
|
+
}
|
|
8750
|
+
view.setUint32(bufused, bufferUsed, true);
|
|
8751
|
+
return 0;
|
|
8752
|
+
}, [
|
|
8753
|
+
"i32",
|
|
8754
|
+
"i32",
|
|
8755
|
+
"i32",
|
|
8756
|
+
"i64",
|
|
8757
|
+
"i32"
|
|
8758
|
+
], ["i32"]);
|
|
8759
|
+
defineImport("fd_renumber", function fd_renumber(from$1, to) {
|
|
8760
|
+
_wasi.get(this).fds.renumber(to, from$1);
|
|
8761
|
+
return 0;
|
|
8762
|
+
}, async function fd_renumber(from$1, to) {
|
|
8763
|
+
await _wasi.get(this).fds.renumber(to, from$1);
|
|
8764
|
+
return 0;
|
|
8765
|
+
}, ["i32", "i32"], ["i32"]);
|
|
8766
|
+
defineImport("fd_sync", function fd_sync(fd) {
|
|
8767
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_SYNC, BigInt(0));
|
|
8768
|
+
getFs(this).fsyncSync(fileDescriptor.fd);
|
|
8769
|
+
return 0;
|
|
8770
|
+
}, async function fd_sync(fd) {
|
|
8771
|
+
await _wasi.get(this).fds.get(fd, WasiRights.FD_SYNC, BigInt(0)).fd.sync();
|
|
8772
|
+
return 0;
|
|
8773
|
+
}, ["i32"], ["i32"]);
|
|
8774
|
+
defineImport("fd_write", function fd_write(fd, iovs, iovslen, size) {
|
|
8775
|
+
iovs = Number(iovs);
|
|
8776
|
+
size = Number(size);
|
|
8777
|
+
if (iovs === 0 && iovslen || size === 0) return 28;
|
|
8778
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8779
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_WRITE, BigInt(0));
|
|
8780
|
+
if (!iovslen) {
|
|
8781
|
+
view.setUint32(size, 0, true);
|
|
8782
|
+
return 0;
|
|
8783
|
+
}
|
|
8784
|
+
const buffer = concatBuffer(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8785
|
+
const offset = iovs + i * 8;
|
|
8786
|
+
const buf = view.getInt32(offset, true);
|
|
8787
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
8788
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8789
|
+
}));
|
|
8790
|
+
let nwritten;
|
|
8791
|
+
if (fd === 1 || fd === 2) nwritten = fileDescriptor.write(buffer);
|
|
8792
|
+
else {
|
|
8793
|
+
nwritten = getFs(this).writeSync(fileDescriptor.fd, buffer, 0, buffer.length, Number(fileDescriptor.pos));
|
|
8794
|
+
fileDescriptor.pos += BigInt(nwritten);
|
|
8795
|
+
}
|
|
8796
|
+
view.setUint32(size, nwritten, true);
|
|
8797
|
+
return 0;
|
|
8798
|
+
}, async function fd_write(fd, iovs, iovslen, size) {
|
|
8799
|
+
iovs = Number(iovs);
|
|
8800
|
+
size = Number(size);
|
|
8801
|
+
if (iovs === 0 && iovslen || size === 0) return 28;
|
|
8802
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8803
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.FD_WRITE, BigInt(0));
|
|
8804
|
+
if (!iovslen) {
|
|
8805
|
+
view.setUint32(size, 0, true);
|
|
8806
|
+
return 0;
|
|
8807
|
+
}
|
|
8808
|
+
const buffer = concatBuffer(Array.from({ length: Number(iovslen) }, (_, i) => {
|
|
8809
|
+
const offset = iovs + i * 8;
|
|
8810
|
+
const buf = view.getInt32(offset, true);
|
|
8811
|
+
const bufLen = view.getUint32(offset + 4, true);
|
|
8812
|
+
return HEAPU8.subarray(buf, buf + bufLen);
|
|
8813
|
+
}));
|
|
8814
|
+
let nwritten;
|
|
8815
|
+
if (fd === 1 || fd === 2) nwritten = fileDescriptor.write(buffer);
|
|
8816
|
+
else {
|
|
8817
|
+
nwritten = await (await fileDescriptor.fd.write(buffer, 0, buffer.length, Number(fileDescriptor.pos))).bytesWritten;
|
|
8818
|
+
fileDescriptor.pos += BigInt(nwritten);
|
|
8819
|
+
}
|
|
8820
|
+
view.setUint32(size, nwritten, true);
|
|
8821
|
+
return 0;
|
|
8822
|
+
}, [
|
|
8823
|
+
"i32",
|
|
8824
|
+
"i32",
|
|
8825
|
+
"i32",
|
|
8826
|
+
"i32"
|
|
8827
|
+
], ["i32"]);
|
|
8828
|
+
defineImport("path_create_directory", function path_create_directory(fd, path$1, path_len) {
|
|
8829
|
+
path$1 = Number(path$1);
|
|
8830
|
+
path_len = Number(path_len);
|
|
8831
|
+
if (path$1 === 0) return 28;
|
|
8832
|
+
const { HEAPU8 } = getMemory(this);
|
|
8833
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
8834
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
8835
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
8836
|
+
getFs(this).mkdirSync(pathString);
|
|
8837
|
+
return 0;
|
|
8838
|
+
}, async function path_create_directory(fd, path$1, path_len) {
|
|
8839
|
+
path$1 = Number(path$1);
|
|
8840
|
+
path_len = Number(path_len);
|
|
8841
|
+
if (path$1 === 0) return 28;
|
|
8842
|
+
const { HEAPU8 } = getMemory(this);
|
|
8843
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_CREATE_DIRECTORY, BigInt(0));
|
|
8844
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
8845
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
8846
|
+
await getFs(this).promises.mkdir(pathString);
|
|
8847
|
+
return 0;
|
|
8848
|
+
}, [
|
|
8849
|
+
"i32",
|
|
8850
|
+
"i32",
|
|
8851
|
+
"i32"
|
|
8852
|
+
], ["i32"]);
|
|
8853
|
+
defineImport("path_filestat_get", function path_filestat_get(fd, flags, path$1, path_len, filestat) {
|
|
8854
|
+
path$1 = Number(path$1);
|
|
8855
|
+
path_len = Number(path_len);
|
|
8856
|
+
filestat = Number(filestat);
|
|
8857
|
+
if (path$1 === 0 || filestat === 0) return 28;
|
|
8858
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8859
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
8860
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
8861
|
+
const fs$2 = getFs(this);
|
|
8862
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
8863
|
+
let stat;
|
|
8864
|
+
if ((flags & 1) === 1) stat = fs$2.statSync(pathString, { bigint: true });
|
|
8865
|
+
else stat = fs$2.lstatSync(pathString, { bigint: true });
|
|
8866
|
+
toFileStat(view, filestat, stat);
|
|
8867
|
+
return 0;
|
|
8868
|
+
}, async function path_filestat_get(fd, flags, path$1, path_len, filestat) {
|
|
8869
|
+
path$1 = Number(path$1);
|
|
8870
|
+
path_len = Number(path_len);
|
|
8871
|
+
filestat = Number(filestat);
|
|
8872
|
+
if (path$1 === 0 || filestat === 0) return 28;
|
|
8873
|
+
const { HEAPU8, view } = getMemory(this);
|
|
8874
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_FILESTAT_GET, BigInt(0));
|
|
8875
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
8876
|
+
const fs$2 = getFs(this);
|
|
8877
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
8878
|
+
let stat;
|
|
8879
|
+
if ((flags & 1) === 1) stat = await fs$2.promises.stat(pathString, { bigint: true });
|
|
8880
|
+
else stat = await fs$2.promises.lstat(pathString, { bigint: true });
|
|
8881
|
+
toFileStat(view, filestat, stat);
|
|
8882
|
+
return 0;
|
|
8883
|
+
}, [
|
|
8884
|
+
"i32",
|
|
8885
|
+
"i32",
|
|
8886
|
+
"i32",
|
|
8887
|
+
"i32",
|
|
8888
|
+
"i32"
|
|
8889
|
+
], ["i32"]);
|
|
8890
|
+
defineImport("path_filestat_set_times", function path_filestat_set_times(fd, flags, path$1, path_len, atim, mtim, fst_flags) {
|
|
8891
|
+
path$1 = Number(path$1);
|
|
8892
|
+
path_len = Number(path_len);
|
|
8893
|
+
if (path$1 === 0) return 28;
|
|
8894
|
+
const { HEAPU8 } = getMemory(this);
|
|
8895
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
8896
|
+
if (validateFstFlagsOrReturn(fst_flags)) return 28;
|
|
8897
|
+
const fs$2 = getFs(this);
|
|
8898
|
+
const resolvedPath = resolvePathSync(fs$2, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len)), flags);
|
|
8899
|
+
if ((fst_flags & 2) === 2) atim = BigInt(Date.now() * 1e6);
|
|
8900
|
+
if ((fst_flags & 8) === 8) mtim = BigInt(Date.now() * 1e6);
|
|
8901
|
+
fs$2.utimesSync(resolvedPath, Number(atim), Number(mtim));
|
|
8902
|
+
return 0;
|
|
8903
|
+
}, async function path_filestat_set_times(fd, flags, path$1, path_len, atim, mtim, fst_flags) {
|
|
8904
|
+
path$1 = Number(path$1);
|
|
8905
|
+
path_len = Number(path_len);
|
|
8906
|
+
if (path$1 === 0) return 28;
|
|
8907
|
+
const { HEAPU8 } = getMemory(this);
|
|
8908
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_FILESTAT_SET_TIMES, BigInt(0));
|
|
8909
|
+
if (validateFstFlagsOrReturn(fst_flags)) return 28;
|
|
8910
|
+
const fs$2 = getFs(this);
|
|
8911
|
+
const resolvedPath = await resolvePathAsync(fs$2, fileDescriptor, decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len)), flags);
|
|
8912
|
+
if ((fst_flags & 2) === 2) atim = BigInt(Date.now() * 1e6);
|
|
8913
|
+
if ((fst_flags & 8) === 8) mtim = BigInt(Date.now() * 1e6);
|
|
8914
|
+
await fs$2.promises.utimes(resolvedPath, Number(atim), Number(mtim));
|
|
8915
|
+
return 0;
|
|
8916
|
+
}, [
|
|
8917
|
+
"i32",
|
|
8918
|
+
"i32",
|
|
8919
|
+
"i32",
|
|
8920
|
+
"i32",
|
|
8921
|
+
"i64",
|
|
8922
|
+
"i64",
|
|
8923
|
+
"i32"
|
|
8924
|
+
], ["i32"]);
|
|
8925
|
+
defineImport("path_link", function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
8926
|
+
old_path = Number(old_path);
|
|
8927
|
+
old_path_len = Number(old_path_len);
|
|
8928
|
+
new_path = Number(new_path);
|
|
8929
|
+
new_path_len = Number(new_path_len);
|
|
8930
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
8931
|
+
const wasi = _wasi.get(this);
|
|
8932
|
+
let oldWrap;
|
|
8933
|
+
let newWrap;
|
|
8934
|
+
if (old_fd === new_fd) oldWrap = newWrap = wasi.fds.get(old_fd, WasiRights.PATH_LINK_SOURCE | WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
8935
|
+
else {
|
|
8936
|
+
oldWrap = wasi.fds.get(old_fd, WasiRights.PATH_LINK_SOURCE, BigInt(0));
|
|
8937
|
+
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
8938
|
+
}
|
|
8939
|
+
const { HEAPU8 } = getMemory(this);
|
|
8940
|
+
const fs$2 = getFs(this);
|
|
8941
|
+
const resolvedOldPath = resolvePathSync(fs$2, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
8942
|
+
const resolvedNewPath = resolve$1(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
8943
|
+
fs$2.linkSync(resolvedOldPath, resolvedNewPath);
|
|
8944
|
+
return 0;
|
|
8945
|
+
}, async function path_link(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
8946
|
+
old_path = Number(old_path);
|
|
8947
|
+
old_path_len = Number(old_path_len);
|
|
8948
|
+
new_path = Number(new_path);
|
|
8949
|
+
new_path_len = Number(new_path_len);
|
|
8950
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
8951
|
+
const wasi = _wasi.get(this);
|
|
8952
|
+
let oldWrap;
|
|
8953
|
+
let newWrap;
|
|
8954
|
+
if (old_fd === new_fd) oldWrap = newWrap = wasi.fds.get(old_fd, WasiRights.PATH_LINK_SOURCE | WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
8955
|
+
else {
|
|
8956
|
+
oldWrap = wasi.fds.get(old_fd, WasiRights.PATH_LINK_SOURCE, BigInt(0));
|
|
8957
|
+
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_LINK_TARGET, BigInt(0));
|
|
8958
|
+
}
|
|
8959
|
+
const { HEAPU8 } = getMemory(this);
|
|
8960
|
+
const fs$2 = getFs(this);
|
|
8961
|
+
const resolvedOldPath = await resolvePathAsync(fs$2, oldWrap, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)), old_flags);
|
|
8962
|
+
const resolvedNewPath = resolve$1(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
8963
|
+
await fs$2.promises.link(resolvedOldPath, resolvedNewPath);
|
|
8964
|
+
return 0;
|
|
8965
|
+
}, [
|
|
8966
|
+
"i32",
|
|
8967
|
+
"i32",
|
|
8968
|
+
"i32",
|
|
8969
|
+
"i32",
|
|
8970
|
+
"i32",
|
|
8971
|
+
"i32",
|
|
8972
|
+
"i32"
|
|
8973
|
+
], ["i32"]);
|
|
8974
|
+
function pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags) {
|
|
8975
|
+
const read = (fs_rights_base & (WasiRights.FD_READ | WasiRights.FD_READDIR)) !== BigInt(0);
|
|
8976
|
+
const write = (fs_rights_base & (WasiRights.FD_DATASYNC | WasiRights.FD_WRITE | WasiRights.FD_ALLOCATE | WasiRights.FD_FILESTAT_SET_SIZE)) !== BigInt(0);
|
|
8977
|
+
let flags = write ? read ? 2 : 1 : 0;
|
|
8978
|
+
let needed_base = WasiRights.PATH_OPEN;
|
|
8979
|
+
let needed_inheriting = fs_rights_base | fs_rights_inheriting;
|
|
8980
|
+
if ((o_flags & 1) !== 0) {
|
|
8981
|
+
flags |= 64;
|
|
8982
|
+
needed_base |= WasiRights.PATH_CREATE_FILE;
|
|
8983
|
+
}
|
|
8984
|
+
if ((o_flags & 2) !== 0) flags |= 65536;
|
|
8985
|
+
if ((o_flags & 4) !== 0) flags |= 128;
|
|
8986
|
+
if ((o_flags & 8) !== 0) {
|
|
8987
|
+
flags |= 512;
|
|
8988
|
+
needed_base |= WasiRights.PATH_FILESTAT_SET_SIZE;
|
|
8989
|
+
}
|
|
8990
|
+
if ((fs_flags & 1) !== 0) flags |= 1024;
|
|
8991
|
+
if ((fs_flags & 2) !== 0) needed_inheriting |= WasiRights.FD_DATASYNC;
|
|
8992
|
+
if ((fs_flags & 4) !== 0) flags |= 2048;
|
|
8993
|
+
if ((fs_flags & 8) !== 0) {
|
|
8994
|
+
flags |= 1052672;
|
|
8995
|
+
needed_inheriting |= WasiRights.FD_SYNC;
|
|
8996
|
+
}
|
|
8997
|
+
if ((fs_flags & 16) !== 0) {
|
|
8998
|
+
flags |= 1052672;
|
|
8999
|
+
needed_inheriting |= WasiRights.FD_SYNC;
|
|
9000
|
+
}
|
|
9001
|
+
if (write && (flags & 1536) === 0) needed_inheriting |= WasiRights.FD_SEEK;
|
|
9002
|
+
return {
|
|
9003
|
+
flags,
|
|
9004
|
+
needed_base,
|
|
9005
|
+
needed_inheriting
|
|
9006
|
+
};
|
|
9007
|
+
}
|
|
9008
|
+
defineImport("path_open", function path_open(dirfd, dirflags, path$1, path_len, o_flags, fs_rights_base, fs_rights_inheriting, fs_flags, fd) {
|
|
9009
|
+
path$1 = Number(path$1);
|
|
9010
|
+
fd = Number(fd);
|
|
9011
|
+
if (path$1 === 0 || fd === 0) return 28;
|
|
9012
|
+
path_len = Number(path_len);
|
|
9013
|
+
fs_rights_base = BigInt(fs_rights_base);
|
|
9014
|
+
fs_rights_inheriting = BigInt(fs_rights_inheriting);
|
|
9015
|
+
const { flags: flagsRes, needed_base: neededBase, needed_inheriting: neededInheriting } = pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags);
|
|
9016
|
+
const wasi = _wasi.get(this);
|
|
9017
|
+
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
9018
|
+
const memory = getMemory(this);
|
|
9019
|
+
const HEAPU8 = memory.HEAPU8;
|
|
9020
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9021
|
+
const fs$2 = getFs(this);
|
|
9022
|
+
const resolved_path = resolvePathSync(fs$2, fileDescriptor, pathString, dirflags);
|
|
9023
|
+
const r = fs$2.openSync(resolved_path, flagsRes, 438);
|
|
9024
|
+
const filetype = wasi.fds.getFileTypeByFd(r);
|
|
9025
|
+
if (filetype !== 3 && ((o_flags & 2) !== 0 || resolved_path.endsWith("/"))) return 54;
|
|
9026
|
+
const { base: max_base, inheriting: max_inheriting } = getRights(wasi.fds.stdio, r, flagsRes, filetype);
|
|
9027
|
+
const wrap$3 = wasi.fds.insert(r, resolved_path, resolved_path, filetype, fs_rights_base & max_base, fs_rights_inheriting & max_inheriting, 0);
|
|
9028
|
+
const stat = fs$2.fstatSync(r, { bigint: true });
|
|
9029
|
+
if (stat.isFile()) {
|
|
9030
|
+
wrap$3.size = stat.size;
|
|
9031
|
+
if ((flagsRes & 1024) !== 0) wrap$3.pos = stat.size;
|
|
9032
|
+
}
|
|
9033
|
+
memory.view.setInt32(fd, wrap$3.id, true);
|
|
9034
|
+
return 0;
|
|
9035
|
+
}, async function path_open(dirfd, dirflags, path$1, path_len, o_flags, fs_rights_base, fs_rights_inheriting, fs_flags, fd) {
|
|
9036
|
+
path$1 = Number(path$1);
|
|
9037
|
+
fd = Number(fd);
|
|
9038
|
+
if (path$1 === 0 || fd === 0) return 28;
|
|
9039
|
+
path_len = Number(path_len);
|
|
9040
|
+
fs_rights_base = BigInt(fs_rights_base);
|
|
9041
|
+
fs_rights_inheriting = BigInt(fs_rights_inheriting);
|
|
9042
|
+
const { flags: flagsRes, needed_base: neededBase, needed_inheriting: neededInheriting } = pathOpen(o_flags, fs_rights_base, fs_rights_inheriting, fs_flags);
|
|
9043
|
+
const wasi = _wasi.get(this);
|
|
9044
|
+
const fileDescriptor = wasi.fds.get(dirfd, neededBase, neededInheriting);
|
|
9045
|
+
const memory = getMemory(this);
|
|
9046
|
+
const HEAPU8 = memory.HEAPU8;
|
|
9047
|
+
const pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9048
|
+
const fs$2 = getFs(this);
|
|
9049
|
+
const resolved_path = await resolvePathAsync(fs$2, fileDescriptor, pathString, dirflags);
|
|
9050
|
+
const r = await fs$2.promises.open(resolved_path, flagsRes, 438);
|
|
9051
|
+
const filetype = await wasi.fds.getFileTypeByFd(r);
|
|
9052
|
+
if ((o_flags & 2) !== 0 && filetype !== 3) return 54;
|
|
9053
|
+
const { base: max_base, inheriting: max_inheriting } = getRights(wasi.fds.stdio, r.fd, flagsRes, filetype);
|
|
9054
|
+
const wrap$3 = wasi.fds.insert(r, resolved_path, resolved_path, filetype, fs_rights_base & max_base, fs_rights_inheriting & max_inheriting, 0);
|
|
9055
|
+
const stat = await r.stat({ bigint: true });
|
|
9056
|
+
if (stat.isFile()) {
|
|
9057
|
+
wrap$3.size = stat.size;
|
|
9058
|
+
if ((flagsRes & 1024) !== 0) wrap$3.pos = stat.size;
|
|
9059
|
+
}
|
|
9060
|
+
memory.view.setInt32(fd, wrap$3.id, true);
|
|
9061
|
+
return 0;
|
|
9062
|
+
}, [
|
|
9063
|
+
"i32",
|
|
9064
|
+
"i32",
|
|
9065
|
+
"i32",
|
|
9066
|
+
"i32",
|
|
9067
|
+
"i32",
|
|
9068
|
+
"i64",
|
|
9069
|
+
"i64",
|
|
9070
|
+
"i32",
|
|
9071
|
+
"i32"
|
|
9072
|
+
], ["i32"]);
|
|
9073
|
+
defineImport("path_readlink", function path_readlink(fd, path$1, path_len, buf, buf_len, bufused) {
|
|
9074
|
+
path$1 = Number(path$1);
|
|
9075
|
+
path_len = Number(path_len);
|
|
9076
|
+
buf = Number(buf);
|
|
9077
|
+
buf_len = Number(buf_len);
|
|
9078
|
+
bufused = Number(bufused);
|
|
9079
|
+
if (path$1 === 0 || buf === 0 || bufused === 0) return 28;
|
|
9080
|
+
const { HEAPU8, view } = getMemory(this);
|
|
9081
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
9082
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9083
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9084
|
+
const link = getFs(this).readlinkSync(pathString);
|
|
9085
|
+
const linkData = encoder.encode(link);
|
|
9086
|
+
const len = Math.min(linkData.length, buf_len);
|
|
9087
|
+
if (len >= buf_len) return 42;
|
|
9088
|
+
HEAPU8.set(linkData.subarray(0, len), buf);
|
|
9089
|
+
HEAPU8[buf + len] = 0;
|
|
9090
|
+
view.setUint32(bufused, len, true);
|
|
9091
|
+
return 0;
|
|
9092
|
+
}, async function path_readlink(fd, path$1, path_len, buf, buf_len, bufused) {
|
|
9093
|
+
path$1 = Number(path$1);
|
|
9094
|
+
path_len = Number(path_len);
|
|
9095
|
+
buf = Number(buf);
|
|
9096
|
+
buf_len = Number(buf_len);
|
|
9097
|
+
bufused = Number(bufused);
|
|
9098
|
+
if (path$1 === 0 || buf === 0 || bufused === 0) return 28;
|
|
9099
|
+
const { HEAPU8, view } = getMemory(this);
|
|
9100
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_READLINK, BigInt(0));
|
|
9101
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9102
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9103
|
+
const link = await getFs(this).promises.readlink(pathString);
|
|
9104
|
+
const linkData = encoder.encode(link);
|
|
9105
|
+
const len = Math.min(linkData.length, buf_len);
|
|
9106
|
+
if (len >= buf_len) return 42;
|
|
9107
|
+
HEAPU8.set(linkData.subarray(0, len), buf);
|
|
9108
|
+
HEAPU8[buf + len] = 0;
|
|
9109
|
+
view.setUint32(bufused, len, true);
|
|
9110
|
+
return 0;
|
|
9111
|
+
}, [
|
|
9112
|
+
"i32",
|
|
9113
|
+
"i32",
|
|
9114
|
+
"i32",
|
|
9115
|
+
"i32",
|
|
9116
|
+
"i32",
|
|
9117
|
+
"i32"
|
|
9118
|
+
], ["i32"]);
|
|
9119
|
+
defineImport("path_remove_directory", function path_remove_directory(fd, path$1, path_len) {
|
|
9120
|
+
path$1 = Number(path$1);
|
|
9121
|
+
path_len = Number(path_len);
|
|
9122
|
+
if (path$1 === 0) return 28;
|
|
9123
|
+
const { HEAPU8 } = getMemory(this);
|
|
9124
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
9125
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9126
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9127
|
+
getFs(this).rmdirSync(pathString);
|
|
9128
|
+
return 0;
|
|
9129
|
+
}, async function path_remove_directory(fd, path$1, path_len) {
|
|
9130
|
+
path$1 = Number(path$1);
|
|
9131
|
+
path_len = Number(path_len);
|
|
9132
|
+
if (path$1 === 0) return 28;
|
|
9133
|
+
const { HEAPU8 } = getMemory(this);
|
|
9134
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_REMOVE_DIRECTORY, BigInt(0));
|
|
9135
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9136
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9137
|
+
await getFs(this).promises.rmdir(pathString);
|
|
9138
|
+
return 0;
|
|
9139
|
+
}, [
|
|
9140
|
+
"i32",
|
|
9141
|
+
"i32",
|
|
9142
|
+
"i32"
|
|
9143
|
+
], ["i32"]);
|
|
9144
|
+
defineImport("path_rename", function path_rename(old_fd, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
9145
|
+
old_path = Number(old_path);
|
|
9146
|
+
old_path_len = Number(old_path_len);
|
|
9147
|
+
new_path = Number(new_path);
|
|
9148
|
+
new_path_len = Number(new_path_len);
|
|
9149
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
9150
|
+
const wasi = _wasi.get(this);
|
|
9151
|
+
let oldWrap;
|
|
9152
|
+
let newWrap;
|
|
9153
|
+
if (old_fd === new_fd) oldWrap = newWrap = wasi.fds.get(old_fd, WasiRights.PATH_RENAME_SOURCE | WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
9154
|
+
else {
|
|
9155
|
+
oldWrap = wasi.fds.get(old_fd, WasiRights.PATH_RENAME_SOURCE, BigInt(0));
|
|
9156
|
+
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
9157
|
+
}
|
|
9158
|
+
const { HEAPU8 } = getMemory(this);
|
|
9159
|
+
const resolvedOldPath = resolve$1(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
9160
|
+
const resolvedNewPath = resolve$1(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
9161
|
+
getFs(this).renameSync(resolvedOldPath, resolvedNewPath);
|
|
9162
|
+
return 0;
|
|
9163
|
+
}, async function path_rename(old_fd, old_path, old_path_len, new_fd, new_path, new_path_len) {
|
|
9164
|
+
old_path = Number(old_path);
|
|
9165
|
+
old_path_len = Number(old_path_len);
|
|
9166
|
+
new_path = Number(new_path);
|
|
9167
|
+
new_path_len = Number(new_path_len);
|
|
9168
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
9169
|
+
const wasi = _wasi.get(this);
|
|
9170
|
+
let oldWrap;
|
|
9171
|
+
let newWrap;
|
|
9172
|
+
if (old_fd === new_fd) oldWrap = newWrap = wasi.fds.get(old_fd, WasiRights.PATH_RENAME_SOURCE | WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
9173
|
+
else {
|
|
9174
|
+
oldWrap = wasi.fds.get(old_fd, WasiRights.PATH_RENAME_SOURCE, BigInt(0));
|
|
9175
|
+
newWrap = wasi.fds.get(new_fd, WasiRights.PATH_RENAME_TARGET, BigInt(0));
|
|
9176
|
+
}
|
|
9177
|
+
const { HEAPU8 } = getMemory(this);
|
|
9178
|
+
const resolvedOldPath = resolve$1(oldWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len)));
|
|
9179
|
+
const resolvedNewPath = resolve$1(newWrap.realPath, decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len)));
|
|
9180
|
+
await getFs(this).promises.rename(resolvedOldPath, resolvedNewPath);
|
|
9181
|
+
return 0;
|
|
9182
|
+
}, [
|
|
9183
|
+
"i32",
|
|
9184
|
+
"i32",
|
|
9185
|
+
"i32",
|
|
9186
|
+
"i32",
|
|
9187
|
+
"i32",
|
|
9188
|
+
"i32"
|
|
9189
|
+
], ["i32"]);
|
|
9190
|
+
defineImport("path_symlink", function path_symlink(old_path, old_path_len, fd, new_path, new_path_len) {
|
|
9191
|
+
old_path = Number(old_path);
|
|
9192
|
+
old_path_len = Number(old_path_len);
|
|
9193
|
+
new_path = Number(new_path);
|
|
9194
|
+
new_path_len = Number(new_path_len);
|
|
9195
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
9196
|
+
const { HEAPU8 } = getMemory(this);
|
|
9197
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
9198
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
9199
|
+
if (oldPath.length > 0 && oldPath[0] === "/") return 63;
|
|
9200
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
9201
|
+
newPath = resolve$1(fileDescriptor.realPath, newPath);
|
|
9202
|
+
getFs(this).symlinkSync(oldPath, newPath);
|
|
9203
|
+
return 0;
|
|
9204
|
+
}, async function path_symlink(old_path, old_path_len, fd, new_path, new_path_len) {
|
|
9205
|
+
old_path = Number(old_path);
|
|
9206
|
+
old_path_len = Number(old_path_len);
|
|
9207
|
+
new_path = Number(new_path);
|
|
9208
|
+
new_path_len = Number(new_path_len);
|
|
9209
|
+
if (old_path === 0 || new_path === 0) return 28;
|
|
9210
|
+
const { HEAPU8 } = getMemory(this);
|
|
9211
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_SYMLINK, BigInt(0));
|
|
9212
|
+
const oldPath = decoder.decode(unsharedSlice(HEAPU8, old_path, old_path + old_path_len));
|
|
9213
|
+
let newPath = decoder.decode(unsharedSlice(HEAPU8, new_path, new_path + new_path_len));
|
|
9214
|
+
newPath = resolve$1(fileDescriptor.realPath, newPath);
|
|
9215
|
+
await getFs(this).promises.symlink(oldPath, newPath);
|
|
9216
|
+
return 0;
|
|
9217
|
+
}, [
|
|
9218
|
+
"i32",
|
|
9219
|
+
"i32",
|
|
9220
|
+
"i32",
|
|
9221
|
+
"i32",
|
|
9222
|
+
"i32"
|
|
9223
|
+
], ["i32"]);
|
|
9224
|
+
defineImport("path_unlink_file", function path_unlink_file(fd, path$1, path_len) {
|
|
9225
|
+
path$1 = Number(path$1);
|
|
9226
|
+
path_len = Number(path_len);
|
|
9227
|
+
if (path$1 === 0) return 28;
|
|
9228
|
+
const { HEAPU8 } = getMemory(this);
|
|
9229
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
9230
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9231
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9232
|
+
getFs(this).unlinkSync(pathString);
|
|
9233
|
+
return 0;
|
|
9234
|
+
}, async function path_unlink_file(fd, path$1, path_len) {
|
|
9235
|
+
path$1 = Number(path$1);
|
|
9236
|
+
path_len = Number(path_len);
|
|
9237
|
+
if (path$1 === 0) return 28;
|
|
9238
|
+
const { HEAPU8 } = getMemory(this);
|
|
9239
|
+
const fileDescriptor = _wasi.get(this).fds.get(fd, WasiRights.PATH_UNLINK_FILE, BigInt(0));
|
|
9240
|
+
let pathString = decoder.decode(unsharedSlice(HEAPU8, path$1, path$1 + path_len));
|
|
9241
|
+
pathString = resolve$1(fileDescriptor.realPath, pathString);
|
|
9242
|
+
await getFs(this).promises.unlink(pathString);
|
|
9243
|
+
return 0;
|
|
9244
|
+
}, [
|
|
9245
|
+
"i32",
|
|
9246
|
+
"i32",
|
|
9247
|
+
"i32"
|
|
9248
|
+
], ["i32"]);
|
|
9249
|
+
this._setMemory = function setMemory(m) {
|
|
9250
|
+
if (!(m instanceof _WebAssembly.Memory)) throw new TypeError("\"instance.exports.memory\" property must be a WebAssembly.Memory");
|
|
9251
|
+
_memory.set(_this, extendMemory(m));
|
|
9252
|
+
};
|
|
9253
|
+
}
|
|
9254
|
+
static createSync(args$1, env, preopens, stdio, fs$1, print$1, printErr) {
|
|
9255
|
+
const fds = new SyncTable({
|
|
9256
|
+
size: 3,
|
|
9257
|
+
in: stdio[0],
|
|
9258
|
+
out: stdio[1],
|
|
9259
|
+
err: stdio[2],
|
|
9260
|
+
fs: fs$1,
|
|
9261
|
+
print: print$1,
|
|
9262
|
+
printErr
|
|
9263
|
+
});
|
|
9264
|
+
const _this = new WASI$1(args$1, env, fds, false, fs$1);
|
|
9265
|
+
if (preopens.length > 0) for (let i = 0; i < preopens.length; ++i) {
|
|
9266
|
+
const realPath = fs$1.realpathSync(preopens[i].realPath, "utf8");
|
|
9267
|
+
const fd = fs$1.openSync(realPath, "r", 438);
|
|
9268
|
+
fds.insertPreopen(fd, preopens[i].mappedPath, realPath);
|
|
9269
|
+
}
|
|
9270
|
+
return _this;
|
|
9271
|
+
}
|
|
9272
|
+
static async createAsync(args$1, env, preopens, stdio, fs$1, print$1, printErr, asyncify) {
|
|
9273
|
+
const fds = new AsyncTable({
|
|
9274
|
+
size: 3,
|
|
9275
|
+
in: stdio[0],
|
|
9276
|
+
out: stdio[1],
|
|
9277
|
+
err: stdio[2],
|
|
9278
|
+
print: print$1,
|
|
9279
|
+
printErr
|
|
9280
|
+
});
|
|
9281
|
+
const _this = new WASI$1(args$1, env, fds, true, fs$1, asyncify);
|
|
9282
|
+
if (preopens.length > 0) for (let i = 0; i < preopens.length; ++i) {
|
|
9283
|
+
const entry = preopens[i];
|
|
9284
|
+
const realPath = await fs$1.promises.realpath(entry.realPath);
|
|
9285
|
+
const fd = await fs$1.promises.open(realPath, "r", 438);
|
|
9286
|
+
await fds.insertPreopen(fd, entry.mappedPath, realPath);
|
|
9287
|
+
}
|
|
9288
|
+
return _this;
|
|
9289
|
+
}
|
|
9290
|
+
};
|
|
9291
|
+
const kEmptyObject = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
|
|
9292
|
+
const kExitCode = Symbol("kExitCode");
|
|
9293
|
+
const kSetMemory = Symbol("kSetMemory");
|
|
9294
|
+
const kStarted = Symbol("kStarted");
|
|
9295
|
+
const kInstance = Symbol("kInstance");
|
|
9296
|
+
const kBindingName = Symbol("kBindingName");
|
|
9297
|
+
function validateOptions(options$1) {
|
|
9298
|
+
var _a;
|
|
9299
|
+
validateObject(options$1, "options");
|
|
9300
|
+
let _WASI;
|
|
9301
|
+
if (options$1.version !== void 0) {
|
|
9302
|
+
validateString(options$1.version, "options.version");
|
|
9303
|
+
switch (options$1.version) {
|
|
9304
|
+
case "unstable":
|
|
9305
|
+
_WASI = WASI$1;
|
|
9306
|
+
this[kBindingName] = "wasi_unstable";
|
|
9307
|
+
break;
|
|
9308
|
+
case "preview1":
|
|
9309
|
+
_WASI = WASI$1;
|
|
9310
|
+
this[kBindingName] = "wasi_snapshot_preview1";
|
|
9311
|
+
break;
|
|
9312
|
+
default: throw new TypeError(`unsupported WASI version "${options$1.version}"`);
|
|
9313
|
+
}
|
|
9314
|
+
} else {
|
|
9315
|
+
_WASI = WASI$1;
|
|
9316
|
+
this[kBindingName] = "wasi_snapshot_preview1";
|
|
9317
|
+
}
|
|
9318
|
+
if (options$1.args !== void 0) validateArray(options$1.args, "options.args");
|
|
9319
|
+
const args$1 = ((_a = options$1.args) !== null && _a !== void 0 ? _a : []).map(String);
|
|
9320
|
+
const env = [];
|
|
9321
|
+
if (options$1.env !== void 0) {
|
|
9322
|
+
validateObject(options$1.env, "options.env");
|
|
9323
|
+
Object.entries(options$1.env).forEach(({ 0: key, 1: value }) => {
|
|
9324
|
+
if (value !== void 0) env.push(`${key}=${value}`);
|
|
9325
|
+
});
|
|
9326
|
+
}
|
|
9327
|
+
const preopens = [];
|
|
9328
|
+
if (options$1.preopens !== void 0) {
|
|
9329
|
+
validateObject(options$1.preopens, "options.preopens");
|
|
9330
|
+
Object.entries(options$1.preopens).forEach(({ 0: key, 1: value }) => preopens.push({
|
|
9331
|
+
mappedPath: String(key),
|
|
9332
|
+
realPath: String(value)
|
|
9333
|
+
}));
|
|
9334
|
+
}
|
|
9335
|
+
if (preopens.length > 0) {
|
|
9336
|
+
if (options$1.fs === void 0) throw new Error("filesystem is disabled, can not preopen directory");
|
|
9337
|
+
try {
|
|
9338
|
+
validateObject(options$1.fs, "options.fs");
|
|
9339
|
+
} catch (_) {
|
|
9340
|
+
throw new TypeError("Node.js fs like implementation is not provided");
|
|
9341
|
+
}
|
|
9342
|
+
}
|
|
9343
|
+
if (options$1.print !== void 0) validateFunction(options$1.print, "options.print");
|
|
9344
|
+
if (options$1.printErr !== void 0) validateFunction(options$1.printErr, "options.printErr");
|
|
9345
|
+
if (options$1.returnOnExit !== void 0) validateBoolean(options$1.returnOnExit, "options.returnOnExit");
|
|
9346
|
+
return {
|
|
9347
|
+
args: args$1,
|
|
9348
|
+
env,
|
|
9349
|
+
preopens,
|
|
9350
|
+
stdio: [
|
|
9351
|
+
0,
|
|
9352
|
+
1,
|
|
9353
|
+
2
|
|
9354
|
+
],
|
|
9355
|
+
_WASI
|
|
9356
|
+
};
|
|
9357
|
+
}
|
|
9358
|
+
function initWASI(setMemory, wrap$3) {
|
|
9359
|
+
this[kSetMemory] = setMemory;
|
|
9360
|
+
this.wasiImport = wrap$3;
|
|
9361
|
+
this[kStarted] = false;
|
|
9362
|
+
this[kExitCode] = 0;
|
|
9363
|
+
this[kInstance] = void 0;
|
|
9364
|
+
}
|
|
9365
|
+
/** @public */
|
|
9366
|
+
var WASI = class {
|
|
9367
|
+
constructor(options$1 = kEmptyObject) {
|
|
9368
|
+
const { args: args$1, env, preopens, stdio, _WASI } = validateOptions.call(this, options$1);
|
|
9369
|
+
const wrap$3 = _WASI.createSync(args$1, env, preopens, stdio, options$1.fs, options$1.print, options$1.printErr);
|
|
9370
|
+
const setMemory = wrap$3._setMemory;
|
|
9371
|
+
delete wrap$3._setMemory;
|
|
9372
|
+
initWASI.call(this, setMemory, wrap$3);
|
|
9373
|
+
if (options$1.returnOnExit) wrap$3.proc_exit = wasiReturnOnProcExit.bind(this);
|
|
9374
|
+
}
|
|
9375
|
+
finalizeBindings(instance$1, _a) {
|
|
9376
|
+
var _b;
|
|
9377
|
+
var { memory = (_b = instance$1 === null || instance$1 === void 0 ? void 0 : instance$1.exports) === null || _b === void 0 ? void 0 : _b.memory } = _a === void 0 ? {} : _a;
|
|
9378
|
+
if (this[kStarted]) throw new Error("WASI instance has already started");
|
|
9379
|
+
validateObject(instance$1, "instance");
|
|
9380
|
+
validateObject(instance$1.exports, "instance.exports");
|
|
9381
|
+
this[kSetMemory](memory);
|
|
9382
|
+
this[kInstance] = instance$1;
|
|
9383
|
+
this[kStarted] = true;
|
|
9384
|
+
}
|
|
9385
|
+
start(instance$1) {
|
|
9386
|
+
this.finalizeBindings(instance$1);
|
|
9387
|
+
const { _start, _initialize } = this[kInstance].exports;
|
|
9388
|
+
validateFunction(_start, "instance.exports._start");
|
|
9389
|
+
validateUndefined(_initialize, "instance.exports._initialize");
|
|
9390
|
+
let ret;
|
|
9391
|
+
try {
|
|
9392
|
+
ret = _start();
|
|
9393
|
+
} catch (err) {
|
|
9394
|
+
if (err !== kExitCode) throw err;
|
|
9395
|
+
}
|
|
9396
|
+
if (ret instanceof Promise) return ret.then(() => this[kExitCode], (err) => {
|
|
9397
|
+
if (err !== kExitCode) throw err;
|
|
9398
|
+
return this[kExitCode];
|
|
9399
|
+
});
|
|
9400
|
+
return this[kExitCode];
|
|
9401
|
+
}
|
|
9402
|
+
initialize(instance$1) {
|
|
9403
|
+
this.finalizeBindings(instance$1);
|
|
9404
|
+
const { _start, _initialize } = this[kInstance].exports;
|
|
9405
|
+
validateUndefined(_start, "instance.exports._start");
|
|
9406
|
+
if (_initialize !== void 0) {
|
|
9407
|
+
validateFunction(_initialize, "instance.exports._initialize");
|
|
9408
|
+
return _initialize();
|
|
9409
|
+
}
|
|
9410
|
+
}
|
|
9411
|
+
getImportObject() {
|
|
9412
|
+
return { [this[kBindingName]]: this.wasiImport };
|
|
9413
|
+
}
|
|
9414
|
+
};
|
|
9415
|
+
function wasiReturnOnProcExit(rval) {
|
|
9416
|
+
this[kExitCode] = rval;
|
|
9417
|
+
throw kExitCode;
|
|
9418
|
+
}
|
|
9419
|
+
|
|
9420
|
+
//#endregion
|
|
9421
|
+
//#region ../../node_modules/.pnpm/@napi-rs+wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/fs-proxy.js
|
|
9422
|
+
/**
|
|
9423
|
+
* @param {unknown} value
|
|
9424
|
+
*/
|
|
9425
|
+
const getType = (value) => {
|
|
9426
|
+
if (value === void 0) return 0;
|
|
9427
|
+
if (value === null) return 1;
|
|
9428
|
+
const t$2 = typeof value;
|
|
9429
|
+
if (t$2 === "boolean") return 2;
|
|
9430
|
+
if (t$2 === "number") return 3;
|
|
9431
|
+
if (t$2 === "string") return 4;
|
|
9432
|
+
if (t$2 === "object") return 6;
|
|
9433
|
+
if (t$2 === "bigint") return 9;
|
|
9434
|
+
return -1;
|
|
9435
|
+
};
|
|
9436
|
+
/**
|
|
9437
|
+
* @param {import('memfs').IFs} memfs
|
|
9438
|
+
* @param {any} value
|
|
6972
9439
|
* @param {ReturnType<typeof getType>} type
|
|
6973
9440
|
* @returns {Uint8Array}
|
|
6974
9441
|
*/
|
|
@@ -7024,66 +9491,6 @@ const encodeValue = (memfs$1, value, type$1) => {
|
|
|
7024
9491
|
}
|
|
7025
9492
|
};
|
|
7026
9493
|
/**
|
|
7027
|
-
* @param {typeof import('memfs')} memfs
|
|
7028
|
-
* @param {Uint8Array} payload
|
|
7029
|
-
* @param {number} type
|
|
7030
|
-
* @returns {any}
|
|
7031
|
-
*/
|
|
7032
|
-
const decodeValue = (memfs$1, payload, type$1) => {
|
|
7033
|
-
if (type$1 === 0) return void 0;
|
|
7034
|
-
if (type$1 === 1) return null;
|
|
7035
|
-
if (type$1 === 2) return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0]);
|
|
7036
|
-
if (type$1 === 3) return new Float64Array(payload.buffer, payload.byteOffset, 1)[0];
|
|
7037
|
-
if (type$1 === 4) return new TextDecoder().decode(payload.slice());
|
|
7038
|
-
if (type$1 === 6) {
|
|
7039
|
-
const obj = JSON.parse(new TextDecoder().decode(payload.slice()), (_key, value) => {
|
|
7040
|
-
if (typeof value === "string") {
|
|
7041
|
-
const matched = value.match(/^BigInt\((-?\d+)\)$/);
|
|
7042
|
-
if (matched && matched[1]) return BigInt(matched[1]);
|
|
7043
|
-
}
|
|
7044
|
-
return value;
|
|
7045
|
-
});
|
|
7046
|
-
function loadConstructor(obj$1, memfs$2, processed = /* @__PURE__ */ new WeakSet()) {
|
|
7047
|
-
if (!obj$1 || typeof obj$1 !== "object") return;
|
|
7048
|
-
if (processed.has(obj$1)) return;
|
|
7049
|
-
processed.add(obj$1);
|
|
7050
|
-
if (obj$1.__constructor__) {
|
|
7051
|
-
const ctor = obj$1.__constructor__;
|
|
7052
|
-
delete obj$1.__constructor__;
|
|
7053
|
-
Object.setPrototypeOf(obj$1, memfs$2[ctor].prototype);
|
|
7054
|
-
}
|
|
7055
|
-
for (const value of Object.values(obj$1)) loadConstructor(value, memfs$2, processed);
|
|
7056
|
-
}
|
|
7057
|
-
loadConstructor(obj, memfs$1);
|
|
7058
|
-
if (obj.__error__) {
|
|
7059
|
-
const name = obj.__error__;
|
|
7060
|
-
const ErrorConstructor = globalThis[name] || Error;
|
|
7061
|
-
delete obj.__error__;
|
|
7062
|
-
const err = new ErrorConstructor(obj.message);
|
|
7063
|
-
Object.defineProperty(err, "stack", {
|
|
7064
|
-
configurable: true,
|
|
7065
|
-
enumerable: false,
|
|
7066
|
-
writable: true,
|
|
7067
|
-
value: err.stack
|
|
7068
|
-
});
|
|
7069
|
-
Object.defineProperty(err, Symbol.toStringTag, {
|
|
7070
|
-
configurable: true,
|
|
7071
|
-
enumerable: false,
|
|
7072
|
-
writable: true,
|
|
7073
|
-
value: name
|
|
7074
|
-
});
|
|
7075
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
7076
|
-
if (k === "message" || k === "stack") continue;
|
|
7077
|
-
err[k] = v;
|
|
7078
|
-
}
|
|
7079
|
-
return err;
|
|
7080
|
-
}
|
|
7081
|
-
return obj;
|
|
7082
|
-
}
|
|
7083
|
-
if (type$1 === 9) return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0];
|
|
7084
|
-
throw new Error("unsupported data");
|
|
7085
|
-
};
|
|
7086
|
-
/**
|
|
7087
9494
|
* @param {import('memfs').IFs} fs
|
|
7088
9495
|
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
|
|
7089
9496
|
*/
|
|
@@ -7117,44 +9524,6 @@ const createOnMessage = (fs$1) => function onMessage(e$1) {
|
|
|
7117
9524
|
}
|
|
7118
9525
|
}
|
|
7119
9526
|
};
|
|
7120
|
-
/**
|
|
7121
|
-
* @param {typeof import('memfs')} memfs
|
|
7122
|
-
*/
|
|
7123
|
-
const createFsProxy = (memfs$1) => new Proxy({}, { get(_target, p, _receiver) {
|
|
7124
|
-
/**
|
|
7125
|
-
* @param {any[]} args
|
|
7126
|
-
*/
|
|
7127
|
-
return function(...args$1) {
|
|
7128
|
-
const sab = new SharedArrayBuffer(10256);
|
|
7129
|
-
const i32arr = new Int32Array(sab);
|
|
7130
|
-
Atomics.store(i32arr, 0, 21);
|
|
7131
|
-
postMessage({ __fs__: {
|
|
7132
|
-
sab: i32arr,
|
|
7133
|
-
type: p,
|
|
7134
|
-
payload: args$1
|
|
7135
|
-
} });
|
|
7136
|
-
Atomics.wait(i32arr, 0, 21);
|
|
7137
|
-
const status = Atomics.load(i32arr, 0);
|
|
7138
|
-
const type$1 = Atomics.load(i32arr, 1);
|
|
7139
|
-
const size = Atomics.load(i32arr, 2);
|
|
7140
|
-
const value = decodeValue(memfs$1, new Uint8Array(sab, 16, size), type$1);
|
|
7141
|
-
if (status === 1) throw value;
|
|
7142
|
-
return value;
|
|
7143
|
-
};
|
|
7144
|
-
} });
|
|
7145
|
-
|
|
7146
|
-
//#endregion
|
|
7147
|
-
//#region ../../node_modules/.pnpm/@napi-rs+wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/runtime.js
|
|
7148
|
-
var runtime_exports = /* @__PURE__ */ __exportAll({
|
|
7149
|
-
MessageHandler: () => MessageHandler,
|
|
7150
|
-
createFsProxy: () => createFsProxy,
|
|
7151
|
-
createOnMessage: () => createOnMessage,
|
|
7152
|
-
getDefaultContext: () => getDefaultContext,
|
|
7153
|
-
instantiateNapiModule: () => instantiateNapiModule,
|
|
7154
|
-
instantiateNapiModuleSync: () => instantiateNapiModuleSync
|
|
7155
|
-
});
|
|
7156
|
-
import * as import__tybys_wasm_util from "@tybys/wasm-util";
|
|
7157
|
-
__reExport(runtime_exports, import__tybys_wasm_util);
|
|
7158
9527
|
|
|
7159
9528
|
//#endregion
|
|
7160
9529
|
//#region ../../node_modules/.pnpm/@napi-rs+wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/dist/fs.js
|
|
@@ -8867,10 +11236,10 @@ function requireUtil$4() {
|
|
|
8867
11236
|
function promisify(fn) {
|
|
8868
11237
|
if (typeof fn !== "function") throw new TypeError("The \"original\" argument must be of type function");
|
|
8869
11238
|
return function(...args$1) {
|
|
8870
|
-
return new Promise((resolve$
|
|
11239
|
+
return new Promise((resolve$2, reject) => {
|
|
8871
11240
|
fn.call(this, ...args$1, (err, result) => {
|
|
8872
11241
|
if (err) reject(err);
|
|
8873
|
-
else resolve$
|
|
11242
|
+
else resolve$2(result);
|
|
8874
11243
|
});
|
|
8875
11244
|
});
|
|
8876
11245
|
};
|
|
@@ -9270,7 +11639,7 @@ function requirePathBrowserify() {
|
|
|
9270
11639
|
return dir + sep$1 + base;
|
|
9271
11640
|
}
|
|
9272
11641
|
var posix$1 = {
|
|
9273
|
-
resolve: function resolve$
|
|
11642
|
+
resolve: function resolve$2() {
|
|
9274
11643
|
var resolvedPath = "";
|
|
9275
11644
|
var resolvedAbsolute = false;
|
|
9276
11645
|
var cwd$1;
|
|
@@ -9628,7 +11997,7 @@ function __extends(d, b) {
|
|
|
9628
11997
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
9629
11998
|
}
|
|
9630
11999
|
var __assign = function() {
|
|
9631
|
-
__assign = Object.assign || function __assign$
|
|
12000
|
+
__assign = Object.assign || function __assign$1(t$2) {
|
|
9632
12001
|
for (var s, i = 1, n$1 = arguments.length; i < n$1; i++) {
|
|
9633
12002
|
s = arguments[i];
|
|
9634
12003
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t$2[p] = s[p];
|
|
@@ -9709,11 +12078,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
9709
12078
|
}
|
|
9710
12079
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
9711
12080
|
function adopt(value) {
|
|
9712
|
-
return value instanceof P ? value : new P(function(resolve$
|
|
9713
|
-
resolve$
|
|
12081
|
+
return value instanceof P ? value : new P(function(resolve$2) {
|
|
12082
|
+
resolve$2(value);
|
|
9714
12083
|
});
|
|
9715
12084
|
}
|
|
9716
|
-
return new (P || (P = Promise))(function(resolve$
|
|
12085
|
+
return new (P || (P = Promise))(function(resolve$2, reject) {
|
|
9717
12086
|
function fulfilled(value) {
|
|
9718
12087
|
try {
|
|
9719
12088
|
step(generator.next(value));
|
|
@@ -9729,7 +12098,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
9729
12098
|
}
|
|
9730
12099
|
}
|
|
9731
12100
|
function step(result) {
|
|
9732
|
-
result.done ? resolve$
|
|
12101
|
+
result.done ? resolve$2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
9733
12102
|
}
|
|
9734
12103
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9735
12104
|
});
|
|
@@ -9953,14 +12322,14 @@ function __asyncValues(o) {
|
|
|
9953
12322
|
}, i);
|
|
9954
12323
|
function verb(n$1) {
|
|
9955
12324
|
i[n$1] = o[n$1] && function(v) {
|
|
9956
|
-
return new Promise(function(resolve$
|
|
9957
|
-
v = o[n$1](v), settle(resolve$
|
|
12325
|
+
return new Promise(function(resolve$2, reject) {
|
|
12326
|
+
v = o[n$1](v), settle(resolve$2, reject, v.done, v.value);
|
|
9958
12327
|
});
|
|
9959
12328
|
};
|
|
9960
12329
|
}
|
|
9961
|
-
function settle(resolve$
|
|
12330
|
+
function settle(resolve$2, reject, d, v) {
|
|
9962
12331
|
Promise.resolve(v).then(function(v$1) {
|
|
9963
|
-
resolve$
|
|
12332
|
+
resolve$2({
|
|
9964
12333
|
value: v$1,
|
|
9965
12334
|
done: d
|
|
9966
12335
|
});
|
|
@@ -10769,14 +13138,14 @@ function requireUtil$3() {
|
|
|
10769
13138
|
return filepath;
|
|
10770
13139
|
};
|
|
10771
13140
|
exports$1.unixify = unixify;
|
|
10772
|
-
let resolve$
|
|
10773
|
-
exports$1.resolve = resolve$
|
|
13141
|
+
let resolve$2 = (filename, base = process_1.default.cwd()) => resolveCrossPlatform(base, filename);
|
|
13142
|
+
exports$1.resolve = resolve$2;
|
|
10774
13143
|
if (exports$1.isWin) {
|
|
10775
|
-
const _resolve = resolve$
|
|
10776
|
-
exports$1.resolve = resolve$
|
|
13144
|
+
const _resolve = resolve$2;
|
|
13145
|
+
exports$1.resolve = resolve$2 = (filename, base) => (0, exports$1.unixify)(_resolve(filename, base));
|
|
10777
13146
|
}
|
|
10778
13147
|
const filenameToSteps = (filename, base) => {
|
|
10779
|
-
const fullPathSansSlash = resolve$
|
|
13148
|
+
const fullPathSansSlash = resolve$2(filename, base).substring(1);
|
|
10780
13149
|
if (!fullPathSansSlash) return [];
|
|
10781
13150
|
return fullPathSansSlash.split(pathSep);
|
|
10782
13151
|
};
|
|
@@ -12762,7 +15131,7 @@ function requireStringify() {
|
|
|
12762
15131
|
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
|
|
12763
15132
|
};
|
|
12764
15133
|
var sentinel = {};
|
|
12765
|
-
var stringify = function stringify$1(object$1, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format$1, formatter, encodeValuesOnly, charset, sideChannel$1) {
|
|
15134
|
+
var stringify = function stringify$1(object$1, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder$1, filter, sort, allowDots, serializeDate, format$1, formatter, encodeValuesOnly, charset, sideChannel$1) {
|
|
12766
15135
|
var obj = object$1;
|
|
12767
15136
|
var tmpSc = sideChannel$1;
|
|
12768
15137
|
var step = 0;
|
|
@@ -12781,18 +15150,18 @@ function requireStringify() {
|
|
|
12781
15150
|
return value$1;
|
|
12782
15151
|
});
|
|
12783
15152
|
if (obj === null) {
|
|
12784
|
-
if (strictNullHandling) return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, "key", format$1) : prefix;
|
|
15153
|
+
if (strictNullHandling) return encoder$1 && !encodeValuesOnly ? encoder$1(prefix, defaults.encoder, charset, "key", format$1) : prefix;
|
|
12785
15154
|
obj = "";
|
|
12786
15155
|
}
|
|
12787
15156
|
if (isNonNullishPrimitive(obj) || utils$2.isBuffer(obj)) {
|
|
12788
|
-
if (encoder) return [formatter(encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, "key", format$1)) + "=" + formatter(encoder(obj, defaults.encoder, charset, "value", format$1))];
|
|
15157
|
+
if (encoder$1) return [formatter(encodeValuesOnly ? prefix : encoder$1(prefix, defaults.encoder, charset, "key", format$1)) + "=" + formatter(encoder$1(obj, defaults.encoder, charset, "value", format$1))];
|
|
12789
15158
|
return [formatter(prefix) + "=" + formatter(String(obj))];
|
|
12790
15159
|
}
|
|
12791
15160
|
var values = [];
|
|
12792
15161
|
if (typeof obj === "undefined") return values;
|
|
12793
15162
|
var objKeys;
|
|
12794
15163
|
if (generateArrayPrefix === "comma" && isArray(obj)) {
|
|
12795
|
-
if (encodeValuesOnly && encoder) obj = utils$2.maybeMap(obj, encoder);
|
|
15164
|
+
if (encodeValuesOnly && encoder$1) obj = utils$2.maybeMap(obj, encoder$1);
|
|
12796
15165
|
objKeys = [{ value: obj.length > 0 ? obj.join(",") || null : void 0 }];
|
|
12797
15166
|
} else if (isArray(filter)) objKeys = filter;
|
|
12798
15167
|
else {
|
|
@@ -12811,7 +15180,7 @@ function requireStringify() {
|
|
|
12811
15180
|
sideChannel$1.set(object$1, step);
|
|
12812
15181
|
var valueSideChannel = getSideChannel();
|
|
12813
15182
|
valueSideChannel.set(sentinel, sideChannel$1);
|
|
12814
|
-
pushToArray(values, stringify$1(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format$1, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
15183
|
+
pushToArray(values, stringify$1(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder$1, filter, sort, allowDots, serializeDate, format$1, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
12815
15184
|
}
|
|
12816
15185
|
return values;
|
|
12817
15186
|
};
|
|
@@ -13530,10 +15899,10 @@ function requireUtil$2() {
|
|
|
13530
15899
|
const queueMicrotask_1 = requireQueueMicrotask();
|
|
13531
15900
|
const util_1 = requireUtil$3();
|
|
13532
15901
|
function promisify(fs$1, fn, getResult = (input) => input) {
|
|
13533
|
-
return (...args$1) => new Promise((resolve$
|
|
15902
|
+
return (...args$1) => new Promise((resolve$2, reject) => {
|
|
13534
15903
|
fs$1[fn].bind(fs$1)(...args$1, (error$1, result) => {
|
|
13535
15904
|
if (error$1) return reject(error$1);
|
|
13536
|
-
return resolve$
|
|
15905
|
+
return resolve$2(getResult(result));
|
|
13537
15906
|
});
|
|
13538
15907
|
});
|
|
13539
15908
|
}
|
|
@@ -13641,9 +16010,9 @@ function requireUtil$2() {
|
|
|
13641
16010
|
}
|
|
13642
16011
|
function streamToBuffer(stream$2) {
|
|
13643
16012
|
const chunks = [];
|
|
13644
|
-
return new Promise((resolve$
|
|
16013
|
+
return new Promise((resolve$2, reject) => {
|
|
13645
16014
|
stream$2.on("data", (chunk) => chunks.push(chunk));
|
|
13646
|
-
stream$2.on("end", () => resolve$
|
|
16015
|
+
stream$2.on("end", () => resolve$2(buffer_1.Buffer.concat(chunks)));
|
|
13647
16016
|
stream$2.on("error", reject);
|
|
13648
16017
|
});
|
|
13649
16018
|
}
|
|
@@ -14992,14 +17361,14 @@ function requireEvents$1() {
|
|
|
14992
17361
|
return ret;
|
|
14993
17362
|
}
|
|
14994
17363
|
function once(emitter, name) {
|
|
14995
|
-
return new Promise(function(resolve$
|
|
17364
|
+
return new Promise(function(resolve$2, reject) {
|
|
14996
17365
|
function errorListener(err) {
|
|
14997
17366
|
emitter.removeListener(name, resolver);
|
|
14998
17367
|
reject(err);
|
|
14999
17368
|
}
|
|
15000
17369
|
function resolver() {
|
|
15001
17370
|
if (typeof emitter.removeListener === "function") emitter.removeListener("error", errorListener);
|
|
15002
|
-
resolve$
|
|
17371
|
+
resolve$2([].slice.call(arguments));
|
|
15003
17372
|
}
|
|
15004
17373
|
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
|
15005
17374
|
if (name !== "error") addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
|
@@ -15040,7 +17409,7 @@ function requireUtil$1() {
|
|
|
15040
17409
|
const validateAbortSignal = (signal, name) => {
|
|
15041
17410
|
if (signal !== void 0 && (signal === null || typeof signal !== "object" || !("aborted" in signal))) throw new ERR_INVALID_ARG_TYPE(name, "AbortSignal", signal);
|
|
15042
17411
|
};
|
|
15043
|
-
const validateFunction = (value, name) => {
|
|
17412
|
+
const validateFunction$1 = (value, name) => {
|
|
15044
17413
|
if (typeof value !== "function") throw new ERR_INVALID_ARG_TYPE(name, "Function", value);
|
|
15045
17414
|
};
|
|
15046
17415
|
module.exports = {
|
|
@@ -15055,22 +17424,22 @@ function requireUtil$1() {
|
|
|
15055
17424
|
};
|
|
15056
17425
|
},
|
|
15057
17426
|
createDeferredPromise: function() {
|
|
15058
|
-
let resolve$
|
|
17427
|
+
let resolve$2;
|
|
15059
17428
|
let reject;
|
|
15060
17429
|
return {
|
|
15061
17430
|
promise: new Promise((res, rej) => {
|
|
15062
|
-
resolve$
|
|
17431
|
+
resolve$2 = res;
|
|
15063
17432
|
reject = rej;
|
|
15064
17433
|
}),
|
|
15065
|
-
resolve: resolve$
|
|
17434
|
+
resolve: resolve$2,
|
|
15066
17435
|
reject
|
|
15067
17436
|
};
|
|
15068
17437
|
},
|
|
15069
17438
|
promisify(fn) {
|
|
15070
|
-
return new Promise((resolve$
|
|
17439
|
+
return new Promise((resolve$2, reject) => {
|
|
15071
17440
|
fn((err, ...args$1) => {
|
|
15072
17441
|
if (err) return reject(err);
|
|
15073
|
-
return resolve$
|
|
17442
|
+
return resolve$2(...args$1);
|
|
15074
17443
|
});
|
|
15075
17444
|
});
|
|
15076
17445
|
},
|
|
@@ -15094,7 +17463,7 @@ function requireUtil$1() {
|
|
|
15094
17463
|
addAbortListener: requireEvents$1().addAbortListener || function addAbortListener(signal, listener) {
|
|
15095
17464
|
if (signal === void 0) throw new ERR_INVALID_ARG_TYPE("signal", "AbortSignal", signal);
|
|
15096
17465
|
validateAbortSignal(signal, "signal");
|
|
15097
|
-
validateFunction(listener, "listener");
|
|
17466
|
+
validateFunction$1(listener, "listener");
|
|
15098
17467
|
let removeEventListener;
|
|
15099
17468
|
if (signal.aborted) queueMicrotask(() => listener());
|
|
15100
17469
|
else {
|
|
@@ -15230,7 +17599,7 @@ function requireValidators() {
|
|
|
15230
17599
|
* @returns {asserts value is string}
|
|
15231
17600
|
*/
|
|
15232
17601
|
/** @type {validateString} */
|
|
15233
|
-
function validateString(value, name) {
|
|
17602
|
+
function validateString$1(value, name) {
|
|
15234
17603
|
if (typeof value !== "string") throw new ERR_INVALID_ARG_TYPE(name, "string", value);
|
|
15235
17604
|
}
|
|
15236
17605
|
/**
|
|
@@ -15264,7 +17633,7 @@ function requireValidators() {
|
|
|
15264
17633
|
* @returns {asserts value is boolean}
|
|
15265
17634
|
*/
|
|
15266
17635
|
/** @type {validateBoolean} */
|
|
15267
|
-
function validateBoolean(value, name) {
|
|
17636
|
+
function validateBoolean$1(value, name) {
|
|
15268
17637
|
if (typeof value !== "boolean") throw new ERR_INVALID_ARG_TYPE(name, "boolean", value);
|
|
15269
17638
|
}
|
|
15270
17639
|
/**
|
|
@@ -15287,7 +17656,7 @@ function requireValidators() {
|
|
|
15287
17656
|
* }} [options]
|
|
15288
17657
|
*/
|
|
15289
17658
|
/** @type {validateObject} */
|
|
15290
|
-
const validateObject = hideStackFrames((value, name, options$1 = null) => {
|
|
17659
|
+
const validateObject$1 = hideStackFrames((value, name, options$1 = null) => {
|
|
15291
17660
|
const allowArray = getOwnPropertyValueOrDefault(options$1, "allowArray", false);
|
|
15292
17661
|
const allowFunction = getOwnPropertyValueOrDefault(options$1, "allowFunction", false);
|
|
15293
17662
|
if (!getOwnPropertyValueOrDefault(options$1, "nullable", false) && value === null || !allowArray && ArrayIsArray(value) || typeof value !== "object" && (!allowFunction || typeof value !== "function")) throw new ERR_INVALID_ARG_TYPE(name, "Object", value);
|
|
@@ -15314,7 +17683,7 @@ function requireValidators() {
|
|
|
15314
17683
|
* @returns {asserts value is any[]}
|
|
15315
17684
|
*/
|
|
15316
17685
|
/** @type {validateArray} */
|
|
15317
|
-
const validateArray = hideStackFrames((value, name, minLength = 0) => {
|
|
17686
|
+
const validateArray$1 = hideStackFrames((value, name, minLength = 0) => {
|
|
15318
17687
|
if (!ArrayIsArray(value)) throw new ERR_INVALID_ARG_TYPE(name, "Array", value);
|
|
15319
17688
|
if (value.length < minLength) throw new ERR_INVALID_ARG_VALUE(name, value, `must be longer than ${minLength}`);
|
|
15320
17689
|
});
|
|
@@ -15326,8 +17695,8 @@ function requireValidators() {
|
|
|
15326
17695
|
*/
|
|
15327
17696
|
/** @type {validateStringArray} */
|
|
15328
17697
|
function validateStringArray(value, name) {
|
|
15329
|
-
validateArray(value, name);
|
|
15330
|
-
for (let i = 0; i < value.length; i++) validateString(value[i], `${name}[${i}]`);
|
|
17698
|
+
validateArray$1(value, name);
|
|
17699
|
+
for (let i = 0; i < value.length; i++) validateString$1(value[i], `${name}[${i}]`);
|
|
15331
17700
|
}
|
|
15332
17701
|
/**
|
|
15333
17702
|
* @callback validateBooleanArray
|
|
@@ -15337,8 +17706,8 @@ function requireValidators() {
|
|
|
15337
17706
|
*/
|
|
15338
17707
|
/** @type {validateBooleanArray} */
|
|
15339
17708
|
function validateBooleanArray(value, name) {
|
|
15340
|
-
validateArray(value, name);
|
|
15341
|
-
for (let i = 0; i < value.length; i++) validateBoolean(value[i], `${name}[${i}]`);
|
|
17709
|
+
validateArray$1(value, name);
|
|
17710
|
+
for (let i = 0; i < value.length; i++) validateBoolean$1(value[i], `${name}[${i}]`);
|
|
15342
17711
|
}
|
|
15343
17712
|
/**
|
|
15344
17713
|
* @callback validateAbortSignalArray
|
|
@@ -15348,7 +17717,7 @@ function requireValidators() {
|
|
|
15348
17717
|
*/
|
|
15349
17718
|
/** @type {validateAbortSignalArray} */
|
|
15350
17719
|
function validateAbortSignalArray(value, name) {
|
|
15351
|
-
validateArray(value, name);
|
|
17720
|
+
validateArray$1(value, name);
|
|
15352
17721
|
for (let i = 0; i < value.length; i++) {
|
|
15353
17722
|
const signal = value[i];
|
|
15354
17723
|
const indexedName = `${name}[${i}]`;
|
|
@@ -15362,7 +17731,7 @@ function requireValidators() {
|
|
|
15362
17731
|
* @returns {asserts signal is keyof signals}
|
|
15363
17732
|
*/
|
|
15364
17733
|
function validateSignalName(signal, name = "signal") {
|
|
15365
|
-
validateString(signal, name);
|
|
17734
|
+
validateString$1(signal, name);
|
|
15366
17735
|
if (signals[signal] === void 0) {
|
|
15367
17736
|
if (signals[StringPrototypeToUpperCase(signal)] !== void 0) throw new ERR_UNKNOWN_SIGNAL(signal + " (signals must use all capital letters)");
|
|
15368
17737
|
throw new ERR_UNKNOWN_SIGNAL(signal);
|
|
@@ -15419,7 +17788,7 @@ function requireValidators() {
|
|
|
15419
17788
|
* @returns {asserts value is Function}
|
|
15420
17789
|
*/
|
|
15421
17790
|
/** @type {validateFunction} */
|
|
15422
|
-
const validateFunction = hideStackFrames((value, name) => {
|
|
17791
|
+
const validateFunction$1 = hideStackFrames((value, name) => {
|
|
15423
17792
|
if (typeof value !== "function") throw new ERR_INVALID_ARG_TYPE(name, "Function", value);
|
|
15424
17793
|
});
|
|
15425
17794
|
/**
|
|
@@ -15439,7 +17808,7 @@ function requireValidators() {
|
|
|
15439
17808
|
* @returns {asserts value is undefined}
|
|
15440
17809
|
*/
|
|
15441
17810
|
/** @type {validateUndefined} */
|
|
15442
|
-
const validateUndefined = hideStackFrames((value, name) => {
|
|
17811
|
+
const validateUndefined$1 = hideStackFrames((value, name) => {
|
|
15443
17812
|
if (value !== void 0) throw new ERR_INVALID_ARG_TYPE(name, "undefined", value);
|
|
15444
17813
|
});
|
|
15445
17814
|
/**
|
|
@@ -15485,26 +17854,26 @@ function requireValidators() {
|
|
|
15485
17854
|
isInt32,
|
|
15486
17855
|
isUint32,
|
|
15487
17856
|
parseFileMode,
|
|
15488
|
-
validateArray,
|
|
17857
|
+
validateArray: validateArray$1,
|
|
15489
17858
|
validateStringArray,
|
|
15490
17859
|
validateBooleanArray,
|
|
15491
17860
|
validateAbortSignalArray,
|
|
15492
|
-
validateBoolean,
|
|
17861
|
+
validateBoolean: validateBoolean$1,
|
|
15493
17862
|
validateBuffer,
|
|
15494
17863
|
validateDictionary,
|
|
15495
17864
|
validateEncoding,
|
|
15496
|
-
validateFunction,
|
|
17865
|
+
validateFunction: validateFunction$1,
|
|
15497
17866
|
validateInt32,
|
|
15498
17867
|
validateInteger,
|
|
15499
17868
|
validateNumber: validateNumber$1,
|
|
15500
|
-
validateObject,
|
|
17869
|
+
validateObject: validateObject$1,
|
|
15501
17870
|
validateOneOf,
|
|
15502
17871
|
validatePlainFunction,
|
|
15503
17872
|
validatePort,
|
|
15504
17873
|
validateSignalName,
|
|
15505
|
-
validateString,
|
|
17874
|
+
validateString: validateString$1,
|
|
15506
17875
|
validateUint32,
|
|
15507
|
-
validateUndefined,
|
|
17876
|
+
validateUndefined: validateUndefined$1,
|
|
15508
17877
|
validateUnion,
|
|
15509
17878
|
validateAbortSignal,
|
|
15510
17879
|
validateLinkHeaderValue
|
|
@@ -15703,8 +18072,8 @@ function requireEndOfStream() {
|
|
|
15703
18072
|
const process$3 = requireBrowser$2();
|
|
15704
18073
|
const { AbortError, codes } = requireErrors();
|
|
15705
18074
|
const { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes;
|
|
15706
|
-
const { kEmptyObject, once } = requireUtil$1();
|
|
15707
|
-
const { validateAbortSignal, validateFunction, validateObject, validateBoolean } = requireValidators();
|
|
18075
|
+
const { kEmptyObject: kEmptyObject$1, once } = requireUtil$1();
|
|
18076
|
+
const { validateAbortSignal, validateFunction: validateFunction$1, validateObject: validateObject$1, validateBoolean: validateBoolean$1 } = requireValidators();
|
|
15708
18077
|
const { Promise: Promise$1, PromisePrototypeThen, SymbolDispose } = requirePrimordials();
|
|
15709
18078
|
const { isClosed, isReadable, isReadableNodeStream, isReadableStream, isReadableFinished, isReadableErrored, isWritable, isWritableNodeStream, isWritableStream, isWritableFinished, isWritableErrored, isNodeStream, willEmitClose: _willEmitClose, kIsClosedPromise } = requireUtils();
|
|
15710
18079
|
let addAbortListener;
|
|
@@ -15716,10 +18085,10 @@ function requireEndOfStream() {
|
|
|
15716
18085
|
var _options$readable, _options$writable;
|
|
15717
18086
|
if (arguments.length === 2) {
|
|
15718
18087
|
callback = options$1;
|
|
15719
|
-
options$1 = kEmptyObject;
|
|
15720
|
-
} else if (options$1 == null) options$1 = kEmptyObject;
|
|
15721
|
-
else validateObject(options$1, "options");
|
|
15722
|
-
validateFunction(callback, "callback");
|
|
18088
|
+
options$1 = kEmptyObject$1;
|
|
18089
|
+
} else if (options$1 == null) options$1 = kEmptyObject$1;
|
|
18090
|
+
else validateObject$1(options$1, "options");
|
|
18091
|
+
validateFunction$1(callback, "callback");
|
|
15723
18092
|
validateAbortSignal(options$1.signal, "options.signal");
|
|
15724
18093
|
callback = once(callback);
|
|
15725
18094
|
if (isReadableStream(stream$2) || isWritableStream(stream$2)) return eosWeb(stream$2, options$1, callback);
|
|
@@ -15856,16 +18225,16 @@ function requireEndOfStream() {
|
|
|
15856
18225
|
function finished(stream$2, opts) {
|
|
15857
18226
|
var _opts;
|
|
15858
18227
|
let autoCleanup = false;
|
|
15859
|
-
if (opts === null) opts = kEmptyObject;
|
|
18228
|
+
if (opts === null) opts = kEmptyObject$1;
|
|
15860
18229
|
if ((_opts = opts) !== null && _opts !== void 0 && _opts.cleanup) {
|
|
15861
|
-
validateBoolean(opts.cleanup, "cleanup");
|
|
18230
|
+
validateBoolean$1(opts.cleanup, "cleanup");
|
|
15862
18231
|
autoCleanup = opts.cleanup;
|
|
15863
18232
|
}
|
|
15864
|
-
return new Promise$1((resolve$
|
|
18233
|
+
return new Promise$1((resolve$2, reject) => {
|
|
15865
18234
|
const cleanup = eos(stream$2, opts, (err) => {
|
|
15866
18235
|
if (autoCleanup) cleanup();
|
|
15867
18236
|
if (err) reject(err);
|
|
15868
|
-
else resolve$
|
|
18237
|
+
else resolve$2();
|
|
15869
18238
|
});
|
|
15870
18239
|
});
|
|
15871
18240
|
}
|
|
@@ -16723,7 +19092,7 @@ function requireReadable() {
|
|
|
16723
19092
|
const destroyImpl = requireDestroy();
|
|
16724
19093
|
const { getHighWaterMark, getDefaultHighWaterMark } = requireState();
|
|
16725
19094
|
const { aggregateTwoErrors, codes: { ERR_INVALID_ARG_TYPE, ERR_METHOD_NOT_IMPLEMENTED, ERR_OUT_OF_RANGE, ERR_STREAM_PUSH_AFTER_EOF, ERR_STREAM_UNSHIFT_AFTER_END_EVENT }, AbortError } = requireErrors();
|
|
16726
|
-
const { validateObject } = requireValidators();
|
|
19095
|
+
const { validateObject: validateObject$1 } = requireValidators();
|
|
16727
19096
|
const kPaused = Symbol$1("kPaused");
|
|
16728
19097
|
const { StringDecoder } = requireString_decoder();
|
|
16729
19098
|
const from$1 = requireFrom();
|
|
@@ -16835,7 +19204,7 @@ function requireReadable() {
|
|
|
16835
19204
|
error$1 = this.readableEnded ? null : new AbortError();
|
|
16836
19205
|
this.destroy(error$1);
|
|
16837
19206
|
}
|
|
16838
|
-
return new Promise$1((resolve$
|
|
19207
|
+
return new Promise$1((resolve$2, reject) => eos(this, (err) => err && err !== error$1 ? reject(err) : resolve$2(null)));
|
|
16839
19208
|
};
|
|
16840
19209
|
Readable.prototype.push = function(chunk, encoding$1) {
|
|
16841
19210
|
return readableAddChunk(this, chunk, encoding$1, false);
|
|
@@ -16907,12 +19276,12 @@ function requireReadable() {
|
|
|
16907
19276
|
return state$1[kPaused] === true || state$1.flowing === false;
|
|
16908
19277
|
};
|
|
16909
19278
|
Readable.prototype.setEncoding = function(enc) {
|
|
16910
|
-
const decoder = new StringDecoder(enc);
|
|
16911
|
-
this._readableState.decoder = decoder;
|
|
19279
|
+
const decoder$1 = new StringDecoder(enc);
|
|
19280
|
+
this._readableState.decoder = decoder$1;
|
|
16912
19281
|
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
16913
19282
|
const buffer = this._readableState.buffer;
|
|
16914
19283
|
let content = "";
|
|
16915
|
-
for (const data of buffer) content += decoder.write(data);
|
|
19284
|
+
for (const data of buffer) content += decoder$1.write(data);
|
|
16916
19285
|
buffer.clear();
|
|
16917
19286
|
if (content !== "") buffer.push(content);
|
|
16918
19287
|
this._readableState.length = content.length;
|
|
@@ -17308,7 +19677,7 @@ function requireReadable() {
|
|
|
17308
19677
|
return streamToAsyncIterator(this);
|
|
17309
19678
|
};
|
|
17310
19679
|
Readable.prototype.iterator = function(options$1) {
|
|
17311
|
-
if (options$1 !== void 0) validateObject(options$1, "options");
|
|
19680
|
+
if (options$1 !== void 0) validateObject$1(options$1, "options");
|
|
17312
19681
|
return streamToAsyncIterator(this, options$1);
|
|
17313
19682
|
};
|
|
17314
19683
|
function streamToAsyncIterator(stream$2, options$1) {
|
|
@@ -17319,11 +19688,11 @@ function requireReadable() {
|
|
|
17319
19688
|
}
|
|
17320
19689
|
async function* createAsyncIterator(stream$2, options$1) {
|
|
17321
19690
|
let callback = nop;
|
|
17322
|
-
function next(resolve$
|
|
19691
|
+
function next(resolve$2) {
|
|
17323
19692
|
if (this === stream$2) {
|
|
17324
19693
|
callback();
|
|
17325
19694
|
callback = nop;
|
|
17326
|
-
} else callback = resolve$
|
|
19695
|
+
} else callback = resolve$2;
|
|
17327
19696
|
}
|
|
17328
19697
|
stream$2.on("readable", next);
|
|
17329
19698
|
let error$1;
|
|
@@ -18170,7 +20539,7 @@ function requireDuplexify() {
|
|
|
18170
20539
|
], body);
|
|
18171
20540
|
};
|
|
18172
20541
|
function fromAsyncGen(fn) {
|
|
18173
|
-
let { promise: promise$1, resolve: resolve$
|
|
20542
|
+
let { promise: promise$1, resolve: resolve$2 } = createDeferredPromise();
|
|
18174
20543
|
const ac = new AbortController();
|
|
18175
20544
|
const signal = ac.signal;
|
|
18176
20545
|
return {
|
|
@@ -18182,13 +20551,13 @@ function requireDuplexify() {
|
|
|
18182
20551
|
process$3.nextTick(cb);
|
|
18183
20552
|
if (done) return;
|
|
18184
20553
|
if (signal.aborted) throw new AbortError(void 0, { cause: signal.reason });
|
|
18185
|
-
({promise: promise$1, resolve: resolve$
|
|
20554
|
+
({promise: promise$1, resolve: resolve$2} = createDeferredPromise());
|
|
18186
20555
|
yield chunk;
|
|
18187
20556
|
}
|
|
18188
20557
|
})(), { signal }),
|
|
18189
20558
|
write(chunk, encoding$1, cb) {
|
|
18190
|
-
const _resolve = resolve$
|
|
18191
|
-
resolve$
|
|
20559
|
+
const _resolve = resolve$2;
|
|
20560
|
+
resolve$2 = null;
|
|
18192
20561
|
_resolve({
|
|
18193
20562
|
chunk,
|
|
18194
20563
|
done: false,
|
|
@@ -18196,8 +20565,8 @@ function requireDuplexify() {
|
|
|
18196
20565
|
});
|
|
18197
20566
|
},
|
|
18198
20567
|
final(cb) {
|
|
18199
|
-
const _resolve = resolve$
|
|
18200
|
-
resolve$
|
|
20568
|
+
const _resolve = resolve$2;
|
|
20569
|
+
resolve$2 = null;
|
|
18201
20570
|
_resolve({
|
|
18202
20571
|
done: true,
|
|
18203
20572
|
cb
|
|
@@ -18517,7 +20886,7 @@ function requirePipeline() {
|
|
|
18517
20886
|
const destroyImpl = requireDestroy();
|
|
18518
20887
|
const Duplex = requireDuplex();
|
|
18519
20888
|
const { aggregateTwoErrors, codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE, ERR_MISSING_ARGS, ERR_STREAM_DESTROYED, ERR_STREAM_PREMATURE_CLOSE }, AbortError } = requireErrors();
|
|
18520
|
-
const { validateFunction, validateAbortSignal } = requireValidators();
|
|
20889
|
+
const { validateFunction: validateFunction$1, validateAbortSignal } = requireValidators();
|
|
18521
20890
|
const { isIterable, isReadable, isReadableNodeStream, isNodeStream, isTransformStream, isWebStream, isReadableStream, isReadableFinished } = requireUtils();
|
|
18522
20891
|
const AbortController = globalThis.AbortController || requireBrowser$1().AbortController;
|
|
18523
20892
|
let PassThrough;
|
|
@@ -18543,7 +20912,7 @@ function requirePipeline() {
|
|
|
18543
20912
|
};
|
|
18544
20913
|
}
|
|
18545
20914
|
function popCallback(streams) {
|
|
18546
|
-
validateFunction(streams[streams.length - 1], "streams[stream.length - 1]");
|
|
20915
|
+
validateFunction$1(streams[streams.length - 1], "streams[stream.length - 1]");
|
|
18547
20916
|
return streams.pop();
|
|
18548
20917
|
}
|
|
18549
20918
|
function makeAsyncIterable(val) {
|
|
@@ -18570,11 +20939,11 @@ function requirePipeline() {
|
|
|
18570
20939
|
callback();
|
|
18571
20940
|
}
|
|
18572
20941
|
};
|
|
18573
|
-
const wait = () => new Promise$1((resolve$
|
|
20942
|
+
const wait = () => new Promise$1((resolve$2, reject) => {
|
|
18574
20943
|
if (error$1) reject(error$1);
|
|
18575
20944
|
else onresolve = () => {
|
|
18576
20945
|
if (error$1) reject(error$1);
|
|
18577
|
-
else resolve$
|
|
20946
|
+
else resolve$2();
|
|
18578
20947
|
};
|
|
18579
20948
|
});
|
|
18580
20949
|
writable$1.on("drain", resume);
|
|
@@ -18941,7 +21310,7 @@ function requireOperators() {
|
|
|
18941
21310
|
hasRequiredOperators = 1;
|
|
18942
21311
|
const AbortController = globalThis.AbortController || requireBrowser$1().AbortController;
|
|
18943
21312
|
const { codes: { ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_TYPE, ERR_MISSING_ARGS, ERR_OUT_OF_RANGE }, AbortError } = requireErrors();
|
|
18944
|
-
const { validateAbortSignal, validateInteger, validateObject } = requireValidators();
|
|
21313
|
+
const { validateAbortSignal, validateInteger, validateObject: validateObject$1 } = requireValidators();
|
|
18945
21314
|
const kWeakHandler = requirePrimordials().Symbol("kWeak");
|
|
18946
21315
|
const kResistStopPropagation = requirePrimordials().Symbol("kResistStopPropagation");
|
|
18947
21316
|
const { finished } = requireEndOfStream();
|
|
@@ -18953,7 +21322,7 @@ function requireOperators() {
|
|
|
18953
21322
|
const kEmpty = Symbol$1("kEmpty");
|
|
18954
21323
|
const kEof = Symbol$1("kEof");
|
|
18955
21324
|
function compose$1(stream$2, options$1) {
|
|
18956
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21325
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
18957
21326
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
18958
21327
|
if (isNodeStream(stream$2) && !isWritable(stream$2)) throw new ERR_INVALID_ARG_VALUE("stream", stream$2, "must be writable");
|
|
18959
21328
|
const composedStream = staticCompose(this, stream$2);
|
|
@@ -18962,7 +21331,7 @@ function requireOperators() {
|
|
|
18962
21331
|
}
|
|
18963
21332
|
function map(fn, options$1) {
|
|
18964
21333
|
if (typeof fn !== "function") throw new ERR_INVALID_ARG_TYPE("fn", ["Function", "AsyncFunction"], fn);
|
|
18965
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21334
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
18966
21335
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
18967
21336
|
let concurrency = 1;
|
|
18968
21337
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.concurrency) != null) concurrency = MathFloor(options$1.concurrency);
|
|
@@ -19013,8 +21382,8 @@ function requireOperators() {
|
|
|
19013
21382
|
next();
|
|
19014
21383
|
next = null;
|
|
19015
21384
|
}
|
|
19016
|
-
if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) await new Promise$1((resolve$
|
|
19017
|
-
resume = resolve$
|
|
21385
|
+
if (!done && (queue.length >= highWaterMark || cnt >= concurrency)) await new Promise$1((resolve$2) => {
|
|
21386
|
+
resume = resolve$2;
|
|
19018
21387
|
});
|
|
19019
21388
|
}
|
|
19020
21389
|
queue.push(kEof);
|
|
@@ -19041,8 +21410,8 @@ function requireOperators() {
|
|
|
19041
21410
|
queue.shift();
|
|
19042
21411
|
maybeResume();
|
|
19043
21412
|
}
|
|
19044
|
-
await new Promise$1((resolve$
|
|
19045
|
-
next = resolve$
|
|
21413
|
+
await new Promise$1((resolve$2) => {
|
|
21414
|
+
next = resolve$2;
|
|
19046
21415
|
});
|
|
19047
21416
|
}
|
|
19048
21417
|
} finally {
|
|
@@ -19055,7 +21424,7 @@ function requireOperators() {
|
|
|
19055
21424
|
}.call(this);
|
|
19056
21425
|
}
|
|
19057
21426
|
function asIndexedPairs(options$1 = void 0) {
|
|
19058
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21427
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
19059
21428
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
19060
21429
|
return async function* asIndexedPairs$1() {
|
|
19061
21430
|
let index = 0;
|
|
@@ -19104,7 +21473,7 @@ function requireOperators() {
|
|
|
19104
21473
|
async function reduce(reducer, initialValue, options$1) {
|
|
19105
21474
|
var _options$signal2;
|
|
19106
21475
|
if (typeof reducer !== "function") throw new ERR_INVALID_ARG_TYPE("reducer", ["Function", "AsyncFunction"], reducer);
|
|
19107
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21476
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
19108
21477
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
19109
21478
|
let hasInitialValue = arguments.length > 1;
|
|
19110
21479
|
if (options$1 !== null && options$1 !== void 0 && (_options$signal2 = options$1.signal) !== null && _options$signal2 !== void 0 && _options$signal2.aborted) {
|
|
@@ -19141,7 +21510,7 @@ function requireOperators() {
|
|
|
19141
21510
|
return initialValue;
|
|
19142
21511
|
}
|
|
19143
21512
|
async function toArray(options$1) {
|
|
19144
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21513
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
19145
21514
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
19146
21515
|
const result = [];
|
|
19147
21516
|
for await (const val of this) {
|
|
@@ -19164,7 +21533,7 @@ function requireOperators() {
|
|
|
19164
21533
|
return number$1;
|
|
19165
21534
|
}
|
|
19166
21535
|
function drop(number$1, options$1 = void 0) {
|
|
19167
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21536
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
19168
21537
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
19169
21538
|
number$1 = toIntegerOrInfinity(number$1);
|
|
19170
21539
|
return async function* drop$1() {
|
|
@@ -19178,7 +21547,7 @@ function requireOperators() {
|
|
|
19178
21547
|
}.call(this);
|
|
19179
21548
|
}
|
|
19180
21549
|
function take(number$1, options$1 = void 0) {
|
|
19181
|
-
if (options$1 != null) validateObject(options$1, "options");
|
|
21550
|
+
if (options$1 != null) validateObject$1(options$1, "options");
|
|
19182
21551
|
if ((options$1 === null || options$1 === void 0 ? void 0 : options$1.signal) != null) validateAbortSignal(options$1.signal, "options.signal");
|
|
19183
21552
|
number$1 = toIntegerOrInfinity(number$1);
|
|
19184
21553
|
return async function* take$1() {
|
|
@@ -19222,7 +21591,7 @@ function requirePromises() {
|
|
|
19222
21591
|
const { finished } = requireEndOfStream();
|
|
19223
21592
|
requireStream$1();
|
|
19224
21593
|
function pipeline(...streams) {
|
|
19225
|
-
return new Promise$1((resolve$
|
|
21594
|
+
return new Promise$1((resolve$2, reject) => {
|
|
19226
21595
|
let signal;
|
|
19227
21596
|
let end;
|
|
19228
21597
|
const lastArg = streams[streams.length - 1];
|
|
@@ -19233,7 +21602,7 @@ function requirePromises() {
|
|
|
19233
21602
|
}
|
|
19234
21603
|
pl(streams, (err, value) => {
|
|
19235
21604
|
if (err) reject(err);
|
|
19236
|
-
else resolve$
|
|
21605
|
+
else resolve$2(value);
|
|
19237
21606
|
}, {
|
|
19238
21607
|
signal,
|
|
19239
21608
|
end
|
|
@@ -19475,8 +21844,8 @@ function requireFileHandle() {
|
|
|
19475
21844
|
this.closePromise = (0, util_1.promisify)(this.fs, "close")(currentFd).finally(() => {
|
|
19476
21845
|
this.closePromise = null;
|
|
19477
21846
|
});
|
|
19478
|
-
} else this.closePromise = new Promise((resolve$
|
|
19479
|
-
this.closeResolve = resolve$
|
|
21847
|
+
} else this.closePromise = new Promise((resolve$2, reject) => {
|
|
21848
|
+
this.closeResolve = resolve$2;
|
|
19480
21849
|
this.closeReject = reject;
|
|
19481
21850
|
}).finally(() => {
|
|
19482
21851
|
this.closePromise = null;
|
|
@@ -19670,8 +22039,8 @@ function requireFsPromises() {
|
|
|
19670
22039
|
}
|
|
19671
22040
|
this.eventQueue.push(event);
|
|
19672
22041
|
if (this.resolveQueue.length > 0) {
|
|
19673
|
-
const { resolve: resolve$
|
|
19674
|
-
resolve$
|
|
22042
|
+
const { resolve: resolve$2 } = this.resolveQueue.shift();
|
|
22043
|
+
resolve$2({
|
|
19675
22044
|
value: this.eventQueue.shift(),
|
|
19676
22045
|
done: false
|
|
19677
22046
|
});
|
|
@@ -19685,9 +22054,9 @@ function requireFsPromises() {
|
|
|
19685
22054
|
this.watcher = null;
|
|
19686
22055
|
}
|
|
19687
22056
|
while (this.resolveQueue.length > 0) {
|
|
19688
|
-
const { resolve: resolve$
|
|
22057
|
+
const { resolve: resolve$2, reject } = this.resolveQueue.shift();
|
|
19689
22058
|
if (error$1) reject(error$1);
|
|
19690
|
-
else resolve$
|
|
22059
|
+
else resolve$2({
|
|
19691
22060
|
value: void 0,
|
|
19692
22061
|
done: true
|
|
19693
22062
|
});
|
|
@@ -19702,9 +22071,9 @@ function requireFsPromises() {
|
|
|
19702
22071
|
value: this.eventQueue.shift(),
|
|
19703
22072
|
done: false
|
|
19704
22073
|
};
|
|
19705
|
-
return new Promise((resolve$
|
|
22074
|
+
return new Promise((resolve$2, reject) => {
|
|
19706
22075
|
this.resolveQueue.push({
|
|
19707
|
-
resolve: resolve$
|
|
22076
|
+
resolve: resolve$2,
|
|
19708
22077
|
reject
|
|
19709
22078
|
});
|
|
19710
22079
|
});
|
|
@@ -20069,10 +22438,10 @@ function requireDir() {
|
|
|
20069
22438
|
close(callback) {
|
|
20070
22439
|
if (callback === void 0) {
|
|
20071
22440
|
if (this.closed) return Promise.reject(new errors$3.Error("ERR_DIR_CLOSED"));
|
|
20072
|
-
return new Promise((resolve$
|
|
22441
|
+
return new Promise((resolve$2, reject) => {
|
|
20073
22442
|
this.close((err) => {
|
|
20074
22443
|
if (err) reject(err);
|
|
20075
|
-
else resolve$
|
|
22444
|
+
else resolve$2();
|
|
20076
22445
|
});
|
|
20077
22446
|
});
|
|
20078
22447
|
}
|
|
@@ -20102,10 +22471,10 @@ function requireDir() {
|
|
|
20102
22471
|
this.closeBase();
|
|
20103
22472
|
}
|
|
20104
22473
|
read(callback) {
|
|
20105
|
-
if (callback === void 0) return new Promise((resolve$
|
|
22474
|
+
if (callback === void 0) return new Promise((resolve$2, reject) => {
|
|
20106
22475
|
this.read((err, result) => {
|
|
20107
22476
|
if (err) reject(err);
|
|
20108
|
-
else resolve$
|
|
22477
|
+
else resolve$2(result ?? null);
|
|
20109
22478
|
});
|
|
20110
22479
|
});
|
|
20111
22480
|
(0, util_1.validateCallback)(callback);
|
|
@@ -22012,7 +24381,7 @@ const { createFsFromVolume, Volume, fs, memfs } = memfsExported;
|
|
|
22012
24381
|
//#endregion
|
|
22013
24382
|
//#region ../../node_modules/.pnpm/@rolldown+browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/rolldown-binding.wasi-browser.js
|
|
22014
24383
|
const { fs: __fs, vol: __volume } = memfs();
|
|
22015
|
-
const __wasi = new
|
|
24384
|
+
const __wasi = new WASI({
|
|
22016
24385
|
version: "preview1",
|
|
22017
24386
|
fs: __fs,
|
|
22018
24387
|
preopens: { "/": "/" }
|
|
@@ -26719,10 +29088,10 @@ function bindingifyExperimental(experimental) {
|
|
|
26719
29088
|
chunkOptimization: experimental?.chunkOptimization
|
|
26720
29089
|
};
|
|
26721
29090
|
}
|
|
26722
|
-
function bindingifyResolve(resolve$1) {
|
|
29091
|
+
function bindingifyResolve(resolve$1$1) {
|
|
26723
29092
|
const yarnPnp = typeof process === "object" && !!process.versions?.pnp;
|
|
26724
|
-
if (resolve$1) {
|
|
26725
|
-
const { alias, extensionAlias, ...rest } = resolve$1;
|
|
29093
|
+
if (resolve$1$1) {
|
|
29094
|
+
const { alias, extensionAlias, ...rest } = resolve$1$1;
|
|
26726
29095
|
return {
|
|
26727
29096
|
alias: alias ? Object.entries(alias).map(([name, replacement]) => ({
|
|
26728
29097
|
find: name,
|