@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 1.51 kB
Source Map (JSON)
{"version":3,"file":"usePluginLinks.mjs","sources":["../../../../src/services/pluginExtensions/usePluginLinks.ts"],"sourcesContent":["import { PluginExtensionLink } from '@grafana/data';\n\nexport type UsePluginLinksOptions = {\n extensionPointId: string;\n context?: object | Record<string | symbol, unknown>;\n limitPerPlugin?: number;\n};\n\nexport type UsePluginLinksResult = {\n isLoading: boolean;\n links: PluginExtensionLink[];\n};\n\nexport type UsePluginLinks = (options: UsePluginLinksOptions) => UsePluginLinksResult;\n\nlet singleton: UsePluginLinks | undefined;\n\nexport function setPluginLinksHook(hook: UsePluginLinks): void {\n // We allow overriding the registry in tests\n if (singleton && process.env.NODE_ENV !== 'test') {\n throw new Error('setPluginLinksHook() function should only be called once, when Grafana is starting.');\n }\n singleton = hook;\n}\n\nexport function usePluginLinks(options: UsePluginLinksOptions): UsePluginLinksResult {\n if (!singleton) {\n throw new Error('setPluginLinksHook(options) can only be used after the Grafana instance has started.');\n }\n return singleton(options);\n}\n"],"names":[],"mappings":";AAeA,IAAI,SAAA;AAEG,SAAS,mBAAmB,IAAA,EAA4B;AAE7D,EAAA,IAAI,SAAA,IAAa,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,MAAA,EAAQ;AAChD,IAAA,MAAM,IAAI,MAAM,qFAAqF,CAAA;AAAA,EACvG;AACA,EAAA,SAAA,GAAY,IAAA;AACd;AAEO,SAAS,eAAe,OAAA,EAAsD;AACnF,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,MAAM,IAAI,MAAM,sFAAsF,CAAA;AAAA,EACxG;AACA,EAAA,OAAO,UAAU,OAAO,CAAA;AAC1B;;;;"}