Make some more fields readonly

This commit is contained in:
Vanilagy
2025-06-09 22:49:54 +02:00
parent 6baff67696
commit 0ca1425036
4 changed files with 28 additions and 16 deletions
+4 -4
View File
@@ -112,9 +112,9 @@ const FALLBACK_SAMPLE_RATE = 48000;
*/
export class Conversion {
/** The input file. */
input: Input;
readonly input: Input;
/** The output file. */
output: Output;
readonly output: Output;
/** @internal */
_options: ConversionOptions;
@@ -168,9 +168,9 @@ export class Conversion {
_lastProgress = 0;
/** The list of tracks that are included in the output file. */
utilizedTracks: InputTrack[] = [];
readonly utilizedTracks: InputTrack[] = [];
/** The list of tracks from the input file that have been discarded, alongside the discard reason. */
discardedTracks: {
readonly discardedTracks: {
/** The track that was discarded. */
track: InputTrack;
/** The reason for discarding the track. */
+12 -12
View File
@@ -9,11 +9,11 @@ import { AudioSample, VideoSample } from './sample';
*/
export abstract class CustomVideoDecoder {
/** The input video's codec. */
codec!: VideoCodec;
readonly codec!: VideoCodec;
/** The input video's decoder config. */
config!: VideoDecoderConfig;
readonly config!: VideoDecoderConfig;
/** The callback to call when a decoded VideoSample is available. */
onSample!: (sample: VideoSample) => unknown;
readonly onSample!: (sample: VideoSample) => unknown;
/** Returns true iff the decoder can decode the given codec configuration. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -38,11 +38,11 @@ export abstract class CustomVideoDecoder {
*/
export abstract class CustomAudioDecoder {
/** The input audio's codec. */
codec!: AudioCodec;
readonly codec!: AudioCodec;
/** The input audio's decoder config. */
config!: AudioDecoderConfig;
readonly config!: AudioDecoderConfig;
/** The callback to call when a decoded AudioSample is available. */
onSample!: (sample: AudioSample) => unknown;
readonly onSample!: (sample: AudioSample) => unknown;
/** Returns true iff the decoder can decode the given codec configuration. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -67,11 +67,11 @@ export abstract class CustomAudioDecoder {
*/
export abstract class CustomVideoEncoder {
/** The codec with which to encode the video. */
codec!: VideoCodec;
readonly codec!: VideoCodec;
/** Config for the encoder. */
config!: VideoEncoderConfig;
readonly config!: VideoEncoderConfig;
/** The callback to call when an EncodedPacket is available. */
onPacket!: (packet: EncodedPacket, meta?: EncodedVideoChunkMetadata) => unknown;
readonly onPacket!: (packet: EncodedPacket, meta?: EncodedVideoChunkMetadata) => unknown;
/** Returns true iff the encoder can encode the given codec configuration. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -96,11 +96,11 @@ export abstract class CustomVideoEncoder {
*/
export abstract class CustomAudioEncoder {
/** The codec with which to encode the audio. */
codec!: AudioCodec;
readonly codec!: AudioCodec;
/** Config for the encoder. */
config!: AudioEncoderConfig;
readonly config!: AudioEncoderConfig;
/** The callback to call when an EncodedPacket is available. */
onPacket!: (packet: EncodedPacket, meta?: EncodedAudioChunkMetadata) => unknown;
readonly onPacket!: (packet: EncodedPacket, meta?: EncodedAudioChunkMetadata) => unknown;
/** Returns true iff the encoder can encode the given codec configuration. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
+6
View File
@@ -705,8 +705,11 @@ class VideoDecoderWrapper extends DecoderWrapper<VideoSample> {
if (MatchingCustomDecoder) {
// @ts-expect-error "Can't create instance of abstract class 🤓"
this.customDecoder = new MatchingCustomDecoder() as CustomVideoDecoder;
// @ts-expect-error It's technically readonly
this.customDecoder.codec = codec;
// @ts-expect-error It's technically readonly
this.customDecoder.config = decoderConfig;
// @ts-expect-error It's technically readonly
this.customDecoder.onSample = (sample) => {
if (!(sample instanceof VideoSample)) {
throw new TypeError('The argument passed to onSample must be a VideoSample.');
@@ -1151,8 +1154,11 @@ class AudioDecoderWrapper extends DecoderWrapper<AudioSample> {
if (MatchingCustomDecoder) {
// @ts-expect-error "Can't create instance of abstract class 🤓"
this.customDecoder = new MatchingCustomDecoder() as CustomAudioDecoder;
// @ts-expect-error It's technically readonly
this.customDecoder.codec = codec;
// @ts-expect-error It's technically readonly
this.customDecoder.config = decoderConfig;
// @ts-expect-error It's technically readonly
this.customDecoder.onSample = (sample) => {
if (!(sample instanceof AudioSample)) {
throw new TypeError('The argument passed to onSample must be an AudioSample.');
+6
View File
@@ -382,8 +382,11 @@ class VideoEncoderWrapper {
if (MatchingCustomEncoder) {
// @ts-expect-error "Can't create instance of abstract class 🤓"
this.customEncoder = new MatchingCustomEncoder() as CustomVideoEncoder;
// @ts-expect-error It's technically readonly
this.customEncoder.codec = this.encodingConfig.codec;
// @ts-expect-error It's technically readonly
this.customEncoder.config = encoderConfig;
// @ts-expect-error It's technically readonly
this.customEncoder.onPacket = (packet, meta) => {
if (!(packet instanceof EncodedPacket)) {
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');
@@ -949,8 +952,11 @@ class AudioEncoderWrapper {
if (MatchingCustomEncoder) {
// @ts-expect-error "Can't create instance of abstract class 🤓"
this.customEncoder = new MatchingCustomEncoder() as CustomAudioEncoder;
// @ts-expect-error It's technically readonly
this.customEncoder.codec = this.encodingConfig.codec;
// @ts-expect-error It's technically readonly
this.customEncoder.config = encoderConfig;
// @ts-expect-error It's technically readonly
this.customEncoder.onPacket = (packet, meta) => {
if (!(packet instanceof EncodedPacket)) {
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');