refactor: correctly serialize nativeImage/buffer with typeUtils (#23666)
* refactor: correctly serialize nativeImage/buffer with typeUtils * test: add serialization specs * fix: construct from dataURL * test: test for dataURL specificity
This commit is contained in:
parent
33d6a99d40
commit
4b23a85475
4 changed files with 166 additions and 16 deletions
|
@ -245,7 +245,7 @@ type MetaTypeFromRenderer = {
|
|||
length: number
|
||||
} | {
|
||||
type: 'nativeimage',
|
||||
value: { size: Size, buffer: Buffer, scaleFactor: number }[]
|
||||
value: { size: Size, buffer: Buffer, scaleFactor: number, dataURL: string }[]
|
||||
}
|
||||
|
||||
const fakeConstructor = (constructor: Function, name: string) =>
|
||||
|
@ -266,13 +266,9 @@ const unwrapArgs = function (sender: electron.WebContents, frameId: number, cont
|
|||
case 'nativeimage': {
|
||||
const image = electron.nativeImage.createEmpty();
|
||||
for (const rep of meta.value) {
|
||||
const { buffer, size, scaleFactor } = rep;
|
||||
image.addRepresentation({
|
||||
buffer,
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
scaleFactor
|
||||
});
|
||||
const { size, scaleFactor, dataURL } = rep;
|
||||
const { width, height } = size;
|
||||
image.addRepresentation({ dataURL, scaleFactor, width, height });
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue