(
CoreClass:
| CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
| (() => Promise<
CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass>
>),
)
| 26 | } |
| 27 | |
| 28 | export function createAngularPanel< |
| 29 | TComponentProps extends DevtoolsPanelProps, |
| 30 | TCoreDevtoolsClass extends BaseCorePanelClass, |
| 31 | >( |
| 32 | CoreClass: |
| 33 | | CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass> |
| 34 | | (() => Promise< |
| 35 | CoreClassConstructor<TanStackDevtoolsPluginProps, TCoreDevtoolsClass> |
| 36 | >), |
| 37 | ) { |
| 38 | return [ |
| 39 | () => |
| 40 | (inputs: () => TComponentProps, host: HTMLElement): (() => void) => { |
| 41 | const panel = host.ownerDocument.createElement('div') |
| 42 | panel.style.height = '100%' |
| 43 | let unmount: null | (() => void) = null |
| 44 | |
| 45 | function mount(instance: TCoreDevtoolsClass) { |
| 46 | instance.mount(panel, inputs()) |
| 47 | unmount = () => instance.unmount() |
| 48 | } |
| 49 | |
| 50 | host.appendChild(panel) |
| 51 | |
| 52 | const isConstructor = isPanelClassConstructor< |
| 53 | TComponentProps, |
| 54 | TCoreDevtoolsClass |
| 55 | >(CoreClass) |
| 56 | |
| 57 | if (isConstructor) { |
| 58 | mount(new CoreClass(inputs())) |
| 59 | } else { |
| 60 | CoreClass() |
| 61 | .then((ResolvedCoreClass) => new ResolvedCoreClass(inputs())) |
| 62 | .then(mount) |
| 63 | } |
| 64 | |
| 65 | return () => { |
| 66 | unmount?.() |
| 67 | } |
| 68 | }, |
| 69 | () => null, |
| 70 | ] as const |
| 71 | } |
no test coverage detected