@grafana/scenes 6.28.4--canary.1198.16595564474.0 → 6.28.4--canary.1196.16600049151.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/esm/behaviors/SceneQueryController.js +10 -15
- package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
- package/dist/esm/behaviors/SceneRenderProfiler.js +20 -19
- package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/variables/macros/index.js +7 -3
- package/dist/esm/variables/macros/index.js.map +1 -1
- package/dist/index.d.ts +5 -19
- package/dist/index.js +203 -205
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -607,77 +607,246 @@ 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);
|
|
610
785
|
var _running, _tryCompleteProfileFrameId;
|
|
611
786
|
function isQueryController(s) {
|
|
612
787
|
return "isQueryController" in s;
|
|
613
788
|
}
|
|
614
789
|
class SceneQueryController extends SceneObjectBase {
|
|
615
|
-
constructor(state = {}
|
|
790
|
+
constructor(state = {}) {
|
|
616
791
|
super({ ...state, isRunning: false });
|
|
617
|
-
this.profiler = profiler;
|
|
618
792
|
this.isQueryController = true;
|
|
619
|
-
|
|
620
|
-
__privateAdd$
|
|
793
|
+
this.profiler = new SceneRenderProfiler(this);
|
|
794
|
+
__privateAdd$2(this, _running, /* @__PURE__ */ new Set());
|
|
795
|
+
__privateAdd$2(this, _tryCompleteProfileFrameId, null);
|
|
621
796
|
this.runningQueriesCount = () => {
|
|
622
|
-
return __privateGet$
|
|
797
|
+
return __privateGet$2(this, _running).size;
|
|
623
798
|
};
|
|
624
|
-
if (profiler) {
|
|
625
|
-
this.profiler = profiler;
|
|
626
|
-
profiler.setQueryController(this);
|
|
627
|
-
}
|
|
628
799
|
this.addActivationHandler(() => {
|
|
629
|
-
return () => __privateGet$
|
|
800
|
+
return () => __privateGet$2(this, _running).clear();
|
|
630
801
|
});
|
|
631
802
|
}
|
|
632
803
|
startProfile(name) {
|
|
633
|
-
var _a;
|
|
634
804
|
if (!this.state.enableProfiling) {
|
|
635
805
|
return;
|
|
636
806
|
}
|
|
637
|
-
|
|
807
|
+
this.profiler.startProfile(name);
|
|
638
808
|
}
|
|
639
809
|
queryStarted(entry) {
|
|
640
|
-
__privateGet$
|
|
810
|
+
__privateGet$2(this, _running).add(entry);
|
|
641
811
|
this.changeRunningQueryCount(1, entry);
|
|
642
812
|
if (!this.state.isRunning) {
|
|
643
813
|
this.setState({ isRunning: true });
|
|
644
814
|
}
|
|
645
815
|
}
|
|
646
816
|
queryCompleted(entry) {
|
|
647
|
-
if (!__privateGet$
|
|
817
|
+
if (!__privateGet$2(this, _running).has(entry)) {
|
|
648
818
|
return;
|
|
649
819
|
}
|
|
650
|
-
__privateGet$
|
|
820
|
+
__privateGet$2(this, _running).delete(entry);
|
|
651
821
|
this.changeRunningQueryCount(-1);
|
|
652
|
-
if (__privateGet$
|
|
822
|
+
if (__privateGet$2(this, _running).size === 0) {
|
|
653
823
|
this.setState({ isRunning: false });
|
|
654
824
|
}
|
|
655
825
|
}
|
|
656
826
|
changeRunningQueryCount(dir, entry) {
|
|
657
|
-
var _a
|
|
827
|
+
var _a;
|
|
658
828
|
window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
|
|
659
829
|
if (dir === 1 && this.state.enableProfiling) {
|
|
660
830
|
if (entry) {
|
|
661
|
-
|
|
831
|
+
this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
|
|
662
832
|
}
|
|
663
|
-
if (
|
|
664
|
-
writeSceneLog(
|
|
665
|
-
|
|
833
|
+
if (this.profiler.isTailRecording()) {
|
|
834
|
+
writeSceneLog(this.constructor.name, "New query started, cancelling tail recording");
|
|
835
|
+
this.profiler.cancelTailRecording();
|
|
666
836
|
}
|
|
667
837
|
}
|
|
668
838
|
if (this.state.enableProfiling) {
|
|
669
|
-
if (__privateGet$
|
|
670
|
-
cancelAnimationFrame(__privateGet$
|
|
839
|
+
if (__privateGet$2(this, _tryCompleteProfileFrameId)) {
|
|
840
|
+
cancelAnimationFrame(__privateGet$2(this, _tryCompleteProfileFrameId));
|
|
671
841
|
}
|
|
672
|
-
__privateSet$
|
|
673
|
-
|
|
674
|
-
(_a2 = this.profiler) == null ? void 0 : _a2.tryCompletingProfile();
|
|
842
|
+
__privateSet$2(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
|
|
843
|
+
this.profiler.tryCompletingProfile();
|
|
675
844
|
}));
|
|
676
845
|
}
|
|
677
846
|
}
|
|
678
847
|
cancelAll() {
|
|
679
848
|
var _a;
|
|
680
|
-
for (const entry of __privateGet$
|
|
849
|
+
for (const entry of __privateGet$2(this, _running).values()) {
|
|
681
850
|
(_a = entry.cancel) == null ? void 0 : _a.call(entry);
|
|
682
851
|
}
|
|
683
852
|
}
|
|
@@ -847,180 +1016,6 @@ function isValid$1(value, roundUp, timeZone) {
|
|
|
847
1016
|
return parsed.isValid();
|
|
848
1017
|
}
|
|
849
1018
|
|
|
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
|
-
// @ts-ignore
|
|
911
|
-
jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
|
|
912
|
-
// @ts-ignore
|
|
913
|
-
usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
|
|
914
|
-
// @ts-ignore
|
|
915
|
-
totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
|
|
916
|
-
});
|
|
917
|
-
__privateSet$2(this, _profileInProgress, null);
|
|
918
|
-
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
919
|
-
}
|
|
920
|
-
if (window.__runs) {
|
|
921
|
-
window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
922
|
-
`;
|
|
923
|
-
} else {
|
|
924
|
-
window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
925
|
-
`;
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
setQueryController(queryController) {
|
|
931
|
-
this.queryController = queryController;
|
|
932
|
-
}
|
|
933
|
-
startProfile(name) {
|
|
934
|
-
if (__privateGet$2(this, _profileInProgress)) {
|
|
935
|
-
this.addCrumb(name);
|
|
936
|
-
} else {
|
|
937
|
-
__privateSet$2(this, _profileInProgress, { origin: name, crumbs: [] });
|
|
938
|
-
__privateSet$2(this, _profileStartTs, performance.now());
|
|
939
|
-
writeSceneLog("SceneRenderProfiler", "Profile started:", __privateGet$2(this, _profileInProgress), __privateGet$2(this, _profileStartTs));
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
recordProfileTail(measurementStartTime, profileStartTs) {
|
|
943
|
-
__privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
944
|
-
() => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
|
|
945
|
-
));
|
|
946
|
-
}
|
|
947
|
-
tryCompletingProfile() {
|
|
948
|
-
var _a;
|
|
949
|
-
writeSceneLog("SceneRenderProfiler", "Trying to complete profile", __privateGet$2(this, _profileInProgress));
|
|
950
|
-
if (((_a = this.queryController) == null ? void 0 : _a.runningQueriesCount()) === 0 && __privateGet$2(this, _profileInProgress)) {
|
|
951
|
-
writeSceneLog("SceneRenderProfiler", "All queries completed, stopping profile");
|
|
952
|
-
this.recordProfileTail(performance.now(), __privateGet$2(this, _profileStartTs));
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
isTailRecording() {
|
|
956
|
-
return Boolean(__privateGet$2(this, _trailAnimationFrameId));
|
|
957
|
-
}
|
|
958
|
-
cancelTailRecording() {
|
|
959
|
-
if (__privateGet$2(this, _trailAnimationFrameId)) {
|
|
960
|
-
cancelAnimationFrame(__privateGet$2(this, _trailAnimationFrameId));
|
|
961
|
-
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
962
|
-
writeSceneLog("SceneRenderProfiler", "Cancelled recording frames, new profile started");
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
addCrumb(crumb) {
|
|
966
|
-
if (__privateGet$2(this, _profileInProgress)) {
|
|
967
|
-
writeSceneLog("SceneRenderProfiler", "Adding crumb:", crumb);
|
|
968
|
-
__privateGet$2(this, _profileInProgress).crumbs.push(crumb);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
_profileInProgress = new WeakMap();
|
|
973
|
-
_profileStartTs = new WeakMap();
|
|
974
|
-
_trailAnimationFrameId = new WeakMap();
|
|
975
|
-
_recordedTrailingSpans = new WeakMap();
|
|
976
|
-
function processRecordedSpans(spans) {
|
|
977
|
-
for (let i = spans.length - 1; i >= 0; i--) {
|
|
978
|
-
if (spans[i] > SPAN_THRESHOLD) {
|
|
979
|
-
return spans.slice(0, i + 1);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
return [spans[0]];
|
|
983
|
-
}
|
|
984
|
-
function captureNetwork(startTs, endTs) {
|
|
985
|
-
const entries = performance.getEntriesByType("resource");
|
|
986
|
-
performance.clearResourceTimings();
|
|
987
|
-
const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
|
|
988
|
-
for (const entry of networkEntries) {
|
|
989
|
-
performance.measure("Network entry " + entry.name, {
|
|
990
|
-
start: entry.startTime,
|
|
991
|
-
end: entry.responseEnd
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
return calculateNetworkTime(networkEntries);
|
|
995
|
-
}
|
|
996
|
-
function calculateNetworkTime(requests) {
|
|
997
|
-
if (requests.length === 0) {
|
|
998
|
-
return 0;
|
|
999
|
-
}
|
|
1000
|
-
requests.sort((a, b) => a.startTime - b.startTime);
|
|
1001
|
-
let totalNetworkTime = 0;
|
|
1002
|
-
let currentStart = requests[0].startTime;
|
|
1003
|
-
let currentEnd = requests[0].responseEnd;
|
|
1004
|
-
for (let i = 1; i < requests.length; i++) {
|
|
1005
|
-
if (requests[i].startTime <= currentEnd) {
|
|
1006
|
-
currentEnd = Math.max(currentEnd, requests[i].responseEnd);
|
|
1007
|
-
} else {
|
|
1008
|
-
totalNetworkTime += currentEnd - currentStart;
|
|
1009
|
-
currentStart = requests[i].startTime;
|
|
1010
|
-
currentEnd = requests[i].responseEnd;
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
totalNetworkTime += currentEnd - currentStart;
|
|
1014
|
-
return totalNetworkTime;
|
|
1015
|
-
}
|
|
1016
|
-
const REFRESH_INTERACTION = "refresh";
|
|
1017
|
-
const TIME_RANGE_CHANGE_INTERACTION = "time_range_change";
|
|
1018
|
-
const FILTER_REMOVED_INTERACTION = "filter_removed";
|
|
1019
|
-
const FILTER_CHANGED_INTERACTION = "filter_changed";
|
|
1020
|
-
const FILTER_RESTORED_INTERACTION = "filter_restored";
|
|
1021
|
-
const VARIABLE_VALUE_CHANGED_INTERACTION = "variable_value_changed";
|
|
1022
|
-
const SCOPES_CHANGED_INTERACTION = "scopes_changed";
|
|
1023
|
-
|
|
1024
1019
|
class SceneTimeRange extends SceneObjectBase {
|
|
1025
1020
|
constructor(state = {}) {
|
|
1026
1021
|
var _a;
|
|
@@ -2425,13 +2420,17 @@ const macrosIndex = /* @__PURE__ */ new Map([
|
|
|
2425
2420
|
["__interval", IntervalMacro],
|
|
2426
2421
|
["__interval_ms", IntervalMacro]
|
|
2427
2422
|
]);
|
|
2428
|
-
function registerVariableMacro(name, macro) {
|
|
2429
|
-
if (macrosIndex.get(name)) {
|
|
2423
|
+
function registerVariableMacro(name, macro, replace = false) {
|
|
2424
|
+
if (!replace && macrosIndex.get(name)) {
|
|
2430
2425
|
throw new Error(`Macro already registered ${name}`);
|
|
2431
2426
|
}
|
|
2432
2427
|
macrosIndex.set(name, macro);
|
|
2433
2428
|
return () => {
|
|
2434
|
-
|
|
2429
|
+
if (replace) {
|
|
2430
|
+
throw new Error(`Replaced macros can not be unregistered. They need to be restored manually.`);
|
|
2431
|
+
} else {
|
|
2432
|
+
macrosIndex.delete(name);
|
|
2433
|
+
}
|
|
2435
2434
|
};
|
|
2436
2435
|
}
|
|
2437
2436
|
|
|
@@ -14601,7 +14600,6 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
|
|
|
14601
14600
|
exports.SceneQueryRunner = SceneQueryRunner;
|
|
14602
14601
|
exports.SceneReactObject = SceneReactObject;
|
|
14603
14602
|
exports.SceneRefreshPicker = SceneRefreshPicker;
|
|
14604
|
-
exports.SceneRenderProfiler = SceneRenderProfiler;
|
|
14605
14603
|
exports.SceneTimePicker = SceneTimePicker;
|
|
14606
14604
|
exports.SceneTimeRange = SceneTimeRange;
|
|
14607
14605
|
exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
|