import m from"path";import{readFile as s,writeFileSync as f}from"fs";import{getSharedDataUrl as d}from"../../utils/url/get-shared-data-url.js";import{logger as l}from"../tools/notifiers/logger.js";import{ensureDir as p}from"./fs.js";const n={},y=async(r,e,t)=>{const o=a(r,t);await n[r],f(p(o),e,{encoding:"utf-8",flush:!0})},P=async(r,e)=>{try{const t=new Promise(o=>s(a(r,e),"utf-8",(i,c)=>{o(i?void 0:JSON.parse(c))}));return n[r]=t,t.finally(()=>{delete n[r]})}catch{l.warnProd(`Failed to read shared data: ${r}`);return}},a=(r,e)=>m.join(e,d(r));export{P as readSharedData,y as writeSharedData};
