function initializeTWind(options = {}) {
const { invalidation, ...restOptions } = Object.assign(
{
hash: true
},
options
);
const hash = restOptions.hash;
if (!invalidation) {
throw new Error(
"Provide `options.invaliation`. See: https://github.com/observablehq/stdlib/#invalidation"
);
}
const sheet = Twind.getSheet();
const hashString = hash2String(hash);
if (hashString) {
document.body.classList.add(hashString + "-body");
document.body.parentElement.classList.add(hashString + "-root");
}
invalidation.then(() => {
console.info("Cell invalidated. Destroying sheet.");
if (hashString) {
document.body.classList.remove(hashString + "-body");
document.body.parentElement.classList.remove(hashString + "-root");
}
sheet.destroy();
});
const tw = setup(restOptions, sheet);
return tw;
}