@grafana/scenes 5.36.2--canary.858.12581750919.0 → 5.36.2--canary.1015.12584248290.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/dist/esm/behaviors/SceneQueryController.js +5 -60
  2. package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
  3. package/dist/esm/components/SceneRefreshPicker.js +1 -6
  4. package/dist/esm/components/SceneRefreshPicker.js.map +1 -1
  5. package/dist/esm/components/VizPanel/VizPanel.js +1 -8
  6. package/dist/esm/components/VizPanel/VizPanel.js.map +1 -1
  7. package/dist/esm/core/SceneTimeRange.js +0 -3
  8. package/dist/esm/core/SceneTimeRange.js.map +1 -1
  9. package/dist/esm/core/sceneGraph/index.js +3 -3
  10. package/dist/esm/core/sceneGraph/index.js.map +1 -1
  11. package/dist/esm/core/sceneGraph/sceneGraph.js +26 -1
  12. package/dist/esm/core/sceneGraph/sceneGraph.js.map +1 -1
  13. package/dist/esm/index.js.map +1 -1
  14. package/dist/esm/querying/registerQueryWithController.js +2 -18
  15. package/dist/esm/querying/registerQueryWithController.js.map +1 -1
  16. package/dist/esm/utils/getDataSource.js +1 -17
  17. package/dist/esm/utils/getDataSource.js.map +1 -1
  18. package/dist/esm/variables/components/VariableValueSelect.js +0 -5
  19. package/dist/esm/variables/components/VariableValueSelect.js.map +1 -1
  20. package/dist/esm/variables/variants/TestVariable.js.map +1 -1
  21. package/dist/esm/variables/variants/query/utils.js +17 -22
  22. package/dist/esm/variables/variants/query/utils.js.map +1 -1
  23. package/dist/index.d.ts +32 -44
  24. package/dist/index.js +227 -487
  25. package/dist/index.js.map +1 -1
  26. package/package.json +2 -2
  27. package/dist/esm/behaviors/SceneRenderProfiler.js +0 -169
  28. package/dist/esm/behaviors/SceneRenderProfiler.js.map +0 -1
  29. package/dist/esm/core/sceneGraph/getQueryController.js +0 -19
  30. package/dist/esm/core/sceneGraph/getQueryController.js.map +0 -1
package/dist/index.js CHANGED
@@ -41,19 +41,19 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
41
41
  var uFuzzy__default = /*#__PURE__*/_interopDefaultLegacy(uFuzzy);
42
42
  var ReactGridLayout__default = /*#__PURE__*/_interopDefaultLegacy(ReactGridLayout);
43
43
 
44
- var __defProp$R = Object.defineProperty;
45
- var __getOwnPropSymbols$R = Object.getOwnPropertySymbols;
46
- var __hasOwnProp$R = Object.prototype.hasOwnProperty;
47
- var __propIsEnum$R = Object.prototype.propertyIsEnumerable;
48
- var __defNormalProp$R = (obj, key, value) => key in obj ? __defProp$R(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
- var __spreadValues$R = (a, b) => {
44
+ var __defProp$Q = Object.defineProperty;
45
+ var __getOwnPropSymbols$Q = Object.getOwnPropertySymbols;
46
+ var __hasOwnProp$Q = Object.prototype.hasOwnProperty;
47
+ var __propIsEnum$Q = Object.prototype.propertyIsEnumerable;
48
+ var __defNormalProp$Q = (obj, key, value) => key in obj ? __defProp$Q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
+ var __spreadValues$Q = (a, b) => {
50
50
  for (var prop in b || (b = {}))
51
- if (__hasOwnProp$R.call(b, prop))
52
- __defNormalProp$R(a, prop, b[prop]);
53
- if (__getOwnPropSymbols$R)
54
- for (var prop of __getOwnPropSymbols$R(b)) {
55
- if (__propIsEnum$R.call(b, prop))
56
- __defNormalProp$R(a, prop, b[prop]);
51
+ if (__hasOwnProp$Q.call(b, prop))
52
+ __defNormalProp$Q(a, prop, b[prop]);
53
+ if (__getOwnPropSymbols$Q)
54
+ for (var prop of __getOwnPropSymbols$Q(b)) {
55
+ if (__propIsEnum$Q.call(b, prop))
56
+ __defNormalProp$Q(a, prop, b[prop]);
57
57
  }
58
58
  return a;
59
59
  };
@@ -62,7 +62,7 @@ function useAppQueryParams() {
62
62
  return runtime.locationSearchToObject(location.search || "");
63
63
  }
64
64
  function getUrlWithAppState(path, searchObject, preserveParams) {
65
- const paramsCopy = __spreadValues$R({}, searchObject);
65
+ const paramsCopy = __spreadValues$Q({}, searchObject);
66
66
  if (preserveParams) {
67
67
  for (const key of Object.keys(paramsCopy)) {
68
68
  if (!preserveParams.includes(key)) {
@@ -76,31 +76,31 @@ function renderSceneComponentWithRouteProps(sceneObject, routeProps) {
76
76
  return React__default["default"].createElement(sceneObject.Component, { model: sceneObject, routeProps });
77
77
  }
78
78
 
79
- var __defProp$Q = Object.defineProperty;
80
- var __defProps$y = Object.defineProperties;
81
- var __getOwnPropDescs$y = Object.getOwnPropertyDescriptors;
82
- var __getOwnPropSymbols$Q = Object.getOwnPropertySymbols;
83
- var __hasOwnProp$Q = Object.prototype.hasOwnProperty;
84
- var __propIsEnum$Q = Object.prototype.propertyIsEnumerable;
85
- var __defNormalProp$Q = (obj, key, value) => key in obj ? __defProp$Q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
- var __spreadValues$Q = (a, b) => {
79
+ var __defProp$P = Object.defineProperty;
80
+ var __defProps$x = Object.defineProperties;
81
+ var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
82
+ var __getOwnPropSymbols$P = Object.getOwnPropertySymbols;
83
+ var __hasOwnProp$P = Object.prototype.hasOwnProperty;
84
+ var __propIsEnum$P = Object.prototype.propertyIsEnumerable;
85
+ var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
86
+ var __spreadValues$P = (a, b) => {
87
87
  for (var prop in b || (b = {}))
88
- if (__hasOwnProp$Q.call(b, prop))
89
- __defNormalProp$Q(a, prop, b[prop]);
90
- if (__getOwnPropSymbols$Q)
91
- for (var prop of __getOwnPropSymbols$Q(b)) {
92
- if (__propIsEnum$Q.call(b, prop))
93
- __defNormalProp$Q(a, prop, b[prop]);
88
+ if (__hasOwnProp$P.call(b, prop))
89
+ __defNormalProp$P(a, prop, b[prop]);
90
+ if (__getOwnPropSymbols$P)
91
+ for (var prop of __getOwnPropSymbols$P(b)) {
92
+ if (__propIsEnum$P.call(b, prop))
93
+ __defNormalProp$P(a, prop, b[prop]);
94
94
  }
95
95
  return a;
96
96
  };
97
- var __spreadProps$y = (a, b) => __defProps$y(a, __getOwnPropDescs$y(b));
97
+ var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
98
98
  const runtimePanelPlugins = /* @__PURE__ */ new Map();
99
99
  function registerRuntimePanelPlugin({ pluginId, plugin }) {
100
100
  if (runtimePanelPlugins.has(pluginId)) {
101
101
  throw new Error(`A runtime panel plugin with id ${pluginId} has already been registered`);
102
102
  }
103
- plugin.meta = __spreadProps$y(__spreadValues$Q({}, plugin.meta), {
103
+ plugin.meta = __spreadProps$x(__spreadValues$P({}, plugin.meta), {
104
104
  id: pluginId,
105
105
  name: pluginId,
106
106
  module: "runtime plugin",
@@ -128,33 +128,33 @@ function loadPanelPluginSync(pluginId) {
128
128
  return (_a = getPanelPluginFromCache(pluginId)) != null ? _a : runtimePanelPlugins.get(pluginId);
129
129
  }
130
130
 
131
- var __defProp$P = Object.defineProperty;
132
- var __defProps$x = Object.defineProperties;
133
- var __getOwnPropDescs$x = Object.getOwnPropertyDescriptors;
134
- var __getOwnPropSymbols$P = Object.getOwnPropertySymbols;
135
- var __hasOwnProp$P = Object.prototype.hasOwnProperty;
136
- var __propIsEnum$P = Object.prototype.propertyIsEnumerable;
137
- var __defNormalProp$P = (obj, key, value) => key in obj ? __defProp$P(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
- var __spreadValues$P = (a, b) => {
131
+ var __defProp$O = Object.defineProperty;
132
+ var __defProps$w = Object.defineProperties;
133
+ var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
134
+ var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
135
+ var __hasOwnProp$O = Object.prototype.hasOwnProperty;
136
+ var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
137
+ var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
138
+ var __spreadValues$O = (a, b) => {
139
139
  for (var prop in b || (b = {}))
140
- if (__hasOwnProp$P.call(b, prop))
141
- __defNormalProp$P(a, prop, b[prop]);
142
- if (__getOwnPropSymbols$P)
143
- for (var prop of __getOwnPropSymbols$P(b)) {
144
- if (__propIsEnum$P.call(b, prop))
145
- __defNormalProp$P(a, prop, b[prop]);
140
+ if (__hasOwnProp$O.call(b, prop))
141
+ __defNormalProp$O(a, prop, b[prop]);
142
+ if (__getOwnPropSymbols$O)
143
+ for (var prop of __getOwnPropSymbols$O(b)) {
144
+ if (__propIsEnum$O.call(b, prop))
145
+ __defNormalProp$O(a, prop, b[prop]);
146
146
  }
147
147
  return a;
148
148
  };
149
- var __spreadProps$x = (a, b) => __defProps$x(a, __getOwnPropDescs$x(b));
149
+ var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
150
150
  var __objRest$5 = (source, exclude) => {
151
151
  var target = {};
152
152
  for (var prop in source)
153
- if (__hasOwnProp$P.call(source, prop) && exclude.indexOf(prop) < 0)
153
+ if (__hasOwnProp$O.call(source, prop) && exclude.indexOf(prop) < 0)
154
154
  target[prop] = source[prop];
155
- if (source != null && __getOwnPropSymbols$P)
156
- for (var prop of __getOwnPropSymbols$P(source)) {
157
- if (exclude.indexOf(prop) < 0 && __propIsEnum$P.call(source, prop))
155
+ if (source != null && __getOwnPropSymbols$O)
156
+ for (var prop of __getOwnPropSymbols$O(source)) {
157
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$O.call(source, prop))
158
158
  target[prop] = source[prop];
159
159
  }
160
160
  return target;
@@ -172,7 +172,7 @@ function SceneComponentWrapperWithoutMemo(_a) {
172
172
  if (!model.isActive && !model.renderBeforeActivation) {
173
173
  return null;
174
174
  }
175
- return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$x(__spreadValues$P({}, otherProps), {
175
+ return /* @__PURE__ */ React__default["default"].createElement(Component, __spreadProps$w(__spreadValues$O({}, otherProps), {
176
176
  model
177
177
  }));
178
178
  }
@@ -188,49 +188,49 @@ class UserActionEvent extends data.BusEventWithPayload {
188
188
  }
189
189
  UserActionEvent.type = "scene-object-user-action";
190
190
 
191
- var __accessCheck$4 = (obj, member, msg) => {
191
+ var __accessCheck$3 = (obj, member, msg) => {
192
192
  if (!member.has(obj))
193
193
  throw TypeError("Cannot " + msg);
194
194
  };
195
- var __privateGet$4 = (obj, member, getter) => {
196
- __accessCheck$4(obj, member, "read from private field");
195
+ var __privateGet$3 = (obj, member, getter) => {
196
+ __accessCheck$3(obj, member, "read from private field");
197
197
  return getter ? getter.call(obj) : member.get(obj);
198
198
  };
199
- var __privateAdd$4 = (obj, member, value) => {
199
+ var __privateAdd$3 = (obj, member, value) => {
200
200
  if (member.has(obj))
201
201
  throw TypeError("Cannot add the same private member more than once");
202
202
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
203
203
  };
204
- var __privateSet$4 = (obj, member, value, setter) => {
205
- __accessCheck$4(obj, member, "write to private field");
204
+ var __privateSet$2 = (obj, member, value, setter) => {
205
+ __accessCheck$3(obj, member, "write to private field");
206
206
  setter ? setter.call(obj, value) : member.set(obj, value);
207
207
  return value;
208
208
  };
209
209
  var _ref;
210
210
  class SceneObjectRef {
211
211
  constructor(ref) {
212
- __privateAdd$4(this, _ref, void 0);
213
- __privateSet$4(this, _ref, ref);
212
+ __privateAdd$3(this, _ref, void 0);
213
+ __privateSet$2(this, _ref, ref);
214
214
  }
215
215
  resolve() {
216
- return __privateGet$4(this, _ref);
216
+ return __privateGet$3(this, _ref);
217
217
  }
218
218
  }
219
219
  _ref = new WeakMap();
220
220
 
221
- var __defProp$O = Object.defineProperty;
222
- var __getOwnPropSymbols$O = Object.getOwnPropertySymbols;
223
- var __hasOwnProp$O = Object.prototype.hasOwnProperty;
224
- var __propIsEnum$O = Object.prototype.propertyIsEnumerable;
225
- var __defNormalProp$O = (obj, key, value) => key in obj ? __defProp$O(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
- var __spreadValues$O = (a, b) => {
221
+ var __defProp$N = Object.defineProperty;
222
+ var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
223
+ var __hasOwnProp$N = Object.prototype.hasOwnProperty;
224
+ var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
225
+ var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
226
+ var __spreadValues$N = (a, b) => {
227
227
  for (var prop in b || (b = {}))
228
- if (__hasOwnProp$O.call(b, prop))
229
- __defNormalProp$O(a, prop, b[prop]);
230
- if (__getOwnPropSymbols$O)
231
- for (var prop of __getOwnPropSymbols$O(b)) {
232
- if (__propIsEnum$O.call(b, prop))
233
- __defNormalProp$O(a, prop, b[prop]);
228
+ if (__hasOwnProp$N.call(b, prop))
229
+ __defNormalProp$N(a, prop, b[prop]);
230
+ if (__getOwnPropSymbols$N)
231
+ for (var prop of __getOwnPropSymbols$N(b)) {
232
+ if (__propIsEnum$N.call(b, prop))
233
+ __defNormalProp$N(a, prop, b[prop]);
234
234
  }
235
235
  return a;
236
236
  };
@@ -297,7 +297,7 @@ class SceneObjectBase {
297
297
  }
298
298
  setState(update) {
299
299
  const prevState = this._state;
300
- const newState = __spreadValues$O(__spreadValues$O({}, this._state), update);
300
+ const newState = __spreadValues$N(__spreadValues$N({}, this._state), update);
301
301
  this._state = Object.freeze(newState);
302
302
  this._setParent(update);
303
303
  this._handleActivationOfChangedStateProps(prevState, newState);
@@ -493,19 +493,19 @@ function forEachChild(state, callback) {
493
493
  }
494
494
  }
495
495
 
496
- var __defProp$N = Object.defineProperty;
497
- var __getOwnPropSymbols$N = Object.getOwnPropertySymbols;
498
- var __hasOwnProp$N = Object.prototype.hasOwnProperty;
499
- var __propIsEnum$N = Object.prototype.propertyIsEnumerable;
500
- var __defNormalProp$N = (obj, key, value) => key in obj ? __defProp$N(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
501
- var __spreadValues$N = (a, b) => {
496
+ var __defProp$M = Object.defineProperty;
497
+ var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
498
+ var __hasOwnProp$M = Object.prototype.hasOwnProperty;
499
+ var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
500
+ var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
501
+ var __spreadValues$M = (a, b) => {
502
502
  for (var prop in b || (b = {}))
503
- if (__hasOwnProp$N.call(b, prop))
504
- __defNormalProp$N(a, prop, b[prop]);
505
- if (__getOwnPropSymbols$N)
506
- for (var prop of __getOwnPropSymbols$N(b)) {
507
- if (__propIsEnum$N.call(b, prop))
508
- __defNormalProp$N(a, prop, b[prop]);
503
+ if (__hasOwnProp$M.call(b, prop))
504
+ __defNormalProp$M(a, prop, b[prop]);
505
+ if (__getOwnPropSymbols$M)
506
+ for (var prop of __getOwnPropSymbols$M(b)) {
507
+ if (__propIsEnum$M.call(b, prop))
508
+ __defNormalProp$M(a, prop, b[prop]);
509
509
  }
510
510
  return a;
511
511
  };
@@ -514,7 +514,7 @@ function cloneSceneObject(sceneObject, withState) {
514
514
  return new sceneObject.constructor(clonedState);
515
515
  }
516
516
  function cloneSceneObjectState(sceneState, withState) {
517
- const clonedState = __spreadValues$N({}, sceneState);
517
+ const clonedState = __spreadValues$M({}, sceneState);
518
518
  Object.assign(clonedState, withState);
519
519
  for (const key in clonedState) {
520
520
  if (withState && withState[key] !== void 0) {
@@ -615,305 +615,6 @@ function lookupVariable(name, sceneObject) {
615
615
  return null;
616
616
  }
617
617
 
618
- function writeSceneLog(logger, message, ...rest) {
619
- let loggingEnabled = false;
620
- if (typeof window !== "undefined") {
621
- loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
622
- }
623
- if (loggingEnabled) {
624
- console.log(`${logger}: `, message, ...rest);
625
- }
626
- }
627
-
628
- var __accessCheck$3 = (obj, member, msg) => {
629
- if (!member.has(obj))
630
- throw TypeError("Cannot " + msg);
631
- };
632
- var __privateGet$3 = (obj, member, getter) => {
633
- __accessCheck$3(obj, member, "read from private field");
634
- return getter ? getter.call(obj) : member.get(obj);
635
- };
636
- var __privateAdd$3 = (obj, member, value) => {
637
- if (member.has(obj))
638
- throw TypeError("Cannot add the same private member more than once");
639
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
640
- };
641
- var __privateSet$3 = (obj, member, value, setter) => {
642
- __accessCheck$3(obj, member, "write to private field");
643
- setter ? setter.call(obj, value) : member.set(obj, value);
644
- return value;
645
- };
646
- var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
647
- const POST_STORM_WINDOW = 2e3;
648
- const SPAN_THRESHOLD = 30;
649
- class SceneRenderProfiler {
650
- constructor(queryController) {
651
- this.queryController = queryController;
652
- __privateAdd$3(this, _profileInProgress, null);
653
- __privateAdd$3(this, _profileStartTs, null);
654
- __privateAdd$3(this, _trailAnimationFrameId, null);
655
- __privateAdd$3(this, _recordedTrailingSpans, []);
656
- this.lastFrameTime = 0;
657
- this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
658
- const currentFrameTime = performance.now();
659
- const frameLength = currentFrameTime - lastFrameTime;
660
- __privateGet$3(this, _recordedTrailingSpans).push(frameLength);
661
- if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
662
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
663
- () => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
664
- ));
665
- } else {
666
- const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
667
- const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
668
- writeSceneLog(
669
- this.constructor.name,
670
- "Profile tail recorded, slow frames duration:",
671
- slowFramesTime,
672
- slowFrames,
673
- __privateGet$3(this, _profileInProgress)
674
- );
675
- __privateSet$3(this, _recordedTrailingSpans, []);
676
- const profileDuration = measurementStartTs - profileStartTs;
677
- writeSceneLog(
678
- this.constructor.name,
679
- "Stoped recording, total measured time (network included):",
680
- profileDuration + slowFramesTime
681
- );
682
- __privateSet$3(this, _trailAnimationFrameId, null);
683
- const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
684
- performance.measure("DashboardInteraction", {
685
- start: profileStartTs,
686
- end: profileEndTs
687
- });
688
- const networkDuration = captureNetwork(profileStartTs, profileEndTs);
689
- if (this.queryController.state.onProfileComplete) {
690
- this.queryController.state.onProfileComplete({
691
- origin: __privateGet$3(this, _profileInProgress).origin,
692
- crumbs: __privateGet$3(this, _profileInProgress).crumbs,
693
- duration: profileDuration + slowFramesTime,
694
- networkDuration,
695
- jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
696
- usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
697
- totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
698
- });
699
- }
700
- if (window.__runs) {
701
- window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
702
- `;
703
- } else {
704
- window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
705
- `;
706
- }
707
- }
708
- };
709
- }
710
- startProfile(name) {
711
- if (__privateGet$3(this, _trailAnimationFrameId)) {
712
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
713
- __privateSet$3(this, _trailAnimationFrameId, null);
714
- writeSceneLog(this.constructor.name, "New profile: Stopped recording frames");
715
- }
716
- __privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
717
- __privateSet$3(this, _profileStartTs, performance.now());
718
- writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
719
- }
720
- recordProfileTail(measurementStartTime, profileStartTs) {
721
- __privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
722
- () => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
723
- ));
724
- }
725
- tryCompletingProfile() {
726
- writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
727
- if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
728
- writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
729
- this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
730
- }
731
- }
732
- isTailRecording() {
733
- return Boolean(__privateGet$3(this, _trailAnimationFrameId));
734
- }
735
- cancelTailRecording() {
736
- if (__privateGet$3(this, _trailAnimationFrameId)) {
737
- cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
738
- __privateSet$3(this, _trailAnimationFrameId, null);
739
- writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
740
- }
741
- }
742
- addCrumb(crumb) {
743
- if (__privateGet$3(this, _profileInProgress)) {
744
- __privateGet$3(this, _profileInProgress).crumbs.push(crumb);
745
- }
746
- }
747
- }
748
- _profileInProgress = new WeakMap();
749
- _profileStartTs = new WeakMap();
750
- _trailAnimationFrameId = new WeakMap();
751
- _recordedTrailingSpans = new WeakMap();
752
- function processRecordedSpans(spans) {
753
- for (let i = spans.length - 1; i >= 0; i--) {
754
- if (spans[i] > SPAN_THRESHOLD) {
755
- return spans.slice(0, i + 1);
756
- }
757
- }
758
- return [spans[0]];
759
- }
760
- function captureNetwork(startTs, endTs) {
761
- const entries = performance.getEntriesByType("resource");
762
- performance.clearResourceTimings();
763
- const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
764
- for (const entry of networkEntries) {
765
- performance.measure("Network entry " + entry.name, {
766
- start: entry.startTime,
767
- end: entry.responseEnd
768
- });
769
- }
770
- return calculateNetworkTime(networkEntries);
771
- }
772
- function calculateNetworkTime(requests) {
773
- if (requests.length === 0) {
774
- return 0;
775
- }
776
- requests.sort((a, b) => a.startTime - b.startTime);
777
- let totalNetworkTime = 0;
778
- let currentStart = requests[0].startTime;
779
- let currentEnd = requests[0].responseEnd;
780
- for (let i = 1; i < requests.length; i++) {
781
- if (requests[i].startTime <= currentEnd) {
782
- currentEnd = Math.max(currentEnd, requests[i].responseEnd);
783
- } else {
784
- totalNetworkTime += currentEnd - currentStart;
785
- currentStart = requests[i].startTime;
786
- currentEnd = requests[i].responseEnd;
787
- }
788
- }
789
- totalNetworkTime += currentEnd - currentStart;
790
- return totalNetworkTime;
791
- }
792
-
793
- var __defProp$M = Object.defineProperty;
794
- var __defProps$w = Object.defineProperties;
795
- var __getOwnPropDescs$w = Object.getOwnPropertyDescriptors;
796
- var __getOwnPropSymbols$M = Object.getOwnPropertySymbols;
797
- var __hasOwnProp$M = Object.prototype.hasOwnProperty;
798
- var __propIsEnum$M = Object.prototype.propertyIsEnumerable;
799
- var __defNormalProp$M = (obj, key, value) => key in obj ? __defProp$M(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
800
- var __spreadValues$M = (a, b) => {
801
- for (var prop in b || (b = {}))
802
- if (__hasOwnProp$M.call(b, prop))
803
- __defNormalProp$M(a, prop, b[prop]);
804
- if (__getOwnPropSymbols$M)
805
- for (var prop of __getOwnPropSymbols$M(b)) {
806
- if (__propIsEnum$M.call(b, prop))
807
- __defNormalProp$M(a, prop, b[prop]);
808
- }
809
- return a;
810
- };
811
- var __spreadProps$w = (a, b) => __defProps$w(a, __getOwnPropDescs$w(b));
812
- var __accessCheck$2 = (obj, member, msg) => {
813
- if (!member.has(obj))
814
- throw TypeError("Cannot " + msg);
815
- };
816
- var __privateGet$2 = (obj, member, getter) => {
817
- __accessCheck$2(obj, member, "read from private field");
818
- return getter ? getter.call(obj) : member.get(obj);
819
- };
820
- var __privateAdd$2 = (obj, member, value) => {
821
- if (member.has(obj))
822
- throw TypeError("Cannot add the same private member more than once");
823
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
824
- };
825
- var __privateSet$2 = (obj, member, value, setter) => {
826
- __accessCheck$2(obj, member, "write to private field");
827
- setter ? setter.call(obj, value) : member.set(obj, value);
828
- return value;
829
- };
830
- var _running, _tryCompleteProfileFrameId;
831
- function isQueryController(s) {
832
- return "isQueryController" in s;
833
- }
834
- class SceneQueryController extends SceneObjectBase {
835
- constructor(state = {}) {
836
- super(__spreadProps$w(__spreadValues$M({}, state), { isRunning: false }));
837
- this.isQueryController = true;
838
- this.profiler = new SceneRenderProfiler(this);
839
- __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
840
- __privateAdd$2(this, _tryCompleteProfileFrameId, null);
841
- this.runningQueriesCount = () => {
842
- return __privateGet$2(this, _running).size;
843
- };
844
- this.addActivationHandler(() => {
845
- return () => __privateGet$2(this, _running).clear();
846
- });
847
- }
848
- startProfile(source) {
849
- if (!this.state.enableProfiling) {
850
- return;
851
- }
852
- this.profiler.startProfile(source.constructor.name);
853
- }
854
- queryStarted(entry) {
855
- __privateGet$2(this, _running).add(entry);
856
- this.changeRunningQueryCount(1, entry);
857
- if (!this.state.isRunning) {
858
- this.setState({ isRunning: true });
859
- }
860
- }
861
- queryCompleted(entry) {
862
- if (!__privateGet$2(this, _running).has(entry)) {
863
- return;
864
- }
865
- __privateGet$2(this, _running).delete(entry);
866
- this.changeRunningQueryCount(-1);
867
- if (__privateGet$2(this, _running).size === 0) {
868
- this.setState({ isRunning: false });
869
- }
870
- }
871
- changeRunningQueryCount(dir, entry) {
872
- var _a;
873
- window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
874
- if (dir === 1 && this.state.enableProfiling) {
875
- if (entry) {
876
- this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
877
- }
878
- if (this.profiler.isTailRecording()) {
879
- writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
880
- this.profiler.cancelTailRecording();
881
- }
882
- }
883
- if (this.state.enableProfiling) {
884
- if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
885
- cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
886
- }
887
- __privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
888
- this.profiler.tryCompletingProfile();
889
- }));
890
- }
891
- }
892
- cancelAll() {
893
- var _a;
894
- for (const entry of __privateGet$2(this, _running).values()) {
895
- (_a = entry.cancel) == null ? void 0 : _a.call(entry);
896
- }
897
- }
898
- }
899
- _running = new WeakMap();
900
- _tryCompleteProfileFrameId = new WeakMap();
901
-
902
- function getQueryController(sceneObject) {
903
- let parent = sceneObject;
904
- while (parent) {
905
- if (parent.state.$behaviors) {
906
- for (const behavior of parent.state.$behaviors) {
907
- if (isQueryController(behavior)) {
908
- return behavior;
909
- }
910
- }
911
- }
912
- parent = parent.parent;
913
- }
914
- return void 0;
915
- }
916
-
917
618
  var __defProp$L = Object.defineProperty;
918
619
  var __getOwnPropSymbols$L = Object.getOwnPropertySymbols;
919
620
  var __hasOwnProp$L = Object.prototype.hasOwnProperty;
@@ -1120,8 +821,6 @@ class SceneTimeRange extends SceneObjectBase {
1120
821
  this.state.weekStart
1121
822
  );
1122
823
  if (update.from !== this.state.from || update.to !== this.state.to) {
1123
- const queryController = getQueryController(this);
1124
- queryController == null ? void 0 : queryController.startProfile(this);
1125
824
  this._urlSync.performBrowserHistoryAction(() => {
1126
825
  this.setState(update);
1127
826
  });
@@ -2457,55 +2156,70 @@ function isDataLayer(obj) {
2457
2156
  return "isDataLayer" in obj;
2458
2157
  }
2459
2158
 
2460
- function registerQueryWithController(entry) {
2461
- return (queryStream) => {
2462
- const queryControler = sceneGraph.getQueryController(entry.origin);
2463
- if (!queryControler) {
2464
- return queryStream;
2465
- }
2466
- return new rxjs.Observable((observer) => {
2467
- if (!entry.cancel) {
2468
- entry.cancel = () => observer.complete();
2469
- }
2470
- queryControler.queryStarted(entry);
2471
- let markedAsCompleted = false;
2472
- const sub = queryStream.subscribe({
2473
- next: (v) => {
2474
- if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2475
- markedAsCompleted = true;
2476
- queryControler.queryCompleted(entry);
2477
- }
2478
- observer.next(v);
2479
- },
2480
- error: (e) => observer.error(e),
2481
- complete: () => {
2482
- observer.complete();
2483
- }
2484
- });
2485
- return () => {
2486
- sub.unsubscribe();
2487
- if (!markedAsCompleted) {
2488
- queryControler.queryCompleted(entry);
2489
- }
2490
- };
2491
- });
2492
- };
2159
+ var __accessCheck$2 = (obj, member, msg) => {
2160
+ if (!member.has(obj))
2161
+ throw TypeError("Cannot " + msg);
2162
+ };
2163
+ var __privateGet$2 = (obj, member, getter) => {
2164
+ __accessCheck$2(obj, member, "read from private field");
2165
+ return getter ? getter.call(obj) : member.get(obj);
2166
+ };
2167
+ var __privateAdd$2 = (obj, member, value) => {
2168
+ if (member.has(obj))
2169
+ throw TypeError("Cannot add the same private member more than once");
2170
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2171
+ };
2172
+ var _running;
2173
+ function isQueryController(s) {
2174
+ return "isQueryController" in s;
2493
2175
  }
2494
- function wrapPromiseInStateObservable(promise) {
2495
- return new rxjs.Observable((observer) => {
2496
- observer.next({ state: schema.LoadingState.Loading });
2497
- const promiseObservable = rxjs.from(promise);
2498
- promiseObservable.pipe(
2499
- rxjs.map(() => ({ state: schema.LoadingState.Done })),
2500
- rxjs.catchError(() => {
2501
- observer.next({ state: schema.LoadingState.Error });
2502
- return [];
2503
- })
2504
- ).subscribe({
2505
- next: (result) => observer.next(result),
2506
- complete: () => observer.complete()
2176
+ class SceneQueryController extends SceneObjectBase {
2177
+ constructor() {
2178
+ super({ isRunning: false });
2179
+ this.isQueryController = true;
2180
+ __privateAdd$2(this, _running, /* @__PURE__ */ new Set());
2181
+ this.addActivationHandler(() => {
2182
+ return () => __privateGet$2(this, _running).clear();
2507
2183
  });
2508
- });
2184
+ }
2185
+ queryStarted(entry) {
2186
+ __privateGet$2(this, _running).add(entry);
2187
+ this.changeRunningQueryCount(1);
2188
+ if (!this.state.isRunning) {
2189
+ this.setState({ isRunning: true });
2190
+ }
2191
+ }
2192
+ queryCompleted(entry) {
2193
+ if (!__privateGet$2(this, _running).has(entry)) {
2194
+ return;
2195
+ }
2196
+ __privateGet$2(this, _running).delete(entry);
2197
+ this.changeRunningQueryCount(-1);
2198
+ if (__privateGet$2(this, _running).size === 0) {
2199
+ this.setState({ isRunning: false });
2200
+ }
2201
+ }
2202
+ changeRunningQueryCount(dir) {
2203
+ var _a;
2204
+ window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
2205
+ }
2206
+ cancelAll() {
2207
+ var _a;
2208
+ for (const entry of __privateGet$2(this, _running).values()) {
2209
+ (_a = entry.cancel) == null ? void 0 : _a.call(entry);
2210
+ }
2211
+ }
2212
+ }
2213
+ _running = new WeakMap();
2214
+
2215
+ function writeSceneLog(logger, message, ...rest) {
2216
+ let loggingEnabled = false;
2217
+ if (typeof window !== "undefined") {
2218
+ loggingEnabled = localStorage.getItem("grafana.debug.scenes") === "true";
2219
+ }
2220
+ if (loggingEnabled) {
2221
+ console.log(`${logger}: `, message, ...rest);
2222
+ }
2509
2223
  }
2510
2224
 
2511
2225
  async function getDataSource(datasource, scopedVars) {
@@ -2518,21 +2232,7 @@ async function getDataSource(datasource, scopedVars) {
2518
2232
  if (datasource && datasource.query) {
2519
2233
  return datasource;
2520
2234
  }
2521
- const dsPromise = runtime.getDataSourceSrv().get(datasource, scopedVars);
2522
- if (scopedVars.__sceneObject && scopedVars.__sceneObject.value.valueOf()) {
2523
- const queryControler = sceneGraph.getQueryController(scopedVars.__sceneObject.value.valueOf());
2524
- if (queryControler && queryControler.state.enableProfiling) {
2525
- wrapPromiseInStateObservable(dsPromise).pipe(
2526
- registerQueryWithController({
2527
- type: "plugin",
2528
- origin: scopedVars.__sceneObject.value.valueOf()
2529
- })
2530
- ).subscribe(() => {
2531
- });
2532
- }
2533
- }
2534
- const result = await dsPromise;
2535
- return result;
2235
+ return await runtime.getDataSourceSrv().get(datasource, scopedVars);
2536
2236
  }
2537
2237
 
2538
2238
  class VariableValueRecorder {
@@ -2781,6 +2481,41 @@ function findActiveAdHocFilterVariableByUid(dsUid) {
2781
2481
  return void 0;
2782
2482
  }
2783
2483
 
2484
+ function registerQueryWithController(entry) {
2485
+ return (queryStream) => {
2486
+ const queryControler = sceneGraph.getQueryController(entry.origin);
2487
+ if (!queryControler) {
2488
+ return queryStream;
2489
+ }
2490
+ return new rxjs.Observable((observer) => {
2491
+ if (!entry.cancel) {
2492
+ entry.cancel = () => observer.complete();
2493
+ }
2494
+ queryControler.queryStarted(entry);
2495
+ let markedAsCompleted = false;
2496
+ const sub = queryStream.subscribe({
2497
+ next: (v) => {
2498
+ if (!markedAsCompleted && v.state !== schema.LoadingState.Loading) {
2499
+ markedAsCompleted = true;
2500
+ queryControler.queryCompleted(entry);
2501
+ }
2502
+ observer.next(v);
2503
+ },
2504
+ error: (e) => observer.error(e),
2505
+ complete: () => {
2506
+ observer.complete();
2507
+ }
2508
+ });
2509
+ return () => {
2510
+ sub.unsubscribe();
2511
+ if (!markedAsCompleted) {
2512
+ queryControler.queryCompleted(entry);
2513
+ }
2514
+ };
2515
+ });
2516
+ };
2517
+ }
2518
+
2784
2519
  const allActiveGroupByVariables = /* @__PURE__ */ new Set();
2785
2520
  function findActiveGroupByVariablesByUid(dsUid) {
2786
2521
  var _a;
@@ -2855,7 +2590,6 @@ function VariableValueSelect({ model }) {
2855
2590
  const [inputValue, setInputValue] = React.useState("");
2856
2591
  const [hasCustomValue, setHasCustomValue] = React.useState(false);
2857
2592
  const selectValue = toSelectableValue$2(value, String(text));
2858
- const queryController = sceneGraph.getQueryController(model);
2859
2593
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2860
2594
  const onInputChange = (value2, { action }) => {
2861
2595
  if (action === "input-change") {
@@ -2895,7 +2629,6 @@ function VariableValueSelect({ model }) {
2895
2629
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${value}`),
2896
2630
  onChange: (newValue) => {
2897
2631
  model.changeValueTo(newValue.value, newValue.label);
2898
- queryController == null ? void 0 : queryController.startProfile(model);
2899
2632
  if (hasCustomValue !== newValue.__isNew__) {
2900
2633
  setHasCustomValue(newValue.__isNew__);
2901
2634
  }
@@ -2916,7 +2649,6 @@ function VariableValueSelectMulti({ model }) {
2916
2649
  const arrayValue = React.useMemo(() => lodash.isArray(value) ? value : [value], [value]);
2917
2650
  const [uncommittedValue, setUncommittedValue] = React.useState(arrayValue);
2918
2651
  const [inputValue, setInputValue] = React.useState("");
2919
- const queryController = sceneGraph.getQueryController(model);
2920
2652
  const optionSearcher = React.useMemo(() => getOptionSearcher(options, includeAll), [options, includeAll]);
2921
2653
  React.useEffect(() => {
2922
2654
  setUncommittedValue(arrayValue);
@@ -2962,7 +2694,6 @@ function VariableValueSelectMulti({ model }) {
2962
2694
  onInputChange,
2963
2695
  onBlur: () => {
2964
2696
  model.changeValueTo(uncommittedValue);
2965
- queryController == null ? void 0 : queryController.startProfile(model);
2966
2697
  },
2967
2698
  filterOption: filterNoOp$2,
2968
2699
  "data-testid": e2eSelectors.selectors.pages.Dashboard.SubMenu.submenuItemValueDropDownValueLinkTexts(`${uncommittedValue}`),
@@ -6610,28 +6341,6 @@ const sortVariableValues = (options, sortOrder) => {
6610
6341
  if (sortOrder === data.VariableSort.disabled) {
6611
6342
  return options;
6612
6343
  }
6613
- const sortByNumeric = (opt) => {
6614
- if (!opt.text) {
6615
- return -1;
6616
- }
6617
- const matches = opt.text.match(/.*?(\d+).*/);
6618
- if (!matches || matches.length < 2) {
6619
- return -1;
6620
- } else {
6621
- return parseInt(matches[1], 10);
6622
- }
6623
- };
6624
- const sortByNaturalSort = (options2) => {
6625
- return options2.sort((a, b) => {
6626
- if (!a.text) {
6627
- return -1;
6628
- }
6629
- if (!b.text) {
6630
- return 1;
6631
- }
6632
- return a.text.localeCompare(b.text, void 0, { numeric: true });
6633
- });
6634
- };
6635
6344
  switch (sortOrder) {
6636
6345
  case data.VariableSort.alphabeticalAsc:
6637
6346
  options = lodash.sortBy(options, "label");
@@ -6667,6 +6376,23 @@ const sortVariableValues = (options, sortOrder) => {
6667
6376
  }
6668
6377
  return options;
6669
6378
  };
6379
+ function sortByNumeric(opt) {
6380
+ if (!opt.label) {
6381
+ return -1;
6382
+ }
6383
+ const matches = opt.label.match(/.*?(\d+).*/);
6384
+ if (!matches || matches.length < 2) {
6385
+ return -1;
6386
+ } else {
6387
+ return parseInt(matches[1], 10);
6388
+ }
6389
+ }
6390
+ const collator = new Intl.Collator(void 0, { sensitivity: "accent", numeric: true });
6391
+ function sortByNaturalSort(options) {
6392
+ return options.slice().sort((a, b) => {
6393
+ return collator.compare(a.label, b.label);
6394
+ });
6395
+ }
6670
6396
 
6671
6397
  function toMetricFindValues() {
6672
6398
  return (source) => source.pipe(
@@ -7022,6 +6748,30 @@ function findDescendents(scene, descendentType) {
7022
6748
  const targetScenes = findAllObjects(scene, isDescendentType);
7023
6749
  return targetScenes.filter(isDescendentType);
7024
6750
  }
6751
+ function getQueryController(sceneObject) {
6752
+ let parent = sceneObject;
6753
+ while (parent) {
6754
+ if (parent.state.$behaviors) {
6755
+ for (const behavior of parent.state.$behaviors) {
6756
+ if (isQueryController(behavior)) {
6757
+ return behavior;
6758
+ }
6759
+ }
6760
+ }
6761
+ parent = parent.parent;
6762
+ }
6763
+ return void 0;
6764
+ }
6765
+ function getUrlSyncManager(sceneObject) {
6766
+ let parent = sceneObject;
6767
+ while (parent) {
6768
+ if ("urlSyncManager" in parent.state) {
6769
+ return parent.state.urlSyncManager;
6770
+ }
6771
+ parent = parent.parent;
6772
+ }
6773
+ return void 0;
6774
+ }
7025
6775
 
7026
6776
  const sceneGraph = {
7027
6777
  getVariables,
@@ -7037,8 +6787,9 @@ const sceneGraph = {
7037
6787
  findObject,
7038
6788
  findAllObjects,
7039
6789
  getAncestor,
6790
+ findDescendents,
7040
6791
  getQueryController,
7041
- findDescendents
6792
+ getUrlSyncManager
7042
6793
  };
7043
6794
 
7044
6795
  class UniqueUrlKeyMapper {
@@ -8008,13 +7759,7 @@ class VizPanel extends SceneObjectBase {
8008
7759
  } else {
8009
7760
  const { importPanelPlugin } = runtime.getPluginImportUtils();
8010
7761
  try {
8011
- const panelPromise = importPanelPlugin(pluginId);
8012
- const queryControler = sceneGraph.getQueryController(this);
8013
- if (queryControler && queryControler.state.enableProfiling) {
8014
- wrapPromiseInStateObservable(panelPromise).pipe(registerQueryWithController({ type: "plugin", origin: this })).subscribe(() => {
8015
- });
8016
- }
8017
- const result = await panelPromise;
7762
+ const result = await importPanelPlugin(pluginId);
8018
7763
  this._pluginLoaded(result, overwriteOptions, overwriteFieldConfig, isAfterPluginChange);
8019
7764
  } catch (err) {
8020
7765
  this._pluginLoaded(getPanelPluginNotFound(pluginId));
@@ -11603,7 +11348,6 @@ class SceneRefreshPicker extends SceneObjectBase {
11603
11348
  this._autoRefreshBlocked = false;
11604
11349
  this.onRefresh = () => {
11605
11350
  const queryController = sceneGraph.getQueryController(this);
11606
- queryController == null ? void 0 : queryController.startProfile(this);
11607
11351
  if (queryController == null ? void 0 : queryController.state.isRunning) {
11608
11352
  queryController.cancelAll();
11609
11353
  return;
@@ -11659,8 +11403,6 @@ class SceneRefreshPicker extends SceneObjectBase {
11659
11403
  }
11660
11404
  this._intervalTimer = setInterval(() => {
11661
11405
  if (this.isTabVisible()) {
11662
- const queryController = sceneGraph.getQueryController(this);
11663
- queryController == null ? void 0 : queryController.startProfile(this);
11664
11406
  timeRange.onRefresh();
11665
11407
  } else {
11666
11408
  this._autoRefreshBlocked = true;
@@ -11734,9 +11476,7 @@ function SceneRefreshPickerRenderer({ model }) {
11734
11476
  tooltip,
11735
11477
  width,
11736
11478
  text,
11737
- onRefresh: () => {
11738
- model.onRefresh();
11739
- },
11479
+ onRefresh: model.onRefresh,
11740
11480
  primary,
11741
11481
  onIntervalChanged: model.onIntervalChanged,
11742
11482
  isLoading: isRunning,