corvée(dépendances) ajoute Carbon Fields

This commit is contained in:
gcch 2024-08-09 18:45:01 +02:00
commit 62368587e5
459 changed files with 72750 additions and 26 deletions

View file

@ -0,0 +1,28 @@
const rootRegistry = {};
export function registerContainerRoot( containerId, root ) {
rootRegistry[ containerId ] = {
createdAt: Math.floor(Date.now() / 1000),
...root,
unmount() {
// Fix issues with race condition by delaying
// the onLoad unmounting of containers
// they would be unmounted later
if ( parseFloat( window.cf.config.wp_version ) >= 6.2 ) {
const currentTime = Math.floor(Date.now() / 1000);
if ( currentTime - rootRegistry[ containerId ].createdAt >= 3 ) {
root.unmount();
delete rootRegistry[ containerId ];
}
} else {
root.unmount();
delete rootRegistry[ containerId ];
}
}
};
}
export function getContainerRoot( containerId ) {
return rootRegistry[ containerId ] || null;
}