import{logger as r}from"../tools/notifiers/logger.js";import{reporter as o}from"../tools/notifiers/reporter.js";import{getBilledPagesCount as p}from"../utils/index.js";function l(t,d){t.on("routes-updated",()=>{d.broadcast({type:"routes-updated"}),r.verbose('Broadcast "routes-updated" over web-socket')}),t.on("build-updated",()=>{d.unfreeze(),d.broadcast({type:"build-updated"})}),t.on("global-data-updated",e=>{d.broadcast({type:"global-data-updated",data:e})}),t.on("build-started",()=>{d.freeze()}),t.on("shared-data-updated",e=>{d.broadcast({type:"shared-data-updated",id:e})}),d.onConnect(e=>{e.send(JSON.stringify({type:"errors-updated",errors:o.getProblems()}));const a=p(t.getAllRoutes());a&&e.send(JSON.stringify({type:"pages-updated",pages:a}))}),t.on("errors-updated",e=>{d.broadcast({type:"errors-updated",errors:e})}),t.on("pages-updated",e=>{d.broadcast({type:"pages-updated",pages:e})})}export{l as listenStore};
