/** * WebKitGTK (2.50) lacks ReadableStream.prototype[Symbol.asyncIterator], which pdf.js uses in * getTextContent. Installs a minimal version when it is missing; a no-op elsewhere. */ export function installStreamAsyncIterator(): void { const proto = (globalThis as { ReadableStream?: { prototype: object } }).ReadableStream?.prototype as | Record | undefined; if (!proto || Symbol.asyncIterator in proto) return; proto[Symbol.asyncIterator] = function (this: ReadableStream) { const reader = this.getReader(); const iterator = { next: () => reader.read(), return: async () => { await reader.cancel().catch(() => {}); reader.releaseLock(); return { done: true as const, value: undefined }; }, [Symbol.asyncIterator]() { return iterator; }, }; return iterator; }; }