import { clearLocalStorage } from '@tldraw/utils' import { deleteDB } from 'idb' import { getAllIndexDbNames } from './indexedDb' /** * Clear the database of all data associated with tldraw. * * @public */ export async function hardReset({ shouldReload = true } = {}) { clearLocalStorage() await Promise.all(getAllIndexDbNames().map((db) => deleteDB(db))) clearLocalStorage() if (shouldReload) { if (typeof window !== 'undefined') { window.location.reload() } } } if (typeof window !== 'undefined') { if (process.env.NODE_ENV === 'development') { ;(window as any).hardReset = hardReset } // window.__tldraw__hardReset is used to inject the logic into the tldraw library ;(window as any).__tldraw__hardReset = hardReset }