{"version":3,"file":"app.cjs","sources":["../../../src/types/app.ts"],"sourcesContent":["import { ComponentType } from 'react';\n\nimport { throwIfAngular } from '../utils/throwIfAngular';\n\nimport { KeyValue } from './data';\nimport { NavModel } from './navModel';\nimport { PluginMeta, GrafanaPlugin, PluginIncludeType } from './plugin';\nimport {\n  PluginExtensionExposedComponentConfig,\n  PluginExtensionAddedComponentConfig,\n  PluginExtensionAddedLinkConfig,\n  PluginExtensionAddedFunctionConfig,\n} from './pluginExtensions';\n\n/**\n * @public\n * The app container that is loading another plugin (panel or query editor)\n * */\nexport enum CoreApp {\n  CloudAlerting = 'cloud-alerting',\n  UnifiedAlerting = 'unified-alerting',\n  Dashboard = 'dashboard',\n  Explore = 'explore',\n  Correlations = 'correlations',\n  Unknown = 'unknown',\n  PanelEditor = 'panel-editor',\n  PanelViewer = 'panel-viewer',\n}\n\nexport interface AppRootProps<T extends KeyValue = KeyValue> {\n  meta: AppPluginMeta<T>;\n  /**\n   * base URL segment for an app, /app/pluginId\n   */\n  basename: string; // The URL path to this page\n\n  /**\n   * Pass the nav model to the container... is there a better way?\n   * @deprecated Use PluginPage component exported from @grafana/runtime instead\n   */\n  onNavChanged: (nav: NavModel) => void;\n\n  /**\n   * The URL query parameters\n   * @deprecated Use react-router instead\n   */\n  query: KeyValue;\n\n  /**\n   * The URL path to this page\n   * @deprecated Use react-router instead\n   */\n  path: string;\n}\n\nexport interface AppPluginMeta<T extends KeyValue = KeyValue> extends PluginMeta<T> {\n  // TODO anything specific to apps?\n}\n\nexport class AppPlugin<T extends KeyValue = KeyValue> extends GrafanaPlugin<AppPluginMeta<T>> {\n  private _exposedComponentConfigs: PluginExtensionExposedComponentConfig[] = [];\n  private _addedComponentConfigs: PluginExtensionAddedComponentConfig[] = [];\n  private _addedLinkConfigs: PluginExtensionAddedLinkConfig[] = [];\n  private _addedFunctionConfigs: PluginExtensionAddedFunctionConfig[] = [];\n\n  // Content under: /a/${plugin-id}/*\n  root?: ComponentType<AppRootProps<T>>;\n\n  /**\n   * Called after the module has loaded, and before the app is used.\n   * This function may be called multiple times on the same instance.\n   * The first time, `this.meta` will be undefined\n   */\n  init(meta: AppPluginMeta<T>) {}\n\n  /**\n   * Set the component displayed under:\n   *   /a/${plugin-id}/*\n   *\n   * If the NavModel is configured, the page will have a managed frame, otheriwse it has full control.\n   */\n  setRootPage(root: ComponentType<AppRootProps<T>>) {\n    this.root = root;\n    return this;\n  }\n\n  setComponentsFromLegacyExports(pluginExports: System.Module) {\n    throwIfAngular(pluginExports);\n\n    if (this.meta && this.meta.includes) {\n      for (const include of this.meta.includes) {\n        if (include.type === PluginIncludeType.page && include.component) {\n          const exp = pluginExports[include.component];\n\n          if (!exp) {\n            console.warn('App Page uses unknown component: ', include.component, this.meta);\n            continue;\n          }\n        }\n      }\n    }\n  }\n\n  get exposedComponentConfigs() {\n    return this._exposedComponentConfigs;\n  }\n\n  get addedComponentConfigs() {\n    return this._addedComponentConfigs;\n  }\n\n  get addedLinkConfigs() {\n    return this._addedLinkConfigs;\n  }\n\n  get addedFunctionConfigs() {\n    return this._addedFunctionConfigs;\n  }\n\n  addLink<Context extends object>(linkConfig: PluginExtensionAddedLinkConfig<Context>) {\n    this._addedLinkConfigs.push(linkConfig as PluginExtensionAddedLinkConfig);\n\n    return this;\n  }\n\n  addComponent<Props = {}>(addedComponentConfig: PluginExtensionAddedComponentConfig<Props>) {\n    this._addedComponentConfigs.push(addedComponentConfig as PluginExtensionAddedComponentConfig);\n\n    return this;\n  }\n\n  addFunction<Signature>(addedFunctionConfig: PluginExtensionAddedFunctionConfig<Signature>) {\n    this._addedFunctionConfigs.push(addedFunctionConfig);\n\n    return this;\n  }\n\n  exposeComponent<Props = {}>(componentConfig: PluginExtensionExposedComponentConfig<Props>) {\n    this._exposedComponentConfigs.push(componentConfig as PluginExtensionExposedComponentConfig);\n\n    return this;\n  }\n}\n\n/**\n * Defines life cycle of a feature\n * @internal\n */\nexport enum FeatureState {\n  /** @deprecated in favor of experimental */\n  alpha = 'alpha',\n  /** @deprecated in favor of preview */\n  beta = 'beta',\n  /** used to mark experimental features with high/unknown risk */\n  experimental = 'experimental',\n  /** used to mark features that are in public preview with medium/hight risk */\n  privatePreview = 'private preview',\n  /** used to mark features that are in public preview with low/medium risk, or as a shared badge for public and private previews */\n  preview = 'preview',\n  /** used to mark new GA features */\n  new = 'new',\n}\n"],"names":["CoreApp","GrafanaPlugin","throwIfAngular","PluginIncludeType","FeatureState"],"mappings":";;;;;;;;AAkBO,IAAK,OAAA,qBAAAA,QAAAA,KAAL;AACL,EAAAA,SAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,EAAAA,SAAA,iBAAA,CAAA,GAAkB,kBAAA;AAClB,EAAAA,SAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,SAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,SAAA,cAAA,CAAA,GAAe,cAAA;AACf,EAAAA,SAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,SAAA,aAAA,CAAA,GAAc,cAAA;AACd,EAAAA,SAAA,aAAA,CAAA,GAAc,cAAA;AARJ,EAAA,OAAAA,QAAAA;AAAA,CAAA,EAAA,OAAA,IAAA,EAAA;AAyCL,MAAM,kBAAiDC,oBAAA,CAAgC;AAAA,EAAvF,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAQ,2BAAoE,EAAC;AAC7E,IAAA,IAAA,CAAQ,yBAAgE,EAAC;AACzE,IAAA,IAAA,CAAQ,oBAAsD,EAAC;AAC/D,IAAA,IAAA,CAAQ,wBAA8D,EAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUvE,KAAK,IAAA,EAAwB;AAAA,EAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9B,YAAY,IAAA,EAAsC;AAChD,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,OAAO,IAAA;A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