@linxiraos/pi-utils 1.1.7 → 1.1.9
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/CHANGELOG.md +2 -8
- package/README.md +18 -18
- package/package.json +57 -63
- package/src/acp/connection.ts +6 -10
- package/src/ar/entries.ts +1 -1
- package/src/ar/sevenzip.ts +17 -2
- package/src/async.ts +25 -4
- package/src/browsers.ts +11 -5
- package/src/dirs.ts +15 -10
- package/src/dom/core.ts +4 -4
- package/src/env.ts +12 -0
- package/src/fetch-retry.ts +36 -1
- package/src/format.ts +1 -1
- package/src/frontmatter.ts +1 -0
- package/src/incoming-json.ts +856 -0
- package/src/index.ts +2 -0
- package/src/json-lexer.ts +413 -0
- package/src/json-parse.ts +93 -350
- package/src/marked/core.ts +8 -1
- package/src/materialize-string.ts +10 -0
- package/src/path.ts +14 -0
- package/src/postmortem.ts +33 -6
- package/src/prompt.ts +1 -0
- package/src/ring.ts +1 -0
- package/src/temp.ts +16 -4
- package/src/template.ts +2 -2
- package/src/tls-fetch.ts +2 -16
- package/src/turndown/html.ts +1 -1
- package/src/vterm/query-responder.ts +76 -0
- package/src/vterm.ts +1 -0
- package/THIRD-PARTY-NOTICES.txt +0 -22909
- package/dist/types/abortable.d.ts +0 -32
- package/dist/types/acp/connection.d.ts +0 -118
- package/dist/types/acp/protocol.d.ts +0 -526
- package/dist/types/acp/schema.d.ts +0 -41
- package/dist/types/acp/stream.d.ts +0 -8
- package/dist/types/acp/transport.d.ts +0 -88
- package/dist/types/acp.d.ts +0 -6
- package/dist/types/ar/arj.d.ts +0 -5
- package/dist/types/ar/asar.d.ts +0 -7
- package/dist/types/ar/bytes.d.ts +0 -20
- package/dist/types/ar/cab.d.ts +0 -5
- package/dist/types/ar/checksums.d.ts +0 -10
- package/dist/types/ar/codecs/bzip2.d.ts +0 -4
- package/dist/types/ar/codecs/gzip.d.ts +0 -6
- package/dist/types/ar/codecs/lzma.d.ts +0 -6
- package/dist/types/ar/codecs/lzw.d.ts +0 -4
- package/dist/types/ar/codecs/lzx.d.ts +0 -7
- package/dist/types/ar/codecs/xz.d.ts +0 -4
- package/dist/types/ar/codecs/zstd.d.ts +0 -6
- package/dist/types/ar/cpio.d.ts +0 -7
- package/dist/types/ar/deb.d.ts +0 -5
- package/dist/types/ar/entries.d.ts +0 -22
- package/dist/types/ar/error.d.ts +0 -8
- package/dist/types/ar/index.d.ts +0 -11
- package/dist/types/ar/iso.d.ts +0 -5
- package/dist/types/ar/limits.d.ts +0 -33
- package/dist/types/ar/lzh.d.ts +0 -7
- package/dist/types/ar/open.d.ts +0 -45
- package/dist/types/ar/paths.d.ts +0 -18
- package/dist/types/ar/rar/rar4-decoder.d.ts +0 -6
- package/dist/types/ar/rar/rar5-decoder.d.ts +0 -6
- package/dist/types/ar/rar.d.ts +0 -5
- package/dist/types/ar/reader.d.ts +0 -28
- package/dist/types/ar/registry.d.ts +0 -17
- package/dist/types/ar/rpm.d.ts +0 -5
- package/dist/types/ar/sevenzip/decode.d.ts +0 -33
- package/dist/types/ar/sevenzip.d.ts +0 -5
- package/dist/types/ar/source.d.ts +0 -54
- package/dist/types/ar/tar.d.ts +0 -9
- package/dist/types/ar/types.d.ts +0 -99
- package/dist/types/ar/unix-ar.d.ts +0 -7
- package/dist/types/ar/write.d.ts +0 -10
- package/dist/types/ar/zip.d.ts +0 -10
- package/dist/types/async.d.ts +0 -22
- package/dist/types/binary.d.ts +0 -23
- package/dist/types/browsers.d.ts +0 -68
- package/dist/types/chalk.d.ts +0 -125
- package/dist/types/cli.d.ts +0 -134
- package/dist/types/color.d.ts +0 -136
- package/dist/types/dates.d.ts +0 -7
- package/dist/types/dirs.d.ts +0 -325
- package/dist/types/docx/converter.d.ts +0 -46
- package/dist/types/docx/xml.d.ts +0 -26
- package/dist/types/docx.d.ts +0 -11
- package/dist/types/dom/core.d.ts +0 -431
- package/dist/types/dom/parser.d.ts +0 -7
- package/dist/types/dom/selector.d.ts +0 -5
- package/dist/types/dom.d.ts +0 -5
- package/dist/types/env.d.ts +0 -124
- package/dist/types/fetch-retry.d.ts +0 -96
- package/dist/types/file-lock.d.ts +0 -23
- package/dist/types/format.d.ts +0 -37
- package/dist/types/frontmatter.d.ts +0 -46
- package/dist/types/fs-error.d.ts +0 -31
- package/dist/types/glob.d.ts +0 -28
- package/dist/types/headers.d.ts +0 -34
- package/dist/types/index.d.ts +0 -41
- package/dist/types/json-parse.d.ts +0 -83
- package/dist/types/json.d.ts +0 -20
- package/dist/types/logger/rotating-file.d.ts +0 -18
- package/dist/types/logger.d.ts +0 -96
- package/dist/types/loop-phase.d.ts +0 -10
- package/dist/types/lru.d.ts +0 -46
- package/dist/types/marked/core.d.ts +0 -445
- package/dist/types/marked.d.ts +0 -2
- package/dist/types/math-delimiters.d.ts +0 -45
- package/dist/types/mermaid-ascii.d.ts +0 -11
- package/dist/types/mime.d.ts +0 -29
- package/dist/types/module-timer.d.ts +0 -1
- package/dist/types/path-tree.d.ts +0 -76
- package/dist/types/path.d.ts +0 -2
- package/dist/types/peek-file.d.ts +0 -29
- package/dist/types/postmortem.d.ts +0 -174
- package/dist/types/process-name.d.ts +0 -7
- package/dist/types/procmgr.d.ts +0 -74
- package/dist/types/prompt.d.ts +0 -18
- package/dist/types/ptree.d.ts +0 -124
- package/dist/types/readability/readability.d.ts +0 -9
- package/dist/types/readability/readerable.d.ts +0 -10
- package/dist/types/readability/types.d.ts +0 -70
- package/dist/types/readability.d.ts +0 -4
- package/dist/types/ring.d.ts +0 -93
- package/dist/types/runtime-install.d.ts +0 -85
- package/dist/types/sanitize-text.d.ts +0 -29
- package/dist/types/snowflake.d.ts +0 -25
- package/dist/types/sqlite.d.ts +0 -26
- package/dist/types/stderr-guard.d.ts +0 -22
- package/dist/types/stream.d.ts +0 -75
- package/dist/types/tab-spacing.d.ts +0 -24
- package/dist/types/temp.d.ts +0 -17
- package/dist/types/template.d.ts +0 -62
- package/dist/types/timing-buffer.d.ts +0 -22
- package/dist/types/tls-fetch.d.ts +0 -37
- package/dist/types/turndown/gfm.d.ts +0 -11
- package/dist/types/turndown/html.d.ts +0 -5
- package/dist/types/turndown/service.d.ts +0 -21
- package/dist/types/turndown/types.d.ts +0 -70
- package/dist/types/turndown.d.ts +0 -4
- package/dist/types/type-guards.d.ts +0 -5
- package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +0 -41
- package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +0 -89
- package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +0 -12
- package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +0 -66
- package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +0 -48
- package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +0 -43
- package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +0 -56
- package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +0 -65
- package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +0 -27
- package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +0 -17
- package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +0 -34
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +0 -26
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +0 -31
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +0 -59
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +0 -17
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +0 -30
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +0 -55
- package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +0 -206
- package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +0 -51
- package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +0 -2
- package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/class/types.d.ts +0 -102
- package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/er/types.d.ts +0 -76
- package/dist/types/vendor/mermaid-ascii/index.d.ts +0 -1
- package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +0 -9
- package/dist/types/vendor/mermaid-ascii/parser.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +0 -130
- package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +0 -23
- package/dist/types/vendor/mermaid-ascii/types.d.ts +0 -114
- package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +0 -25
- package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +0 -145
- package/dist/types/version.d.ts +0 -18
- package/dist/types/vterm/buffer.d.ts +0 -99
- package/dist/types/vterm/terminal.d.ts +0 -44
- package/dist/types/vterm.d.ts +0 -8
- package/dist/types/which.d.ts +0 -37
- package/dist/types/worker-host.d.ts +0 -51
- package/dist/types/xml.d.ts +0 -31
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cleanup and postmortem handler utilities.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a system for registering and running cleanup callbacks
|
|
5
|
-
* in response to process exit, signals, or fatal exceptions. It is intended to
|
|
6
|
-
* allow reliably releasing resources or shutting down subprocesses, files, sockets, etc.
|
|
7
|
-
*/
|
|
8
|
-
export declare enum Reason {
|
|
9
|
-
PRE_EXIT = "pre_exit",// Pre-exit phase (not used by default)
|
|
10
|
-
EXIT = "exit",// Normal process exit
|
|
11
|
-
SIGINT = "sigint",// Ctrl-C or SIGINT
|
|
12
|
-
SIGTERM = "sigterm",// SIGTERM
|
|
13
|
-
SIGHUP = "sighup",// SIGHUP
|
|
14
|
-
UNCAUGHT_EXCEPTION = "uncaught_exception",// Fatal exception
|
|
15
|
-
UNHANDLED_REJECTION = "unhandled_rejection",// Unhandled promise rejection
|
|
16
|
-
MANUAL = "manual"
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Symbol stamped by the extension-load guard onto the throwing replacement it
|
|
20
|
-
* installs over `process.exit` / `process.reallyExit`, carrying the native
|
|
21
|
-
* primitive that replacement shadows.
|
|
22
|
-
*
|
|
23
|
-
* Host-owned shutdown ({@link exitProcess}) reads through it so a signal that
|
|
24
|
-
* lands while the guard is active still terminates the process (#6488), while
|
|
25
|
-
* a signal that lands after the guard has restored the native exit also
|
|
26
|
-
* terminates cleanly (#7393). `Symbol.for` so it survives duplicate module
|
|
27
|
-
* instances across bundles/realms.
|
|
28
|
-
*/
|
|
29
|
-
export declare const NATIVE_PROCESS_EXIT: unique symbol;
|
|
30
|
-
/** User-facing command printed before fatal cleanup so interrupted work can be resumed. */
|
|
31
|
-
export interface FatalRecoveryHint {
|
|
32
|
-
/** Stable label identifying the recoverable session or process. */
|
|
33
|
-
label: string;
|
|
34
|
-
/** Complete shell command the user can execute to resume the interrupted work. */
|
|
35
|
-
command: string;
|
|
36
|
-
}
|
|
37
|
-
type FatalRecoveryHintProvider = () => FatalRecoveryHint | undefined;
|
|
38
|
-
/** Origin of an EPIPE raised by a process communication channel. */
|
|
39
|
-
export type BrokenPipeSource = "ipc-send" | "stdio-write";
|
|
40
|
-
/**
|
|
41
|
-
* Classify EPIPE errors from worker IPC and stdio without treating unrelated
|
|
42
|
-
* broken pipes as globally recoverable.
|
|
43
|
-
*/
|
|
44
|
-
export declare function classifyBrokenPipe(err: Error): BrokenPipeSource | undefined;
|
|
45
|
-
/** Whether an EPIPE came from an IPC `send()` to an optional worker. */
|
|
46
|
-
export declare function isIpcSendEpipe(err: Error): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Whether an uncaught error is Bun's asynchronous `ERR_SOCKET_CLOSED` thrown
|
|
49
|
-
* from inside `node:net` internals with no application frames on the stack.
|
|
50
|
-
*
|
|
51
|
-
* Bun ≥1.4 can fire the close callback of an already-closed `node:net` socket
|
|
52
|
-
* on a fresh stack; the throw bypasses every callsite try/catch and surfaces
|
|
53
|
-
* here as a process-level uncaughtException. Closing an already-closed socket
|
|
54
|
-
* is inherently a no-op — the socket owner's own `error`/`close` handlers
|
|
55
|
-
* still drive recovery — so tearing the session down for it is pure loss.
|
|
56
|
-
* Only frameless internal stacks qualify: an `ERR_SOCKET_CLOSED` raised
|
|
57
|
-
* through application code keeps the fatal path.
|
|
58
|
-
*/
|
|
59
|
-
export declare function isInternalSocketClosedError(err: unknown): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Detect Bun's advanced-serialization (structured-clone) IPC decode failure.
|
|
62
|
-
*
|
|
63
|
-
* When a worker subprocess spawned with `serialization: "advanced"` sends a
|
|
64
|
-
* malformed or truncated frame, Bun raises the decode failure as a
|
|
65
|
-
* process-level `uncaughtException` in the *parent* rather than routing it to
|
|
66
|
-
* the channel's `ipc()` callback (oven-sh/bun#37287). The error is a bare
|
|
67
|
-
* `TypeError: Unable to deserialize data.` whose only own property is `message`
|
|
68
|
-
* — it carries no `code`, no `syscall`, and no `stack`. Matching all four traits
|
|
69
|
-
* keeps unrelated application `TypeError`s (which always carry a populated
|
|
70
|
-
* multi-frame stack) on the fatal path, so a genuine bug is never silently
|
|
71
|
-
* swallowed.
|
|
72
|
-
*
|
|
73
|
-
* Every advanced-serialization channel in this process is an optional worker
|
|
74
|
-
* subsystem (TTS, STT, tiny-title, mnemopi embeddings, JS eval), so one
|
|
75
|
-
* worker's bad frame must fault only that worker — via its own `onExit`/error
|
|
76
|
-
* path — never tear down the whole session. Callers log-and-continue instead of
|
|
77
|
-
* taking the fatal path. Mirrors {@link classifyBrokenPipe} for the send side
|
|
78
|
-
* (#2997, #9158).
|
|
79
|
-
*/
|
|
80
|
-
export declare function isWorkerIpcDeserializeError(err: unknown): boolean;
|
|
81
|
-
/**
|
|
82
|
-
* Register a fault/recycle callback for an active advanced-serialization worker
|
|
83
|
-
* IPC channel.
|
|
84
|
-
*
|
|
85
|
-
* Bun surfaces a malformed frame as a process-global `uncaughtException`
|
|
86
|
-
* ({@link isWorkerIpcDeserializeError}) with no way to attribute it to a
|
|
87
|
-
* specific channel, so when one fires every registered handler is invoked to
|
|
88
|
-
* conservatively fault its worker — reject in-flight requests and recycle the
|
|
89
|
-
* subprocess — instead of leaving pending work to await forever. Returns an
|
|
90
|
-
* unregister function; callers MUST unregister when the worker exits.
|
|
91
|
-
*/
|
|
92
|
-
export declare function registerWorkerIpcFaultHandler(handler: (err: Error) => void): () => void;
|
|
93
|
-
/**
|
|
94
|
-
* Treat unhandled stdout EPIPE rejections as a graceful peer disconnect.
|
|
95
|
-
*
|
|
96
|
-
* Stdio protocol servers call this for their process lifetime so a closed
|
|
97
|
-
* client pipe runs registered cleanup callbacks instead of the fatal path.
|
|
98
|
-
* The returned callback removes the registration.
|
|
99
|
-
*/
|
|
100
|
-
export declare function registerStdioDisconnectHandling(): () => void;
|
|
101
|
-
/**
|
|
102
|
-
* Mark an error as expected cleanup fallout so the global fatal handlers
|
|
103
|
-
* downgrade it to a log line instead of tearing down the process. Use for
|
|
104
|
-
* abort reasons fired by routine resource teardown (browser run end, tab
|
|
105
|
-
* close) whose rejections may surface on fire-and-forget promises with no
|
|
106
|
-
* consumer. Returns the same error for inline use at the `abort()` callsite.
|
|
107
|
-
*/
|
|
108
|
-
export declare function markExpectedCleanupError<T extends object>(reason: T): T;
|
|
109
|
-
/**
|
|
110
|
-
* Whether `reason` (or any object in its bounded `cause` chain) was explicitly
|
|
111
|
-
* marked via {@link markExpectedCleanupError}. Runtime error names and codes
|
|
112
|
-
* are intentionally insufficient: unmarked `AbortError` and socket failures
|
|
113
|
-
* can originate from application code and must remain fatal when unhandled.
|
|
114
|
-
*/
|
|
115
|
-
export declare function isExpectedCleanupError(reason: unknown): boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Register an interceptor consulted before an unhandled rejection tears the
|
|
118
|
-
* process down. A consuming interceptor owns reporting and keeps the process alive.
|
|
119
|
-
*/
|
|
120
|
-
export declare function interceptUnhandledRejections(interceptor: (reason: unknown) => boolean): () => void;
|
|
121
|
-
/**
|
|
122
|
-
* Register a synchronous recovery command to print when the process exits
|
|
123
|
-
* through an uncaught exception or unhandled rejection.
|
|
124
|
-
*/
|
|
125
|
-
export declare function registerFatalRecoveryHint(provider: FatalRecoveryHintProvider): () => void;
|
|
126
|
-
/** Controls when a registered cleanup callback participates in cleanup passes. */
|
|
127
|
-
export interface CleanupRegistrationOptions {
|
|
128
|
-
/**
|
|
129
|
-
* Run only on a real exit, never during a manual keep-alive cleanup.
|
|
130
|
-
* The registration remains armed when a keep-alive pass skips it.
|
|
131
|
-
*/
|
|
132
|
-
exitOnly?: boolean;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Registers a cleanup callback for shutdown, signals, fatal errors, and
|
|
136
|
-
* repeatable manual cleanup passes.
|
|
137
|
-
*
|
|
138
|
-
* Registrations persist across keep-alive {@link cleanup} passes and run at
|
|
139
|
-
* most once per pass. Set `exitOnly` for resources the continuing process still
|
|
140
|
-
* holds (open databases, cached handles): keep-alive passes skip the callback
|
|
141
|
-
* without consuming its registration, while the eventual real exit runs it.
|
|
142
|
-
*
|
|
143
|
-
* A callback registered during a running keep-alive pass joins future passes;
|
|
144
|
-
* normal callbacks also run immediately for the current pass. Registrations
|
|
145
|
-
* made during a real exit run immediately.
|
|
146
|
-
*
|
|
147
|
-
* Returns a function that permanently cancels the registration.
|
|
148
|
-
*/
|
|
149
|
-
export declare function register(id: string, callback: (reason: Reason) => void | Promise<void>, options?: CleanupRegistrationOptions): () => void;
|
|
150
|
-
/**
|
|
151
|
-
* Runs all cleanup callbacks without exiting, then re-arms the system so
|
|
152
|
-
* resources opened afterwards are still cleaned at the eventual real exit.
|
|
153
|
-
* Use this in workers or when you need to clean up but continue execution.
|
|
154
|
-
*/
|
|
155
|
-
export declare function cleanup(): Promise<void>;
|
|
156
|
-
/** Controls how manual process shutdown handles terminal output. */
|
|
157
|
-
export interface QuitOptions {
|
|
158
|
-
/** Wait for buffered stdout before exiting; disable after the terminal has disconnected. */
|
|
159
|
-
drainStdout?: boolean;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Waits (bounded) for buffered stdout to reach the terminal. Used before
|
|
163
|
-
* process exit and before an exec-replace, where unflushed output would be
|
|
164
|
-
* lost with the process image.
|
|
165
|
-
*/
|
|
166
|
-
export declare function drainStdout(): Promise<void>;
|
|
167
|
-
/**
|
|
168
|
-
* Runs all cleanup callbacks and exits through the current `process.exit`.
|
|
169
|
-
*
|
|
170
|
-
* In main thread: waits for stdout drain unless disabled, then calls `process.exit()`.
|
|
171
|
-
* In workers: runs cleanup only (process.exit would kill entire process).
|
|
172
|
-
*/
|
|
173
|
-
export declare function quit(code?: number, options?: QuitOptions): Promise<void>;
|
|
174
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set both the JS `process.title` and — on Linux — the kernel `comm` name.
|
|
3
|
-
*
|
|
4
|
-
* Never throws: `bun:ffi` unavailability or a failed syscall degrades silently
|
|
5
|
-
* to the `process.title`-only behavior, so it is safe to call at startup.
|
|
6
|
-
*/
|
|
7
|
-
export declare function setProcessName(name: string): void;
|
package/dist/types/procmgr.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { Subprocess } from "bun";
|
|
2
|
-
export interface ShellConfig {
|
|
3
|
-
shell: string;
|
|
4
|
-
args: string[];
|
|
5
|
-
env: Record<string, string>;
|
|
6
|
-
prefix: string | undefined;
|
|
7
|
-
}
|
|
8
|
-
/** Identifies the settings source users should edit when shell resolution fails. */
|
|
9
|
-
export interface ShellConfigOptions {
|
|
10
|
-
/** File path or runtime layer that supplied the active shell setting. */
|
|
11
|
-
configSource?: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Check if a shell binary is executable.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isExecutable(path: string): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Get shell args for the resolved shell.
|
|
19
|
-
* cmd.exe takes `/c`; PowerShell (powershell.exe / pwsh) takes
|
|
20
|
-
* `-NoLogo -Command`, with `-NoProfile` when PI_BASH_NO_LOGIN /
|
|
21
|
-
* CLAUDE_BASH_NO_LOGIN is set (profile scripts are PowerShell's login-shell
|
|
22
|
-
* analog); POSIX shells take `-c`, with `-l` unless the same env is set.
|
|
23
|
-
*
|
|
24
|
-
* Exported for tests; `env` overrides the process env gate.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getShellArgs(shell: string, env?: Record<string, string | undefined>): string[];
|
|
27
|
-
/** Whether the shell is Windows cmd.exe (spawn paths must use `/c`, not `-c`). */
|
|
28
|
-
export declare function isCmdShell(shell: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether the shell is Windows PowerShell or PowerShell Core (pwsh). Spawn
|
|
31
|
-
* paths must use `-Command`: passing the POSIX `-l -c` pair makes PowerShell
|
|
32
|
-
* parse `-l` as the command and fail with `The term '-l' is not recognized`.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isPowerShell(shell: string): boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Resolve a basic shell (bash or sh) as fallback.
|
|
37
|
-
*/
|
|
38
|
-
export declare function resolveBasicShell(): string | undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Resolve the external shell to advertise on Windows.
|
|
41
|
-
*
|
|
42
|
-
* A host bash is OPTIONAL: bash tool commands always execute in the embedded
|
|
43
|
-
* brush-core shell. The resolved binary only serves the spawn-a-shell paths
|
|
44
|
-
* (interactive PTY sessions, ACP client terminals, SHELL env), so this
|
|
45
|
-
* prefers a real Git Bash when one exists and otherwise falls back to
|
|
46
|
-
* cmd.exe — it never fails.
|
|
47
|
-
*
|
|
48
|
-
* Search order:
|
|
49
|
-
* 1. Git for Windows install roots (machine + per-user installers)
|
|
50
|
-
* 2. scoop installs — scoop's git manifest sets GIT_INSTALL_ROOT and shims
|
|
51
|
-
* sh.exe/git.exe but never bash.exe, so PATH lookup alone misses it
|
|
52
|
-
* 3. bash.exe on PATH (Cygwin, MSYS2, ...)
|
|
53
|
-
* 4. sh.exe on PATH (Git for Windows' sh.exe is bash; prefer a sibling
|
|
54
|
-
* bash.exe when present)
|
|
55
|
-
* 5. cmd.exe from ComSpec
|
|
56
|
-
*
|
|
57
|
-
* Exported for tests; `env` overrides Bun.env-based discovery.
|
|
58
|
-
*/
|
|
59
|
-
export declare function resolveWindowsShell(env?: Record<string, string | undefined>): string;
|
|
60
|
-
/**
|
|
61
|
-
* Get shell configuration based on platform.
|
|
62
|
-
* Resolution order:
|
|
63
|
-
* 1. User-specified shellPath from the active settings source
|
|
64
|
-
* 2. On Windows: Git Bash / bash / sh discovery, then cmd.exe (see
|
|
65
|
-
* {@link resolveWindowsShell}) — never fails
|
|
66
|
-
* 3. On Unix: $SHELL if bash/zsh, then fallback paths
|
|
67
|
-
* 4. Fallback: sh
|
|
68
|
-
*/
|
|
69
|
-
export declare function getShellConfig(customShellPath?: string, options?: ShellConfigOptions): ShellConfig;
|
|
70
|
-
/**
|
|
71
|
-
* Check if a process is running.
|
|
72
|
-
*/
|
|
73
|
-
export declare function isPidRunning(pid: number | Subprocess): boolean;
|
|
74
|
-
export declare function onProcessExit(proc: Subprocess | number, abortSignal?: AbortSignal): Promise<boolean>;
|
package/dist/types/prompt.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { HelperDelegate, Template } from "./template.js";
|
|
2
|
-
export type { HelperDelegate, HelperOptions, Template, TemplateDelegate } from "./template.js";
|
|
3
|
-
export type PromptRenderPhase = "pre-render" | "post-render";
|
|
4
|
-
export interface PromptFormatOptions {
|
|
5
|
-
renderPhase?: PromptRenderPhase;
|
|
6
|
-
replaceAsciiSymbols?: boolean;
|
|
7
|
-
normalizeRfc2119?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function format(content: string, options?: PromptFormatOptions): string;
|
|
10
|
-
export interface TemplateContext extends Record<string, unknown> {
|
|
11
|
-
args?: string[];
|
|
12
|
-
ARGUMENTS?: string;
|
|
13
|
-
arguments?: string;
|
|
14
|
-
}
|
|
15
|
-
export declare function registerHelper(name: string, fn: HelperDelegate): void;
|
|
16
|
-
export declare function registerPartial(name: string, fn: Template): void;
|
|
17
|
-
export declare function compile(template: string): (context: TemplateContext) => string;
|
|
18
|
-
export declare function render(template: string, context?: TemplateContext): string;
|
package/dist/types/ptree.d.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process tree management utilities for Bun subprocesses.
|
|
3
|
-
*
|
|
4
|
-
* - Track managed child processes for cleanup on shutdown (postmortem).
|
|
5
|
-
* - Drain stdout/stderr to avoid subprocess pipe deadlocks.
|
|
6
|
-
* - Cross-platform tree kill for process groups (Windows taskkill, Unix -pid).
|
|
7
|
-
* - Convenience helpers: captureText / execText, AbortSignal, timeouts.
|
|
8
|
-
*/
|
|
9
|
-
import type { Spawn, Subprocess } from "bun";
|
|
10
|
-
type InMask = "pipe" | "ignore" | Buffer | Uint8Array | null;
|
|
11
|
-
/** A Bun subprocess with stdout/stderr always piped (stdin may vary). */
|
|
12
|
-
type PipedSubprocess<In extends InMask = InMask> = Subprocess<In, "pipe", "pipe">;
|
|
13
|
-
/**
|
|
14
|
-
* Build the Linux child-subreaper entrypoint.
|
|
15
|
-
*
|
|
16
|
-
* @internal Exported so tests can force a missing first libc soname and verify
|
|
17
|
-
* the loader continues to the next candidate.
|
|
18
|
-
*/
|
|
19
|
-
export declare function createLinuxSubreaperScript(libcCandidates?: readonly string[]): string;
|
|
20
|
-
/**
|
|
21
|
-
* Base for all exceptions representing child process nonzero exit, killed, or
|
|
22
|
-
* cancellation.
|
|
23
|
-
*/
|
|
24
|
-
export declare abstract class Exception extends Error {
|
|
25
|
-
readonly exitCode: number;
|
|
26
|
-
readonly stderr: string;
|
|
27
|
-
constructor(message: string, exitCode: number, stderr: string);
|
|
28
|
-
abstract readonly aborted: boolean;
|
|
29
|
-
}
|
|
30
|
-
/** Exception for nonzero exit codes (not cancellation). */
|
|
31
|
-
export declare class NonZeroExitError extends Exception {
|
|
32
|
-
static readonly MAX_TRACE: number;
|
|
33
|
-
constructor(exitCode: number, stderr: string);
|
|
34
|
-
get aborted(): boolean;
|
|
35
|
-
}
|
|
36
|
-
/** Exception for explicit process abortion (via signal). */
|
|
37
|
-
export declare class AbortError extends Exception {
|
|
38
|
-
readonly reason: unknown;
|
|
39
|
-
constructor(reason: unknown, stderr: string);
|
|
40
|
-
get aborted(): boolean;
|
|
41
|
-
}
|
|
42
|
-
/** Exception for process timeout. */
|
|
43
|
-
export declare class TimeoutError extends AbortError {
|
|
44
|
-
constructor(timeout: number, stderr: string);
|
|
45
|
-
}
|
|
46
|
-
/** Options for waiting for process exit and capturing output. */
|
|
47
|
-
export interface WaitOptions {
|
|
48
|
-
allowNonZero?: boolean;
|
|
49
|
-
allowAbort?: boolean;
|
|
50
|
-
/** `full` requires upfront capture; `exec` enables it, while direct `spawn` callers pass `stderr: "full"`. */
|
|
51
|
-
stderr?: "full" | "buffer";
|
|
52
|
-
}
|
|
53
|
-
/** Result from wait and exec. */
|
|
54
|
-
export interface ExecResult {
|
|
55
|
-
stdout: string;
|
|
56
|
-
stderr: string;
|
|
57
|
-
exitCode: number | null;
|
|
58
|
-
ok: boolean;
|
|
59
|
-
exitError?: Exception;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* ChildProcess wraps a managed subprocess, capturing stderr tail, providing
|
|
63
|
-
* cross-platform kill/detach logic plus AbortSignal integration.
|
|
64
|
-
*
|
|
65
|
-
* Stdout is exposed directly from the underlying Bun subprocess; consumers
|
|
66
|
-
* must read it (via text(), wait(), etc.) to prevent pipe deadlock.
|
|
67
|
-
* Stderr is eagerly drained into an internal buffer.
|
|
68
|
-
*/
|
|
69
|
-
export declare class ChildProcess<In extends InMask = InMask> {
|
|
70
|
-
#private;
|
|
71
|
-
readonly proc: PipedSubprocess<In>;
|
|
72
|
-
readonly exposeStderr: boolean;
|
|
73
|
-
constructor(proc: PipedSubprocess<In>, exposeStderr: boolean, retainFullStderr?: boolean, terminateGroup?: boolean, hardKillTree?: boolean);
|
|
74
|
-
get pid(): number;
|
|
75
|
-
get exited(): Promise<number>;
|
|
76
|
-
get exitCode(): number | null;
|
|
77
|
-
get exitReason(): Exception | undefined;
|
|
78
|
-
get killed(): boolean;
|
|
79
|
-
get stdin(): Bun.SpawnOptions.WritableToIO<In>;
|
|
80
|
-
/** Raw stdout stream. Must be consumed to prevent pipe deadlock. */
|
|
81
|
-
get stdout(): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
82
|
-
/** Optional stderr stream (only when requested in spawn options). */
|
|
83
|
-
get stderr(): ReadableStream<Uint8Array<ArrayBufferLike>> | undefined;
|
|
84
|
-
get exitedCleanly(): Promise<number>;
|
|
85
|
-
/** Returns the truncated stderr tail (last 32KB). */
|
|
86
|
-
peekStderr(): string;
|
|
87
|
-
nothrow(): this;
|
|
88
|
-
kill(reason?: Exception, gracefulMs?: number): void;
|
|
89
|
-
text(): Promise<string>;
|
|
90
|
-
blob(): Promise<Blob>;
|
|
91
|
-
json(): Promise<unknown>;
|
|
92
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
93
|
-
bytes(): Promise<Uint8Array>;
|
|
94
|
-
wait(opts?: WaitOptions): Promise<ExecResult>;
|
|
95
|
-
attachSignal(signal: AbortSignal): void;
|
|
96
|
-
attachTimeout(ms: number): void;
|
|
97
|
-
[Symbol.dispose](): void;
|
|
98
|
-
}
|
|
99
|
-
/** Options for child spawn. Always pipes stdout/stderr. */
|
|
100
|
-
type ChildSpawnOptions<In extends InMask = InMask> = Omit<Spawn.SpawnOptions<In, "pipe", "pipe">, "stdout" | "stderr" | "detached"> & {
|
|
101
|
-
signal?: AbortSignal;
|
|
102
|
-
detached?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* On Linux, supervise the command from a child subreaper so descendants
|
|
105
|
-
* remain reachable after changing session and reparenting. Other platforms
|
|
106
|
-
* ignore this option. macOS process groups cannot retain a daemonized
|
|
107
|
-
* descendant that creates a new session and reparents to launchd.
|
|
108
|
-
*/
|
|
109
|
-
subreaper?: boolean;
|
|
110
|
-
/** Expose and retain complete stderr for a later `wait({ stderr: "full" })`. */
|
|
111
|
-
stderr?: "full" | null;
|
|
112
|
-
};
|
|
113
|
-
/** Spawn a child process with piped stdout/stderr. */
|
|
114
|
-
export declare function spawn<In extends InMask = InMask>(cmd: string[], opts?: ChildSpawnOptions<In>): ChildProcess<In>;
|
|
115
|
-
/** Options for exec. */
|
|
116
|
-
export interface ExecOptions extends Omit<ChildSpawnOptions, "stderr" | "stdin">, WaitOptions {
|
|
117
|
-
input?: string | Buffer | Uint8Array;
|
|
118
|
-
}
|
|
119
|
-
/** Spawn, wait, and return captured output. */
|
|
120
|
-
export declare function exec(cmd: string[], opts?: ExecOptions): Promise<ExecResult>;
|
|
121
|
-
type SignalValue = AbortSignal | number | null | undefined;
|
|
122
|
-
/** Combine AbortSignals and timeout values into a single signal. */
|
|
123
|
-
export declare function combineSignals(...signals: SignalValue[]): AbortSignal | undefined;
|
|
124
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
|
|
2
|
-
import type { ReadabilityArticle, ReadabilityDocument, ReadabilityOptions } from "./types.js";
|
|
3
|
-
/** Extracts the article body and metadata from a standards-shaped document. */
|
|
4
|
-
export declare class Readability<T = string> {
|
|
5
|
-
#private;
|
|
6
|
-
constructor(document: ReadabilityDocument, options?: ReadabilityOptions<T>);
|
|
7
|
-
/** Runs extraction once; the supplied document is consumed and should not be reused. */
|
|
8
|
-
parse(): ReadabilityArticle<T> | null;
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
|
|
2
|
-
import type { ReadabilityDocument, ReadabilityNode } from "./types.js";
|
|
3
|
-
/** Options for the inexpensive readerability estimate. */
|
|
4
|
-
export interface ReaderableOptions {
|
|
5
|
-
minContentLength?: number;
|
|
6
|
-
minScore?: number;
|
|
7
|
-
visibilityChecker?: (node: ReadabilityNode) => boolean;
|
|
8
|
-
}
|
|
9
|
-
/** Estimates whether a document contains enough prose for article extraction. */
|
|
10
|
-
export declare function isProbablyReaderable(document: ReadabilityDocument, options?: ReaderableOptions | ((node: ReadabilityNode) => boolean)): boolean;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
|
|
2
|
-
/** Minimal standards-shaped DOM node accepted by the readability extractor. */
|
|
3
|
-
export interface ReadabilityNode {
|
|
4
|
-
readonly nodeType: number;
|
|
5
|
-
readonly nodeName: string;
|
|
6
|
-
readonly tagName?: string;
|
|
7
|
-
readonly ownerDocument?: ReadabilityDocument | null;
|
|
8
|
-
parentNode: ReadabilityNode | null;
|
|
9
|
-
readonly children?: ArrayLike<ReadabilityElement>;
|
|
10
|
-
readonly childNodes: ArrayLike<ReadabilityNode>;
|
|
11
|
-
readonly firstChild: ReadabilityNode | null;
|
|
12
|
-
readonly textContent: string | null;
|
|
13
|
-
appendChild(node: ReadabilityNode): ReadabilityNode;
|
|
14
|
-
cloneNode(deep?: boolean): ReadabilityNode;
|
|
15
|
-
remove(): void;
|
|
16
|
-
}
|
|
17
|
-
/** Minimal standards-shaped DOM element accepted by the readability extractor. */
|
|
18
|
-
export interface ReadabilityElement extends ReadabilityNode {
|
|
19
|
-
readonly children: ArrayLike<ReadabilityElement>;
|
|
20
|
-
readonly tagName: string;
|
|
21
|
-
id: string;
|
|
22
|
-
className: string;
|
|
23
|
-
innerHTML: string;
|
|
24
|
-
readonly attributes: ArrayLike<{
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly value: string;
|
|
27
|
-
}>;
|
|
28
|
-
getAttribute(name: string): string | null;
|
|
29
|
-
hasAttribute(name: string): boolean;
|
|
30
|
-
setAttribute(name: string, value: string): void;
|
|
31
|
-
removeAttribute(name: string): void;
|
|
32
|
-
getElementsByTagName(name: string): ArrayLike<ReadabilityElement>;
|
|
33
|
-
querySelector(selector: string): ReadabilityElement | null;
|
|
34
|
-
querySelectorAll(selector: string): ArrayLike<ReadabilityElement>;
|
|
35
|
-
}
|
|
36
|
-
/** Minimal standards-shaped document accepted by the readability extractor. */
|
|
37
|
-
export interface ReadabilityDocument extends ReadabilityNode {
|
|
38
|
-
title: string;
|
|
39
|
-
readonly body: ReadabilityElement | null;
|
|
40
|
-
readonly documentElement: ReadabilityElement | null;
|
|
41
|
-
createElement(name: string): ReadabilityElement;
|
|
42
|
-
getElementsByTagName(name: string): ArrayLike<ReadabilityElement>;
|
|
43
|
-
querySelector(selector: string): ReadabilityElement | null;
|
|
44
|
-
querySelectorAll(selector: string): ArrayLike<ReadabilityElement>;
|
|
45
|
-
}
|
|
46
|
-
/** Configuration for article extraction. */
|
|
47
|
-
export interface ReadabilityOptions<T = string> {
|
|
48
|
-
debug?: boolean;
|
|
49
|
-
maxElemsToParse?: number;
|
|
50
|
-
nbTopCandidates?: number;
|
|
51
|
-
charThreshold?: number;
|
|
52
|
-
classesToPreserve?: string[];
|
|
53
|
-
keepClasses?: boolean;
|
|
54
|
-
serializer?: (node: ReadabilityNode) => T;
|
|
55
|
-
disableJSONLD?: boolean;
|
|
56
|
-
allowedVideoRegex?: RegExp;
|
|
57
|
-
}
|
|
58
|
-
/** Extracted article and metadata. */
|
|
59
|
-
export interface ReadabilityArticle<T = string> {
|
|
60
|
-
title: string | null | undefined;
|
|
61
|
-
content: T | null | undefined;
|
|
62
|
-
textContent: string | null | undefined;
|
|
63
|
-
length: number | null | undefined;
|
|
64
|
-
excerpt: string | null | undefined;
|
|
65
|
-
byline: string | null | undefined;
|
|
66
|
-
dir: string | null | undefined;
|
|
67
|
-
siteName: string | null | undefined;
|
|
68
|
-
lang: string | null | undefined;
|
|
69
|
-
publishedTime: string | null | undefined;
|
|
70
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
|
|
2
|
-
export { Readability } from "./readability/readability.js";
|
|
3
|
-
export { isProbablyReaderable, type ReaderableOptions } from "./readability/readerable.js";
|
|
4
|
-
export type { ReadabilityArticle, ReadabilityDocument, ReadabilityElement, ReadabilityNode, ReadabilityOptions, } from "./readability/types.js";
|
package/dist/types/ring.d.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A fixed-capacity circular buffer that supports efficient push/pop/shift/unshift operations.
|
|
3
|
-
* When the buffer is full, adding new items overwrites the oldest items (FIFO behavior).
|
|
4
|
-
*
|
|
5
|
-
* @template T The type of elements stored in the buffer.
|
|
6
|
-
*/
|
|
7
|
-
export declare class RingBuffer<T> {
|
|
8
|
-
#private;
|
|
9
|
-
readonly capacity: number;
|
|
10
|
-
/**
|
|
11
|
-
* Creates a new ring buffer with the specified capacity.
|
|
12
|
-
*
|
|
13
|
-
* @param capacity - The maximum number of elements the buffer can hold. Must be positive.
|
|
14
|
-
*/
|
|
15
|
-
constructor(capacity: number);
|
|
16
|
-
/**
|
|
17
|
-
* The number of elements currently in the buffer.
|
|
18
|
-
*/
|
|
19
|
-
get length(): number;
|
|
20
|
-
/**
|
|
21
|
-
* Whether the buffer is at full capacity.
|
|
22
|
-
*/
|
|
23
|
-
get isFull(): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Whether the buffer is empty (contains no elements).
|
|
26
|
-
*/
|
|
27
|
-
get isEmpty(): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Adds an item to the end of the buffer.
|
|
30
|
-
* If the buffer is full, the oldest item is overwritten and returned.
|
|
31
|
-
*
|
|
32
|
-
* @param item - The item to add.
|
|
33
|
-
* @returns The overwritten item if the buffer was full, otherwise `undefined`.
|
|
34
|
-
*/
|
|
35
|
-
push(item: T): T | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Removes and returns the first (oldest) item from the buffer.
|
|
38
|
-
*
|
|
39
|
-
* @returns The removed item, or `undefined` if the buffer is empty.
|
|
40
|
-
*/
|
|
41
|
-
shift(): T | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Removes and returns the last (newest) item from the buffer.
|
|
44
|
-
*
|
|
45
|
-
* @returns The removed item, or `undefined` if the buffer is empty.
|
|
46
|
-
*/
|
|
47
|
-
pop(): T | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Adds an item to the beginning of the buffer.
|
|
50
|
-
* If the buffer is full, the newest item is overwritten and returned.
|
|
51
|
-
*
|
|
52
|
-
* @param item - The item to add.
|
|
53
|
-
* @returns The overwritten item if the buffer was full, otherwise `undefined`.
|
|
54
|
-
*/
|
|
55
|
-
unshift(item: T): T | undefined;
|
|
56
|
-
/**
|
|
57
|
-
* Returns the element at the specified index without removing it.
|
|
58
|
-
* Supports negative indices (e.g., `-1` for the last element).
|
|
59
|
-
*
|
|
60
|
-
* @param index - The zero-based index, or negative index from the end.
|
|
61
|
-
* @returns The element at the index, or `undefined` if the index is out of bounds.
|
|
62
|
-
*/
|
|
63
|
-
at(index: number): T | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* Returns the first (oldest) element without removing it.
|
|
66
|
-
*
|
|
67
|
-
* @returns The first element, or `undefined` if the buffer is empty.
|
|
68
|
-
*/
|
|
69
|
-
peek(): T | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the last (newest) element without removing it.
|
|
72
|
-
*
|
|
73
|
-
* @returns The last element, or `undefined` if the buffer is empty.
|
|
74
|
-
*/
|
|
75
|
-
peekBack(): T | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Removes all elements from the buffer, resetting it to an empty state.
|
|
78
|
-
*/
|
|
79
|
-
clear(): void;
|
|
80
|
-
/**
|
|
81
|
-
* Returns an iterator that yields elements in logical order (oldest to newest).
|
|
82
|
-
* Allows the buffer to be used with `for...of` loops and spread syntax.
|
|
83
|
-
*
|
|
84
|
-
* @yields Elements in FIFO order.
|
|
85
|
-
*/
|
|
86
|
-
[Symbol.iterator](): Iterator<T>;
|
|
87
|
-
/**
|
|
88
|
-
* Creates a new array containing all elements in logical order (oldest to newest).
|
|
89
|
-
*
|
|
90
|
-
* @returns A new array with all buffer elements.
|
|
91
|
-
*/
|
|
92
|
-
toArray(): T[];
|
|
93
|
-
}
|