@grafana/scenes 6.28.2--canary.1195.16517016489.0 → 6.28.2--canary.1196.16518846434.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.
package/dist/index.js CHANGED
@@ -646,7 +646,7 @@ class SceneRenderProfiler {
646
646
  );
647
647
  __privateSet$3(this, _trailAnimationFrameId, null);
648
648
  const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
649
- performance.measure(`DashboardInteraction ${__privateGet$3(this, _profileInProgress).origin}`, {
649
+ performance.measure("DashboardInteraction", {
650
650
  start: profileStartTs,
651
651
  end: profileEndTs
652
652
  });
@@ -664,7 +664,6 @@ class SceneRenderProfiler {
664
664
  // @ts-ignore
665
665
  totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
666
666
  });
667
- __privateSet$3(this, _profileInProgress, null);
668
667
  }
669
668
  if (window.__runs) {
670
669
  window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
@@ -677,22 +676,14 @@ class SceneRenderProfiler {
677
676
  };
678
677
  }
679
678
  startProfile(name) {
680
- if (__privateGet$3(this, _profileInProgress)) {
681
- if (__privateGet$3(this, _trailAnimationFrameId)) {
682
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
683
- __privateSet$3(this, _trailAnimationFrameId, null);
684
- writeSceneLog(this.constructor.name, "New profile: Stopped recording frames ");
685
- __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
686
- __privateSet$3(this, _profileStartTs, performance.now());
687
- writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
688
- } else {
689
- this.addCrumb(name);
690
- }
691
- } else {
692
- __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
693
- __privateSet$3(this, _profileStartTs, performance.now());
694
- writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
679
+ if (__privateGet$3(this, _trailAnimationFrameId)) {
680
+ cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
681
+ __privateSet$3(this, _trailAnimationFrameId, null);
682
+ writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
695
683
  }
684
+ __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
685
+ __privateSet$3(this, _profileStartTs, performance.now());
686
+ writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
696
687
  }
697
688
  recordProfileTail(measurementStartTime, profileStartTs) {
698
689
  __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
@@ -718,7 +709,6 @@ class SceneRenderProfiler {
718
709
  }
719
710
  addCrumb(crumb) {
720
711
  if (__privateGet$3(this, _profileInProgress)) {
721
- writeSceneLog(this.constructor.name, "Adding crumb:", crumb);
722
712
  __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
723
713
  }
724
714
  }
@@ -767,13 +757,6 @@ function calculateNetworkTime(requests) {
767
757
  totalNetworkTime += currentEnd - currentStart;
768
758
  return totalNetworkTime;
769
759
  }
770
- const REFRESH_INTERACTION = "refresh";
771
- const TIME_RANGE_CHANGE_INTERACTION = "time-range-change";
772
- const FILTER_REMOVED_INTERACTION = "filter-removed";
773
- const FILTER_CHANGED_INTERACTION = "filter-changed";
774
- const FILTER_RESTORED_INTERACTION = "filter-restored";
775
- const VARIABLE_VALUE_CHANGED_INTERACTION = "variable-value-changed";
776
- const SCOPES_CHANGED_INTERACTION = "scopes-changed";
777
760
 
778
761
  var __typeError$2 = (msg) => {
779
762
  throw TypeError(msg);
@@ -1055,7 +1038,7 @@ class SceneTimeRange extends SceneObjectBase {
1055
1038
  );
1056
1039
  if (update.from !== this.state.from || update.to !== this.state.to) {
1057
1040
  const queryController = getQueryController(this);
1058
- queryController == null ? void 0 : queryController.startProfile(TIME_RANGE_CHANGE_INTERACTION);
1041
+ queryController == null ? void 0 : queryController.startProfile("SceneTimeRange");
1059
1042
  this._urlSync.performBrowserHistoryAction(() => {
1060
1043
  this.setState(update);
1061
1044
  });
@@ -2418,13 +2401,21 @@ const macrosIndex = /* @__PURE__ */ new Map([
2418
2401
  ["__interval", IntervalMacro],
2419
2402
  ["__interval_ms", IntervalMacro]
2420
2403
  ]);
2421
- function registerVariableMacro(name, macro) {
2422
- if (macrosIndex.get(name)) {
2404
+ function registerVariableMacro(name, macro, replace = false) {
2405
+ if (macrosIndex.get(name) && !replace) {
2423
2406
  throw new Error(`Macro already registered ${name}`);
2424
2407
  }
2408
+ let replacedMacro;
2409
+ if (macrosIndex.has(name) && !replace) {
2410
+ replacedMacro = macrosIndex.get(name);
2411
+ }
2425
2412
  macrosIndex.set(name, macro);
2426
2413
  return () => {
2427
- macrosIndex.delete(name);
2414
+ if (replacedMacro) {
2415
+ macrosIndex.set(name, replacedMacro);
2416
+ } else {
2417
+ macrosIndex.delete(name);
2418
+ }
2428
2419
  };
2429
2420
  }
2430
2421
 
@@ -2570,7 +2561,6 @@ function wrapPromiseInStateObservable(promise) {
2570
2561
  }
2571
2562
 
2572
2563
  async function getDataSource(datasource, scopedVars) {
2573
- var _a;
2574
2564
  if (datasource == null ? void 0 : datasource.uid) {
2575
2565
  const runtimeDataSource = runtimeDataSources.get(datasource.uid);
2576
2566
  if (runtimeDataSource) {
@@ -2586,7 +2576,7 @@ async function getDataSource(datasource, scopedVars) {
2586
2576
  if (queryControler && queryControler.state.enableProfiling) {
2587
2577
  wrapPromiseInStateObservable(dsPromise).pipe(
2588
2578
  registerQueryWithController({
2589
- type: `plugin/${(_a = datasource == null ? void 0 : datasource.type) != null ? _a : "unknown"}`,
2579
+ type: "plugin",
2590
2580
  origin: scopedVars.__sceneObject.value.valueOf()
2591
2581
  })
2592
2582
  ).subscribe(() => {
@@ -2928,7 +2918,7 @@ function VariableValueSelect({ model, state }) {
2928
2918
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2929
2919
  onChange: (newValue) => {
2930
2920
  model.changeValueTo(newValue.value, newValue.label, true);
2931
- queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
2921
+ queryController == null ? void 0 : queryController.startProfile("VariableValueSelect");
2932
2922
  if (hasCustomValue !== newValue.__isNew__) {
2933
2923
  setHasCustomValue(newValue.__isNew__);
2934
2924
  }
@@ -3001,7 +2991,7 @@ function VariableValueSelectMulti({
3001
2991
  onInputChange,
3002
2992
  onBlur: () => {
3003
2993
  model.changeValueTo(uncommittedValue, void 0, true);
3004
- queryController == null ? void 0 : queryController.startProfile(VARIABLE_VALUE_CHANGED_INTERACTION);
2994
+ queryController == null ? void 0 : queryController.startProfile("VariableValueSelectMulti");
3005
2995
  },
3006
2996
  filterOption: filterNoOp$2,
3007
2997
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -4644,14 +4634,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4644
4634
  valueLabels.push((_a2 = item.label) != null ? _a2 : item.value);
4645
4635
  values.push(item.value);
4646
4636
  });
4647
- let shouldUpdate = true;
4648
- if (Array.isArray(filter2.values) && filter2.values.length === values.length) {
4649
- shouldUpdate = !filter2.values.every((v, i) => v === values[i]);
4650
- }
4651
- if (shouldUpdate) {
4652
- const queryController = getQueryController(model2);
4653
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
4654
- }
4655
4637
  model2._updateFilter(filter2, { valueLabels, values, value: values[0] });
4656
4638
  setFilterMultiValues([]);
4657
4639
  }
@@ -4804,10 +4786,6 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4804
4786
  return;
4805
4787
  }
4806
4788
  focusOnWipInputRef == null ? void 0 : focusOnWipInputRef();
4807
- if (isFilterComplete(filter)) {
4808
- const queryController = getQueryController(model);
4809
- queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
4810
- }
4811
4789
  model._handleComboboxBackspace(filter);
4812
4790
  if (isAlwaysWip) {
4813
4791
  handleResetWip();
@@ -4872,18 +4850,16 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
4872
4850
  handleLocalMultiValueChange(selectedItem);
4873
4851
  setInputValue("");
4874
4852
  } else {
4875
- const payload = generateFilterUpdatePayload({
4876
- filterInputType,
4877
- item: selectedItem,
4853
+ model._updateFilter(
4878
4854
  filter,
4879
- setFilterMultiValues,
4880
- onAddCustomValue
4881
- });
4882
- if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
4883
- const queryController = getQueryController(model);
4884
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
4885
- }
4886
- model._updateFilter(filter, payload);
4855
+ generateFilterUpdatePayload({
4856
+ filterInputType,
4857
+ item: selectedItem,
4858
+ filter,
4859
+ setFilterMultiValues,
4860
+ onAddCustomValue
4861
+ })
4862
+ );
4887
4863
  populateInputValueOnInputTypeSwitch({
4888
4864
  populateInputOnEdit,
4889
4865
  item: selectedItem,
@@ -5131,18 +5107,16 @@ const AdHocCombobox = React.forwardRef(function AdHocCombobox2({ filter, model,
5131
5107
  setInputValue("");
5132
5108
  (_a3 = refs.domReference.current) == null ? void 0 : _a3.focus();
5133
5109
  } else {
5134
- const payload = generateFilterUpdatePayload({
5135
- filterInputType,
5136
- item,
5110
+ model._updateFilter(
5137
5111
  filter,
5138
- setFilterMultiValues,
5139
- onAddCustomValue
5140
- });
5141
- if (filterInputType === "value" && payload.value !== (filter == null ? void 0 : filter.value)) {
5142
- const queryController = getQueryController(model);
5143
- queryController == null ? void 0 : queryController.startProfile(FILTER_CHANGED_INTERACTION);
5144
- }
5145
- model._updateFilter(filter, payload);
5112
+ generateFilterUpdatePayload({
5113
+ filterInputType,
5114
+ item,
5115
+ filter,
5116
+ setFilterMultiValues,
5117
+ onAddCustomValue
5118
+ })
5119
+ );
5146
5120
  populateInputValueOnInputTypeSwitch({
5147
5121
  populateInputOnEdit,
5148
5122
  item,
@@ -5868,8 +5842,6 @@ class AdHocFiltersVariable extends SceneObjectBase {
5868
5842
  original.valueLabels = originalFilter == null ? void 0 : originalFilter.value;
5869
5843
  original.operator = originalFilter == null ? void 0 : originalFilter.operator;
5870
5844
  original.nonApplicable = originalFilter == null ? void 0 : originalFilter.nonApplicable;
5871
- const queryController = getQueryController(this);
5872
- queryController == null ? void 0 : queryController.startProfile(FILTER_RESTORED_INTERACTION);
5873
5845
  this._updateFilter(filter, original);
5874
5846
  }
5875
5847
  }
@@ -5926,8 +5898,6 @@ class AdHocFiltersVariable extends SceneObjectBase {
5926
5898
  this.setState({ _wip: void 0 });
5927
5899
  return;
5928
5900
  }
5929
- const queryController = getQueryController(this);
5930
- queryController == null ? void 0 : queryController.startProfile(FILTER_REMOVED_INTERACTION);
5931
5901
  this._setStateWithFiltersApplicabilityCheck({
5932
5902
  filters: this.state.filters.filter((f) => f !== filter),
5933
5903
  originFilters: this.state.originFilters
@@ -7570,8 +7540,6 @@ class ScopesVariable extends SceneObjectBase {
7570
7540
  const newScopes = state.value.map((scope) => scope.metadata.name);
7571
7541
  const scopesHaveChanged = !lodash.isEqual(oldScopes, newScopes);
7572
7542
  if (!loading && (scopesHaveChanged || newScopes.length === 0)) {
7573
- const queryController = getQueryController(this);
7574
- queryController == null ? void 0 : queryController.startProfile(SCOPES_CHANGED_INTERACTION);
7575
7543
  this.setState({ scopes: state.value, loading });
7576
7544
  this.publishEvent(new SceneVariableValueChangedEvent(this), true);
7577
7545
  } else {
@@ -8688,7 +8656,7 @@ class VizPanel extends SceneObjectBase {
8688
8656
  const panelPromise = importPanelPlugin(pluginId);
8689
8657
  const queryControler = sceneGraph.getQueryController(this);
8690
8658
  if (queryControler && queryControler.state.enableProfiling) {
8691
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: `plugin/${pluginId}`, origin: this })).subscribe(() => {
8659
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
8692
8660
  });
8693
8661
  }
8694
8662
  const result = await panelPromise;
@@ -12055,7 +12023,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12055
12023
  this._autoRefreshBlocked = false;
12056
12024
  this.onRefresh = () => {
12057
12025
  const queryController = sceneGraph.getQueryController(this);
12058
- queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12026
+ queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12059
12027
  if (queryController == null ? void 0 : queryController.state.isRunning) {
12060
12028
  queryController.cancelAll();
12061
12029
  return;
@@ -12112,7 +12080,7 @@ class SceneRefreshPicker extends SceneObjectBase {
12112
12080
  this._intervalTimer = setInterval(() => {
12113
12081
  if (this.isTabVisible()) {
12114
12082
  const queryController = sceneGraph.getQueryController(this);
12115
- queryController == null ? void 0 : queryController.startProfile(REFRESH_INTERACTION);
12083
+ queryController == null ? void 0 : queryController.startProfile("SceneRefreshPicker");
12116
12084
  timeRange.onRefresh();
12117
12085
  } else {
12118
12086
  this._autoRefreshBlocked = true;