fix(build): align TypeScript and test imports with NodeNext builds and safely copy Uint8Array inputs in browser processing
This commit is contained in:
@@ -243,7 +243,7 @@ export class SmartPreview {
|
||||
if (input instanceof ArrayBuffer) {
|
||||
buffer = input;
|
||||
} else if (input instanceof Uint8Array) {
|
||||
buffer = input.buffer.slice(input.byteOffset, input.byteOffset + input.byteLength);
|
||||
buffer = this.uint8ArrayToArrayBuffer(input);
|
||||
} else if (input instanceof File || input instanceof Blob) {
|
||||
// Read first few bytes to detect format
|
||||
const headerBlob = input.slice(0, 8);
|
||||
@@ -299,4 +299,10 @@ export class SmartPreview {
|
||||
await instance.init();
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private uint8ArrayToArrayBuffer(input: Uint8Array): ArrayBuffer {
|
||||
const arrayBuffer = new ArrayBuffer(input.byteLength);
|
||||
new Uint8Array(arrayBuffer).set(input);
|
||||
return arrayBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user