@grafana/scenes 6.12.0--canary.1122.15063334499.0 → 6.12.0--canary.1121.15070832166.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/esm/components/SceneApp/SceneApp.js +2 -2
  2. package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
  3. package/dist/esm/components/SceneApp/SceneAppPage.js +2 -18
  4. package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
  5. package/dist/esm/core/sceneGraph/index.js +2 -2
  6. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  7. package/dist/esm/core/sceneGraph/sceneGraph.js +9 -5
  8. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  9. package/dist/esm/index.js +1 -1
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/querying/SceneQueryRunner.js +10 -33
  12. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  13. package/dist/esm/variables/VariableDependencyConfig.js +4 -1
  14. package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
  15. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +19 -18
  16. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  17. package/dist/esm/variables/components/VariableValueSelectors.js +3 -0
  18. package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
  19. package/dist/esm/variables/constants.js +2 -1
  20. package/dist/esm/variables/constants.js.map +1 -1
  21. package/dist/esm/variables/groupby/GroupByVariable.js +7 -40
  22. package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
  23. package/dist/esm/variables/groupby/GroupByVariableUrlSyncHandler.js +7 -31
  24. package/dist/esm/variables/groupby/GroupByVariableUrlSyncHandler.js.map +1 -1
  25. package/dist/esm/variables/sets/SceneVariableSet.js +10 -7
  26. package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
  27. package/dist/esm/variables/types.js.map +1 -1
  28. package/dist/esm/variables/variants/ScopesVariable.js +87 -0
  29. package/dist/esm/variables/variants/ScopesVariable.js.map +1 -0
  30. package/dist/index.d.ts +51 -56
  31. package/dist/index.js +128 -310
  32. package/dist/index.js.map +1 -1
  33. package/package.json +2 -2
  34. package/dist/esm/core/SceneScopesBridge.js +0 -93
  35. package/dist/esm/core/SceneScopesBridge.js.map +0 -1
  36. package/dist/esm/variables/groupby/DefaultGroupByCustomIndicatorContainer.js +0 -102
  37. package/dist/esm/variables/groupby/DefaultGroupByCustomIndicatorContainer.js.map +0 -1
@@ -14,8 +14,8 @@ class SceneApp extends SceneObjectBase {
14
14
  }
15
15
  }
16
16
  SceneApp.Component = ({ model }) => {
17
- const { pages, scopesBridge } = model.useState();
18
- return /* @__PURE__ */ React.createElement(React.Fragment, null, scopesBridge && /* @__PURE__ */ React.createElement(scopesBridge.Component, { model: scopesBridge }), /* @__PURE__ */ React.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React.createElement(Routes, null, pages.map((page) => /* @__PURE__ */ React.createElement(Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React.createElement(page.Component, { model: page }) })))));
17
+ const { pages } = model.useState();
18
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React.createElement(Routes, null, pages.map((page) => /* @__PURE__ */ React.createElement(Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React.createElement(page.Component, { model: page }) })))));
19
19
  };
20
20
  const SceneAppContext = createContext(null);
21
21
  const sceneAppCache = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"SceneApp.js","sources":["../../../../src/components/SceneApp/SceneApp.tsx"],"sourcesContent":["import React, { createContext } from 'react';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { DataRequestEnricher, SceneComponentProps } from '../../core/types';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneAppState } from './types';\n\n/**\n * Responsible for top level pages routing\n */\nexport class SceneApp extends SceneObjectBase<SceneAppState> implements DataRequestEnricher {\n protected _renderBeforeActivation = true;\n\n public enrichDataRequest() {\n return {\n app: this.state.name || 'app',\n };\n }\n\n public static Component = ({ model }: SceneComponentProps<SceneApp>) => {\n const { pages, scopesBridge } = model.useState();\n\n return (\n <>\n {scopesBridge && <scopesBridge.Component model={scopesBridge} />}\n <SceneAppContext.Provider value={model}>\n <Routes>\n {pages.map((page) => (\n <Route key={page.state.url} path={page.state.routePath} element={<page.Component model={page} />} />\n ))}\n </Routes>\n </SceneAppContext.Provider>\n </>\n );\n };\n}\n\nexport const SceneAppContext = createContext<SceneApp | null>(null);\n\nconst sceneAppCache = new Map<object, SceneApp>();\n\n/**\n * Caches the the resulting SceneApp returned by the factory function so that it's only called once during the lifetime of the browser tab\n */\nexport function useSceneApp(factory: () => SceneApp) {\n const cachedApp = sceneAppCache.get(factory);\n\n if (cachedApp) {\n return cachedApp;\n }\n\n const newApp = factory();\n sceneAppCache.set(factory, newApp);\n\n return newApp;\n}\n"],"names":[],"mappings":";;;;AAUO,MAAM,iBAAiB,eAA8D,CAAA;AAAA,EAArF,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAU,uBAA0B,GAAA,IAAA;AAAA;AAAA,EAE7B,iBAAoB,GAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAA,EAAK,IAAK,CAAA,KAAA,CAAM,IAAQ,IAAA;AAAA,KAC1B;AAAA;AAmBJ;AAzBa,QAAA,CASG,SAAY,GAAA,CAAC,EAAE,KAAA,EAA2C,KAAA;AACtE,EAAA,MAAM,EAAE,KAAA,EAAO,YAAa,EAAA,GAAI,MAAM,QAAS,EAAA;AAE/C,EAAA,iEAEK,YAAgB,oBAAA,KAAA,CAAA,aAAA,CAAC,aAAa,SAAb,EAAA,EAAuB,OAAO,YAAc,EAAA,CAAA,sCAC7D,eAAgB,CAAA,QAAA,EAAhB,EAAyB,KAAO,EAAA,KAAA,EAAA,sCAC9B,MACE,EAAA,IAAA,EAAA,KAAA,CAAM,IAAI,CAAC,IAAA,qBACT,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAM,KAAK,IAAK,CAAA,KAAA,CAAM,KAAK,IAAM,EAAA,IAAA,CAAK,MAAM,SAAW,EAAA,OAAA,sCAAU,IAAK,CAAA,SAAA,EAAL,EAAe,KAAO,EAAA,IAAA,EAAM,GAAI,CACnG,CACH,CACF,CACF,CAAA;AAEJ,CAAA;AAGW,MAAA,eAAA,GAAkB,cAA+B,IAAI;AAElE,MAAM,aAAA,uBAAoB,GAAsB,EAAA;AAKzC,SAAS,YAAY,OAAyB,EAAA;AACnD,EAAM,MAAA,SAAA,GAAY,aAAc,CAAA,GAAA,CAAI,OAAO,CAAA;AAE3C,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA;AAAA;AAGT,EAAA,MAAM,SAAS,OAAQ,EAAA;AACvB,EAAc,aAAA,CAAA,GAAA,CAAI,SAAS,MAAM,CAAA;AAEjC,EAAO,OAAA,MAAA;AACT;;;;"}
1
+ {"version":3,"file":"SceneApp.js","sources":["../../../../src/components/SceneApp/SceneApp.tsx"],"sourcesContent":["import React, { createContext } from 'react';\nimport { Route, Routes } from 'react-router-dom';\n\nimport { DataRequestEnricher, SceneComponentProps } from '../../core/types';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneAppState } from './types';\n\n/**\n * Responsible for top level pages routing\n */\nexport class SceneApp extends SceneObjectBase<SceneAppState> implements DataRequestEnricher {\n protected _renderBeforeActivation = true;\n\n public enrichDataRequest() {\n return {\n app: this.state.name || 'app',\n };\n }\n\n public static Component = ({ model }: SceneComponentProps<SceneApp>) => {\n const { pages } = model.useState();\n\n return (\n <>\n <SceneAppContext.Provider value={model}>\n <Routes>\n {pages.map((page) => (\n <Route key={page.state.url} path={page.state.routePath} element={<page.Component model={page} />} />\n ))}\n </Routes>\n </SceneAppContext.Provider>\n </>\n );\n };\n}\n\nexport const SceneAppContext = createContext<SceneApp | null>(null);\n\nconst sceneAppCache = new Map<object, SceneApp>();\n\n/**\n * Caches the the resulting SceneApp returned by the factory function so that it's only called once during the lifetime of the browser tab\n */\nexport function useSceneApp(factory: () => SceneApp) {\n const cachedApp = sceneAppCache.get(factory);\n\n if (cachedApp) {\n return cachedApp;\n }\n\n const newApp = factory();\n sceneAppCache.set(factory, newApp);\n\n return newApp;\n}\n"],"names":[],"mappings":";;;;AAUO,MAAM,iBAAiB,eAA8D,CAAA;AAAA,EAArF,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AACL,IAAA,IAAA,CAAU,uBAA0B,GAAA,IAAA;AAAA;AAAA,EAE7B,iBAAoB,GAAA;AACzB,IAAO,OAAA;AAAA,MACL,GAAA,EAAK,IAAK,CAAA,KAAA,CAAM,IAAQ,IAAA;AAAA,KAC1B;AAAA;AAkBJ;AAxBa,QAAA,CASG,SAAY,GAAA,CAAC,EAAE,KAAA,EAA2C,KAAA;AACtE,EAAA,MAAM,EAAE,KAAA,EAAU,GAAA,KAAA,CAAM,QAAS,EAAA;AAEjC,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,CAAA,QAAA,EAAhB,EAAyB,KAAO,EAAA,KAAA,EAAA,kBAC9B,KAAA,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EACE,MAAM,GAAI,CAAA,CAAC,IACV,qBAAA,KAAA,CAAA,aAAA,CAAC,SAAM,GAAK,EAAA,IAAA,CAAK,KAAM,CAAA,GAAA,EAAK,IAAM,EAAA,IAAA,CAAK,KAAM,CAAA,SAAA,EAAW,yBAAU,KAAA,CAAA,aAAA,CAAA,IAAA,CAAK,SAAL,EAAA,EAAe,OAAO,IAAM,EAAA,CAAA,EAAI,CACnG,CACH,CACF,CACF,CAAA;AAEJ,CAAA;AAGW,MAAA,eAAA,GAAkB,cAA+B,IAAI;AAElE,MAAM,aAAA,uBAAoB,GAAsB,EAAA;AAKzC,SAAS,YAAY,OAAyB,EAAA;AACnD,EAAM,MAAA,SAAA,GAAY,aAAc,CAAA,GAAA,CAAI,OAAO,CAAA;AAE3C,EAAA,IAAI,SAAW,EAAA;AACb,IAAO,OAAA,SAAA;AAAA;AAGT,EAAA,MAAM,SAAS,OAAQ,EAAA;AACvB,EAAc,aAAA,CAAA,GAAA,CAAI,SAAS,MAAM,CAAA;AAEjC,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
2
  import { Route, Routes } from 'react-router-dom';
3
- import { sceneGraph } from '../../core/sceneGraph/index.js';
4
3
  import { SceneObjectBase } from '../../core/SceneObjectBase.js';
5
4
  import { isDataRequestEnricher } from '../../core/types.js';
6
5
  import { EmbeddedScene } from '../EmbeddedScene.js';
@@ -9,25 +8,10 @@ import { SceneReactObject } from '../SceneReactObject.js';
9
8
  import { SceneAppDrilldownViewRender, SceneAppPageView } from './SceneAppPageView.js';
10
9
 
11
10
  class SceneAppPage extends SceneObjectBase {
12
- constructor(state) {
13
- super(state);
11
+ constructor() {
12
+ super(...arguments);
14
13
  this._sceneCache = /* @__PURE__ */ new Map();
15
14
  this._drilldownCache = /* @__PURE__ */ new Map();
16
- this._activationHandler = () => {
17
- if (!this.state.useScopes) {
18
- return;
19
- }
20
- this._scopesBridge = sceneGraph.getScopesBridge(this);
21
- if (!this._scopesBridge) {
22
- throw new Error("Use of scopes is enabled but no scopes bridge found");
23
- }
24
- this._scopesBridge.setEnabled(true);
25
- return () => {
26
- var _a;
27
- (_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
28
- };
29
- };
30
- this.addActivationHandler(this._activationHandler);
31
15
  }
32
16
  initializeScene(scene) {
33
17
  this.setState({ initializedScene: scene });
@@ -1 +1 @@
1
- {"version":3,"file":"SceneAppPage.js","sources":["../../../../src/components/SceneApp/SceneAppPage.tsx"],"sourcesContent":["import React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport { sceneGraph } from '../../core/sceneGraph';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneScopesBridge } from '../../core/SceneScopesBridge';\nimport { SceneComponentProps, SceneObject, isDataRequestEnricher } from '../../core/types';\nimport { EmbeddedScene } from '../EmbeddedScene';\nimport { SceneFlexItem, SceneFlexLayout } from '../layout/SceneFlexLayout';\nimport { SceneReactObject } from '../SceneReactObject';\nimport { SceneAppDrilldownViewRender, SceneAppPageView } from './SceneAppPageView';\nimport { SceneAppDrilldownView, SceneAppPageLike, SceneAppPageState, SceneRouteMatch } from './types';\n\n/**\n * Responsible for page's drilldown & tabs routing\n */\nexport class SceneAppPage extends SceneObjectBase<SceneAppPageState> implements SceneAppPageLike {\n public static Component = SceneAppPageRenderer;\n private _sceneCache = new Map<string, EmbeddedScene>();\n private _drilldownCache = new Map<string, SceneAppPageLike>();\n private _scopesBridge: SceneScopesBridge | undefined;\n\n public constructor(state: SceneAppPageState) {\n super(state);\n\n this.addActivationHandler(this._activationHandler);\n }\n\n private _activationHandler = () => {\n if (!this.state.useScopes) {\n return;\n }\n\n this._scopesBridge = sceneGraph.getScopesBridge(this);\n\n if (!this._scopesBridge) {\n throw new Error('Use of scopes is enabled but no scopes bridge found');\n }\n\n this._scopesBridge.setEnabled(true);\n\n return () => {\n this._scopesBridge?.setEnabled(false);\n };\n };\n\n public initializeScene(scene: EmbeddedScene) {\n this.setState({ initializedScene: scene });\n }\n\n public getScene(routeMatch: SceneRouteMatch): EmbeddedScene {\n let scene = this._sceneCache.get(routeMatch.url);\n\n if (scene) {\n return scene;\n }\n\n if (!this.state.getScene) {\n throw new Error('Missing getScene on SceneAppPage ' + this.state.title);\n }\n\n scene = this.state.getScene(routeMatch);\n this._sceneCache.set(routeMatch.url, scene);\n\n return scene;\n }\n\n public getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch<{}>): SceneAppPageLike {\n let page = this._drilldownCache.get(routeMatch!.url);\n if (page) {\n return page;\n }\n\n page = drilldown.getPage(routeMatch, this);\n this._drilldownCache.set(routeMatch!.url, page);\n\n return page;\n }\n\n public enrichDataRequest(source: SceneObject) {\n if (this.state.getParentPage) {\n return this.state.getParentPage().enrichDataRequest(source);\n }\n\n if (!this.parent) {\n return null;\n }\n\n const root = this.getRoot();\n\n if (isDataRequestEnricher(root)) {\n return root.enrichDataRequest(source);\n }\n\n return null;\n }\n}\nfunction SceneAppPageRenderer({ model }: SceneComponentProps<SceneAppPage>) {\n const { tabs, drilldowns } = model.useState();\n const routes: React.ReactNode[] = [];\n\n routes.push(getFallbackRoute(model));\n\n if (tabs && tabs.length > 0) {\n for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) {\n const tab = tabs[tabIndex];\n\n // Add first tab as a default route, this makes it possible for the first tab to render with the url of the parent page\n if (tabIndex === 0) {\n routes.push(<Route key={model.state.routePath} path=\"\" element={<tab.Component model={tab} />}></Route>);\n }\n\n routes.push(\n <Route key={tab.state.url} path={tab.state.routePath} element={<tab.Component model={tab} />}></Route>\n );\n\n if (tab.state.drilldowns) {\n for (const drilldown of tab.state.drilldowns) {\n routes.push(\n <Route\n key={drilldown.routePath}\n path={drilldown.routePath}\n element={<SceneAppDrilldownViewRender drilldown={drilldown} parent={tab} />}\n ></Route>\n );\n }\n }\n }\n }\n\n if (drilldowns) {\n for (const drilldown of drilldowns) {\n routes.push(\n <Route\n key={drilldown.routePath}\n path={drilldown.routePath}\n Component={() => <SceneAppDrilldownViewRender drilldown={drilldown} parent={model} />}\n ></Route>\n );\n }\n }\n\n if (!tabs) {\n routes.push(<Route key=\"home route\" path=\"/\" element={<SceneAppPageView page={model} />}></Route>);\n }\n\n return <Routes>{routes}</Routes>;\n}\n\nfunction getFallbackRoute(page: SceneAppPage) {\n return (\n <Route\n key={'fallback route'}\n path=\"*\"\n element={<SceneAppPageView page={page.state.getFallbackPage?.() ?? getDefaultFallbackPage()} />}\n ></Route>\n );\n}\n\nfunction getDefaultFallbackPage() {\n return new SceneAppPage({\n url: '',\n title: 'Not found',\n subTitle: 'The url did not match any page',\n routePath: '*',\n getScene: () => {\n return new EmbeddedScene({\n body: new SceneFlexLayout({\n direction: 'column',\n children: [\n new SceneFlexItem({\n body: new SceneReactObject({\n component: () => {\n return (\n <div data-testid=\"default-fallback-content\">\n If you found your way here using a link then there might be a bug in this application.\n </div>\n );\n },\n }),\n }),\n ],\n }),\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;AAeO,MAAM,qBAAqB,eAA+D,CAAA;AAAA,EAMxF,YAAY,KAA0B,EAAA;AAC3C,IAAA,KAAA,CAAM,KAAK,CAAA;AALb,IAAQ,IAAA,CAAA,WAAA,uBAAkB,GAA2B,EAAA;AACrD,IAAQ,IAAA,CAAA,eAAA,uBAAsB,GAA8B,EAAA;AAS5D,IAAA,IAAA,CAAQ,qBAAqB,MAAM;AACjC,MAAI,IAAA,CAAC,IAAK,CAAA,KAAA,CAAM,SAAW,EAAA;AACzB,QAAA;AAAA;AAGF,MAAK,IAAA,CAAA,aAAA,GAAgB,UAAW,CAAA,eAAA,CAAgB,IAAI,CAAA;AAEpD,MAAI,IAAA,CAAC,KAAK,aAAe,EAAA;AACvB,QAAM,MAAA,IAAI,MAAM,qDAAqD,CAAA;AAAA;AAGvE,MAAK,IAAA,CAAA,aAAA,CAAc,WAAW,IAAI,CAAA;AAElC,MAAA,OAAO,MAAM;AAxCjB,QAAA,IAAA,EAAA;AAyCM,QAAK,CAAA,EAAA,GAAA,IAAA,CAAA,aAAA,KAAL,mBAAoB,UAAW,CAAA,KAAA,CAAA;AAAA,OACjC;AAAA,KACF;AAnBE,IAAK,IAAA,CAAA,oBAAA,CAAqB,KAAK,kBAAkB,CAAA;AAAA;AACnD,EAoBO,gBAAgB,KAAsB,EAAA;AAC3C,IAAA,IAAA,CAAK,QAAS,CAAA,EAAE,gBAAkB,EAAA,KAAA,EAAO,C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,GAAA;AAAA,MACL,OAAA,sCAAU,gBAAiB,EAAA,EAAA,IAAA,EAAA,CAAM,sBAAK,KAAM,EAAA,eAAA,KAAX,IAAkC,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,KAAA,IAAA,GAAA,EAAA,GAAA,sBAAA,EAA0B,EAAA;AAAA;AAAA,GAC9F;AAEL;AAEA,SAAS,sBAAyB,GAAA;AAChC,EAAA,OAAO,IAAI,YAAa,CAAA;AAAA,IACtB,GAAK,EAAA,EAAA;AAAA,IACL,KAAO,EAAA,WAAA;AAAA,IACP,QAAU,EAAA,gCAAA;AAAA,IACV,SAAW,EAAA,GAAA;AAAA,IACX,UAAU,MAAM;AACd,MAAA,OAAO,IAAI,aAAc,CAAA;AAAA,QACvB,IAAA,EAAM,IAAI,eAAgB,CAAA;AAAA,UACxB,SAAW,EAAA,QAAA;AAAA,UACX,QAAU,EAAA;AAAA,YACR,IAAI,aAAc,CAAA;AAAA,cAChB,IAAA,EAAM,IAAI,gBAAiB,CAAA;AAAA,gBACzB,WAAW,MAAM;AACf,kBAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,aAAY,EAAA,0BAAA,EAAA,EAA2B,wFAE5C,CAAA;AAAA;AAEJ,eACD;AAAA,aACF;AAAA;AACH,SACD;AAAA,OACF,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"SceneAppPage.js","sources":["../../../../src/components/SceneApp/SceneAppPage.tsx"],"sourcesContent":["import React from 'react';\nimport { Route, Routes } from 'react-router-dom';\nimport { SceneObjectBase } from '../../core/SceneObjectBase';\nimport { SceneComponentProps, SceneObject, isDataRequestEnricher } from '../../core/types';\nimport { EmbeddedScene } from '../EmbeddedScene';\nimport { SceneFlexItem, SceneFlexLayout } from '../layout/SceneFlexLayout';\nimport { SceneReactObject } from '../SceneReactObject';\nimport { SceneAppDrilldownViewRender, SceneAppPageView } from './SceneAppPageView';\nimport { SceneAppDrilldownView, SceneAppPageLike, SceneAppPageState, SceneRouteMatch } from './types';\n\n/**\n * Responsible for page's drilldown & tabs routing\n */\nexport class SceneAppPage extends SceneObjectBase<SceneAppPageState> implements SceneAppPageLike {\n public static Component = SceneAppPageRenderer;\n private _sceneCache = new Map<string, EmbeddedScene>();\n private _drilldownCache = new Map<string, SceneAppPageLike>();\n\n public initializeScene(scene: EmbeddedScene) {\n this.setState({ initializedScene: scene });\n }\n\n public getScene(routeMatch: SceneRouteMatch): EmbeddedScene {\n let scene = this._sceneCache.get(routeMatch.url);\n\n if (scene) {\n return scene;\n }\n\n if (!this.state.getScene) {\n throw new Error('Missing getScene on SceneAppPage ' + this.state.title);\n }\n\n scene = this.state.getScene(routeMatch);\n this._sceneCache.set(routeMatch.url, scene);\n\n return scene;\n }\n\n public getDrilldownPage(drilldown: SceneAppDrilldownView, routeMatch: SceneRouteMatch<{}>): SceneAppPageLike {\n let page = this._drilldownCache.get(routeMatch!.url);\n if (page) {\n return page;\n }\n\n page = drilldown.getPage(routeMatch, this);\n this._drilldownCache.set(routeMatch!.url, page);\n\n return page;\n }\n\n public enrichDataRequest(source: SceneObject) {\n if (this.state.getParentPage) {\n return this.state.getParentPage().enrichDataRequest(source);\n }\n\n if (!this.parent) {\n return null;\n }\n\n const root = this.getRoot();\n\n if (isDataRequestEnricher(root)) {\n return root.enrichDataRequest(source);\n }\n\n return null;\n }\n}\nfunction SceneAppPageRenderer({ model }: SceneComponentProps<SceneAppPage>) {\n const { tabs, drilldowns } = model.useState();\n const routes: React.ReactNode[] = [];\n\n routes.push(getFallbackRoute(model));\n\n if (tabs && tabs.length > 0) {\n for (let tabIndex = 0; tabIndex < tabs.length; tabIndex++) {\n const tab = tabs[tabIndex];\n\n // Add first tab as a default route, this makes it possible for the first tab to render with the url of the parent page\n if (tabIndex === 0) {\n routes.push(<Route key={model.state.routePath} path=\"\" element={<tab.Component model={tab} />}></Route>);\n }\n\n routes.push(\n <Route key={tab.state.url} path={tab.state.routePath} element={<tab.Component model={tab} />}></Route>\n );\n\n if (tab.state.drilldowns) {\n for (const drilldown of tab.state.drilldowns) {\n routes.push(\n <Route\n key={drilldown.routePath}\n path={drilldown.routePath}\n element={<SceneAppDrilldownViewRender drilldown={drilldown} parent={tab} />}\n ></Route>\n );\n }\n }\n }\n }\n\n if (drilldowns) {\n for (const drilldown of drilldowns) {\n routes.push(\n <Route\n key={drilldown.routePath}\n path={drilldown.routePath}\n Component={() => <SceneAppDrilldownViewRender drilldown={drilldown} parent={model} />}\n ></Route>\n );\n }\n }\n\n if (!tabs) {\n routes.push(<Route key=\"home route\" path=\"/\" element={<SceneAppPageView page={model} />}></Route>);\n }\n\n return <Routes>{routes}</Routes>;\n}\n\nfunction getFallbackRoute(page: SceneAppPage) {\n return (\n <Route\n key={'fallback route'}\n path=\"*\"\n element={<SceneAppPageView page={page.state.getFallbackPage?.() ?? getDefaultFallbackPage()} />}\n ></Route>\n );\n}\n\nfunction getDefaultFallbackPage() {\n return new SceneAppPage({\n url: '',\n title: 'Not found',\n subTitle: 'The url did not match any page',\n routePath: '*',\n getScene: () => {\n return new EmbeddedScene({\n body: new SceneFlexLayout({\n direction: 'column',\n children: [\n new SceneFlexItem({\n body: new SceneReactObject({\n component: () => {\n return (\n <div data-testid=\"default-fallback-content\">\n If you found your way here using a link then there might be a bug in this application.\n </div>\n );\n },\n }),\n }),\n ],\n }),\n });\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAaO,MAAM,qBAAqB,eAA+D,CAAA;AAAA,EAA1F,WAAA,GAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAEL,IAAQ,IAAA,CAAA,WAAA,uBAAkB,GAA2B,EAAA;AACrD,IAAQ,IAAA,CAAA,eAAA,uBAAsB,GAA8B,EAAA;AAAA;AAAA,EAErD,gBAAgB,KAAsB,EAAA;AAC3C,IAAA,IAAA,CAAK,QAAS,CAAA,EAAE,gBAAkB,EAAA,KAAA,EAAO,CAAA;AAAA;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A,MACL,OAAA,sCAAU,gBAAiB,EAAA,EAAA,IAAA,EAAA,CAAM,sBAAK,KAAM,EAAA,eAAA,KAAX,IAAkC,GAAA,MAAA,GAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,KAAA,IAAA,GAAA,EAAA,GAAA,sBAAA,EAA0B,EAAA;AAAA;AAAA,GAC9F;AAEL;AAEA,SAAS,sBAAyB,GAAA;AAChC,EAAA,OAAO,IAAI,YAAa,CAAA;AAAA,IACtB,GAAK,EAAA,EAAA;AAAA,IACL,KAAO,EAAA,WAAA;AAAA,IACP,QAAU,EAAA,gCAAA;AAAA,IACV,SAAW,EAAA,GAAA;AAAA,IACX,UAAU,MAAM;AACd,MAAA,OAAO,IAAI,aAAc,CAAA;AAAA,QACvB,IAAA,EAAM,IAAI,eAAgB,CAAA;AAAA,UACxB,SAAW,EAAA,QAAA;AAAA,UACX,QAAU,EAAA;AAAA,YACR,IAAI,aAAc,CAAA;AAAA,cAChB,IAAA,EAAM,IAAI,gBAAiB,CAAA;AAAA,gBACzB,WAAW,MAAM;AACf,kBAAA,uBACG,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,aAAY,EAAA,0BAAA,EAAA,EAA2B,wFAE5C,CAAA;AAAA;AAEJ,eACD;AAAA,aACF;AAAA;AACH,SACD;AAAA,OACF,CAAA;AAAA;AACH,GACD,CAAA;AACH;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { lookupVariable } from '../../variables/lookupVariable.js';
2
2
  import { getQueryController } from './getQueryController.js';
3
3
  import { getTimeRange } from './getTimeRange.js';
4
- import { getScopesBridge, findDescendents, getAncestor, findAllObjects, findObject, findByKeyAndType, findByKey, hasVariableDependencyInLoadingState, interpolate, getDataLayers, getLayout, getData, getVariables } from './sceneGraph.js';
4
+ import { getScopes, findDescendents, getAncestor, findAllObjects, findObject, findByKeyAndType, findByKey, hasVariableDependencyInLoadingState, interpolate, getDataLayers, getLayout, getData, getVariables } from './sceneGraph.js';
5
5
 
6
6
  const sceneGraph = {
7
7
  getVariables,
@@ -19,7 +19,7 @@ const sceneGraph = {
19
19
  getAncestor,
20
20
  getQueryController,
21
21
  findDescendents,
22
- getScopesBridge
22
+ getScopes
23
23
  };
24
24
 
25
25
  export { sceneGraph };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/core/sceneGraph/index.ts"],"sourcesContent":["import { lookupVariable } from '../../variables/lookupVariable';\nimport { getQueryController } from './getQueryController';\nimport { getTimeRange } from './getTimeRange';\nimport {\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getData,\n getLayout,\n getVariables,\n getDataLayers,\n hasVariableDependencyInLoadingState,\n interpolate,\n getAncestor,\n findDescendents,\n getScopesBridge,\n} from './sceneGraph';\n\nexport const sceneGraph = {\n getVariables,\n getData,\n getTimeRange,\n getLayout,\n getDataLayers,\n interpolate,\n lookupVariable,\n hasVariableDependencyInLoadingState,\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getAncestor,\n getQueryController,\n findDescendents,\n getScopesBridge,\n};\n"],"names":[],"mappings":";;;;;AAmBO,MAAM,UAAa,GAAA;AAAA,EACxB,YAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,mCAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/core/sceneGraph/index.ts"],"sourcesContent":["import { lookupVariable } from '../../variables/lookupVariable';\nimport { getQueryController } from './getQueryController';\nimport { getTimeRange } from './getTimeRange';\nimport {\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getData,\n getLayout,\n getVariables,\n getDataLayers,\n hasVariableDependencyInLoadingState,\n interpolate,\n getAncestor,\n findDescendents,\n getScopes,\n} from './sceneGraph';\n\nexport const sceneGraph = {\n getVariables,\n getData,\n getTimeRange,\n getLayout,\n getDataLayers,\n interpolate,\n lookupVariable,\n hasVariableDependencyInLoadingState,\n findByKey,\n findByKeyAndType,\n findObject,\n findAllObjects,\n getAncestor,\n getQueryController,\n findDescendents,\n getScopes,\n};\n"],"names":[],"mappings":";;;;;AAmBO,MAAM,UAAa,GAAA;AAAA,EACxB,YAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAA;AAAA,EACA,SAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,cAAA;AAAA,EACA,mCAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,UAAA;AAAA,EACA,cAAA;AAAA,EACA,WAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA;AACF;;;;"}
@@ -4,7 +4,8 @@ import { isDataLayer } from '../types.js';
4
4
  import { lookupVariable } from '../../variables/lookupVariable.js';
5
5
  import { getClosest } from './utils.js';
6
6
  import { QueryVariable } from '../../variables/variants/query/QueryVariable.js';
7
- import { SceneScopesBridge } from '../SceneScopesBridge.js';
7
+ import { ScopesVariable } from '../../variables/variants/ScopesVariable.js';
8
+ import { SCOPES_VARIABLE_NAME } from '../../variables/constants.js';
8
9
 
9
10
  function getVariables(sceneObject) {
10
11
  var _a;
@@ -149,10 +150,13 @@ function findDescendents(scene, descendentType) {
149
150
  const targetScenes = findAllObjects(scene, isDescendentType);
150
151
  return targetScenes.filter(isDescendentType);
151
152
  }
152
- function getScopesBridge(sceneObject) {
153
- var _a;
154
- return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
153
+ function getScopes(sceneObject) {
154
+ const scopesVariable = lookupVariable(SCOPES_VARIABLE_NAME, sceneObject);
155
+ if (scopesVariable instanceof ScopesVariable) {
156
+ return scopesVariable.state.scopes;
157
+ }
158
+ return void 0;
155
159
  }
156
160
 
157
- export { findAllObjects, findByKey, findByKeyAndType, findDescendents, findObject, getAncestor, getData, getDataLayers, getLayout, getScopesBridge, getVariables, hasVariableDependencyInLoadingState, interpolate };
161
+ export { findAllObjects, findByKey, findByKeyAndType, findDescendents, findObject, getAncestor, getData, getDataLayers, getLayout, getScopes, getVariables, hasVariableDependencyInLoadingState, interpolate };
158
162
  //# sourceMappingURL=sceneGraph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sceneGraph.js","sources":["../../../../src/core/sceneGraph/sceneGraph.ts"],"sourcesContent":["import { ScopedVars } from '@grafana/data';\nimport { EmptyDataNode, EmptyVariableSet } from '../../variables/interpolation/defaults';\n\nimport { sceneInterpolator } from '../../variables/interpolation/sceneInterpolator';\nimport { VariableCustomFormatterFn, SceneVariables } from '../../variables/types';\n\nimport { isDataLayer, SceneDataLayerProvider, SceneDataProvider, SceneLayout, SceneObject } from '../types';\nimport { lookupVariable } from '../../variables/lookupVariable';\nimport { getClosest } from './utils';\nimport { VariableInterpolation } from '@grafana/runtime';\nimport { QueryVariable } from '../../variables/variants/query/QueryVariable';\nimport { UrlSyncManagerLike } from '../../services/UrlSyncManager';\nimport { SceneScopesBridge } from '../SceneScopesBridge';\n\n/**\n * Get the closest node with variables\n */\nexport function getVariables(sceneObject: SceneObject): SceneVariables {\n return getClosest(sceneObject, (s) => s.state.$variables) ?? EmptyVariableSet;\n}\n\n/**\n * Will walk up the scene object graph to the closest $data scene object\n */\nexport function getData(sceneObject: SceneObject): SceneDataProvider {\n return getClosest(sceneObject, (s) => s.state.$data) ?? EmptyDataNode;\n}\n\nfunction isSceneLayout(s: SceneObject): s is SceneLayout {\n return 'isDraggable' in s;\n}\n\n/**\n * Will walk up the scene object graph to the closest $layout scene object\n */\nexport function getLayout(scene: SceneObject): SceneLayout | null {\n const parent = getClosest(scene, (s) => (isSceneLayout(s) ? s : undefined));\n if (parent) {\n return parent;\n }\n\n return null;\n}\n\n/**\n * Interpolates the given string using the current scene object as context. *\n *\n * Note: the interpolations array will be mutated by adding information about variables that\n * have been interpolated during replacement. Variables that were specified in the target but not found in\n * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details.\n *\n * @param {VariableInterpolation[]} interpolations an optional array that is updated with interpolated variables.\n */\nexport function interpolate(\n sceneObject: SceneObject,\n value: string | undefined | null,\n scopedVars?: ScopedVars,\n format?: string | VariableCustomFormatterFn,\n interpolations?: VariableInterpolation[]\n): string {\n if (value === '' || value == null) {\n return '';\n }\n\n return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);\n}\n\n/**\n * Checks if the variable is currently loading or waiting to update.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\nexport function hasVariableDependencyInLoadingState(sceneObject: SceneObject) {\n if (!sceneObject.variableDependency) {\n return false;\n }\n\n for (const name of sceneObject.variableDependency.getNames()) {\n // This is for backwards compability. In the old architecture query variables could reference itself in a query without breaking.\n if (sceneObject instanceof QueryVariable && sceneObject.state.name === name) {\n console.warn('Query variable is referencing itself');\n continue;\n }\n\n const variable = lookupVariable(name, sceneObject);\n if (!variable) {\n continue;\n }\n\n const set = variable.parent as SceneVariables;\n if (set.isVariableLoadingOrWaitingToUpdate(variable)) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction findObjectInternal(\n scene: SceneObject,\n check: (obj: SceneObject) => boolean,\n alreadySearchedChild?: SceneObject,\n shouldSearchUp?: boolean\n): SceneObject | null {\n if (check(scene)) {\n return scene;\n }\n\n let found: SceneObject | null = null;\n\n scene.forEachChild((child) => {\n if (child === alreadySearchedChild) {\n return;\n }\n\n let maybe = findObjectInternal(child, check);\n if (maybe) {\n found = maybe;\n }\n });\n\n if (found) {\n return found;\n }\n\n if (shouldSearchUp && scene.parent) {\n return findObjectInternal(scene.parent, check, scene, true);\n }\n\n return null;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key.\n *\n * Throws error if no key-matching scene object found.\n */\nexport function findByKey(sceneObject: SceneObject, key: string) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n return found;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key and type.\n *\n * Throws error if no key-matching scene object found.\n * Throws error if the given type does not match.\n */\nexport function findByKeyAndType<TargetType extends SceneObject>(\n sceneObject: SceneObject,\n key: string,\n targetType: { new (...args: never[]): TargetType }\n) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n if (!(found instanceof targetType)) {\n throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);\n }\n return found;\n}\n\n/**\n * This will search the full scene graph, starting with the scene node passed in, then walking up the parent chain. *\n */\nexport function findObject(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject | null {\n return findObjectInternal(scene, check, undefined, true);\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided predicate.\n */\nexport function findAllObjects(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject[] {\n const found: SceneObject[] = [];\n\n scene.forEachChild((child) => {\n if (check(child)) {\n found.push(child);\n }\n\n found.push(...findAllObjects(child, check));\n });\n\n return found;\n}\n\n/**\n * Will walk up the scene object graph up until the root and collect all SceneDataLayerProvider objects.\n * When localOnly set to true, it will only collect the closest layers.\n */\nexport function getDataLayers(sceneObject: SceneObject, localOnly = false): SceneDataLayerProvider[] {\n let currentLevel: SceneObject | undefined = sceneObject;\n let collected: SceneDataLayerProvider[] = [];\n\n while (currentLevel) {\n const dataProvider = currentLevel.state.$data;\n if (!dataProvider) {\n currentLevel = currentLevel.parent;\n continue;\n }\n\n // Check if data layer exists nested inside another data provider\n if (isDataLayer(dataProvider)) {\n collected = collected.concat(dataProvider);\n } else {\n if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {\n collected = collected.concat(dataProvider.state.$data);\n }\n }\n\n if (localOnly && collected.length > 0) {\n break;\n }\n\n currentLevel = currentLevel.parent;\n }\n\n return collected;\n}\n\ninterface SceneType<T> extends Function {\n new (...args: never[]): T;\n}\n\n/**\n * A utility function to find the closest ancestor of a given type. This function expects\n * to find it and will throw an error if it does not.\n */\nexport function getAncestor<ParentType>(sceneObject: SceneObject, ancestorType: SceneType<ParentType>): ParentType {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent instanceof ancestorType) {\n return parent;\n }\n parent = parent.parent;\n }\n\n if (!parent) {\n throw new Error('Unable to find parent of type ' + ancestorType.name);\n }\n\n return parent as ParentType;\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided descendentType type.\n */\nexport function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>) {\n function isDescendentType(scene: SceneObject): scene is T {\n return scene instanceof descendentType;\n }\n\n const targetScenes = findAllObjects(scene, isDescendentType);\n return targetScenes.filter(isDescendentType);\n}\n\n/**\n * Returns the closest SceneObject that has a state property with the\n * name urlSyncManager that is of type UrlSyncManager\n */\nexport function getUrlSyncManager(sceneObject: SceneObject): UrlSyncManagerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if ('urlSyncManager' in parent.state) {\n return parent.state.urlSyncManager as UrlSyncManagerLike;\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n\n/**\n * Will walk up the scene object graph to the closest $scopesBridge scene object\n */\nexport function getScopesBridge(sceneObject: SceneObject): SceneScopesBridge | undefined {\n return (findObject(sceneObject, (s) => s instanceof SceneScopesBridge) as SceneScopesBridge) ?? undefined;\n}\n"],"names":["scene"],"mappings":";;;;;;;;AAiBO,SAAS,aAAa,WAA0C,EAAA;AAjBvE,EAAA,IAAA,EAAA;AAkBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,UAAU,MAAjD,IAAsD,GAAA,EAAA,GAAA,gBAAA;AAC/D;AAKO,SA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AAQ,gBAAW,WAAa,EAAA,CAAC,MAAM,CAAa,YAAA,iBAAiB,MAA7D,IAAwF,GAAA,EAAA,GAAA,MAAA;AAClG;;;;"}
1
+ {"version":3,"file":"sceneGraph.js","sources":["../../../../src/core/sceneGraph/sceneGraph.ts"],"sourcesContent":["import { Scope, ScopedVars } from '@grafana/data';\nimport { EmptyDataNode, EmptyVariableSet } from '../../variables/interpolation/defaults';\n\nimport { sceneInterpolator } from '../../variables/interpolation/sceneInterpolator';\nimport { VariableCustomFormatterFn, SceneVariables } from '../../variables/types';\n\nimport { isDataLayer, SceneDataLayerProvider, SceneDataProvider, SceneLayout, SceneObject } from '../types';\nimport { lookupVariable } from '../../variables/lookupVariable';\nimport { getClosest } from './utils';\nimport { VariableInterpolation } from '@grafana/runtime';\nimport { QueryVariable } from '../../variables/variants/query/QueryVariable';\nimport { UrlSyncManagerLike } from '../../services/UrlSyncManager';\nimport { ScopesVariable } from '../../variables/variants/ScopesVariable';\nimport { SCOPES_VARIABLE_NAME } from '../../variables/constants';\n\n/**\n * Get the closest node with variables\n */\nexport function getVariables(sceneObject: SceneObject): SceneVariables {\n return getClosest(sceneObject, (s) => s.state.$variables) ?? EmptyVariableSet;\n}\n\n/**\n * Will walk up the scene object graph to the closest $data scene object\n */\nexport function getData(sceneObject: SceneObject): SceneDataProvider {\n return getClosest(sceneObject, (s) => s.state.$data) ?? EmptyDataNode;\n}\n\nfunction isSceneLayout(s: SceneObject): s is SceneLayout {\n return 'isDraggable' in s;\n}\n\n/**\n * Will walk up the scene object graph to the closest $layout scene object\n */\nexport function getLayout(scene: SceneObject): SceneLayout | null {\n const parent = getClosest(scene, (s) => (isSceneLayout(s) ? s : undefined));\n if (parent) {\n return parent;\n }\n\n return null;\n}\n\n/**\n * Interpolates the given string using the current scene object as context. *\n *\n * Note: the interpolations array will be mutated by adding information about variables that\n * have been interpolated during replacement. Variables that were specified in the target but not found in\n * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details.\n *\n * @param {VariableInterpolation[]} interpolations an optional array that is updated with interpolated variables.\n */\nexport function interpolate(\n sceneObject: SceneObject,\n value: string | undefined | null,\n scopedVars?: ScopedVars,\n format?: string | VariableCustomFormatterFn,\n interpolations?: VariableInterpolation[]\n): string {\n if (value === '' || value == null) {\n return '';\n }\n\n return sceneInterpolator(sceneObject, value, scopedVars, format, interpolations);\n}\n\n/**\n * Checks if the variable is currently loading or waiting to update.\n * It also returns true if a dependency of the variable is loading.\n *\n * For example if C depends on variable B which depends on variable A and A is loading this returns true for variable C and B.\n */\nexport function hasVariableDependencyInLoadingState(sceneObject: SceneObject) {\n if (!sceneObject.variableDependency) {\n return false;\n }\n\n for (const name of sceneObject.variableDependency.getNames()) {\n // This is for backwards compability. In the old architecture query variables could reference itself in a query without breaking.\n if (sceneObject instanceof QueryVariable && sceneObject.state.name === name) {\n console.warn('Query variable is referencing itself');\n continue;\n }\n\n const variable = lookupVariable(name, sceneObject);\n if (!variable) {\n continue;\n }\n\n const set = variable.parent as SceneVariables;\n if (set.isVariableLoadingOrWaitingToUpdate(variable)) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction findObjectInternal(\n scene: SceneObject,\n check: (obj: SceneObject) => boolean,\n alreadySearchedChild?: SceneObject,\n shouldSearchUp?: boolean\n): SceneObject | null {\n if (check(scene)) {\n return scene;\n }\n\n let found: SceneObject | null = null;\n\n scene.forEachChild((child) => {\n if (child === alreadySearchedChild) {\n return;\n }\n\n let maybe = findObjectInternal(child, check);\n if (maybe) {\n found = maybe;\n }\n });\n\n if (found) {\n return found;\n }\n\n if (shouldSearchUp && scene.parent) {\n return findObjectInternal(scene.parent, check, scene, true);\n }\n\n return null;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key.\n *\n * Throws error if no key-matching scene object found.\n */\nexport function findByKey(sceneObject: SceneObject, key: string) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n return found;\n}\n\n/**\n * Returns a scene object from the scene graph with the requested key and type.\n *\n * Throws error if no key-matching scene object found.\n * Throws error if the given type does not match.\n */\nexport function findByKeyAndType<TargetType extends SceneObject>(\n sceneObject: SceneObject,\n key: string,\n targetType: { new (...args: never[]): TargetType }\n) {\n const found = findObject(sceneObject, (sceneToCheck) => {\n return sceneToCheck.state.key === key;\n });\n if (!found) {\n throw new Error('Unable to find scene with key ' + key);\n }\n if (!(found instanceof targetType)) {\n throw new Error(`Found scene object with key ${key} does not match type ${targetType.name}`);\n }\n return found;\n}\n\n/**\n * This will search the full scene graph, starting with the scene node passed in, then walking up the parent chain. *\n */\nexport function findObject(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject | null {\n return findObjectInternal(scene, check, undefined, true);\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided predicate.\n */\nexport function findAllObjects(scene: SceneObject, check: (obj: SceneObject) => boolean): SceneObject[] {\n const found: SceneObject[] = [];\n\n scene.forEachChild((child) => {\n if (check(child)) {\n found.push(child);\n }\n\n found.push(...findAllObjects(child, check));\n });\n\n return found;\n}\n\n/**\n * Will walk up the scene object graph up until the root and collect all SceneDataLayerProvider objects.\n * When localOnly set to true, it will only collect the closest layers.\n */\nexport function getDataLayers(sceneObject: SceneObject, localOnly = false): SceneDataLayerProvider[] {\n let currentLevel: SceneObject | undefined = sceneObject;\n let collected: SceneDataLayerProvider[] = [];\n\n while (currentLevel) {\n const dataProvider = currentLevel.state.$data;\n if (!dataProvider) {\n currentLevel = currentLevel.parent;\n continue;\n }\n\n // Check if data layer exists nested inside another data provider\n if (isDataLayer(dataProvider)) {\n collected = collected.concat(dataProvider);\n } else {\n if (dataProvider.state.$data && isDataLayer(dataProvider.state.$data)) {\n collected = collected.concat(dataProvider.state.$data);\n }\n }\n\n if (localOnly && collected.length > 0) {\n break;\n }\n\n currentLevel = currentLevel.parent;\n }\n\n return collected;\n}\n\ninterface SceneType<T> extends Function {\n new (...args: never[]): T;\n}\n\n/**\n * A utility function to find the closest ancestor of a given type. This function expects\n * to find it and will throw an error if it does not.\n */\nexport function getAncestor<ParentType>(sceneObject: SceneObject, ancestorType: SceneType<ParentType>): ParentType {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if (parent instanceof ancestorType) {\n return parent;\n }\n parent = parent.parent;\n }\n\n if (!parent) {\n throw new Error('Unable to find parent of type ' + ancestorType.name);\n }\n\n return parent as ParentType;\n}\n\n/**\n * This will search down the full scene graph, looking for objects that match the provided descendentType type.\n */\nexport function findDescendents<T extends SceneObject>(scene: SceneObject, descendentType: SceneType<T>) {\n function isDescendentType(scene: SceneObject): scene is T {\n return scene instanceof descendentType;\n }\n\n const targetScenes = findAllObjects(scene, isDescendentType);\n return targetScenes.filter(isDescendentType);\n}\n\n/**\n * Returns the closest SceneObject that has a state property with the\n * name urlSyncManager that is of type UrlSyncManager\n */\nexport function getUrlSyncManager(sceneObject: SceneObject): UrlSyncManagerLike | undefined {\n let parent: SceneObject | undefined = sceneObject;\n\n while (parent) {\n if ('urlSyncManager' in parent.state) {\n return parent.state.urlSyncManager as UrlSyncManagerLike;\n }\n parent = parent.parent;\n }\n\n return undefined;\n}\n\n/**\n * Will return the scopes from the scopes variable if available.\n */\nexport function getScopes(sceneObject: SceneObject): Scope[] | undefined {\n const scopesVariable = lookupVariable(SCOPES_VARIABLE_NAME, sceneObject);\n if (scopesVariable instanceof ScopesVariable) {\n return scopesVariable.state.scopes;\n }\n\n return undefined;\n}\n"],"names":["scene"],"mappings":";;;;;;;;;AAkBO,SAAS,aAAa,WAA0C,EAAA;AAlBvE,EAAA,IAAA,EAAA;AAmBE,EAAO,OAAA,CAAA,EAAA,GAAA,UAAA,CAAW,aAAa,CAAC,CAAA,KAAM,EAAE,KAAM,CAAA,UAAU,MAAjD,IAAsD,GAAA,EAAA,GAAA,gBAAA;AAC/D;AAKO,SAAS,QAAQ,WAA6C,EAAA;AAzBrE,EAAA,IAAA,EAAA;AA0BE,EAAO,OAAA,CAAA,EAA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eAAe,KAAM,CAAA,MAAA;AAAA;AAG9B,EAAO,OAAA,MAAA;AACT;;;;"}
package/dist/esm/index.js CHANGED
@@ -37,6 +37,7 @@ export { DataSourceVariable } from './variables/variants/DataSourceVariable.js';
37
37
  export { QueryVariable } from './variables/variants/query/QueryVariable.js';
38
38
  export { TestVariable } from './variables/variants/TestVariable.js';
39
39
  export { TextBoxVariable } from './variables/variants/TextBoxVariable.js';
40
+ export { ScopesVariable } from './variables/variants/ScopesVariable.js';
40
41
  export { MultiValueVariable } from './variables/variants/MultiValueVariable.js';
41
42
  export { LocalValueVariable } from './variables/variants/LocalValueVariable.js';
42
43
  export { IntervalVariable } from './variables/variants/IntervalVariable.js';
@@ -80,7 +81,6 @@ export { ControlsLabel } from './utils/ControlsLabel.js';
80
81
  export { MultiOrSingleValueSelect } from './variables/components/VariableValueSelect.js';
81
82
  export { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder.js';
82
83
  export { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders.js';
83
- export { SceneScopesBridge } from './core/SceneScopesBridge.js';
84
84
  export { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject.js';
85
85
  export { getExploreURL } from './utils/explore.js';
86
86
  export { PanelOptionsBuilders } from './core/PanelBuilders/PanelOptionsBuilders.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/cloneSceneObject';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport {\n escapeLabelValueInExactSelector,\n escapeLabelValueInRegexSelector,\n escapeURLDelimiters,\n renderPrometheusLabelFilters,\n} from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n SceneInteractionProfileEvent,\n} from './behaviors/types';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport type { AdHocFilterWithLabels } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridLayoutDragStartEvent } from './components/layout/grid/types';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport { LazyLoader } from './components/layout/LazyLoader';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { MultiOrSingleValueSelect } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\nexport { SceneScopesBridge } from './core/SceneScopesBridge';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n escapeLabelValueInRegexSelector,\n escapeLabelValueInExactSelector,\n escapeURLDelimiters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EACA,+BAAA;AAAA,EACA,+BAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { getUrlWithAppState } from './components/SceneApp/utils';\nimport { registerRuntimePanelPlugin } from './components/VizPanel/registerRuntimePanelPlugin';\nimport { cloneSceneObjectState } from './core/sceneGraph/cloneSceneObject';\nimport { registerRuntimeDataSource } from './querying/RuntimeDataSource';\nimport { getUrlState, syncStateFromSearchParams } from './services/utils';\n\nimport { registerVariableMacro } from './variables/macros';\nimport {\n escapeLabelValueInExactSelector,\n escapeLabelValueInRegexSelector,\n escapeURLDelimiters,\n renderPrometheusLabelFilters,\n} from './variables/utils';\nimport {\n isAdHocVariable,\n isQueryVariable,\n isTextBoxVariable,\n isCustomVariable,\n isDataSourceVariable,\n isConstantVariable,\n isIntervalVariable,\n isGroupByVariable,\n} from './variables/variants/guards';\n\nexport * from './core/types';\nexport * from './core/events';\nexport { sceneGraph } from './core/sceneGraph';\nexport * as behaviors from './behaviors';\nexport * as dataLayers from './querying/layers';\n\nexport { SceneObjectBase, useSceneObjectState } from './core/SceneObjectBase';\nexport { SceneDataNode } from './core/SceneDataNode';\nexport { SceneTimeRange } from './core/SceneTimeRange';\nexport { SceneTimeZoneOverride } from './core/SceneTimeZoneOverride';\n\nexport { SceneQueryRunner, type QueryRunnerState } from './querying/SceneQueryRunner';\nexport { DataProviderProxy } from './querying/DataProviderProxy';\nexport {\n type ExtraQueryDescriptor,\n type ExtraQueryProvider,\n type ExtraQueryDataProcessor,\n} from './querying/ExtraQueryProvider';\nexport { SceneDataLayerSet, SceneDataLayerSetBase } from './querying/SceneDataLayerSet';\nexport { SceneDataLayerBase } from './querying/layers/SceneDataLayerBase';\nexport { SceneDataLayerControls } from './querying/layers/SceneDataLayerControls';\nexport { SceneDataTransformer, type SceneDataTransformerState } from './querying/SceneDataTransformer';\nexport { registerQueryWithController } from './querying/registerQueryWithController';\nexport { registerRuntimeDataSource, RuntimeDataSource } from './querying/RuntimeDataSource';\nexport type {\n SceneQueryControllerLike,\n SceneQueryControllerEntryType,\n SceneQueryControllerEntry,\n SceneInteractionProfileEvent,\n} from './behaviors/types';\n\nexport * from './variables/types';\nexport { VariableDependencyConfig } from './variables/VariableDependencyConfig';\nexport { formatRegistry, type FormatVariable } from './variables/interpolation/formatRegistry';\nexport { VariableValueSelectors } from './variables/components/VariableValueSelectors';\nexport { VariableValueControl } from './variables/components/VariableValueControl';\nexport { SceneVariableSet } from './variables/sets/SceneVariableSet';\nexport { ConstantVariable } from './variables/variants/ConstantVariable';\nexport { CustomVariable } from './variables/variants/CustomVariable';\nexport { DataSourceVariable } from './variables/variants/DataSourceVariable';\nexport { QueryVariable } from './variables/variants/query/QueryVariable';\nexport { TestVariable } from './variables/variants/TestVariable';\nexport { TextBoxVariable } from './variables/variants/TextBoxVariable';\nexport { ScopesVariable } from './variables/variants/ScopesVariable';\nexport {\n MultiValueVariable,\n type MultiValueVariableState,\n type VariableGetOptionsArgs,\n} from './variables/variants/MultiValueVariable';\nexport { LocalValueVariable } from './variables/variants/LocalValueVariable';\nexport { IntervalVariable } from './variables/variants/IntervalVariable';\nexport { AdHocFiltersVariable } from './variables/adhoc/AdHocFiltersVariable';\nexport type { AdHocFilterWithLabels } from './variables/adhoc/AdHocFiltersVariable';\nexport { GroupByVariable } from './variables/groupby/GroupByVariable';\nexport { type MacroVariableConstructor } from './variables/macros/types';\n\nexport { type UrlSyncManagerLike, UrlSyncManager, NewSceneObjectAddedEvent } from './services/UrlSyncManager';\nexport { useUrlSync } from './services/useUrlSync';\nexport { UrlSyncContextProvider } from './services/UrlSyncContextProvider';\nexport { SceneObjectUrlSyncConfig } from './services/SceneObjectUrlSyncConfig';\n\nexport { EmbeddedScene, type EmbeddedSceneState } from './components/EmbeddedScene';\nexport { VizPanel, type VizPanelState } from './components/VizPanel/VizPanel';\nexport { VizPanelMenu } from './components/VizPanel/VizPanelMenu';\nexport { VizPanelExploreButton } from './components/VizPanel/VizPanelExploreButton';\nexport { NestedScene } from './components/NestedScene';\nexport { SceneCanvasText } from './components/SceneCanvasText';\nexport { SceneToolbarButton, SceneToolbarInput } from './components/SceneToolbarButton';\nexport { SceneTimePicker } from './components/SceneTimePicker';\nexport { SceneRefreshPicker, type SceneRefreshPickerState } from './components/SceneRefreshPicker';\nexport { SceneTimeRangeTransformerBase } from './core/SceneTimeRangeTransformerBase';\nexport { SceneTimeRangeCompare } from './components/SceneTimeRangeCompare';\nexport { SceneByFrameRepeater } from './components/SceneByFrameRepeater';\nexport { SceneByVariableRepeater } from './components/SceneByVariableRepeater';\nexport { SceneControlsSpacer } from './components/SceneControlsSpacer';\nexport {\n SceneFlexLayout,\n SceneFlexItem,\n type SceneFlexItemState,\n type SceneFlexItemLike,\n} from './components/layout/SceneFlexLayout';\nexport { SceneCSSGridLayout, SceneCSSGridItem } from './components/layout/CSSGrid/SceneCSSGridLayout';\nexport { SceneGridLayout } from './components/layout/grid/SceneGridLayout';\nexport { SceneGridLayoutDragStartEvent } from './components/layout/grid/types';\nexport { SceneGridItem } from './components/layout/grid/SceneGridItem';\nexport { SceneGridRow } from './components/layout/grid/SceneGridRow';\nexport { type SceneGridItemStateLike, type SceneGridItemLike } from './components/layout/grid/types';\nexport { SplitLayout } from './components/layout/split/SplitLayout';\nexport { LazyLoader } from './components/layout/LazyLoader';\nexport {\n type SceneAppPageLike,\n type SceneRouteMatch,\n type SceneAppPageState,\n type SceneAppDrilldownView,\n type SceneAppRoute,\n} from './components/SceneApp/types';\nexport { SceneApp, useSceneApp } from './components/SceneApp/SceneApp';\nexport { SceneAppPage } from './components/SceneApp/SceneAppPage';\nexport { SceneReactObject } from './components/SceneReactObject';\nexport { SceneObjectRef } from './core/SceneObjectRef';\nexport {\n PanelBuilders,\n PanelOptionsBuilders,\n FieldConfigBuilders,\n FieldConfigOverridesBuilder,\n} from './core/PanelBuilders';\nexport { FieldConfigBuilder } from './core/PanelBuilders/FieldConfigBuilder';\nexport { VizPanelBuilder } from './core/PanelBuilders/VizPanelBuilder';\nexport { SceneDebugger } from './components/SceneDebugger/SceneDebugger';\nexport { VariableValueSelectWrapper } from './variables/components/VariableValueSelectors';\nexport { ControlsLabel } from './utils/ControlsLabel';\nexport { MultiOrSingleValueSelect } from './variables/components/VariableValueSelect';\nexport { VizConfigBuilder } from './core/PanelBuilders/VizConfigBuilder';\nexport { VizConfigBuilders } from './core/PanelBuilders/VizConfigBuilders';\nexport { type VizConfig } from './core/PanelBuilders/types';\n\nexport const sceneUtils = {\n getUrlWithAppState,\n registerRuntimePanelPlugin,\n registerRuntimeDataSource,\n registerVariableMacro,\n cloneSceneObjectState,\n syncStateFromSearchParams,\n getUrlState,\n renderPrometheusLabelFilters,\n escapeLabelValueInRegexSelector,\n escapeLabelValueInExactSelector,\n escapeURLDelimiters,\n\n // Variable guards\n isAdHocVariable,\n isConstantVariable,\n isCustomVariable,\n isDataSourceVariable,\n isIntervalVariable,\n isQueryVariable,\n isTextBoxVariable,\n isGroupByVariable,\n};\n\nexport { SafeSerializableSceneObject } from './utils/SafeSerializableSceneObject';\nexport { getExploreURL } from './utils/explore';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4IO,MAAM,UAAa,GAAA;AAAA,EACxB,kBAAA;AAAA,EACA,0BAAA;AAAA,EACA,yBAAA;AAAA,EACA,qBAAA;AAAA,EACA,qBAAA;AAAA,EACA,yBAAA;AAAA,EACA,WAAA;AAAA,EACA,4BAAA;AAAA,EACA,+BAAA;AAAA,EACA,+BAAA;AAAA,EACA,mBAAA;AAAA;AAAA,EAGA,eAAA;AAAA,EACA,kBAAA;AAAA,EACA,gBAAA;AAAA,EACA,oBAAA;AAAA,EACA,kBAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF;;;;"}
@@ -38,7 +38,8 @@ class SceneQueryRunner extends SceneObjectBase {
38
38
  this._variableDependency = new VariableDependencyConfig(this, {
39
39
  statePaths: ["queries", "datasource", "minInterval"],
40
40
  onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
41
- onAnyVariableChanged: this.onAnyVariableChanged.bind(this)
41
+ onAnyVariableChanged: this.onAnyVariableChanged.bind(this),
42
+ dependsOnScopes: true
42
43
  });
43
44
  this.onDataReceived = (data) => {
44
45
  const preProcessedData = preProcessPanelData(data, this.state.data);
@@ -59,7 +60,6 @@ class SceneQueryRunner extends SceneObjectBase {
59
60
  _onActivate() {
60
61
  if (this.isQueryModeAuto()) {
61
62
  const timeRange = sceneGraph.getTimeRange(this);
62
- const scopesBridge = sceneGraph.getScopesBridge(this);
63
63
  const providers = this.getClosestExtraQueryProviders();
64
64
  for (const provider of providers) {
65
65
  this._subs.add(
@@ -70,7 +70,6 @@ class SceneQueryRunner extends SceneObjectBase {
70
70
  })
71
71
  );
72
72
  }
73
- this.subscribeToScopesChanges(scopesBridge);
74
73
  this.subscribeToTimeRangeChanges(timeRange);
75
74
  if (this.shouldRunQueriesOnActivate()) {
76
75
  this.runQueries();
@@ -234,21 +233,6 @@ class SceneQueryRunner extends SceneObjectBase {
234
233
  isDataReadyToDisplay() {
235
234
  return Boolean(this.state._hasFetchedData);
236
235
  }
237
- subscribeToScopesChanges(scopesBridge) {
238
- if (!scopesBridge) {
239
- return;
240
- }
241
- if (this._scopesSubBridge === scopesBridge) {
242
- return;
243
- }
244
- if (this._scopesSub) {
245
- this._scopesSub.unsubscribe();
246
- }
247
- this._scopesSubBridge = scopesBridge;
248
- this._scopesSub = scopesBridge.subscribeToValue(() => {
249
- this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
250
- });
251
- }
252
236
  subscribeToTimeRangeChanges(timeRange) {
253
237
  if (this._timeSubRange === timeRange) {
254
238
  return;
@@ -258,17 +242,15 @@ class SceneQueryRunner extends SceneObjectBase {
258
242
  }
259
243
  this._timeSubRange = timeRange;
260
244
  this._timeSub = timeRange.subscribeToState(() => {
261
- this.runWithTimeRangeAndScopes(timeRange, sceneGraph.getScopesBridge(this));
245
+ this.runWithTimeRange(timeRange);
262
246
  });
263
247
  }
264
248
  runQueries() {
265
249
  const timeRange = sceneGraph.getTimeRange(this);
266
- const scopesBridge = sceneGraph.getScopesBridge(this);
267
250
  if (this.isQueryModeAuto()) {
268
251
  this.subscribeToTimeRangeChanges(timeRange);
269
- this.subscribeToScopesChanges(scopesBridge);
270
252
  }
271
- this.runWithTimeRangeAndScopes(timeRange, scopesBridge);
253
+ this.runWithTimeRange(timeRange);
272
254
  }
273
255
  getMaxDataPoints() {
274
256
  var _a;
@@ -288,8 +270,8 @@ class SceneQueryRunner extends SceneObjectBase {
288
270
  data: { ...this.state.data, state: LoadingState.Done }
289
271
  });
290
272
  }
291
- async runWithTimeRangeAndScopes(timeRange, scopesBridge) {
292
- var _a, _b, _c, _d;
273
+ async runWithTimeRange(timeRange) {
274
+ var _a, _b, _c;
293
275
  if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
294
276
  return;
295
277
  }
@@ -302,22 +284,17 @@ class SceneQueryRunner extends SceneObjectBase {
302
284
  this.setState({ data: { ...(_b = this.state.data) != null ? _b : emptyPanelData, state: LoadingState.Loading } });
303
285
  return;
304
286
  }
305
- if ((scopesBridge == null ? void 0 : scopesBridge.isLoading()) && (scopesBridge == null ? void 0 : scopesBridge.getValue().length)) {
306
- writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
307
- this.setState({ data: { ...(_c = this.state.data) != null ? _c : emptyPanelData, state: LoadingState.Loading } });
308
- return;
309
- }
310
287
  const { queries } = this.state;
311
288
  if (!(queries == null ? void 0 : queries.length)) {
312
289
  this._setNoDataState();
313
290
  return;
314
291
  }
315
292
  try {
316
- const datasource = (_d = this.state.datasource) != null ? _d : findFirstDatasource(queries);
293
+ const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
317
294
  const ds = await getDataSource(datasource, this._scopedVars);
318
295
  this.findAndSubscribeToAdHocFilters(ds.uid);
319
296
  const runRequest = getRunRequest();
320
- const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds, scopesBridge);
297
+ const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
321
298
  writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
322
299
  let stream = runRequest(ds, primary);
323
300
  if (secondaries.length > 0) {
@@ -358,7 +335,7 @@ class SceneQueryRunner extends SceneObjectBase {
358
335
  clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
359
336
  return clone;
360
337
  }
361
- prepareRequests(timeRange, ds, scopesBridge) {
338
+ prepareRequests(timeRange, ds) {
362
339
  var _a, _b;
363
340
  const { minInterval, queries } = this.state;
364
341
  let request = {
@@ -379,7 +356,7 @@ class SceneQueryRunner extends SceneObjectBase {
379
356
  },
380
357
  cacheTimeout: this.state.cacheTimeout,
381
358
  queryCachingTTL: this.state.queryCachingTTL,
382
- scopes: scopesBridge == null ? void 0 : scopesBridge.getValue(),
359
+ scopes: sceneGraph.getScopes(this),
383
360
  // This asks the scene root to provide context properties like app, panel and dashboardUID
384
361
  ...getEnrichedDataRequest(this)
385
362
  };