@grafana/runtime
Version:
Grafana Runtime Library
1 lines • 1.6 kB
Source Map (JSON)
{"version":3,"file":"usePluginFunctions.mjs","sources":["../../../../src/services/pluginExtensions/usePluginFunctions.ts"],"sourcesContent":["import { PluginExtensionFunction } from '@grafana/data';\n\nexport type UsePluginFunctionsOptions = {\n extensionPointId: string;\n limitPerPlugin?: number;\n};\n\nexport type UsePluginFunctionsResult<Signature> = {\n isLoading: boolean;\n functions: Array<PluginExtensionFunction<Signature>>;\n};\n\nexport type UsePluginFunctions<T> = (options: UsePluginFunctionsOptions) => UsePluginFunctionsResult<T>;\n\nlet singleton: UsePluginFunctions<unknown> | undefined;\n\nexport function setPluginFunctionsHook(hook: UsePluginFunctions<unknown>): void {\n // We allow overriding the registry in tests\n if (singleton && process.env.NODE_ENV !== 'test') {\n throw new Error('setUsePluginFunctionsHook() function should only be called once, when Grafana is starting.');\n }\n singleton = hook;\n}\n\nexport function usePluginFunctions<T>(options: UsePluginFunctionsOptions): UsePluginFunctionsResult<T> {\n if (!singleton) {\n throw new Error('usePluginFunctions(options) can only be used after the Grafana instance has started.');\n }\n return singleton(options) as UsePluginFunctionsResult<T>;\n}\n"],"names":[],"mappings":"AAcA,IAAI,SAAA;AAEG,SAAS,uBAAuB,IAAyC,EAAA;AAE9E,EAAA,IAAI,SAAa,IAAA,OAAA,CAAQ,GAAI,CAAA,QAAA,KAAa,MAAQ,EAAA;AAChD,IAAM,MAAA,IAAI,MAAM,4FAA4F,CAAA;AAAA;AAE9G,EAAY,SAAA,GAAA,IAAA;AACd;AAEO,SAAS,mBAAsB,OAAiE,EAAA;AACrG,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,sFAAsF,CAAA;AAAA;AAExG,EAAA,OAAO,UAAU,OAAO,CAAA;AAC1B;;;;"}