Add metadata tag support to Conversion API

This commit is contained in:
Vanilagy
2025-09-05 23:34:24 +02:00
parent c6cb8f7b43
commit dcd99f8930
7 changed files with 230 additions and 13 deletions
+32
View File
@@ -36,6 +36,8 @@ export abstract class Source {
abstract _retrieveSize(): MaybePromise<number | null>;
/** @internal */
abstract _read(start: number, end: number): MaybePromise<ReadResult | null>;
/** @internal */
abstract get _supportsRandomAccess(): boolean;
/** @internal */
private _sizePromise: Promise<number | null> | null = null;
@@ -113,6 +115,11 @@ export class BufferSource extends Source {
offset: 0,
};
}
/** @internal */
get _supportsRandomAccess() {
return true;
}
}
/**
@@ -210,6 +217,11 @@ export class BlobSource extends Source {
worker.running = false;
}
/** @internal */
get _supportsRandomAccess() {
return true;
}
}
const URL_SOURCE_MIN_LOAD_AMOUNT = 0.5 * 2 ** 20; // 0.5 MiB
@@ -488,6 +500,11 @@ export class UrlSource extends Source {
}
}
}
/** @internal */
get _supportsRandomAccess() {
return true;
}
}
/**
@@ -559,6 +576,11 @@ export class FilePathSource extends Source {
_retrieveSize(): MaybePromise<number> {
return this._streamSource._retrieveSize();
}
/** @internal */
get _supportsRandomAccess() {
return true;
}
}
/**
@@ -728,6 +750,11 @@ export class StreamSource extends Source {
worker.running = false;
}
/** @internal */
get _supportsRandomAccess() {
return true;
}
}
type ReadableStreamSourcePendingSlice = {
@@ -987,6 +1014,11 @@ export class ReadableStreamSource extends Source {
this._pulling = false;
}
/** @internal */
get _supportsRandomAccess() {
return false;
}
}
type PrefetchProfile = (start: number, end: number, workers: ReadWorker[]) => {