20 lines
1.1 KiB
JavaScript
20 lines
1.1 KiB
JavaScript
// Rôle : expose les commandes du vrai stockage et des actions sous StrictMode pour tester leur verrouillage initial.
|
|
import { createElement, StrictMode, useLayoutEffect } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
import { flushSync } from "react-dom";
|
|
import { useIndexedToolboxes } from "../../website/src/features/toolboxes/storage/useIndexedToolboxes.js";
|
|
import { useToolboxActions } from "../../website/src/features/toolboxes/useToolboxActions.js";
|
|
|
|
export function mountStorageStartupProbe(element) {
|
|
const root = createRoot(element);
|
|
const api = { store: null, actions: null, notices: [] };
|
|
const notify = (message) => api.notices.push(message);
|
|
function Probe() {
|
|
const store = useIndexedToolboxes(notify);
|
|
const actions = useToolboxActions({ store, notify, setConfirmModal: notify });
|
|
useLayoutEffect(() => { api.store = store; api.actions = actions; });
|
|
return null;
|
|
}
|
|
flushSync(() => root.render(createElement(StrictMode, null, createElement(Probe))));
|
|
return { ...api, get store() { return api.store; }, get actions() { return api.actions; }, unmount: () => root.unmount() };
|
|
}
|