🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@opentui/core

Package Overview
Dependencies
Maintainers
3
Versions
301
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentui/core - npm Package Compare versions

Comparing version
0.4.3
to
0.4.4
+19
audio-stream/demuxer.d.ts
import type { AudioStreamMetadata } from "../audio.js";
export type AudioStreamDemuxOutput<M> = {
type: "audio";
data: Uint8Array;
} | {
type: "metadata";
metadata: M | null;
};
export interface AudioStreamDemuxer<M> {
readonly initialMetadata: M | null;
push(chunk: Uint8Array): Iterable<AudioStreamDemuxOutput<M>>;
flush(): Iterable<AudioStreamDemuxOutput<M>>;
abort?(reason: unknown): void;
}
export type AudioStreamDemuxerFactory<M> = () => AudioStreamDemuxer<M>;
export declare function selectAudioStreamDemuxer(options: {
headers: Headers;
metadataEncoding: string;
}): AudioStreamDemuxer<AudioStreamMetadata> | null;
import type { AudioStreamMetadata } from "../../audio.js";
import type { AudioStreamDemuxer, AudioStreamDemuxOutput } from "../demuxer.js";
export interface IcyStreamDemuxerOptions {
metadataInterval: number;
metadataEncoding?: string;
headers?: Readonly<Record<string, string>>;
}
export declare class IcyStreamDemuxer implements AudioStreamDemuxer<AudioStreamMetadata> {
readonly initialMetadata: AudioStreamMetadata;
private audioRemaining;
private metadata;
private metadataOffset;
private fields;
private readonly interval;
private readonly decoder;
private readonly headers;
constructor(options: IcyStreamDemuxerOptions);
push(chunk: Uint8Array): IterableIterator<AudioStreamDemuxOutput<AudioStreamMetadata>>;
flush(): IterableIterator<AudioStreamDemuxOutput<AudioStreamMetadata>>;
}
export declare function createIcyStreamDemuxer(options: IcyStreamDemuxerOptions): AudioStreamDemuxer<AudioStreamMetadata>;
export declare function parseIcyMetadata(bytes: Uint8Array, decoder: TextDecoder): Readonly<Record<string, string>> | null;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

export declare function allocateProportionalColumnWidths(widths: number[], targetWidth: number, minWidth: number): number[];
+201
-1
import { EventEmitter } from "events";
import type { AudioStats } from "./zig-structs.js";
import { type AudioStreamDemuxer, type AudioStreamDemuxerFactory } from "./audio-stream/demuxer.js";
import { type AudioStats } from "./zig-structs.js";
export interface AudioSetupOptions {

@@ -32,2 +33,115 @@ autoStart?: boolean;

}
export type AudioStreamBody = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
export type AudioStreamFormat = "mp3" | "flac";
export interface AudioStreamContentTypeContext {
readonly format: AudioStreamFormat;
readonly contentType: string | null;
readonly status: number;
readonly url: string;
}
export type AudioStreamContentTypePolicy = "validate" | "ignore" | ((context: AudioStreamContentTypeContext) => boolean);
export interface AudioStreamConnectContext {
readonly signal: AbortSignal;
readonly attempt: number;
}
export interface AudioStreamConnection<I = unknown> {
readonly body: AudioStreamBody;
readonly info: I;
close?(): void | Promise<void>;
}
export type AudioStreamRetryPhase = "connect" | "read";
export interface AudioStreamRetryContext {
readonly attempt: number;
readonly maxRetries: number;
readonly phase: AudioStreamRetryPhase;
}
export type AudioStreamRetryDecision = false | {
readonly delayMs?: number;
};
export interface AudioStreamConnector<I = unknown> {
connect(context: AudioStreamConnectContext): Promise<AudioStreamConnection<I>>;
}
export interface AudioStreamBufferOptions {
capacityMs?: number;
startupMs?: number;
resumeMs?: number;
}
export interface AudioStreamReconnectOptions {
maxRetries?: number;
initialDelayMs?: number;
maxDelayMs?: number;
backoffFactor?: number;
retryOnEnd?: boolean;
retry?(error: AudioStreamError, context: AudioStreamRetryContext): AudioStreamRetryDecision;
}
export interface AudioStreamOptions {
format?: AudioStreamFormat;
volume?: number;
pan?: number;
groupId?: number;
maxProbeBytes?: number;
buffer?: AudioStreamBufferOptions;
signal?: AbortSignal;
}
export interface AudioStreamBodyOptions<M = AudioStreamMetadata> extends AudioStreamOptions {
demuxer?: AudioStreamDemuxerFactory<M>;
contentTypePolicy?: never;
request?: never;
reconnect?: never;
metadataEncoding?: never;
}
export interface AudioStreamSourceOptions<I = unknown, M = AudioStreamMetadata> extends AudioStreamOptions {
demuxer?: (info: I) => AudioStreamDemuxer<M> | null;
reconnect?: AudioStreamReconnectOptions;
contentTypePolicy?: never;
request?: never;
metadataEncoding?: never;
}
export interface AudioStreamUrlOptions extends AudioStreamOptions {
request?: Omit<RequestInit, "body" | "signal">;
reconnect?: AudioStreamReconnectOptions;
metadataEncoding?: string;
contentTypePolicy?: AudioStreamContentTypePolicy;
demuxer?: never;
}
export type AudioStreamState = "initializing" | "buffering" | "playing" | "reconnecting" | "ended" | "errored" | "disposed";
export interface AudioStreamStats {
state: AudioStreamState;
sampleRate: number;
channels: number;
bufferedFrames: number;
capacityFrames: number;
bufferedDurationMs: number;
bytesReceived: bigint;
framesDecoded: bigint;
framesPlayed: bigint;
underruns: number;
reconnectAttempts: number;
}
export type AudioStreamMetadataFormat = "icy";
export interface AudioStreamMetadata {
readonly format: AudioStreamMetadataFormat;
readonly headers: Readonly<Record<string, string>>;
readonly fields: Readonly<Record<string, string>>;
}
export type AudioStreamAction = "fetch" | "response" | "source" | "demuxer" | "create" | "write" | "end" | "restart" | "stats" | "decoder" | "destroy" | "setVolume" | "setPan" | "setGroup";
export interface AudioStreamErrorContext {
action: AudioStreamAction;
status?: number;
errorCode?: number;
attempt?: number;
}
export interface AudioStreamReconnectEvent {
attempt: number;
delayMs: number;
maxRetries: number;
error: AudioStreamError;
}
export interface AudioStreamEvents<M = AudioStreamMetadata> {
metadata: [metadata: M | null];
reconnecting: [event: AudioStreamReconnectEvent];
ended: [];
error: [error: Error, context: AudioStreamErrorContext];
disposed: [];
}
export type AudioGroup = number;

@@ -53,4 +167,83 @@ export type AudioVoice = number;

}
export type AudioInitializationAction = "resolveRenderLib" | "createAudioEngine" | "start";
export declare class AudioInitializationError extends Error {
readonly action: AudioInitializationAction;
readonly status?: number;
constructor(action: AudioInitializationAction, message: string, status?: number, cause?: unknown);
}
export declare class AudioStreamError extends Error {
readonly context: AudioStreamErrorContext;
constructor(message: string, context: AudioStreamErrorContext, cause?: unknown);
}
export declare class AudioStream<M = AudioStreamMetadata> extends EventEmitter<AudioStreamEvents<M>> {
readonly closed: Promise<void>;
readonly format: AudioStreamFormat;
private readonly lib;
private readonly engine;
private readonly connector;
private readonly demuxerFactory?;
private readonly readAction;
private readonly options;
private readonly removeFromOwner;
private readonly lifecycleController;
private nativeStreamId;
private nativeStats;
private activeAttempt;
private pendingCleanup;
private reconnectAttempts;
private consecutiveReconnectAttempts;
private disposed;
private exposed;
private terminalError;
private metadata;
private pendingMetadataEvent;
private metadataEventScheduled;
private terminalEventScheduled;
private setupResolve;
private setupReject;
private closedResolve;
private readonly setupPromise;
private readonly overallAbortListener;
private constructor();
get state(): AudioStreamState;
private open;
getStats(): AudioStreamStats;
getMetadata(): M | null;
setVolume(volume: number): boolean;
setPan(pan: number): boolean;
setGroup(groupId: number): boolean;
private control;
dispose(): void;
private runLifecycle;
private createNativeStream;
private consumeSource;
private pumpSource;
private processDemuxOutput;
private writeStreamChunk;
private resolveConnection;
private beginResourceAcquisition;
private cleanupAttempt;
private performAttemptCleanup;
private runBoundedAttemptCleanup;
private retry;
private awaitReady;
private observeReady;
private awaitEnded;
private pollNativeSnapshot;
private snapshotError;
private finish;
private publishMetadata;
private emitMetadata;
private emitAsync;
private emitTerminal;
private isAttemptActive;
private stopSource;
private closeNativeStream;
private readNativeStats;
private toPublicStats;
private removeOwner;
}
export declare class Audio extends EventEmitter<AudioEvents> {
static create(options?: AudioSetupOptions): Audio;
readonly sampleRate: number;
private readonly lib;

@@ -60,5 +253,8 @@ private readonly defaultStartOptions;

private readonly groups;
private readonly streams;
private playbackStarted;
private mixerStarted;
private disposing;
private constructor();
private throwAfterInitializationCleanup;
private emitError;

@@ -75,2 +271,6 @@ start(options?: AudioStartOptions): boolean;

play(sound: AudioSound, options?: AudioPlayOptions): AudioVoice | null;
playStream<M = AudioStreamMetadata>(source: AudioStreamBody, options?: AudioStreamBodyOptions<M>): Promise<AudioStream<M>>;
playStreamUrl(source: string | URL, options?: AudioStreamUrlOptions): Promise<AudioStream<AudioStreamMetadata>>;
playStreamSource<I, M = AudioStreamMetadata>(connector: AudioStreamConnector<I>, options?: AudioStreamSourceOptions<I, M>): Promise<AudioStream<M>>;
private openStream;
stopVoice(voice: AudioVoice): boolean;

@@ -77,0 +277,0 @@ setVoiceGroup(voice: AudioVoice, group: AudioGroup): boolean;

@@ -21,2 +21,5 @@ export * from "./Renderable.js";

export * from "./audio.js";
export type { AudioStreamDemuxOutput, AudioStreamDemuxer, AudioStreamDemuxerFactory } from "./audio-stream/demuxer.js";
export { createIcyStreamDemuxer } from "./audio-stream/icy/demuxer.js";
export type { IcyStreamDemuxerOptions } from "./audio-stream/icy/demuxer.js";
export * from "./renderables/index.js";

@@ -23,0 +26,0 @@ export * from "./zig.js";

+9
-9

@@ -7,3 +7,3 @@ {

"type": "module",
"version": "0.4.3",
"version": "0.4.4",
"description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",

@@ -69,11 +69,11 @@ "license": "MIT",

"optionalDependencies": {
"@opentui/core-darwin-x64": "0.4.3",
"@opentui/core-darwin-arm64": "0.4.3",
"@opentui/core-linux-x64": "0.4.3",
"@opentui/core-linux-arm64": "0.4.3",
"@opentui/core-win32-x64": "0.4.3",
"@opentui/core-win32-arm64": "0.4.3",
"@opentui/core-linux-x64-musl": "0.4.3",
"@opentui/core-linux-arm64-musl": "0.4.3"
"@opentui/core-darwin-x64": "0.4.4",
"@opentui/core-darwin-arm64": "0.4.4",
"@opentui/core-linux-x64": "0.4.4",
"@opentui/core-linux-arm64": "0.4.4",
"@opentui/core-win32-x64": "0.4.4",
"@opentui/core-win32-arm64": "0.4.4",
"@opentui/core-linux-x64-musl": "0.4.4",
"@opentui/core-linux-arm64-musl": "0.4.4"
}
}
import {
ANSI,
CliRenderer
} from "./index-xt9f071j.js";
} from "./index-7z5n7k9m.js";
import {
SystemClock,
TreeSitterClient
} from "./index-d5xqskty.js";
} from "./index-za1krqsf.js";

@@ -10,0 +10,0 @@ // src/testing/mock-keys.ts

@@ -30,2 +30,3 @@ import { after, afterEach, before, beforeEach, describe as nodeDescribe, test as nodeTest } from "node:test";

toContain(expected: unknown): Promise<void>;
toHaveProperty(property: PropertyKey, expectedValue?: unknown): Promise<void>;
toMatchSnapshot(snapshotName?: string): Promise<void>;

@@ -32,0 +33,0 @@ toMatchInlineSnapshot(snapshot: string): Promise<void>;

@@ -95,3 +95,3 @@ import {

yoga_default
} from "./index-d5xqskty.js";
} from "./index-za1krqsf.js";
export {

@@ -98,0 +98,0 @@ yoga_default as default,

@@ -202,2 +202,47 @@ import { type Pointer } from "./platform/ffi.js";

};
export declare const NativeAudioStreamFormat: {
readonly Mp3: 1;
readonly Flac: 2;
};
export type NativeAudioStreamFormat = (typeof NativeAudioStreamFormat)[keyof typeof NativeAudioStreamFormat];
export type AudioStreamCreateOptions = {
capacityMs: number;
startupMs: number;
resumeMs: number;
volume: number;
pan: number;
groupId: number;
maxProbeBytes: number;
format: NativeAudioStreamFormat;
};
export type NativeAudioStreamStats = {
bytesReceived: bigint;
framesDecoded: bigint;
framesPlayed: bigint;
state: number;
sampleRate: number;
channels: number;
bufferedFrames: number;
capacityFrames: number;
underruns: number;
errorCode: number;
readyGeneration: number;
};
export declare const NativeAudioStreamState: {
readonly Initializing: 0;
readonly Buffering: 1;
readonly Playing: 2;
readonly Ended: 3;
readonly Failed: 4;
readonly Cancelled: 5;
readonly Reconnecting: 6;
};
export type NativeAudioStreamState = (typeof NativeAudioStreamState)[keyof typeof NativeAudioStreamState];
export declare const NativeAudioStreamStateNames: readonly ["initializing", "buffering", "playing", "ended", "errored", "disposed", "reconnecting"];
export declare const NativeAudioStreamCloseReason: {
readonly PreserveNativeTerminal: 0;
readonly TransportError: 1;
readonly Disposed: 2;
};
export type NativeAudioStreamCloseReason = (typeof NativeAudioStreamCloseReason)[keyof typeof NativeAudioStreamCloseReason];
export type AudioStats = {

@@ -256,3 +301,5 @@ soundsLoaded: number;

}]], {}>;
export declare const AudioStreamCreateOptionsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["capacityMs", "u32"], readonly ["startupMs", "u32"], readonly ["resumeMs", "u32"], readonly ["volume", "f32"], readonly ["pan", "f32"], readonly ["groupId", "u32"], readonly ["maxProbeBytes", "u32"], readonly ["format", "u32"]], {}>;
export declare const AudioStreamStatsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["bytesReceived", "u64"], readonly ["framesDecoded", "u64"], readonly ["framesPlayed", "u64"], readonly ["state", "u32"], readonly ["sampleRate", "u32"], readonly ["channels", "u32"], readonly ["bufferedFrames", "u32"], readonly ["capacityFrames", "u32"], readonly ["underruns", "u32"], readonly ["errorCode", "i32"], readonly ["readyGeneration", "u32"]], {}>;
export declare const AudioStatsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["soundsLoaded", "u32"], readonly ["voicesActive", "u32"], readonly ["framesMixed", "u64"], readonly ["lockMisses", "u32"], readonly ["lastPeak", "f32"], readonly ["lastRms", "f32"]], {}>;
export {};
import { type FFICallbackInstance, type Pointer } from "./platform/ffi.js";
import { type CursorStyle, type CursorStyleOptions, type TargetChannel, type DebugOverlayCorner, type WidthMethod, type TerminalCapabilities, type Highlight, type LineInfo } from "./types.js";
export type { LineInfo, AllocatorStats, BuildOptions, NativeRenderStats };
export type { LineInfo, AllocatorStats, AudioStreamCreateOptions, BuildOptions, NativeAudioStreamStats, NativeRenderStats, };
import { RGBA } from "./lib/RGBA.js";
import { OptimizedBuffer } from "./buffer.js";
import { TextBuffer } from "./text-buffer.js";
import type { NativeSpanFeedOptions, NativeSpanFeedStats, ReserveInfo, AudioCreateOptions, AudioStartOptions, AudioVoiceOptions, AudioStats, BuildOptions, AllocatorStats, NativeRenderStats } from "./zig-structs.js";
import type { NativeSpanFeedOptions, NativeSpanFeedStats, ReserveInfo, AudioCreateOptions, AudioStartOptions, AudioVoiceOptions, AudioStreamCreateOptions, NativeAudioStreamCloseReason as NativeAudioStreamCloseReasonType, NativeAudioStreamFormat as NativeAudioStreamFormatType, NativeAudioStreamState as NativeAudioStreamStateType, NativeAudioStreamStats, AudioStats, BuildOptions, AllocatorStats, NativeRenderStats } from "./zig-structs.js";
export declare const NativeAudioStreamState: {
readonly Initializing: 0;
readonly Buffering: 1;
readonly Playing: 2;
readonly Ended: 3;
readonly Failed: 4;
readonly Cancelled: 5;
readonly Reconnecting: 6;
};
export type NativeAudioStreamState = NativeAudioStreamStateType;
export declare const NativeAudioStreamCloseReason: {
readonly PreserveNativeTerminal: 0;
readonly TransportError: 1;
readonly Disposed: 2;
};
export type NativeAudioStreamCloseReason = NativeAudioStreamCloseReasonType;
export declare const NativeAudioStreamFormat: {
readonly Mp3: 1;
readonly Flac: 2;
};
export type NativeAudioStreamFormat = NativeAudioStreamFormatType;
export type NativeHandle<T extends string> = Pointer & {

@@ -93,2 +114,17 @@ readonly __nativeHandle: T;

audioStop: (engine: AudioEngineHandle) => number;
audioCreateStream: (engine: AudioEngineHandle, options: AudioStreamCreateOptions) => {
status: number;
streamId: number | null;
};
audioWriteStream: (engine: AudioEngineHandle, streamId: number, data: Uint8Array) => number;
audioEndStream: (engine: AudioEngineHandle, streamId: number) => number;
audioRestartStream: (engine: AudioEngineHandle, streamId: number) => number;
audioSetStreamVolume: (engine: AudioEngineHandle, streamId: number, volume: number) => number;
audioSetStreamPan: (engine: AudioEngineHandle, streamId: number, pan: number) => number;
audioSetStreamGroup: (engine: AudioEngineHandle, streamId: number, groupId: number) => number;
audioGetStreamStats: (engine: AudioEngineHandle, streamId: number) => NativeAudioStreamStats | null;
audioCloseStream: (engine: AudioEngineHandle, streamId: number, reason: NativeAudioStreamCloseReason) => {
status: number;
stats: NativeAudioStreamStats | null;
};
audioLoad: (engine: AudioEngineHandle, data: Uint8Array) => {

@@ -95,0 +131,0 @@ status: number;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display