@grafana/scenes 6.11.1 → 6.12.0--canary.1121.15045230319.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 (36) hide show
  1. package/CHANGELOG.md +0 -12
  2. package/dist/esm/components/SceneApp/SceneApp.js +2 -2
  3. package/dist/esm/components/SceneApp/SceneApp.js.map +1 -1
  4. package/dist/esm/components/SceneApp/SceneAppPage.js +2 -18
  5. package/dist/esm/components/SceneApp/SceneAppPage.js.map +1 -1
  6. package/dist/esm/components/VizPanel/VizPanel.js +2 -2
  7. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  8. package/dist/esm/core/sceneGraph/index.js +2 -2
  9. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  10. package/dist/esm/core/sceneGraph/sceneGraph.js +9 -5
  11. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  12. package/dist/esm/index.js +1 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/querying/SceneQueryRunner.js +10 -33
  15. package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
  16. package/dist/esm/variables/VariableDependencyConfig.js +4 -1
  17. package/dist/esm/variables/VariableDependencyConfig.js.map +1 -1
  18. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js +19 -18
  19. package/dist/esm/variables/adhoc/AdHocFiltersVariable.js.map +1 -1
  20. package/dist/esm/variables/components/VariableValueSelectors.js +3 -0
  21. package/dist/esm/variables/components/VariableValueSelectors.js.map +1 -1
  22. package/dist/esm/variables/constants.js +2 -1
  23. package/dist/esm/variables/constants.js.map +1 -1
  24. package/dist/esm/variables/groupby/GroupByVariable.js +2 -2
  25. package/dist/esm/variables/groupby/GroupByVariable.js.map +1 -1
  26. package/dist/esm/variables/sets/SceneVariableSet.js +10 -7
  27. package/dist/esm/variables/sets/SceneVariableSet.js.map +1 -1
  28. package/dist/esm/variables/types.js.map +1 -1
  29. package/dist/esm/variables/variants/ScopesVariable.js +80 -0
  30. package/dist/esm/variables/variants/ScopesVariable.js.map +1 -0
  31. package/dist/index.d.ts +56 -53
  32. package/dist/index.js +112 -151
  33. package/dist/index.js.map +1 -1
  34. package/package.json +2 -2
  35. package/dist/esm/core/SceneScopesBridge.js +0 -93
  36. package/dist/esm/core/SceneScopesBridge.js.map +0 -1
package/dist/index.js CHANGED
@@ -1283,6 +1283,7 @@ const AUTO_VARIABLE_TEXT = "Auto";
1283
1283
  const AUTO_VARIABLE_VALUE = "$__auto";
1284
1284
  const VARIABLE_REGEX = /\$(\w+)|\[\[(\w+?)(?::(\w+))?\]\]|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/g;
1285
1285
  const SEARCH_FILTER_VARIABLE = "__searchFilter";
1286
+ const SCOPES_VARIABLE_NAME = "__scopes";
1286
1287
 
1287
1288
  const formatRegistry = new data.Registry(() => {
1288
1289
  const formats = [
@@ -3098,7 +3099,7 @@ class GroupByVariable extends MultiValueVariable {
3098
3099
  * Get possible keys given current filters. Do not call from plugins directly
3099
3100
  */
3100
3101
  this._getKeys = async (ds) => {
3101
- var _a, _b, _c, _d;
3102
+ var _a, _b, _c;
3102
3103
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, null));
3103
3104
  if (override && override.replace) {
3104
3105
  return override.values;
@@ -3116,7 +3117,7 @@ class GroupByVariable extends MultiValueVariable {
3116
3117
  filters: otherFilters,
3117
3118
  queries,
3118
3119
  timeRange,
3119
- scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue(),
3120
+ scopes: sceneGraph.getScopes(this),
3120
3121
  ...getEnrichedFiltersRequest(this)
3121
3122
  });
3122
3123
  if (responseHasError(response)) {
@@ -5350,25 +5351,21 @@ class AdHocFiltersVariable extends SceneObjectBase {
5350
5351
  // are set on construct and used to restore a baseFilter with an origin
5351
5352
  // to its original value if edited at some point
5352
5353
  this._originalValues = /* @__PURE__ */ new Map();
5354
+ /** Needed for scopes dependency */
5355
+ this._variableDependency = new VariableDependencyConfig(this, {
5356
+ dependsOnScopes: true,
5357
+ onReferencedVariableValueChanged: () => this._updateScopesFilters()
5358
+ });
5353
5359
  this._urlSync = new AdHocFiltersVariableUrlSyncHandler(this);
5354
5360
  this._activationHandler = () => {
5355
- var _a, _b;
5356
- this._scopesBridge = sceneGraph.getScopesBridge(this);
5357
- const scopes = (_a = this._scopesBridge) == null ? void 0 : _a.getValue();
5358
- if (scopes) {
5359
- this._updateScopesFilters(scopes);
5360
- }
5361
- const sub = (_b = this._scopesBridge) == null ? void 0 : _b.subscribeToValue((n, _) => {
5362
- this._updateScopesFilters(n);
5363
- });
5361
+ this._updateScopesFilters();
5364
5362
  return () => {
5365
- var _a2, _b2;
5366
- sub == null ? void 0 : sub.unsubscribe();
5367
- if ((_a2 = this.state.baseFilters) == null ? void 0 : _a2.length) {
5363
+ var _a, _b;
5364
+ if ((_a = this.state.baseFilters) == null ? void 0 : _a.length) {
5368
5365
  this.setState({
5369
5366
  baseFilters: [...this.state.baseFilters.filter((filter) => filter.origin !== "scope")]
5370
5367
  });
5371
- (_b2 = this.state.baseFilters) == null ? void 0 : _b2.forEach((filter) => {
5368
+ (_b = this.state.baseFilters) == null ? void 0 : _b.forEach((filter) => {
5372
5369
  if (filter.origin === "dashboard" && filter.restorable) {
5373
5370
  this.restoreOriginalFilter(filter);
5374
5371
  }
@@ -5390,8 +5387,12 @@ class AdHocFiltersVariable extends SceneObjectBase {
5390
5387
  });
5391
5388
  this.addActivationHandler(this._activationHandler);
5392
5389
  }
5393
- _updateScopesFilters(scopes) {
5390
+ _updateScopesFilters() {
5394
5391
  var _a, _b;
5392
+ const scopes = sceneGraph.getScopes(this);
5393
+ if (!scopes) {
5394
+ return;
5395
+ }
5395
5396
  if (!scopes.length) {
5396
5397
  this.setState({
5397
5398
  baseFilters: (_a = this.state.baseFilters) == null ? void 0 : _a.filter((filter) => filter.origin !== "scope")
@@ -5592,7 +5593,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5592
5593
  * Get possible keys given current filters. Do not call from plugins directly
5593
5594
  */
5594
5595
  async _getKeys(currentKey) {
5595
- var _a, _b, _c, _d;
5596
+ var _a, _b, _c;
5596
5597
  const override = await ((_b = (_a = this.state).getTagKeysProvider) == null ? void 0 : _b.call(_a, this, currentKey));
5597
5598
  if (override && override.replace) {
5598
5599
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5611,7 +5612,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5611
5612
  filters: otherFilters,
5612
5613
  queries,
5613
5614
  timeRange,
5614
- scopes: (_d = this._scopesBridge) == null ? void 0 : _d.getValue(),
5615
+ scopes: sceneGraph.getScopes(this),
5615
5616
  ...getEnrichedFiltersRequest(this)
5616
5617
  });
5617
5618
  if (responseHasError(response)) {
@@ -5631,7 +5632,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5631
5632
  * Get possible key values for a specific key given current filters. Do not call from plugins directly
5632
5633
  */
5633
5634
  async _getValuesFor(filter) {
5634
- var _a, _b, _c, _d, _e;
5635
+ var _a, _b, _c, _d;
5635
5636
  const override = await ((_b = (_a = this.state).getTagValuesProvider) == null ? void 0 : _b.call(_a, this, filter));
5636
5637
  if (override && override.replace) {
5637
5638
  return dataFromResponse(override.values).map(toSelectableValue);
@@ -5644,7 +5645,7 @@ class AdHocFiltersVariable extends SceneObjectBase {
5644
5645
  const otherFilters = this.state.filters.filter((f) => f.key !== filter.key).concat(filteredBaseFilters);
5645
5646
  const timeRange = sceneGraph.getTimeRange(this).state.value;
5646
5647
  const queries = this.state.useQueriesAsFilterForOptions ? getQueriesForVariables(this) : void 0;
5647
- let scopes = (_e = this._scopesBridge) == null ? void 0 : _e.getValue();
5648
+ let scopes = sceneGraph.getScopes(this);
5648
5649
  if (filter.origin === "scope") {
5649
5650
  scopes = scopes == null ? void 0 : scopes.map((scope) => {
5650
5651
  return {
@@ -5802,7 +5803,8 @@ class SceneQueryRunner extends SceneObjectBase {
5802
5803
  this._variableDependency = new VariableDependencyConfig(this, {
5803
5804
  statePaths: ["queries", "datasource", "minInterval"],
5804
5805
  onVariableUpdateCompleted: this.onVariableUpdatesCompleted.bind(this),
5805
- onAnyVariableChanged: this.onAnyVariableChanged.bind(this)
5806
+ onAnyVariableChanged: this.onAnyVariableChanged.bind(this),
5807
+ dependsOnScopes: true
5806
5808
  });
5807
5809
  this.onDataReceived = (data$1) => {
5808
5810
  const preProcessedData = data.preProcessPanelData(data$1, this.state.data);
@@ -5823,7 +5825,6 @@ class SceneQueryRunner extends SceneObjectBase {
5823
5825
  _onActivate() {
5824
5826
  if (this.isQueryModeAuto()) {
5825
5827
  const timeRange = sceneGraph.getTimeRange(this);
5826
- const scopesBridge = sceneGraph.getScopesBridge(this);
5827
5828
  const providers = this.getClosestExtraQueryProviders();
5828
5829
  for (const provider of providers) {
5829
5830
  this._subs.add(
@@ -5834,7 +5835,6 @@ class SceneQueryRunner extends SceneObjectBase {
5834
5835
  })
5835
5836
  );
5836
5837
  }
5837
- this.subscribeToScopesChanges(scopesBridge);
5838
5838
  this.subscribeToTimeRangeChanges(timeRange);
5839
5839
  if (this.shouldRunQueriesOnActivate()) {
5840
5840
  this.runQueries();
@@ -5998,21 +5998,6 @@ class SceneQueryRunner extends SceneObjectBase {
5998
5998
  isDataReadyToDisplay() {
5999
5999
  return Boolean(this.state._hasFetchedData);
6000
6000
  }
6001
- subscribeToScopesChanges(scopesBridge) {
6002
- if (!scopesBridge) {
6003
- return;
6004
- }
6005
- if (this._scopesSubBridge === scopesBridge) {
6006
- return;
6007
- }
6008
- if (this._scopesSub) {
6009
- this._scopesSub.unsubscribe();
6010
- }
6011
- this._scopesSubBridge = scopesBridge;
6012
- this._scopesSub = scopesBridge.subscribeToValue(() => {
6013
- this.runWithTimeRangeAndScopes(sceneGraph.getTimeRange(this), scopesBridge);
6014
- });
6015
- }
6016
6001
  subscribeToTimeRangeChanges(timeRange) {
6017
6002
  if (this._timeSubRange === timeRange) {
6018
6003
  return;
@@ -6022,17 +6007,15 @@ class SceneQueryRunner extends SceneObjectBase {
6022
6007
  }
6023
6008
  this._timeSubRange = timeRange;
6024
6009
  this._timeSub = timeRange.subscribeToState(() => {
6025
- this.runWithTimeRangeAndScopes(timeRange, sceneGraph.getScopesBridge(this));
6010
+ this.runWithTimeRange(timeRange);
6026
6011
  });
6027
6012
  }
6028
6013
  runQueries() {
6029
6014
  const timeRange = sceneGraph.getTimeRange(this);
6030
- const scopesBridge = sceneGraph.getScopesBridge(this);
6031
6015
  if (this.isQueryModeAuto()) {
6032
6016
  this.subscribeToTimeRangeChanges(timeRange);
6033
- this.subscribeToScopesChanges(scopesBridge);
6034
6017
  }
6035
- this.runWithTimeRangeAndScopes(timeRange, scopesBridge);
6018
+ this.runWithTimeRange(timeRange);
6036
6019
  }
6037
6020
  getMaxDataPoints() {
6038
6021
  var _a;
@@ -6052,8 +6035,8 @@ class SceneQueryRunner extends SceneObjectBase {
6052
6035
  data: { ...this.state.data, state: schema.LoadingState.Done }
6053
6036
  });
6054
6037
  }
6055
- async runWithTimeRangeAndScopes(timeRange, scopesBridge) {
6056
- var _a, _b, _c, _d;
6038
+ async runWithTimeRange(timeRange) {
6039
+ var _a, _b, _c;
6057
6040
  if (!this.state.maxDataPoints && this.state.maxDataPointsFromWidth && !this._containerWidth) {
6058
6041
  return;
6059
6042
  }
@@ -6066,22 +6049,17 @@ class SceneQueryRunner extends SceneObjectBase {
6066
6049
  this.setState({ data: { ...(_b = this.state.data) != null ? _b : emptyPanelData, state: schema.LoadingState.Loading } });
6067
6050
  return;
6068
6051
  }
6069
- if ((scopesBridge == null ? void 0 : scopesBridge.isLoading()) && (scopesBridge == null ? void 0 : scopesBridge.getValue().length)) {
6070
- writeSceneLog("SceneQueryRunner", "Scopes are in loading state, skipping query execution");
6071
- this.setState({ data: { ...(_c = this.state.data) != null ? _c : emptyPanelData, state: schema.LoadingState.Loading } });
6072
- return;
6073
- }
6074
6052
  const { queries } = this.state;
6075
6053
  if (!(queries == null ? void 0 : queries.length)) {
6076
6054
  this._setNoDataState();
6077
6055
  return;
6078
6056
  }
6079
6057
  try {
6080
- const datasource = (_d = this.state.datasource) != null ? _d : findFirstDatasource(queries);
6058
+ const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
6081
6059
  const ds = await getDataSource(datasource, this._scopedVars);
6082
6060
  this.findAndSubscribeToAdHocFilters(ds.uid);
6083
6061
  const runRequest = runtime.getRunRequest();
6084
- const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds, scopesBridge);
6062
+ const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
6085
6063
  writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
6086
6064
  let stream = runRequest(ds, primary);
6087
6065
  if (secondaries.length > 0) {
@@ -6122,7 +6100,7 @@ class SceneQueryRunner extends SceneObjectBase {
6122
6100
  clone["_results"].next({ origin: this, data: (_a = this.state.data) != null ? _a : emptyPanelData });
6123
6101
  return clone;
6124
6102
  }
6125
- prepareRequests(timeRange, ds, scopesBridge) {
6103
+ prepareRequests(timeRange, ds) {
6126
6104
  var _a, _b;
6127
6105
  const { minInterval, queries } = this.state;
6128
6106
  let request = {
@@ -6143,7 +6121,7 @@ class SceneQueryRunner extends SceneObjectBase {
6143
6121
  },
6144
6122
  cacheTimeout: this.state.cacheTimeout,
6145
6123
  queryCachingTTL: this.state.queryCachingTTL,
6146
- scopes: scopesBridge == null ? void 0 : scopesBridge.getValue(),
6124
+ scopes: sceneGraph.getScopes(this),
6147
6125
  // This asks the scene root to provide context properties like app, panel and dashboardUID
6148
6126
  ...getEnrichedDataRequest(this)
6149
6127
  };
@@ -6566,6 +6544,9 @@ class VariableDependencyConfig {
6566
6544
  this._dependencies.add(name);
6567
6545
  }
6568
6546
  }
6547
+ if (this._options.dependsOnScopes) {
6548
+ this._dependencies.add(SCOPES_VARIABLE_NAME);
6549
+ }
6569
6550
  if (this._statePaths) {
6570
6551
  for (const path of this._statePaths) {
6571
6552
  if (path === "*") {
@@ -7094,87 +7075,73 @@ function containsSearchFilter(query) {
7094
7075
  return str.indexOf(SEARCH_FILTER_VARIABLE) > -1;
7095
7076
  }
7096
7077
 
7097
- class SceneScopesBridge extends SceneObjectBase {
7098
- constructor() {
7099
- super(...arguments);
7078
+ class ScopesVariable extends SceneObjectBase {
7079
+ constructor(state) {
7080
+ super({
7081
+ skipUrlSync: true,
7082
+ loading: true,
7083
+ scopes: [],
7084
+ ...state,
7085
+ type: "system",
7086
+ name: SCOPES_VARIABLE_NAME,
7087
+ hide: schema.VariableHide.hideVariable
7088
+ });
7100
7089
  this._renderBeforeActivation = true;
7101
- this._contextSubject = new rxjs.BehaviorSubject(void 0);
7102
- }
7103
- getValue() {
7104
- var _a, _b;
7105
- return (_b = (_a = this.context) == null ? void 0 : _a.state.value) != null ? _b : [];
7106
7090
  }
7107
7091
  /**
7108
- * Emits values of the selected scopes array. It emits the current value and the previous value if there is a change.
7109
- * @param cb
7092
+ * Temporary simple implementation to stringify the scopes.
7110
7093
  */
7111
- subscribeToValue(cb) {
7112
- return this.contextObservable.pipe(
7113
- rxjs.map((context) => {
7114
- var _a;
7115
- return (_a = context == null ? void 0 : context.state.value) != null ? _a : [];
7116
- }),
7117
- rxjs.pairwise(),
7118
- rxjs.filter(([prevScopes, newScopes]) => !lodash.isEqual(prevScopes, newScopes))
7119
- ).subscribe(([prevScopes, newScopes]) => {
7120
- cb(newScopes, prevScopes);
7121
- });
7122
- }
7123
- isLoading() {
7124
- var _a, _b;
7125
- return (_b = (_a = this.context) == null ? void 0 : _a.state.loading) != null ? _b : false;
7126
- }
7127
- subscribeToLoading(cb) {
7128
- return this.contextObservable.pipe(
7129
- rxjs.filter((context) => !!context),
7130
- rxjs.pairwise(),
7131
- rxjs.map(
7132
- ([prevContext, newContext]) => {
7133
- var _a, _b;
7134
- return [(_a = prevContext == null ? void 0 : prevContext.state.loading) != null ? _a : false, (_b = newContext == null ? void 0 : newContext.state.loading) != null ? _b : false];
7135
- }
7136
- ),
7137
- rxjs.filter(([prevLoading, newLoading]) => prevLoading !== newLoading)
7138
- ).subscribe(([_prevLoading, newLoading]) => {
7139
- cb(newLoading);
7140
- });
7141
- }
7142
- setEnabled(enabled) {
7094
+ getValue(fieldPath) {
7143
7095
  var _a;
7144
- (_a = this.context) == null ? void 0 : _a.setEnabled(enabled);
7096
+ const scopes = (_a = this.state.scopes) != null ? _a : [];
7097
+ const scopeNames = scopes.map((scope) => scope.metadata.name);
7098
+ return scopeNames.join(", ");
7145
7099
  }
7146
- setReadOnly(readOnly) {
7147
- var _a;
7148
- (_a = this.context) == null ? void 0 : _a.setReadOnly(readOnly);
7100
+ getScopes() {
7101
+ return this.state.scopes;
7149
7102
  }
7150
7103
  /**
7151
7104
  * This method is used to keep the context up to date with the scopes context received from React
7152
- *
7153
- * Its rationale is:
7154
- * - When a new context is available, check if we have pending scopes passed from the URL
7155
- * - If we have pending scopes, ask the new context to load them
7156
- * - The loading should happen in a setTimeout to allow the existing context to pass its values to the URL sync handler
7157
- * - If a new context is received, propagate it as a new value in the behavior subject
7158
- * - If a new value is received, force a re-render to trigger the URL sync handler
7105
+ * 1) Subscribes to ScopesContext state changes and synchronizes it with the variable state
7106
+ * 2) Handles enable / disabling of scopes based on variable enable option.
7159
7107
  */
7160
- updateContext(newContext) {
7161
- var _a;
7162
- if (this.context !== newContext || ((_a = this.context) == null ? void 0 : _a.state) !== (newContext == null ? void 0 : newContext.state)) {
7163
- this._contextSubject.next(newContext);
7108
+ setContext(context) {
7109
+ if (!context) {
7110
+ return;
7111
+ }
7112
+ this._context = context;
7113
+ const oldState = context.state;
7114
+ if (this.state.enable != null) {
7115
+ context.setEnabled(this.state.enable);
7164
7116
  }
7117
+ const sub = context.stateObservable.subscribe((state) => {
7118
+ this.updateStateFromContext(state);
7119
+ });
7120
+ return () => {
7121
+ sub.unsubscribe();
7122
+ if (this.state.enable != null) {
7123
+ context.setEnabled(oldState.enabled);
7124
+ }
7125
+ };
7165
7126
  }
7166
- get context() {
7167
- return this._contextSubject.getValue();
7127
+ updateStateFromContext(state) {
7128
+ const loading = state.value.length === 0 ? false : state.loading;
7129
+ this.setState({ scopes: state.value, loading });
7130
+ if (!loading) {
7131
+ this.publishEvent(new SceneVariableValueChangedEvent(this), true);
7132
+ }
7168
7133
  }
7169
- get contextObservable() {
7170
- return this._contextSubject.asObservable();
7134
+ /**
7135
+ * Special function that enables variables to be hidden but still render to access react contexts
7136
+ */
7137
+ hiddenRender() {
7138
+ return /* @__PURE__ */ React__default.default.createElement(ScopesVariableRenderer, { model: this });
7171
7139
  }
7172
7140
  }
7173
- SceneScopesBridge.Component = SceneScopesBridgeRenderer;
7174
- function SceneScopesBridgeRenderer({ model }) {
7175
- const context = runtime.useScopes();
7141
+ function ScopesVariableRenderer({ model }) {
7142
+ const context = React.useContext(runtime.ScopesContext);
7176
7143
  React.useEffect(() => {
7177
- model.updateContext(context);
7144
+ return model.setContext(context);
7178
7145
  }, [context, model]);
7179
7146
  return null;
7180
7147
  }
@@ -7322,9 +7289,12 @@ function findDescendents(scene, descendentType) {
7322
7289
  const targetScenes = findAllObjects(scene, isDescendentType);
7323
7290
  return targetScenes.filter(isDescendentType);
7324
7291
  }
7325
- function getScopesBridge(sceneObject) {
7326
- var _a;
7327
- return (_a = findObject(sceneObject, (s) => s instanceof SceneScopesBridge)) != null ? _a : void 0;
7292
+ function getScopes(sceneObject) {
7293
+ const scopesVariable = lookupVariable(SCOPES_VARIABLE_NAME, sceneObject);
7294
+ if (scopesVariable instanceof ScopesVariable) {
7295
+ return scopesVariable.state.scopes;
7296
+ }
7297
+ return void 0;
7328
7298
  }
7329
7299
 
7330
7300
  const sceneGraph = {
@@ -7343,7 +7313,7 @@ const sceneGraph = {
7343
7313
  getAncestor,
7344
7314
  getQueryController,
7345
7315
  findDescendents,
7346
- getScopesBridge
7316
+ getScopes
7347
7317
  };
7348
7318
 
7349
7319
  class UniqueUrlKeyMapper {
@@ -8381,8 +8351,8 @@ class VizPanel extends SceneObjectBase {
8381
8351
  this._prevData = rawData;
8382
8352
  return this._dataWithFieldConfig;
8383
8353
  }
8384
- clone(withState) {
8385
- return super.clone({ _pluginInstanceState: void 0, _pluginLoadError: void 0, ...withState });
8354
+ clone() {
8355
+ return super.clone({ _pluginInstanceState: void 0, _pluginLoadError: void 0 });
8386
8356
  }
8387
8357
  buildPanelContext() {
8388
8358
  const sync = getCursorSyncScope(this);
@@ -9437,6 +9407,9 @@ function VariableValueSelectorsRenderer({ model }) {
9437
9407
  function VariableValueSelectWrapper({ variable, layout, showAlways, hideLabel }) {
9438
9408
  const state = useSceneObjectState(variable, { shouldActivateOrKeepAlive: true });
9439
9409
  if (state.hide === data.VariableHide.hideVariable && !showAlways) {
9410
+ if (variable.hiddenRender) {
9411
+ return variable.hiddenRender();
9412
+ }
9440
9413
  return null;
9441
9414
  }
9442
9415
  if (layout === "vertical") {
@@ -9500,8 +9473,6 @@ function VariableValueControlRenderer({ model }) {
9500
9473
  class SceneVariableSet extends SceneObjectBase {
9501
9474
  constructor(state) {
9502
9475
  super(state);
9503
- /** Variables that have changed in since the activation or since the first manual value change */
9504
- this._variablesThatHaveChanged = /* @__PURE__ */ new Set();
9505
9476
  /** Variables that are scheduled to be validated and updated */
9506
9477
  this._variablesToUpdate = /* @__PURE__ */ new Set();
9507
9478
  /** Variables currently updating */
@@ -9628,7 +9599,8 @@ class SceneVariableSet extends SceneObjectBase {
9628
9599
  _updateNextBatch() {
9629
9600
  for (const variable of this._variablesToUpdate) {
9630
9601
  if (!variable.validateAndUpdate) {
9631
- throw new Error("Variable added to variablesToUpdate but does not have validateAndUpdate");
9602
+ console.error("Variable added to variablesToUpdate but does not have validateAndUpdate");
9603
+ continue;
9632
9604
  }
9633
9605
  if (this._updating.has(variable)) {
9634
9606
  continue;
@@ -9684,7 +9656,6 @@ class SceneVariableSet extends SceneObjectBase {
9684
9656
  this._updateNextBatch();
9685
9657
  }
9686
9658
  _handleVariableValueChanged(variableThatChanged) {
9687
- this._variablesThatHaveChanged.add(variableThatChanged);
9688
9659
  this._addDependentVariablesToUpdateQueue(variableThatChanged);
9689
9660
  if (!this._updating.has(variableThatChanged)) {
9690
9661
  this._updateNextBatch();
@@ -9711,7 +9682,10 @@ class SceneVariableSet extends SceneObjectBase {
9711
9682
  if (this._updating.has(otherVariable) && otherVariable.onCancel) {
9712
9683
  otherVariable.onCancel();
9713
9684
  }
9714
- this._variablesToUpdate.add(otherVariable);
9685
+ if (otherVariable.validateAndUpdate) {
9686
+ this._variablesToUpdate.add(otherVariable);
9687
+ }
9688
+ otherVariable.variableDependency.variableUpdateCompleted(variableThatChanged, true);
9715
9689
  }
9716
9690
  }
9717
9691
  }
@@ -9723,8 +9697,7 @@ class SceneVariableSet extends SceneObjectBase {
9723
9697
  if (!this.parent) {
9724
9698
  return;
9725
9699
  }
9726
- this._traverseSceneAndNotify(this.parent, variable, this._variablesThatHaveChanged.has(variable));
9727
- this._variablesThatHaveChanged.delete(variable);
9700
+ this._traverseSceneAndNotify(this.parent, variable, true);
9728
9701
  }
9729
9702
  /**
9730
9703
  * Recursivly walk the full scene object graph and notify all objects with dependencies that include any of changed variables
@@ -9756,6 +9729,9 @@ class SceneVariableSet extends SceneObjectBase {
9756
9729
  * 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.
9757
9730
  */
9758
9731
  isVariableLoadingOrWaitingToUpdate(variable) {
9732
+ if (variable.state.loading) {
9733
+ return true;
9734
+ }
9759
9735
  if (variable.isAncestorLoading && variable.isAncestorLoading()) {
9760
9736
  return true;
9761
9737
  }
@@ -12644,8 +12620,8 @@ class SceneApp extends SceneObjectBase {
12644
12620
  }
12645
12621
  }
12646
12622
  SceneApp.Component = ({ model }) => {
12647
- const { pages, scopesBridge } = model.useState();
12648
- return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, scopesBridge && /* @__PURE__ */ React__default.default.createElement(scopesBridge.Component, { model: scopesBridge }), /* @__PURE__ */ React__default.default.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React__default.default.createElement(page.Component, { model: page }) })))));
12623
+ const { pages } = model.useState();
12624
+ return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(SceneAppContext.Provider, { value: model }, /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Routes, null, pages.map((page) => /* @__PURE__ */ React__default.default.createElement(reactRouterDom.Route, { key: page.state.url, path: page.state.routePath, element: /* @__PURE__ */ React__default.default.createElement(page.Component, { model: page }) })))));
12649
12625
  };
12650
12626
  const SceneAppContext = React.createContext(null);
12651
12627
  const sceneAppCache = /* @__PURE__ */ new Map();
@@ -12921,25 +12897,10 @@ function SceneAppDrilldownViewRender({ drilldown, parent }) {
12921
12897
  }
12922
12898
 
12923
12899
  class SceneAppPage extends SceneObjectBase {
12924
- constructor(state) {
12925
- super(state);
12900
+ constructor() {
12901
+ super(...arguments);
12926
12902
  this._sceneCache = /* @__PURE__ */ new Map();
12927
12903
  this._drilldownCache = /* @__PURE__ */ new Map();
12928
- this._activationHandler = () => {
12929
- if (!this.state.useScopes) {
12930
- return;
12931
- }
12932
- this._scopesBridge = sceneGraph.getScopesBridge(this);
12933
- if (!this._scopesBridge) {
12934
- throw new Error("Use of scopes is enabled but no scopes bridge found");
12935
- }
12936
- this._scopesBridge.setEnabled(true);
12937
- return () => {
12938
- var _a;
12939
- (_a = this._scopesBridge) == null ? void 0 : _a.setEnabled(false);
12940
- };
12941
- };
12942
- this.addActivationHandler(this._activationHandler);
12943
12904
  }
12944
12905
  initializeScene(scene) {
12945
12906
  this.setState({ initializedScene: scene });
@@ -14047,7 +14008,6 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
14047
14008
  exports.SceneQueryRunner = SceneQueryRunner;
14048
14009
  exports.SceneReactObject = SceneReactObject;
14049
14010
  exports.SceneRefreshPicker = SceneRefreshPicker;
14050
- exports.SceneScopesBridge = SceneScopesBridge;
14051
14011
  exports.SceneTimePicker = SceneTimePicker;
14052
14012
  exports.SceneTimeRange = SceneTimeRange;
14053
14013
  exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
@@ -14057,6 +14017,7 @@ exports.SceneToolbarButton = SceneToolbarButton;
14057
14017
  exports.SceneToolbarInput = SceneToolbarInput;
14058
14018
  exports.SceneVariableSet = SceneVariableSet;
14059
14019
  exports.SceneVariableValueChangedEvent = SceneVariableValueChangedEvent;
14020
+ exports.ScopesVariable = ScopesVariable;
14060
14021
  exports.SplitLayout = SplitLayout;
14061
14022
  exports.TestVariable = TestVariable;
14062
14023
  exports.TextBoxVariable = TextBoxVariable;