rearrage_stuff

This commit is contained in:
Kim Ravn Hansen
2025-09-16 11:26:40 +02:00
parent 40e8c5e0ab
commit 3f11ebe6dc
4937 changed files with 1146031 additions and 134 deletions

55
node_modules/sync-child-process/dist/lib/event.d.ts generated vendored Normal file
View File

@@ -0,0 +1,55 @@
/** An event emitted by the child process. */
export type Event = StdoutEvent | StderrEvent | ExitEvent;
/** An event sent from the worker to the host. */
export type InternalEvent = InternalStdoutEvent | InternalStderrEvent | ExitEvent | ErrorEvent;
/** An event indicating that data has been emitted over stdout. */
export interface StdoutEvent {
type: 'stdout';
data: Buffer;
}
/** An event indicating that data has been emitted over stderr. */
export interface StderrEvent {
type: 'stderr';
data: Buffer;
}
/** An event indicating that process has exited. */
export interface ExitEvent {
type: 'exit';
/**
* The exit code. This will be `undefined` if the subprocess was killed via
* signal.
*/
code?: number;
/**
* The signal that caused this process to exit. This will be `undefined` if
* the subprocess exited normally.
*/
signal?: NodeJS.Signals;
}
/**
* The stdout event sent from the worker to the host. The structured clone
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to
* `Uint8Array`s.
*/
export interface InternalStdoutEvent {
type: 'stdout';
data: Buffer | Uint8Array;
}
/**
* The stderr event sent from the worker to the host. The structured clone
* algorithm automatically converts `Buffer`s sent through `MessagePort`s to
* `Uint8Array`s.
*/
export interface InternalStderrEvent {
type: 'stderr';
data: Buffer | Uint8Array;
}
/**
* An error occurred when starting or closing the child process. This is only
* used internally; the host will throw the error rather than returning it to
* the caller.
*/
export interface ErrorEvent {
type: 'error';
error: Error;
}

6
node_modules/sync-child-process/dist/lib/event.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
// Copyright 2021 Google LLC. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=event.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../lib/event.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC"}

52
node_modules/sync-child-process/dist/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import * as stream from 'stream';
import { ExitEvent, StderrEvent, StdoutEvent } from './event';
export { ExitEvent, StderrEvent, StdoutEvent } from './event';
/**
* A child process that runs synchronously while also allowing the user to
* interact with it before it shuts down.
*/
export declare class SyncChildProcess implements Iterator<StderrEvent | StdoutEvent, ExitEvent | undefined> {
/** The port that communicates with the worker thread. */
private readonly port;
/** The worker in which the child process runs. */
private readonly worker;
/** The standard input stream to write to the process. */
readonly stdin: stream.Writable;
/** Creates a new synchronous process running `command` with `args`. */
constructor(command: string, options?: Options);
constructor(command: string, args: string[], options?: Options);
/**
* Blocks until the child process is ready to emit another event, then returns
* that event. This will return an [IteratorReturnResult] with an [ExitEvent]
* once when the process exits. If it's called again after that, it will
* return `{done: true}` without a value.
*
* If there's an error running the child process, this will throw that error.
*/
next(): IteratorResult<StdoutEvent | StderrEvent, ExitEvent | undefined>;
/**
* Sends a signal (`SIGTERM` by default) to the child process.
*
* This has no effect if the process has already exited.
*/
kill(signal?: NodeJS.Signals | number): void;
/** Closes down the worker thread and the stdin stream. */
private close;
}
/**
* A subset of the options for [`child_process.spawn()`].
*
* [`child_process.spawn()`]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
*/
export interface Options {
cwd?: string;
env?: Record<string, string>;
argv0?: string;
uid?: number;
gid?: number;
shell?: boolean | string;
windowsVerbatimArguments?: boolean;
windowsHide?: boolean;
timeout?: number;
killSignal?: string | number;
}

128
node_modules/sync-child-process/dist/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
"use strict";
// Copyright 2021 Google LLC. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SyncChildProcess = void 0;
const fs = require("fs");
const p = require("path");
const stream = require("stream");
const worker_threads_1 = require("worker_threads");
const worker_threads = require("worker_threads");
const sync_message_port_1 = require("sync-message-port");
/** Whether {@link object} can't be transferred between threads, only cloned. */
function isMarkedAsUntransferable(object) {
// TODO: Remove this check when we no longer support Node v20 (after
// 2026-04-30).
return 'isMarkedAsUntransferable' in worker_threads
? // TODO - DefinitelyTyped/DefinitelyTyped#71033: Remove this cast
worker_threads.isMarkedAsUntransferable(object)
: false;
}
/**
* A child process that runs synchronously while also allowing the user to
* interact with it before it shuts down.
*/
class SyncChildProcess {
/** The port that communicates with the worker thread. */
port;
/** The worker in which the child process runs. */
worker;
/** The standard input stream to write to the process. */
stdin;
constructor(command, argsOrOptions, options) {
let args;
if (Array.isArray(argsOrOptions)) {
args = argsOrOptions;
}
else {
args = [];
options = argsOrOptions;
}
const { port1, port2 } = sync_message_port_1.SyncMessagePort.createChannel();
this.port = new sync_message_port_1.SyncMessagePort(port1);
this.worker = spawnWorker(p.join(p.dirname(__filename), 'worker'), {
workerData: { port: port2, command, args, options },
transferList: [port2],
});
// The worker shouldn't emit any errors unless it breaks in development.
this.worker.on('error', console.error);
this.stdin = new stream.Writable({
write: (chunk, encoding, callback) => {
this.port.postMessage({
type: 'stdin',
data: chunk,
}, isMarkedAsUntransferable(chunk.buffer) ? undefined : [chunk.buffer]);
callback();
},
final: () => this.port.postMessage({ type: 'stdinClosed' }),
});
}
/**
* Blocks until the child process is ready to emit another event, then returns
* that event. This will return an [IteratorReturnResult] with an [ExitEvent]
* once when the process exits. If it's called again after that, it will
* return `{done: true}` without a value.
*
* If there's an error running the child process, this will throw that error.
*/
next() {
if (this.stdin.destroyed)
return { done: true, value: undefined };
const message = this.port.receiveMessage();
switch (message.type) {
case 'stdout':
return {
value: { type: 'stdout', data: Buffer.from(message.data.buffer) },
};
case 'stderr':
return {
value: { type: 'stderr', data: Buffer.from(message.data.buffer) },
};
case 'error':
this.close();
throw message.error;
case 'exit':
this.close();
return { done: true, value: message };
}
}
// TODO(nex3): Add a non-blocking `yieldIfReady()` function that returns
// `null` if the worker hasn't queued up an event.
// TODO(nex3): Add a `yieldAsync()` function that returns a `Promise<Event>`.
/**
* Sends a signal (`SIGTERM` by default) to the child process.
*
* This has no effect if the process has already exited.
*/
kill(signal) {
this.port.postMessage({ type: 'kill', signal });
}
/** Closes down the worker thread and the stdin stream. */
close() {
this.port.close();
void this.worker.terminate();
this.stdin.destroy();
}
}
exports.SyncChildProcess = SyncChildProcess;
/**
* Spawns a worker for the given `fileWithoutExtension` in either a JS or TS
* worker, depending on which file exists.
*/
function spawnWorker(fileWithoutExtension, options) {
// The released version always spawns the JS worker. The TS worker is only
// used for development.
const jsFile = fileWithoutExtension + '.js';
if (fs.existsSync(jsFile))
return new worker_threads_1.Worker(jsFile, options);
const tsFile = fileWithoutExtension + '.ts';
if (fs.existsSync(tsFile)) {
return new worker_threads_1.Worker(`
require('ts-node').register();
require(${JSON.stringify(tsFile)});
`, { ...options, eval: true });
}
throw new Error(`Neither "${jsFile}" nor ".ts" exists.`);
}
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,yBAAyB;AACzB,0BAA0B;AAC1B,iCAAiC;AACjC,mDAAqD;AACrD,iDAAiD;AAEjD,yDAAkD;AAMlD,gFAAgF;AAChF,SAAS,wBAAwB,CAAC,MAAe;IAC/C,oEAAoE;IACpE,eAAe;IACf,OAAO,0BAA0B,IAAI,cAAc;QACjD,CAAC,CAAC,iEAAiE;YAChE,cAAc,CAAC,wBAAyD,CACvE,MAAM,CACP;QACH,CAAC,CAAC,KAAK,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,MAAa,gBAAgB;IAG3B,yDAAyD;IACxC,IAAI,CAAkB;IAEvC,kDAAkD;IACjC,MAAM,CAAS;IAEhC,yDAAyD;IAChD,KAAK,CAAkB;IAMhC,YACE,OAAe,EACf,aAAkC,EAClC,O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CAAC;IACvB,CAAC;CACF;AA5GD,4CA4GC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,oBAA4B,EAC5B,OAAsB;IAEtB,0EAA0E;IAC1E,wBAAwB;IACxB,MAAM,MAAM,GAAG,oBAAoB,GAAG,KAAK,CAAC;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,uBAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,oBAAoB,GAAG,KAAK,CAAC;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,uBAAM,CACf;;kBAEY,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;OACjC,EACD,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,IAAI,EAAC,CACzB,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,YAAY,MAAM,qBAAqB,CAAC,CAAC;AAC3D,CAAC"}

1
node_modules/sync-child-process/dist/lib/worker.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

51
node_modules/sync-child-process/dist/lib/worker.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
"use strict";
// Copyright 2021 Google LLC. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
Object.defineProperty(exports, "__esModule", { value: true });
const worker_threads_1 = require("worker_threads");
const child_process_1 = require("child_process");
const assert_1 = require("assert");
const sync_message_port_1 = require("sync-message-port");
const port = new sync_message_port_1.SyncMessagePort(worker_threads_1.workerData.port);
/** A more type-safe way to call `port.postMesage()` */
function emit(event, transferList) {
port.postMessage(event, transferList);
}
const process = (0, child_process_1.spawn)(worker_threads_1.workerData.command, worker_threads_1.workerData.args, worker_threads_1.workerData.options);
port.on('message', message => {
if (message.type === 'stdin') {
process.stdin.write(message.data);
}
else if (message.type === 'stdinClosed') {
process.stdin.end();
}
else {
assert_1.strict.equal(message.type, 'kill');
process.kill(message.signal);
}
});
process.stdout.on('data', data => {
emit({ type: 'stdout', data }, [data.buffer]);
});
process.stderr.on('data', data => {
emit({ type: 'stderr', data }, [data.buffer]);
});
process.on('error', error => {
emit({ type: 'error', error });
process.kill();
worker_threads_1.parentPort.close();
port.close();
});
process.on('exit', (code, signal) => {
if (code !== null) {
emit({ type: 'exit', code });
}
else {
(0, assert_1.strict)(signal);
emit({ type: 'exit', signal });
}
worker_threads_1.parentPort.close();
port.close();
});
//# sourceMappingURL=worker.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../lib/worker.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,mDAKwB;AACxB,iDAA8D;AAC9D,mCAAwC;AAExC,yDAAkD;AAIlD,MAAM,IAAI,GAAG,IAAI,mCAAe,CAAC,2BAAU,CAAC,IAAmB,CAAC,CAAC;AAEjE,uDAAuD;AACvD,SAAS,IAAI,CAAC,KAAoB,EAAE,YAAiC;IACnE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,OAAO,GAAG,IAAA,qBAAK,EACnB,2BAAU,CAAC,OAAiB,EAC5B,2BAAU,CAAC,IAAgB,EAC3B,2BAAU,CAAC,OAA+C,CAC3D,CAAC;AAEF,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE;IAC3B,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAc,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;QAC1C,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,eAAM,CAAC,KAAK,CAAC,O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