(withDevtoolsFn)
| 64 | * @see {@link DevtoolsOptions} |
| 65 | */ |
| 66 | export const withDevtools: WithDevtools = (withDevtoolsFn) => |
| 67 | queryFeature( |
| 68 | makeEnvironmentProviders([ |
| 69 | { |
| 70 | provide: DEVTOOLS_OPTIONS, |
| 71 | useFactory: () => withDevtoolsFn?.() ?? {}, |
| 72 | }, |
| 73 | provideEnvironmentInitializer(() => { |
| 74 | const devtoolsProvided = inject(DEVTOOLS_PROVIDED) |
| 75 | if ( |
| 76 | !isPlatformBrowser(inject(PLATFORM_ID)) || |
| 77 | devtoolsProvided.isProvided |
| 78 | ) |
| 79 | return |
| 80 | |
| 81 | const injectedClient = inject(QueryClient, { optional: true }) |
| 82 | const options = inject(DEVTOOLS_OPTIONS) |
| 83 | const destroyRef = inject(DestroyRef) |
| 84 | |
| 85 | const client = resolveOption(options.client) ?? injectedClient |
| 86 | |
| 87 | devtoolsProvided.isProvided = true |
| 88 | destroyRef.onDestroy(() => { |
| 89 | devtoolsProvided.isProvided = false |
| 90 | }) |
| 91 | |
| 92 | if (!client) throw new Error('No QueryClient found') |
| 93 | |
| 94 | const devtools = new TanstackQueryDevtools({ |
| 95 | client, |
| 96 | queryFlavor: 'Angular Query', |
| 97 | version: '5', |
| 98 | onlineManager, |
| 99 | buttonPosition: resolveOption(options.buttonPosition), |
| 100 | position: resolveOption(options.position), |
| 101 | initialIsOpen: resolveOption(options.initialIsOpen), |
| 102 | errorTypes: resolveOption(options.errorTypes), |
| 103 | styleNonce: options.styleNonce, |
| 104 | shadowDOMTarget: options.shadowDOMTarget, |
| 105 | hideDisabledQueries: options.hideDisabledQueries, |
| 106 | theme: resolveOption(options.theme), |
| 107 | }) |
| 108 | |
| 109 | const shouldMount = computed(() => { |
| 110 | const loadDevtools = resolveOption(options.loadDevtools) |
| 111 | return typeof loadDevtools === 'boolean' ? loadDevtools : isDevMode() |
| 112 | }) |
| 113 | |
| 114 | const mount = () => { |
| 115 | const element = document.body.appendChild( |
| 116 | document.createElement('div'), |
| 117 | ) |
| 118 | element.classList.add('tsqd-parent-container') |
| 119 | devtools.mount(element) |
| 120 | |
| 121 | return () => { |
| 122 | devtools.unmount() |
| 123 | element.remove() |
nothing calls this directly
no test coverage detected