Spaces:
Sleeping
Sleeping
File size: 6,787 Bytes
b0166a6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | "use strict";
"use strict";
var __getOwnPropNames = Object.getOwnPropertyNames;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
// ../../node_modules/.pnpm/real-require@0.2.0/node_modules/real-require/src/index.js
var require_src = __commonJS({
"../../node_modules/.pnpm/real-require@0.2.0/node_modules/real-require/src/index.js"(exports2, module2) {
var realImport2 = new Function("modulePath", "return import(modulePath)");
function realRequire2(modulePath) {
if (typeof __non_webpack__require__ === "function") {
return __non_webpack__require__(modulePath);
}
return require(modulePath);
}
module2.exports = { realImport: realImport2, realRequire: realRequire2 };
}
});
// ../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/indexes.js
var require_indexes = __commonJS({
"../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/indexes.js"(exports2, module2) {
"use strict";
var WRITE_INDEX2 = 4;
var READ_INDEX2 = 8;
module2.exports = {
WRITE_INDEX: WRITE_INDEX2,
READ_INDEX: READ_INDEX2
};
}
});
// ../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js
var require_wait = __commonJS({
"../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js"(exports2, module2) {
"use strict";
var MAX_TIMEOUT = 1e3;
function wait(state2, index, expected, timeout, done) {
const max = Date.now() + timeout;
let current = Atomics.load(state2, index);
if (current === expected) {
done(null, "ok");
return;
}
let prior = current;
const check = (backoff) => {
if (Date.now() > max) {
done(null, "timed-out");
} else {
setTimeout(() => {
prior = current;
current = Atomics.load(state2, index);
if (current === prior) {
check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
} else {
if (current === expected) done(null, "ok");
else done(null, "not-equal");
}
}, backoff);
}
};
check(1);
}
function waitDiff2(state2, index, expected, timeout, done) {
const max = Date.now() + timeout;
let current = Atomics.load(state2, index);
if (current !== expected) {
done(null, "ok");
return;
}
const check = (backoff) => {
if (Date.now() > max) {
done(null, "timed-out");
} else {
setTimeout(() => {
current = Atomics.load(state2, index);
if (current !== expected) {
done(null, "ok");
} else {
check(backoff >= MAX_TIMEOUT ? MAX_TIMEOUT : backoff * 2);
}
}, backoff);
}
};
check(1);
}
module2.exports = { wait, waitDiff: waitDiff2 };
}
});
// ../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/worker.js
var { realImport, realRequire } = require_src();
var { workerData, parentPort } = require("worker_threads");
var { WRITE_INDEX, READ_INDEX } = require_indexes();
var { waitDiff } = require_wait();
var {
dataBuf,
filename,
stateBuf
} = workerData;
var destination;
var state = new Int32Array(stateBuf);
var data = Buffer.from(dataBuf);
async function start() {
let worker;
try {
if (filename.endsWith(".ts") || filename.endsWith(".cts")) {
if (!process[/* @__PURE__ */ Symbol.for("ts-node.register.instance")]) {
realRequire("ts-node/register");
} else if (process.env.TS_NODE_DEV) {
realRequire("ts-node-dev");
}
worker = realRequire(decodeURIComponent(filename.replace(process.platform === "win32" ? "file:///" : "file://", "")));
} else {
worker = await realImport(filename);
}
} catch (error) {
if ((error.code === "ENOTDIR" || error.code === "ERR_MODULE_NOT_FOUND") && filename.startsWith("file://")) {
worker = realRequire(decodeURIComponent(filename.replace("file://", "")));
} else if (error.code === void 0 || error.code === "ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING") {
try {
worker = realRequire(decodeURIComponent(filename.replace(process.platform === "win32" ? "file:///" : "file://", "")));
} catch {
throw error;
}
} else {
throw error;
}
}
if (typeof worker === "object") worker = worker.default;
if (typeof worker === "object") worker = worker.default;
destination = await worker(workerData.workerData);
destination.on("error", function(err) {
Atomics.store(state, WRITE_INDEX, -2);
Atomics.notify(state, WRITE_INDEX);
Atomics.store(state, READ_INDEX, -2);
Atomics.notify(state, READ_INDEX);
parentPort.postMessage({
code: "ERROR",
err
});
});
destination.on("close", function() {
const end = Atomics.load(state, WRITE_INDEX);
Atomics.store(state, READ_INDEX, end);
Atomics.notify(state, READ_INDEX);
setImmediate(() => {
process.exit(0);
});
});
}
start().then(function() {
parentPort.postMessage({
code: "READY"
});
process.nextTick(run);
});
function run() {
const current = Atomics.load(state, READ_INDEX);
const end = Atomics.load(state, WRITE_INDEX);
if (end === current) {
if (end === data.length) {
waitDiff(state, READ_INDEX, end, Infinity, run);
} else {
waitDiff(state, WRITE_INDEX, end, Infinity, run);
}
return;
}
if (end === -1) {
destination.end();
return;
}
const toWrite = data.toString("utf8", current, end);
const res = destination.write(toWrite);
if (res) {
Atomics.store(state, READ_INDEX, end);
Atomics.notify(state, READ_INDEX);
setImmediate(run);
} else {
destination.once("drain", function() {
Atomics.store(state, READ_INDEX, end);
Atomics.notify(state, READ_INDEX);
run();
});
}
}
process.on("unhandledRejection", function(err) {
parentPort.postMessage({
code: "ERROR",
err
});
process.exit(1);
});
process.on("uncaughtException", function(err) {
parentPort.postMessage({
code: "ERROR",
err
});
process.exit(1);
});
process.once("exit", (exitCode) => {
if (exitCode !== 0) {
process.exit(exitCode);
return;
}
if (destination?.writableNeedDrain && !destination?.writableEnded) {
parentPort.postMessage({
code: "WARNING",
err: new Error("ThreadStream: process exited before destination stream was drained. this may indicate that the destination stream try to write to a another missing stream")
});
}
process.exit(0);
});
|