Rendering moves into a module Web Worker behind a latest-wins RenderClient with a watchdog and a handshake-based main-thread fallback. The preview shows the real PDF through pdf.js at 2x with zoom, page indicator, audit issues popover and a focus modal. A4/Letter and margin controls are frozen into each invoice at issue and can be saved as the default (migration M3). react-pdf and pdf.js are lazy-loaded; the main chunk shrinks from 1.8 MB to 0.5 MB. The HTML twin and its styles are removed.
26 lines
889 B
TypeScript
26 lines
889 B
TypeScript
/**
|
|
* 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<symbol, unknown>
|
|
| undefined;
|
|
if (!proto || Symbol.asyncIterator in proto) return;
|
|
proto[Symbol.asyncIterator] = function (this: ReadableStream<unknown>) {
|
|
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;
|
|
};
|
|
}
|