@grafana/scenes 6.29.0--canary.1197.16594317686.0 → 6.29.0--canary.1197.16645626691.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
@@ -607,246 +607,77 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
607
607
  var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
608
608
  var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
609
609
  var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
610
- var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
611
- const POST_STORM_WINDOW = 2e3;
612
- const SPAN_THRESHOLD = 30;
613
- class SceneRenderProfiler {
614
- constructor(queryController) {
615
- this.queryController = queryController;
616
- __privateAdd$3(this, _profileInProgress, null);
617
- __privateAdd$3(this, _profileStartTs, null);
618
- __privateAdd$3(this, _trailAnimationFrameId, null);
619
- // Will keep measured lengths trailing frames
620
- __privateAdd$3(this, _recordedTrailingSpans, []);
621
- this.lastFrameTime = 0;
622
- this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
623
- const currentFrameTime = performance.now();
624
- const frameLength = currentFrameTime - lastFrameTime;
625
- __privateGet$3(this, _recordedTrailingSpans).push(frameLength);
626
- if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
627
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
628
- () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
629
- ));
630
- } else {
631
- const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
632
- const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
633
- writeSceneLog(
634
- this.constructor.name,
635
- "Profile tail recorded, slow frames duration:",
636
- slowFramesTime,
637
- slowFrames,
638
- __privateGet$3(this, _profileInProgress)
639
- );
640
- __privateSet$3(this, _recordedTrailingSpans, []);
641
- const profileDuration = measurementStartTs - profileStartTs;
642
- writeSceneLog(
643
- this.constructor.name,
644
- "Stoped recording, total measured time (network included):",
645
- profileDuration + slowFramesTime
646
- );
647
- __privateSet$3(this, _trailAnimationFrameId, null);
648
- const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
649
- performance.measure(`DashboardInteraction ${__privateGet$3(this, _profileInProgress).origin}`, {
650
- start: profileStartTs,
651
- end: profileEndTs
652
- });
653
- const networkDuration = captureNetwork(profileStartTs, profileEndTs);
654
- if (this.queryController.state.onProfileComplete) {
655
- this.queryController.state.onProfileComplete({
656
- origin: __privateGet$3(this, _profileInProgress).origin,
657
- crumbs: __privateGet$3(this, _profileInProgress).crumbs,
658
- duration: profileDuration + slowFramesTime,
659
- networkDuration,
660
- // @ts-ignore
661
- jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
662
- // @ts-ignore
663
- usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
664
- // @ts-ignore
665
- totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
666
- });
667
- __privateSet$3(this, _profileInProgress, null);
668
- }
669
- if (window.__runs) {
670
- window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
671
- `;
672
- } else {
673
- window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
674
- `;
675
- }
676
- }
677
- };
678
- }
679
- 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));
695
- }
696
- }
697
- recordProfileTail(measurementStartTime, profileStartTs) {
698
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
699
- () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
700
- ));
701
- }
702
- tryCompletingProfile() {
703
- writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
704
- if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
705
- writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
706
- this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
707
- }
708
- }
709
- isTailRecording() {
710
- return Boolean(__privateGet$3(this, _trailAnimationFrameId));
711
- }
712
- cancelTailRecording() {
713
- if (__privateGet$3(this, _trailAnimationFrameId)) {
714
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
715
- __privateSet$3(this, _trailAnimationFrameId, null);
716
- writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
717
- }
718
- }
719
- addCrumb(crumb) {
720
- if (__privateGet$3(this, _profileInProgress)) {
721
- writeSceneLog(this.constructor.name, "Adding crumb:", crumb);
722
- __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
723
- }
724
- }
725
- }
726
- _profileInProgress = new WeakMap();
727
- _profileStartTs = new WeakMap();
728
- _trailAnimationFrameId = new WeakMap();
729
- _recordedTrailingSpans = new WeakMap();
730
- function processRecordedSpans(spans) {
731
- for (let i = spans.length - 1; i >= 0; i--) {
732
- if (spans[i] > SPAN_THRESHOLD) {
733
- return spans.slice(0, i + 1);
734
- }
735
- }
736
- return [spans[0]];
737
- }
738
- function captureNetwork(startTs, endTs) {
739
- const entries = performance.getEntriesByType("resource");
740
- performance.clearResourceTimings();
741
- const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
742
- for (const entry of networkEntries) {
743
- performance.measure("Network entry " + entry.name, {
744
- start: entry.startTime,
745
- end: entry.responseEnd
746
- });
747
- }
748
- return calculateNetworkTime(networkEntries);
749
- }
750
- function calculateNetworkTime(requests) {
751
- if (requests.length === 0) {
752
- return 0;
753
- }
754
- requests.sort((a, b) => a.startTime - b.startTime);
755
- let totalNetworkTime = 0;
756
- let currentStart = requests[0].startTime;
757
- let currentEnd = requests[0].responseEnd;
758
- for (let i = 1; i < requests.length; i++) {
759
- if (requests[i].startTime <= currentEnd) {
760
- currentEnd = Math.max(currentEnd, requests[i].responseEnd);
761
- } else {
762
- totalNetworkTime += currentEnd - currentStart;
763
- currentStart = requests[i].startTime;
764
- currentEnd = requests[i].responseEnd;
765
- }
766
- }
767
- totalNetworkTime += currentEnd - currentStart;
768
- return totalNetworkTime;
769
- }
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
-
778
- var __typeError$2 = (msg) => {
779
- throw TypeError(msg);
780
- };
781
- var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
782
- var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
783
- var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
784
- var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
785
610
  var _running, _tryCompleteProfileFrameId;
786
611
  function isQueryController(s) {
787
612
  return "isQueryController" in s;
788
613
  }
789
614
  class SceneQueryController extends SceneObjectBase {
790
- constructor(state = {}) {
615
+ constructor(state = {}, profiler) {
791
616
  super({ ...state, isRunning: false });
617
+ this.profiler = profiler;
792
618
  this.isQueryController = true;
793
- this.profiler = new SceneRenderProfiler(this);
794
- __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
795
- __privateAdd$2(this, _tryCompleteProfileFrameId, null);
619
+ __privateAdd$3(this, _running, /* @__PURE__ */ new Set());
620
+ __privateAdd$3(this, _tryCompleteProfileFrameId, null);
796
621
  this.runningQueriesCount = () => {
797
- return __privateGet$2(this, _running).size;
622
+ return __privateGet$3(this, _running).size;
798
623
  };
624
+ if (profiler) {
625
+ this.profiler = profiler;
626
+ profiler.setQueryController(this);
627
+ }
799
628
  this.addActivationHandler(() => {
800
- return () => __privateGet$2(this, _running).clear();
629
+ return () => __privateGet$3(this, _running).clear();
801
630
  });
802
631
  }
803
632
  startProfile(name) {
633
+ var _a;
804
634
  if (!this.state.enableProfiling) {
805
635
  return;
806
636
  }
807
- this.profiler.startProfile(name);
637
+ (_a = this.profiler) == null ? void 0 : _a.startProfile(name);
808
638
  }
809
639
  queryStarted(entry) {
810
- __privateGet$2(this, _running).add(entry);
640
+ __privateGet$3(this, _running).add(entry);
811
641
  this.changeRunningQueryCount(1, entry);
812
642
  if (!this.state.isRunning) {
813
643
  this.setState({ isRunning: true });
814
644
  }
815
645
  }
816
646
  queryCompleted(entry) {
817
- if (!__privateGet$2(this, _running).has(entry)) {
647
+ if (!__privateGet$3(this, _running).has(entry)) {
818
648
  return;
819
649
  }
820
- __privateGet$2(this, _running).delete(entry);
650
+ __privateGet$3(this, _running).delete(entry);
821
651
  this.changeRunningQueryCount(-1);
822
- if (__privateGet$2(this, _running).size === 0) {
652
+ if (__privateGet$3(this, _running).size === 0) {
823
653
  this.setState({ isRunning: false });
824
654
  }
825
655
  }
826
656
  changeRunningQueryCount(dir, entry) {
827
- var _a;
657
+ var _a, _b, _c, _d;
828
658
  window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
829
659
  if (dir === 1 && this.state.enableProfiling) {
830
660
  if (entry) {
831
- this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
661
+ (_b = this.profiler) == null ? void 0 : _b.addCrumb(`${entry.type}`);
832
662
  }
833
- if (this.profiler.isTailRecording()) {
834
- writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
835
- this.profiler.cancelTailRecording();
663
+ if ((_c = this.profiler) == null ? void 0 : _c.isTailRecording()) {
664
+ writeSceneLog("SceneQueryController", "New query started, cancelling tail recording");
665
+ (_d = this.profiler) == null ? void 0 : _d.cancelTailRecording();
836
666
  }
837
667
  }
838
668
  if (this.state.enableProfiling) {
839
- if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
840
- cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
669
+ if (__privateGet$3(this, _tryCompleteProfileFrameId)) {
670
+ cancelAnimationFrame(__privateGet$3(this, _tryCompleteProfileFrameId));
841
671
  }
842
- __privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
843
- this.profiler.tryCompletingProfile();
672
+ __privateSet$3(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
673
+ var _a2;
674
+ (_a2 = this.profiler) == null ? void 0 : _a2.tryCompletingProfile();
844
675
  }));
845
676
  }
846
677
  }
847
678
  cancelAll() {
848
679
  var _a;
849
- for (const entry of __privateGet$2(this, _running).values()) {
680
+ for (const entry of __privateGet$3(this, _running).values()) {
850
681
  (_a = entry.cancel) == null ? void 0 : _a.call(entry);
851
682
  }
852
683
  }
@@ -1016,6 +847,182 @@ function isValid$1(value, roundUp, timeZone) {
1016
847
  return parsed.isValid();
1017
848
  }
1018
849
 
850
+ var __typeError$2 = (msg) => {
851
+ throw TypeError(msg);
852
+ };
853
+ var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
854
+ var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
855
+ var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
856
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
857
+ var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
858
+ const POST_STORM_WINDOW = 2e3;
859
+ const SPAN_THRESHOLD = 30;
860
+ class SceneRenderProfiler {
861
+ constructor(queryController) {
862
+ this.queryController = queryController;
863
+ __privateAdd$2(this, _profileInProgress, null);
864
+ __privateAdd$2(this, _profileStartTs, null);
865
+ __privateAdd$2(this, _trailAnimationFrameId, null);
866
+ // Will keep measured lengths trailing frames
867
+ __privateAdd$2(this, _recordedTrailingSpans, []);
868
+ this.lastFrameTime = 0;
869
+ this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
870
+ var _a;
871
+ const currentFrameTime = performance.now();
872
+ const frameLength = currentFrameTime - lastFrameTime;
873
+ __privateGet$2(this, _recordedTrailingSpans).push(frameLength);
874
+ if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
875
+ if (__privateGet$2(this, _profileInProgress)) {
876
+ __privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
877
+ () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
878
+ ));
879
+ }
880
+ } else {
881
+ const slowFrames = processRecordedSpans(__privateGet$2(this, _recordedTrailingSpans));
882
+ const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
883
+ writeSceneLog(
884
+ this.constructor.name,
885
+ "Profile tail recorded, slow frames duration:",
886
+ slowFramesTime,
887
+ slowFrames,
888
+ __privateGet$2(this, _profileInProgress)
889
+ );
890
+ __privateSet$2(this, _recordedTrailingSpans, []);
891
+ const profileDuration = measurementStartTs - profileStartTs;
892
+ writeSceneLog(
893
+ this.constructor.name,
894
+ "Stoped recording, total measured time (network included):",
895
+ profileDuration + slowFramesTime
896
+ );
897
+ __privateSet$2(this, _trailAnimationFrameId, null);
898
+ const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
899
+ performance.measure(`DashboardInteraction ${__privateGet$2(this, _profileInProgress).origin}`, {
900
+ start: profileStartTs,
901
+ end: profileEndTs
902
+ });
903
+ const networkDuration = captureNetwork(profileStartTs, profileEndTs);
904
+ if ((_a = this.queryController) == null ? void 0 : _a.state.onProfileComplete) {
905
+ this.queryController.state.onProfileComplete({
906
+ origin: __privateGet$2(this, _profileInProgress).origin,
907
+ crumbs: __privateGet$2(this, _profileInProgress).crumbs,
908
+ duration: profileDuration + slowFramesTime,
909
+ networkDuration,
910
+ startTs: profileStartTs,
911
+ endTs: profileEndTs,
912
+ // @ts-ignore
913
+ jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
914
+ // @ts-ignore
915
+ usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
916
+ // @ts-ignore
917
+ totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
918
+ });
919
+ __privateSet$2(this, _profileInProgress, null);
920
+ __privateSet$2(this, _trailAnimationFrameId, null);
921
+ }
922
+ if (window.__runs) {
923
+ window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
924
+ `;
925
+ } else {
926
+ window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
927
+ `;
928
+ }
929
+ }
930
+ };
931
+ }
932
+ setQueryController(queryController) {
933
+ this.queryController = queryController;
934
+ }
935
+ startProfile(name) {
936
+ if (__privateGet$2(this, _profileInProgress)) {
937
+ this.addCrumb(name);
938
+ } else {
939
+ __privateSet$2(this, _profileInProgress, { origin: name, crumbs: [] });
940
+ __privateSet$2(this, _profileStartTs, performance.now());
941
+ writeSceneLog("SceneRenderProfiler", "Profile started:", __privateGet$2(this, _profileInProgress), __privateGet$2(this, _profileStartTs));
942
+ }
943
+ }
944
+ recordProfileTail(measurementStartTime, profileStartTs) {
945
+ __privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
946
+ () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
947
+ ));
948
+ }
949
+ tryCompletingProfile() {
950
+ var _a;
951
+ writeSceneLog("SceneRenderProfiler", "Trying to complete profile", __privateGet$2(this, _profileInProgress));
952
+ if (((_a = this.queryController) == null ? void 0 : _a.runningQueriesCount()) === 0 && __privateGet$2(this, _profileInProgress)) {
953
+ writeSceneLog("SceneRenderProfiler", "All queries completed, stopping profile");
954
+ this.recordProfileTail(performance.now(), __privateGet$2(this, _profileStartTs));
955
+ }
956
+ }
957
+ isTailRecording() {
958
+ return Boolean(__privateGet$2(this, _trailAnimationFrameId));
959
+ }
960
+ cancelTailRecording() {
961
+ if (__privateGet$2(this, _trailAnimationFrameId)) {
962
+ cancelAnimationFrame(__privateGet$2(this, _trailAnimationFrameId));
963
+ __privateSet$2(this, _trailAnimationFrameId, null);
964
+ writeSceneLog("SceneRenderProfiler", "Cancelled recording frames, new profile started");
965
+ }
966
+ }
967
+ addCrumb(crumb) {
968
+ if (__privateGet$2(this, _profileInProgress)) {
969
+ writeSceneLog("SceneRenderProfiler", "Adding crumb:", crumb);
970
+ __privateGet$2(this, _profileInProgress).crumbs.push(crumb);
971
+ }
972
+ }
973
+ }
974
+ _profileInProgress = new WeakMap();
975
+ _profileStartTs = new WeakMap();
976
+ _trailAnimationFrameId = new WeakMap();
977
+ _recordedTrailingSpans = new WeakMap();
978
+ function processRecordedSpans(spans) {
979
+ for (let i = spans.length - 1; i >= 0; i--) {
980
+ if (spans[i] > SPAN_THRESHOLD) {
981
+ return spans.slice(0, i + 1);
982
+ }
983
+ }
984
+ return [spans[0]];
985
+ }
986
+ function captureNetwork(startTs, endTs) {
987
+ const entries = performance.getEntriesByType("resource");
988
+ performance.clearResourceTimings();
989
+ const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
990
+ for (const entry of networkEntries) {
991
+ performance.measure("Network entry " + entry.name, {
992
+ start: entry.startTime,
993
+ end: entry.responseEnd
994
+ });
995
+ }
996
+ return calculateNetworkTime(networkEntries);
997
+ }
998
+ function calculateNetworkTime(requests) {
999
+ if (requests.length === 0) {
1000
+ return 0;
1001
+ }
1002
+ requests.sort((a, b) => a.startTime - b.startTime);
1003
+ let totalNetworkTime = 0;
1004
+ let currentStart = requests[0].startTime;
1005
+ let currentEnd = requests[0].responseEnd;
1006
+ for (let i = 1; i < requests.length; i++) {
1007
+ if (requests[i].startTime <= currentEnd) {
1008
+ currentEnd = Math.max(currentEnd, requests[i].responseEnd);
1009
+ } else {
1010
+ totalNetworkTime += currentEnd - currentStart;
1011
+ currentStart = requests[i].startTime;
1012
+ currentEnd = requests[i].responseEnd;
1013
+ }
1014
+ }
1015
+ totalNetworkTime += currentEnd - currentStart;
1016
+ return totalNetworkTime;
1017
+ }
1018
+ const REFRESH_INTERACTION = "refresh";
1019
+ const TIME_RANGE_CHANGE_INTERACTION = "time_range_change";
1020
+ const FILTER_REMOVED_INTERACTION = "filter_removed";
1021
+ const FILTER_CHANGED_INTERACTION = "filter_changed";
1022
+ const FILTER_RESTORED_INTERACTION = "filter_restored";
1023
+ const VARIABLE_VALUE_CHANGED_INTERACTION = "variable_value_changed";
1024
+ const SCOPES_CHANGED_INTERACTION = "scopes_changed";
1025
+
1019
1026
  class SceneTimeRange extends SceneObjectBase {
1020
1027
  constructor(state = {}) {
1021
1028
  var _a;
@@ -2420,13 +2427,17 @@ const macrosIndex = /* @__PURE__ */ new Map([
2420
2427
  ["__interval", IntervalMacro],
2421
2428
  ["__interval_ms", IntervalMacro]
2422
2429
  ]);
2423
- function registerVariableMacro(name, macro) {
2424
- if (macrosIndex.get(name)) {
2430
+ function registerVariableMacro(name, macro, replace = false) {
2431
+ if (!replace && macrosIndex.get(name)) {
2425
2432
  throw new Error(`Macro already registered ${name}`);
2426
2433
  }
2427
2434
  macrosIndex.set(name, macro);
2428
2435
  return () => {
2429
- macrosIndex.delete(name);
2436
+ if (replace) {
2437
+ throw new Error(`Replaced macros can not be unregistered. They need to be restored manually.`);
2438
+ } else {
2439
+ macrosIndex.delete(name);
2440
+ }
2430
2441
  };
2431
2442
  }
2432
2443
 
@@ -2588,7 +2599,7 @@ async function getDataSource(datasource, scopedVars) {
2588
2599
  if (queryControler && queryControler.state.enableProfiling) {
2589
2600
  wrapPromiseInStateObservable(dsPromise).pipe(
2590
2601
  registerQueryWithController({
2591
- type: `plugin/${(_a = datasource == null ? void 0 : datasource.type) != null ? _a : "unknown"}`,
2602
+ type: `getDataSource/${(_a = datasource == null ? void 0 : datasource.type) != null ? _a : "unknown"}`,
2592
2603
  origin: scopedVars.__sceneObject.value.valueOf()
2593
2604
  })
2594
2605
  ).subscribe(() => {
@@ -6518,7 +6529,7 @@ class SceneQueryRunner extends SceneObjectBase {
6518
6529
  }
6519
6530
  stream = stream.pipe(
6520
6531
  registerQueryWithController({
6521
- type: "data",
6532
+ type: "SceneQueryRunner/runQueries",
6522
6533
  request: primary,
6523
6534
  origin: this,
6524
6535
  cancel: () => this.cancelQuery()
@@ -7439,7 +7450,7 @@ class QueryVariable extends MultiValueVariable {
7439
7450
  const request = this.getRequest(target, args.searchFilter);
7440
7451
  return runner.runRequest({ variable: this, searchFilter: args.searchFilter }, request).pipe(
7441
7452
  registerQueryWithController({
7442
- type: "variable",
7453
+ type: "QueryVariable/getValueOptions",
7443
7454
  request,
7444
7455
  origin: this
7445
7456
  }),
@@ -8688,7 +8699,7 @@ class VizPanel extends SceneObjectBase {
8688
8699
  const panelPromise = importPanelPlugin(pluginId);
8689
8700
  const queryControler = sceneGraph.getQueryController(this);
8690
8701
  if (queryControler && queryControler.state.enableProfiling) {
8691
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: `plugin/${pluginId}`, origin: this })).subscribe(() => {
8702
+ wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: `VizPanel/loadPlugin/${pluginId}`, origin: this })).subscribe(() => {
8692
8703
  });
8693
8704
  }
8694
8705
  const result = await panelPromise;
@@ -9480,7 +9491,7 @@ class AnnotationsDataLayer extends SceneDataLayerBase {
9480
9491
  const ds = await this.resolveDataSource(query);
9481
9492
  let stream = executeAnnotationQuery(ds, timeRange, query, this).pipe(
9482
9493
  registerQueryWithController({
9483
- type: "annotations",
9494
+ type: "AnnotationsDataLayer/annotationsLoading",
9484
9495
  origin: this,
9485
9496
  cancel: () => this.cancelQuery()
9486
9497
  }),
@@ -14489,7 +14500,7 @@ function __variableDynamicImportRuntime0__(path) {
14489
14500
  switch (path) {
14490
14501
  case '../locales/cs-CZ/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-CY85TD5F.js'); });
14491
14502
  case '../locales/de-DE/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-n10eQkNF.js'); });
14492
- case '../locales/en-US/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-uBsCv-Bu.js'); });
14503
+ case '../locales/en-US/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-C_CT7peT.js'); });
14493
14504
  case '../locales/es-ES/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-YMli37Xh.js'); });
14494
14505
  case '../locales/fr-FR/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-DXM1LI4B.js'); });
14495
14506
  case '../locales/hu-HU/grafana-scenes.json': return Promise.resolve().then(function () { return require('./grafana-scenes-DlUSL8jI.js'); });
@@ -14596,6 +14607,7 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
14596
14607
  exports.SceneQueryRunner = SceneQueryRunner;
14597
14608
  exports.SceneReactObject = SceneReactObject;
14598
14609
  exports.SceneRefreshPicker = SceneRefreshPicker;
14610
+ exports.SceneRenderProfiler = SceneRenderProfiler;
14599
14611
  exports.SceneTimePicker = SceneTimePicker;
14600
14612
  exports.SceneTimeRange = SceneTimeRange;
14601
14613
  exports.SceneTimeRangeCompare = SceneTimeRangeCompare;