import { commands } from '@config/commands' ; import { PluginMessage } from '@typings/pluginEvent' ; export const downloadJson = ( parent , link , json ) => { if ( json === '[]' ) { parent . postMessage ( { pluginMessage : { command : commands . closePlugin , payload : { notification : '⛔️ No design token detected!' } } as PluginMessage } , '*' ) ; return ; } try { link . href = `data:application/design-tokens+json;charset=utf-8,${ encodeURIComponent ( json ) }` ; link . click ( ) ; parent . postMessage ( { pluginMessage : { command : commands . closePlugin , payload : { notification : '🎉 Design token export succesfull!' } } as PluginMessage } , '*' ) ; } catch ( error ) { parent . postMessage ( { pluginMessage : { command : commands . closePlugin , payload : { notification : '⛔️ Design token failed!' } } as PluginMessage } , '*' ) ; console . error ( 'Export error: ' , error ) ; } } ;