(el: T)
| 57 | } |
| 58 | |
| 59 | mount<T extends HTMLElement>(el: T) { |
| 60 | if (typeof document === 'undefined') return |
| 61 | |
| 62 | if (this.#state === 'mounted' || this.#state === 'mounting') { |
| 63 | throw new Error('Devtools is already mounted') |
| 64 | } |
| 65 | this.#state = 'mounting' |
| 66 | const { signal } = (this.#mountAbortController = new AbortController()) |
| 67 | |
| 68 | import('./mount-impl') |
| 69 | .then(({ mountDevtools }) => { |
| 70 | if (signal.aborted) { |
| 71 | return |
| 72 | } |
| 73 | |
| 74 | const result = mountDevtools({ |
| 75 | el, |
| 76 | plugins: this.#plugins, |
| 77 | config: this.#config, |
| 78 | eventBusConfig: this.#eventBusConfig, |
| 79 | onSetPlugins: (setPlugins) => { |
| 80 | this.#setPlugins = setPlugins |
| 81 | }, |
| 82 | }) |
| 83 | |
| 84 | this.#dispose = result.dispose |
| 85 | this.#eventBus = result.eventBus |
| 86 | this.#state = 'mounted' |
| 87 | }) |
| 88 | .catch((err) => { |
| 89 | this.#state = 'unmounted' |
| 90 | console.error('[TanStack Devtools] Failed to load:', err) |
| 91 | }) |
| 92 | } |
| 93 | |
| 94 | unmount() { |
| 95 | if (this.#state === 'unmounted') { |
no test coverage detected