Uncaught TypeError: Cannot read properties of undefined (reading 'pluginMessage')

I was able to communicate between my typescript and html file by plugin message.
it was working fine.

window.onmessage = msg => {
let msg_type = msg.data.pluginMessage.pluginMessage.type
if (msg_type === ‘img’) {

   ............
   ............ 


}
if (msg_type === 'msg') {
   .......... 
   ..........
}
};

Based on this tutorial, Javascript JSZip Example to Compress Multiple Files Using HTML5 Form & Download it as ZIP File - YouTube
I added these 2 lines in my HTML.

After that I am getting this error
Uncaught TypeError: Cannot read properties of undefined (reading ‘pluginMessage’)
it is the highlighted one in previous code snippet

It is something from here…