const PLUGIN_NAME_SPACE = 'RTLPLZ' ; const getData = async ( defaultData ) => { const data = await figma . clientStorage . getAsync ( PLUGIN_NAME_SPACE ) ; return data || defaultData ; } ; const setData = async ( value ) => { return await figma . clientStorage . setAsync ( PLUGIN_NAME_SPACE , value ) ; } ; const clearData = async ( ) => await figma . clientStorage . setAsync ( PLUGIN_NAME_SPACE , undefined ) ; const getNodePluginData = ( node , defaultData , key ? ) : { [ key ] : any ; } => { let data ; try { data = JSON . parse ( node . getSharedPluginData ( PLUGIN_NAME_SPACE , key || 'data' ) ) ; } catch ( error ) { data = undefined ; } return data || defaultData ; } ; const setNodePluginData = ( node , value , key ? ) => { try { node . setSharedPluginData ( PLUGIN_NAME_SPACE , key || 'data' , typeof value === "object" ? JSON . stringify ( value ) : '' ) ; } catch ( error ) { console . error ( error ) ; } } ; const clearNodePluginData = ( node , key ? ) => node . setSharedPluginData ( PLUGIN_NAME_SPACE , key || 'data' , '' ) ; const getDocumentPluginData = ( defaultData , key ? ) : { [ key ] : any ; } => getNodePluginData ( figma . root , defaultData , key || 'setting' ) ; const setDocumentPluginData = ( value , key ? ) => setNodePluginData ( figma . root , value , key || 'setting' ) ; const clearDocumentPluginData = ( key ? ) => clearNodePluginData ( figma . root , key || 'setting' ) ; export { getData , setData , clearData , getNodePluginData , setNodePluginData , clearNodePluginData , getDocumentPluginData , setDocumentPluginData , clearDocumentPluginData , } ;