@parca/profile 0.19.140 → 0.19.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
  9. package/dist/MatchersInput/SuggestionItem.js +91 -12
  10. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  11. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  12. package/dist/MatchersInput/SuggestionsList.js +371 -157
  13. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  15. package/dist/MatchersInput/index.js +308 -115
  16. package/dist/MetricsCircle/index.js +39 -3
  17. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  18. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  19. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  20. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  21. package/dist/MetricsGraph/index.js +552 -203
  22. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  23. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  24. package/dist/MetricsSeries/index.js +70 -7
  25. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  26. package/dist/PreSelectedMatchers/index.js +249 -102
  27. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
  29. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  30. package/dist/ProfileExplorer/index.js +183 -32
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  33. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  34. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  35. package/dist/ProfileFlameChart/index.js +260 -126
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  56. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  57. package/dist/ProfileFlameGraph/index.js +322 -147
  58. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  59. package/dist/ProfileMetricsGraph/index.js +515 -256
  60. package/dist/ProfileSelector/CompareButton.js +132 -12
  61. package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
  62. package/dist/ProfileSelector/index.d.ts +1 -1
  63. package/dist/ProfileSelector/index.d.ts.map +1 -1
  64. package/dist/ProfileSelector/index.js +734 -142
  65. package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
  66. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  67. package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
  68. package/dist/ProfileSource.js +230 -163
  69. package/dist/ProfileTypeSelector/index.js +214 -125
  70. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  71. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
  72. package/dist/ProfileView/components/ColorStackLegend.js +182 -54
  73. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  74. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  75. package/dist/ProfileView/components/DiffLegend.js +172 -29
  76. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  77. package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
  78. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  79. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  80. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  81. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
  82. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  83. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  84. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  85. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  86. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
  87. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  88. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
  89. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  90. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  91. package/dist/ProfileView/components/ViewSelector/index.js +186 -82
  92. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  93. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  94. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  95. package/dist/ProfileView/context/DashboardContext.js +74 -26
  96. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  97. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  98. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  99. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  100. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  101. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
  102. package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
  103. package/dist/ProfileView/index.js +383 -45
  104. package/dist/ProfileView/types/visualization.js +1 -13
  105. package/dist/ProfileView/utils/colorUtils.js +8 -7
  106. package/dist/ProfileViewWithData.js +319 -225
  107. package/dist/QueryControls/index.js +418 -47
  108. package/dist/Sandwich/components/CalleesSection.js +54 -4
  109. package/dist/Sandwich/components/CallersSection.js +97 -27
  110. package/dist/Sandwich/components/TableSection.js +77 -4
  111. package/dist/Sandwich/index.js +125 -12
  112. package/dist/Sandwich/utils/processRowData.js +48 -39
  113. package/dist/SelectWithRefresh/index.js +102 -28
  114. package/dist/SimpleMatchers/Select.js +520 -187
  115. package/dist/SimpleMatchers/index.js +590 -288
  116. package/dist/SourceView/Highlighter.js +230 -70
  117. package/dist/SourceView/LineNo.js +72 -17
  118. package/dist/SourceView/index.js +177 -101
  119. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  120. package/dist/SourceView/lang-detector/index.js +28 -14
  121. package/dist/SourceView/useSelectedLineRange.js +72 -20
  122. package/dist/Table/ColorCell.js +42 -1
  123. package/dist/Table/ColumnsVisibility.js +114 -6
  124. package/dist/Table/MoreDropdown.js +107 -21
  125. package/dist/Table/TableContextMenu.js +144 -134
  126. package/dist/Table/TableContextMenuWrapper.js +59 -14
  127. package/dist/Table/hooks/useColorManagement.js +58 -16
  128. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  129. package/dist/Table/hooks/useTableConfiguration.js +323 -167
  130. package/dist/Table/index.js +217 -123
  131. package/dist/Table/utils/functions.js +169 -144
  132. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  133. package/dist/TimelineGuide/index.js +209 -16
  134. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  135. package/dist/TopTable/index.js +325 -121
  136. package/dist/contexts/LabelsQueryProvider.js +94 -32
  137. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  138. package/dist/contexts/utils.js +37 -15
  139. package/dist/hooks/urlParsers.js +27 -15
  140. package/dist/hooks/useColorBy.js +47 -10
  141. package/dist/hooks/useCompareModeMeta.js +112 -62
  142. package/dist/hooks/useDashboardItems.js +52 -11
  143. package/dist/hooks/useLabels.js +295 -52
  144. package/dist/hooks/useQueryState.d.ts +1 -1
  145. package/dist/hooks/useQueryState.d.ts.map +1 -1
  146. package/dist/hooks/useQueryState.js +375 -329
  147. package/dist/index.js +11 -6
  148. package/dist/testdata/fg-diff.json +3750 -0
  149. package/dist/testdata/fg-simple.json +1879 -0
  150. package/dist/testdata/link_data.json +56 -0
  151. package/dist/testdata/tabular.json +30 -0
  152. package/dist/testdata/test_flamegraph.json +26846 -0
  153. package/dist/testdata/test_graph.json +53 -0
  154. package/dist/useDelayedLoader.js +32 -18
  155. package/dist/useGrpcQuery/index.js +71 -11
  156. package/dist/useHasProfileData.js +90 -12
  157. package/dist/useQuery.js +205 -64
  158. package/dist/useSumBy.d.ts.map +1 -1
  159. package/dist/useSumBy.js +294 -138
  160. package/dist/utils.js +62 -30
  161. package/package.json +9 -9
  162. package/src/GraphTooltipArrow/index.tsx +3 -0
  163. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  164. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  165. package/src/MatchersInput/index.tsx +1 -1
  166. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  167. package/src/PreSelectedMatchers/index.tsx +3 -0
  168. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
  169. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  170. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  171. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  172. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  173. package/src/ProfileSelector/index.tsx +31 -9
  174. package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
  175. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  176. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  177. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  178. package/src/hooks/useQueryState.ts +18 -3
  179. package/src/useDelayedLoader.ts +10 -10
  180. package/src/useSumBy.ts +12 -18
  181. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  182. package/dist/hooks/useQueryState.test.js +0 -868
@@ -0,0 +1,53 @@
1
+ {
2
+ "total": "4358676",
3
+ "unit": "count",
4
+ "height": 27,
5
+ "root": {
6
+ "id": "root",
7
+ "cumulative": "4358676",
8
+ "diff": "0",
9
+ "children": [
10
+ {
11
+ "id": "child_1",
12
+ "cumulative": "1",
13
+ "diff": "0",
14
+ "children": [
15
+ {
16
+ "id": "child_2",
17
+ "cumulative": "1",
18
+ "diff": "0",
19
+ "children": [
20
+ {
21
+ "id": "root",
22
+ "cumulative": "4358676",
23
+ "diff": "0",
24
+ "children": [
25
+ {
26
+ "id": "child_1",
27
+ "cumulative": "1",
28
+ "diff": "0",
29
+ "children": [
30
+ {
31
+ "id": "child_2",
32
+ "cumulative": "1",
33
+ "diff": "0",
34
+ "children": [
35
+ {
36
+ "id": "child_1",
37
+ "cumulative": "1",
38
+ "diff": "0",
39
+ "children": []
40
+ }
41
+ ]
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ ]
52
+ }
53
+ }
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
4
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
1
7
  // Copyright 2022 The Parca Authors
2
8
  // Licensed under the Apache License, Version 2.0 (the "License");
3
9
  // you may not use this file except in compliance with the License.
@@ -10,23 +16,31 @@
10
16
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
17
  // See the License for the specific language governing permissions and
12
18
  // limitations under the License.
19
+
13
20
  import { useEffect, useState } from 'react';
14
- const useDelayedLoader = (isLoading = false, options) => {
15
- const { delay = 500 } = options ?? {};
16
- const [isLoaderVisible, setIsLoaderVisible] = useState(false);
17
- useEffect(() => {
18
- let showLoaderTimeout;
19
- if (isLoading && !isLoaderVisible) {
20
- // if the request takes longer than half a second, show the loading icon
21
- showLoaderTimeout = setTimeout(() => {
22
- setIsLoaderVisible(true);
23
- }, delay);
24
- }
25
- else if (!isLoading && isLoaderVisible) {
26
- setIsLoaderVisible(false);
27
- }
28
- return () => clearTimeout(showLoaderTimeout);
29
- }, [isLoading, isLoaderVisible, delay]);
30
- return isLoaderVisible;
21
+ var useDelayedLoader = function useDelayedLoader() {
22
+ 'use no memo';
23
+
24
+ var isLoading = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
25
+ var options = arguments.length > 1 ? arguments[1] : undefined;
26
+ var _ref = options !== null && options !== void 0 ? options : {},
27
+ _ref$delay = _ref.delay,
28
+ delay = _ref$delay === void 0 ? 500 : _ref$delay;
29
+ var _useState = useState(false),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ isLoaderVisible = _useState2[0],
32
+ setIsLoaderVisible = _useState2[1];
33
+ useEffect(function () {
34
+ if (!isLoading) return;
35
+ // if the request takes longer than half a second, show the loading icon
36
+ var showLoaderTimeout = setTimeout(function () {
37
+ setIsLoaderVisible(true);
38
+ }, delay);
39
+ return function () {
40
+ clearTimeout(showLoaderTimeout);
41
+ setIsLoaderVisible(false);
42
+ };
43
+ }, [isLoading, delay]);
44
+ return isLoaderVisible;
31
45
  };
32
- export default useDelayedLoader;
46
+ export default useDelayedLoader;
@@ -1,3 +1,8 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ import { c as _c } from "react-compiler-runtime";
1
6
  // Copyright 2022 The Parca Authors
2
7
  // Licensed under the Apache License, Version 2.0 (the "License");
3
8
  // you may not use this file except in compliance with the License.
@@ -10,16 +15,71 @@
10
15
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
16
  // See the License for the specific language governing permissions and
12
17
  // limitations under the License.
18
+
13
19
  import { useQuery } from '@tanstack/react-query';
14
- const useGrpcQuery = ({ key, queryFn, options: { enabled = true, staleTime, retry, keepPreviousData, cacheTime } = {}, }) => {
15
- return useQuery(key, async ({ signal }) => {
16
- return await queryFn(signal);
17
- }, {
18
- enabled,
19
- staleTime,
20
- retry,
21
- keepPreviousData,
22
- cacheTime,
23
- });
20
+ var useGrpcQuery = function useGrpcQuery(t0) {
21
+ var $ = _c(10);
22
+ var key = t0.key,
23
+ queryFn = t0.queryFn,
24
+ t1 = t0.options;
25
+ var t2;
26
+ if ($[0] !== t1) {
27
+ t2 = t1 === undefined ? {} : t1;
28
+ $[0] = t1;
29
+ $[1] = t2;
30
+ } else {
31
+ t2 = $[1];
32
+ }
33
+ var _t = t2,
34
+ t3 = _t.enabled,
35
+ staleTime = _t.staleTime,
36
+ retry = _t.retry,
37
+ keepPreviousData = _t.keepPreviousData,
38
+ cacheTime = _t.cacheTime;
39
+ var enabled = t3 === undefined ? true : t3;
40
+ var t4;
41
+ if ($[2] !== queryFn) {
42
+ t4 = /*#__PURE__*/function () {
43
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(t5) {
44
+ var signal;
45
+ return _regenerator().w(function (_context) {
46
+ while (1) switch (_context.n) {
47
+ case 0:
48
+ signal = t5.signal;
49
+ _context.n = 1;
50
+ return queryFn(signal);
51
+ case 1:
52
+ return _context.a(2, _context.v);
53
+ }
54
+ }, _callee);
55
+ }));
56
+ return function t4(_x) {
57
+ return _ref.apply(this, arguments);
58
+ };
59
+ }();
60
+ $[2] = queryFn;
61
+ $[3] = t4;
62
+ } else {
63
+ t4 = $[3];
64
+ }
65
+ var t5;
66
+ if ($[4] !== cacheTime || $[5] !== enabled || $[6] !== keepPreviousData || $[7] !== retry || $[8] !== staleTime) {
67
+ t5 = {
68
+ enabled: enabled,
69
+ staleTime: staleTime,
70
+ retry: retry,
71
+ keepPreviousData: keepPreviousData,
72
+ cacheTime: cacheTime
73
+ };
74
+ $[4] = cacheTime;
75
+ $[5] = enabled;
76
+ $[6] = keepPreviousData;
77
+ $[7] = retry;
78
+ $[8] = staleTime;
79
+ $[9] = t5;
80
+ } else {
81
+ t5 = $[9];
82
+ }
83
+ return useQuery(key, t4, t5);
24
84
  };
25
- export default useGrpcQuery;
85
+ export default useGrpcQuery;
@@ -1,3 +1,8 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ import { c as _c } from "react-compiler-runtime";
1
6
  // Copyright 2022 The Parca Authors
2
7
  // Licensed under the Apache License, Version 2.0 (the "License");
3
8
  // you may not use this file except in compliance with the License.
@@ -10,18 +15,91 @@
10
15
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
16
  // See the License for the specific language governing permissions and
12
17
  // limitations under the License.
18
+
13
19
  import { useMemo } from 'react';
14
20
  import { useGrpcMetadata } from '@parca/components';
15
21
  import useGrpcQuery from './useGrpcQuery';
16
- export const useHasProfileData = (client) => {
17
- const metadata = useGrpcMetadata();
18
- const metadataString = useMemo(() => JSON.stringify(metadata), [metadata]);
19
- const { data, isLoading, error } = useGrpcQuery({
20
- key: ['hasProfileData', metadataString],
21
- queryFn: async (signal) => {
22
- const { response } = await client.hasProfileData({}, { abort: signal, meta: metadata });
23
- return response;
24
- },
25
- });
26
- return { loading: isLoading, data: data?.hasData ?? false, error };
27
- };
22
+ export var useHasProfileData = function useHasProfileData(client) {
23
+ var _data$hasData;
24
+ var $ = _c(14);
25
+ var metadata = useGrpcMetadata();
26
+ var t0;
27
+ if ($[0] !== metadata) {
28
+ t0 = JSON.stringify(metadata);
29
+ $[0] = metadata;
30
+ $[1] = t0;
31
+ } else {
32
+ t0 = $[1];
33
+ }
34
+ var metadataString = t0;
35
+ var t1;
36
+ if ($[2] !== metadataString) {
37
+ t1 = ["hasProfileData", metadataString];
38
+ $[2] = metadataString;
39
+ $[3] = t1;
40
+ } else {
41
+ t1 = $[3];
42
+ }
43
+ var t2;
44
+ if ($[4] !== client || $[5] !== metadata) {
45
+ t2 = /*#__PURE__*/function () {
46
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signal) {
47
+ var _yield$client$hasProf, response;
48
+ return _regenerator().w(function (_context) {
49
+ while (1) switch (_context.n) {
50
+ case 0:
51
+ _context.n = 1;
52
+ return client.hasProfileData({}, {
53
+ abort: signal,
54
+ meta: metadata
55
+ });
56
+ case 1:
57
+ _yield$client$hasProf = _context.v;
58
+ response = _yield$client$hasProf.response;
59
+ return _context.a(2, response);
60
+ }
61
+ }, _callee);
62
+ }));
63
+ return function t2(_x) {
64
+ return _ref.apply(this, arguments);
65
+ };
66
+ }();
67
+ $[4] = client;
68
+ $[5] = metadata;
69
+ $[6] = t2;
70
+ } else {
71
+ t2 = $[6];
72
+ }
73
+ var t3;
74
+ if ($[7] !== t1 || $[8] !== t2) {
75
+ t3 = {
76
+ key: t1,
77
+ queryFn: t2
78
+ };
79
+ $[7] = t1;
80
+ $[8] = t2;
81
+ $[9] = t3;
82
+ } else {
83
+ t3 = $[9];
84
+ }
85
+ var _useGrpcQuery = useGrpcQuery(t3),
86
+ data = _useGrpcQuery.data,
87
+ isLoading = _useGrpcQuery.isLoading,
88
+ error = _useGrpcQuery.error;
89
+ var t4 = (_data$hasData = data === null || data === void 0 ? void 0 : data.hasData) !== null && _data$hasData !== void 0 ? _data$hasData : false;
90
+ var t5;
91
+ if ($[10] !== error || $[11] !== isLoading || $[12] !== t4) {
92
+ t5 = {
93
+ loading: isLoading,
94
+ data: t4,
95
+ error: error
96
+ };
97
+ $[10] = error;
98
+ $[11] = isLoading;
99
+ $[12] = t4;
100
+ $[13] = t5;
101
+ } else {
102
+ t5 = $[13];
103
+ }
104
+ return t5;
105
+ };
package/dist/useQuery.js CHANGED
@@ -1,3 +1,8 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
2
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ import { c as _c } from "react-compiler-runtime";
1
6
  // Copyright 2022 The Parca Authors
2
7
  // Licensed under the Apache License, Version 2.0 (the "License");
3
8
  // you may not use this file except in compliance with the License.
@@ -10,75 +15,211 @@
10
15
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
16
  // See the License for the specific language governing permissions and
12
17
  // limitations under the License.
18
+
13
19
  import { useMemo } from 'react';
14
20
  import { useGrpcMetadata } from '@parca/components';
15
21
  import useGrpcQuery from './useGrpcQuery';
16
- export const useQuery = (client, profileSource, reportType, options) => {
17
- const { skip = false } = options ?? {};
18
- const metadata = useGrpcMetadata();
19
- const protoFiltersKey = useMemo(() => {
20
- return JSON.stringify(options?.protoFilters ?? []);
21
- }, [options?.protoFilters]);
22
- const { data, isLoading, error, refetch } = useGrpcQuery({
23
- key: [
24
- 'query',
25
- profileSource.toKey(),
26
- reportType,
27
- options?.nodeTrimThreshold,
28
- options?.groupBy,
29
- options?.sourceBuildID,
30
- options?.sourceOnly,
31
- options?.sourceOnly === true ? '' : options?.sourceFilename,
32
- options?.invertCallStack ?? false,
33
- options?.sandwichByFunction ?? '',
34
- protoFiltersKey,
35
- ],
36
- queryFn: async (signal) => {
37
- const req = profileSource.QueryRequest();
38
- req.reportType = reportType;
39
- req.nodeTrimThreshold = options?.nodeTrimThreshold;
40
- req.groupBy = {
41
- fields: options?.groupBy ?? [],
42
- };
43
- if (options?.sourceBuildID !== undefined && options?.sourceFilename !== undefined) {
22
+ export var useQuery = function useQuery(client, profileSource, reportType, options) {
23
+ var _options$invertCallSt, _options$sandwichByFu, _options$staleTime;
24
+ var $ = _c(37);
25
+ var t0;
26
+ if ($[0] !== options) {
27
+ t0 = options !== null && options !== void 0 ? options : {};
28
+ $[0] = options;
29
+ $[1] = t0;
30
+ } else {
31
+ t0 = $[1];
32
+ }
33
+ var _t = t0,
34
+ t1 = _t.skip;
35
+ var skip = t1 === undefined ? false : t1;
36
+ var metadata = useGrpcMetadata();
37
+ options === null || options === void 0 || options.protoFilters;
38
+ var t2;
39
+ if ($[2] !== (options === null || options === void 0 ? void 0 : options.protoFilters)) {
40
+ var _options$protoFilters;
41
+ t2 = JSON.stringify((_options$protoFilters = options === null || options === void 0 ? void 0 : options.protoFilters) !== null && _options$protoFilters !== void 0 ? _options$protoFilters : []);
42
+ $[2] = options === null || options === void 0 ? void 0 : options.protoFilters;
43
+ $[3] = t2;
44
+ } else {
45
+ t2 = $[3];
46
+ }
47
+ var protoFiltersKey = t2;
48
+ var t3;
49
+ if ($[4] !== profileSource) {
50
+ t3 = profileSource.toKey();
51
+ $[4] = profileSource;
52
+ $[5] = t3;
53
+ } else {
54
+ t3 = $[5];
55
+ }
56
+ var t4 = options === null || options === void 0 ? void 0 : options.nodeTrimThreshold;
57
+ var t5 = options === null || options === void 0 ? void 0 : options.groupBy;
58
+ var t6 = options === null || options === void 0 ? void 0 : options.sourceBuildID;
59
+ var t7 = options === null || options === void 0 ? void 0 : options.sourceOnly;
60
+ var t8 = (options === null || options === void 0 ? void 0 : options.sourceOnly) === true ? "" : options === null || options === void 0 ? void 0 : options.sourceFilename;
61
+ var t9 = (_options$invertCallSt = options === null || options === void 0 ? void 0 : options.invertCallStack) !== null && _options$invertCallSt !== void 0 ? _options$invertCallSt : false;
62
+ var t10 = (_options$sandwichByFu = options === null || options === void 0 ? void 0 : options.sandwichByFunction) !== null && _options$sandwichByFu !== void 0 ? _options$sandwichByFu : "";
63
+ var t11;
64
+ if ($[6] !== protoFiltersKey || $[7] !== reportType || $[8] !== t10 || $[9] !== t3 || $[10] !== t4 || $[11] !== t5 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8 || $[15] !== t9) {
65
+ t11 = ["query", t3, reportType, t4, t5, t6, t7, t8, t9, t10, protoFiltersKey];
66
+ $[6] = protoFiltersKey;
67
+ $[7] = reportType;
68
+ $[8] = t10;
69
+ $[9] = t3;
70
+ $[10] = t4;
71
+ $[11] = t5;
72
+ $[12] = t6;
73
+ $[13] = t7;
74
+ $[14] = t8;
75
+ $[15] = t9;
76
+ $[16] = t11;
77
+ } else {
78
+ t11 = $[16];
79
+ }
80
+ var t12;
81
+ if ($[17] !== client || $[18] !== metadata || $[19] !== options || $[20] !== profileSource || $[21] !== reportType) {
82
+ t12 = /*#__PURE__*/function () {
83
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signal) {
84
+ var _options$groupBy, _options$invertCallSt2, _options$protoFilters2;
85
+ var req, _options$sourceBuildI, _options$sourceFilena, _options$sourceOnly, _yield$client$query, response, e, _t2;
86
+ return _regenerator().w(function (_context) {
87
+ while (1) switch (_context.p = _context.n) {
88
+ case 0:
89
+ req = profileSource.QueryRequest();
90
+ req.reportType = reportType;
91
+ req.nodeTrimThreshold = options === null || options === void 0 ? void 0 : options.nodeTrimThreshold;
92
+ req.groupBy = {
93
+ fields: (_options$groupBy = options === null || options === void 0 ? void 0 : options.groupBy) !== null && _options$groupBy !== void 0 ? _options$groupBy : []
94
+ };
95
+ if ((options === null || options === void 0 ? void 0 : options.sourceBuildID) !== undefined && (options === null || options === void 0 ? void 0 : options.sourceFilename) !== undefined) {
44
96
  req.sourceReference = {
45
- buildId: options?.sourceBuildID ?? '',
46
- filename: options?.sourceFilename ?? '',
47
- sourceOnly: options?.sourceOnly ?? false,
97
+ buildId: (_options$sourceBuildI = options === null || options === void 0 ? void 0 : options.sourceBuildID) !== null && _options$sourceBuildI !== void 0 ? _options$sourceBuildI : "",
98
+ filename: (_options$sourceFilena = options === null || options === void 0 ? void 0 : options.sourceFilename) !== null && _options$sourceFilena !== void 0 ? _options$sourceFilena : "",
99
+ sourceOnly: (_options$sourceOnly = options === null || options === void 0 ? void 0 : options.sourceOnly) !== null && _options$sourceOnly !== void 0 ? _options$sourceOnly : false
48
100
  };
49
- }
50
- req.invertCallStack = options?.invertCallStack ?? false;
51
- if (options?.protoFilters != null && options?.protoFilters?.length > 0) {
101
+ }
102
+ req.invertCallStack = (_options$invertCallSt2 = options === null || options === void 0 ? void 0 : options.invertCallStack) !== null && _options$invertCallSt2 !== void 0 ? _options$invertCallSt2 : false;
103
+ if ((options === null || options === void 0 ? void 0 : options.protoFilters) != null && (options === null || options === void 0 || (_options$protoFilters2 = options.protoFilters) === null || _options$protoFilters2 === void 0 ? void 0 : _options$protoFilters2.length) > 0) {
52
104
  req.filter = options.protoFilters;
53
- }
54
- // Handle sandwich view filter separately
55
- if (options?.sandwichByFunction !== undefined) {
105
+ }
106
+ if ((options === null || options === void 0 ? void 0 : options.sandwichByFunction) !== undefined) {
56
107
  req.sandwichByFunction = options.sandwichByFunction;
57
- }
58
- try {
59
- const { response } = await client.query(req, { meta: metadata, abort: signal });
60
- return response;
61
- }
62
- catch (e) {
63
- if (options?.sourceOnly === true) {
64
- // ignore
65
- return {};
66
- }
67
- throw e;
68
- }
69
- },
70
- options: {
71
- retry: false,
72
- enabled: !skip,
73
- staleTime: options?.staleTime ?? 1000 * 60 * 5, // 5 minutes
74
- },
75
- });
76
- return {
77
- isLoading,
78
- error: error,
79
- response: data ?? null,
80
- refetch: async () => {
81
- await refetch();
82
- },
108
+ }
109
+ ;
110
+ _context.p = 1;
111
+ _context.n = 2;
112
+ return client.query(req, {
113
+ meta: metadata,
114
+ abort: signal
115
+ });
116
+ case 2:
117
+ _yield$client$query = _context.v;
118
+ response = _yield$client$query.response;
119
+ return _context.a(2, response);
120
+ case 3:
121
+ _context.p = 3;
122
+ _t2 = _context.v;
123
+ e = _t2;
124
+ if (!((options === null || options === void 0 ? void 0 : options.sourceOnly) === true)) {
125
+ _context.n = 4;
126
+ break;
127
+ }
128
+ return _context.a(2, {});
129
+ case 4:
130
+ throw e;
131
+ case 5:
132
+ return _context.a(2);
133
+ }
134
+ }, _callee, null, [[1, 3]]);
135
+ }));
136
+ return function t12(_x) {
137
+ return _ref.apply(this, arguments);
138
+ };
139
+ }();
140
+ $[17] = client;
141
+ $[18] = metadata;
142
+ $[19] = options;
143
+ $[20] = profileSource;
144
+ $[21] = reportType;
145
+ $[22] = t12;
146
+ } else {
147
+ t12 = $[22];
148
+ }
149
+ var t13 = !skip;
150
+ var t14 = (_options$staleTime = options === null || options === void 0 ? void 0 : options.staleTime) !== null && _options$staleTime !== void 0 ? _options$staleTime : 300000;
151
+ var t15;
152
+ if ($[23] !== t13 || $[24] !== t14) {
153
+ t15 = {
154
+ retry: false,
155
+ enabled: t13,
156
+ staleTime: t14
83
157
  };
84
- };
158
+ $[23] = t13;
159
+ $[24] = t14;
160
+ $[25] = t15;
161
+ } else {
162
+ t15 = $[25];
163
+ }
164
+ var t16;
165
+ if ($[26] !== t11 || $[27] !== t12 || $[28] !== t15) {
166
+ t16 = {
167
+ key: t11,
168
+ queryFn: t12,
169
+ options: t15
170
+ };
171
+ $[26] = t11;
172
+ $[27] = t12;
173
+ $[28] = t15;
174
+ $[29] = t16;
175
+ } else {
176
+ t16 = $[29];
177
+ }
178
+ var _useGrpcQuery = useGrpcQuery(t16),
179
+ data = _useGrpcQuery.data,
180
+ isLoading = _useGrpcQuery.isLoading,
181
+ error = _useGrpcQuery.error,
182
+ refetch = _useGrpcQuery.refetch;
183
+ var t17 = error;
184
+ var t18 = data !== null && data !== void 0 ? data : null;
185
+ var t19;
186
+ if ($[30] !== refetch) {
187
+ t19 = /*#__PURE__*/function () {
188
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
189
+ return _regenerator().w(function (_context2) {
190
+ while (1) switch (_context2.n) {
191
+ case 0:
192
+ _context2.n = 1;
193
+ return refetch();
194
+ case 1:
195
+ return _context2.a(2);
196
+ }
197
+ }, _callee2);
198
+ }));
199
+ return function t19() {
200
+ return _ref2.apply(this, arguments);
201
+ };
202
+ }();
203
+ $[30] = refetch;
204
+ $[31] = t19;
205
+ } else {
206
+ t19 = $[31];
207
+ }
208
+ var t20;
209
+ if ($[32] !== isLoading || $[33] !== t17 || $[34] !== t18 || $[35] !== t19) {
210
+ t20 = {
211
+ isLoading: isLoading,
212
+ error: t17,
213
+ response: t18,
214
+ refetch: t19
215
+ };
216
+ $[32] = isLoading;
217
+ $[33] = t17;
218
+ $[34] = t18;
219
+ $[35] = t19;
220
+ $[36] = t20;
221
+ } else {
222
+ t20 = $[36];
223
+ }
224
+ return t20;
225
+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