| import { createRequire as __bannerCrReq } from 'node:module'; |
| import __bannerPath from 'node:path'; |
| import __bannerUrl from 'node:url'; |
|
|
| globalThis.require = __bannerCrReq(import.meta.url); |
| globalThis.__filename = __bannerUrl.fileURLToPath(import.meta.url); |
| globalThis.__dirname = __bannerPath.dirname(globalThis.__filename); |
| |
| var __getOwnPropNames = Object.getOwnPropertyNames; |
| var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { |
| get: (a, b) => (typeof require !== "undefined" ? require : a)[b] |
| }) : x)(function(x) { |
| if (typeof require !== "undefined") return require.apply(this, arguments); |
| throw Error('Dynamic require of "' + x + '" is not supported'); |
| }); |
| var __commonJS = (cb, mod) => function __require2() { |
| return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; |
| }; |
|
|
| |
| var require_src = __commonJS({ |
| "../../node_modules/.pnpm/real-require@0.2.0/node_modules/real-require/src/index.js"(exports, module) { |
| 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); |
| } |
| module.exports = { realImport: realImport2, realRequire: realRequire2 }; |
| } |
| }); |
|
|
| |
| var require_indexes = __commonJS({ |
| "../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/indexes.js"(exports, module) { |
| "use strict"; |
| var WRITE_INDEX2 = 4; |
| var READ_INDEX2 = 8; |
| module.exports = { |
| WRITE_INDEX: WRITE_INDEX2, |
| READ_INDEX: READ_INDEX2 |
| }; |
| } |
| }); |
|
|
| |
| var require_wait = __commonJS({ |
| "../../node_modules/.pnpm/thread-stream@3.1.0/node_modules/thread-stream/lib/wait.js"(exports, module) { |
| "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); |
| } |
| module.exports = { wait, waitDiff: waitDiff2 }; |
| } |
| }); |
|
|
| |
| 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[ 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); |
| }); |
| |
|
|