@perses-dev/plugin-system 0.53.0-rc.1 → 0.53.0-rc.3

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 (349) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/CalculationSelector/index.js +1 -1
  3. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -1
  4. package/dist/cjs/components/DatasourceEditorForm/index.js +1 -1
  5. package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +1 -1
  6. package/dist/cjs/components/DatasourceSelect/index.js +1 -1
  7. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  8. package/dist/cjs/components/HTTPSettingsEditor/index.js +1 -1
  9. package/dist/cjs/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1175 -0
  10. package/dist/cjs/components/ItemSelectionActionsOptionsEditor/index.js +30 -0
  11. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  12. package/dist/cjs/components/LegendOptionsEditor/index.js +1 -1
  13. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +1 -1
  14. package/dist/cjs/components/MetricLabelInput/index.js +1 -1
  15. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  16. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  17. package/dist/cjs/components/MultiQueryEditor/index.js +1 -1
  18. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
  19. package/dist/cjs/components/OptionsEditorRadios/index.js +1 -1
  20. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  21. package/dist/cjs/components/OptionsEditorTabPanel/index.js +1 -1
  22. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  23. package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
  24. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +1 -1
  25. package/dist/cjs/components/PanelSpecEditor/index.js +1 -1
  26. package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
  27. package/dist/cjs/components/PluginEditor/index.js +1 -1
  28. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
  29. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +1 -1
  30. package/dist/cjs/components/PluginKindSelect/index.js +1 -1
  31. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  32. package/dist/cjs/components/PluginRegistry/index.js +1 -1
  33. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
  34. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  35. package/dist/cjs/components/PluginSpecEditor/index.js +1 -1
  36. package/dist/cjs/components/SelectionOptionsEditor/SelectionOptionsEditor.js +43 -0
  37. package/dist/cjs/components/SelectionOptionsEditor/index.js +30 -0
  38. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +11 -3
  39. package/dist/cjs/components/TimeRangeControls/index.js +1 -1
  40. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +1 -1
  41. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  42. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -1
  43. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  44. package/dist/cjs/components/Variables/index.js +1 -1
  45. package/dist/cjs/components/Variables/variable-model.js +1 -1
  46. package/dist/cjs/components/index.js +2 -1
  47. package/dist/cjs/constants/index.js +1 -1
  48. package/dist/cjs/constants/user-interface-text.js +1 -1
  49. package/dist/cjs/context/ValidationProvider.js +1 -1
  50. package/dist/cjs/context/index.js +1 -1
  51. package/dist/cjs/index.js +1 -1
  52. package/dist/cjs/model/datasource.js +1 -1
  53. package/dist/cjs/model/explore.js +1 -1
  54. package/dist/cjs/model/index.js +1 -1
  55. package/dist/cjs/model/legend.js +1 -1
  56. package/dist/cjs/model/log-queries.js +1 -1
  57. package/dist/cjs/model/panels.js +1 -1
  58. package/dist/cjs/model/plugin-base.js +1 -1
  59. package/dist/cjs/model/plugin-loading.js +1 -1
  60. package/dist/cjs/model/plugins.js +1 -1
  61. package/dist/cjs/model/profile-queries.js +1 -1
  62. package/dist/cjs/model/time-series-queries.js +1 -1
  63. package/dist/cjs/model/trace-queries.js +1 -1
  64. package/dist/cjs/model/variables.js +1 -1
  65. package/dist/cjs/remote/PersesPlugin.types.js +1 -1
  66. package/dist/cjs/remote/PluginLoaderComponent.js +13 -1
  67. package/dist/cjs/remote/PluginRuntime.js +13 -1
  68. package/dist/cjs/remote/index.js +1 -1
  69. package/dist/cjs/remote/remotePluginLoader.js +1 -1
  70. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +1 -1
  71. package/dist/cjs/runtime/DataQueriesProvider/index.js +1 -1
  72. package/dist/cjs/runtime/DataQueriesProvider/model.js +1 -1
  73. package/dist/cjs/runtime/QueryCountProvider.js +1 -1
  74. package/dist/cjs/runtime/RouterProvider.js +1 -1
  75. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  76. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +7 -2
  77. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
  78. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  79. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +28 -1
  80. package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +1 -1
  81. package/dist/cjs/runtime/UsageMetricsProvider.js +1 -1
  82. package/dist/cjs/runtime/builtin-variables.js +1 -1
  83. package/dist/cjs/runtime/datasources.js +1 -1
  84. package/dist/cjs/runtime/index.js +2 -1
  85. package/dist/cjs/runtime/item-actions.js +303 -0
  86. package/dist/cjs/runtime/log-queries.js +1 -1
  87. package/dist/cjs/runtime/plugin-registry.js +1 -1
  88. package/dist/cjs/runtime/profile-queries.js +1 -1
  89. package/dist/cjs/runtime/time-series-queries.js +1 -1
  90. package/dist/cjs/runtime/trace-queries.js +1 -1
  91. package/dist/cjs/runtime/utils.js +1 -1
  92. package/dist/cjs/runtime/variables.js +6 -6
  93. package/dist/cjs/test/index.js +1 -1
  94. package/dist/cjs/test/mock-data.js +1 -1
  95. package/dist/cjs/test/render-hook.js +1 -1
  96. package/dist/cjs/test/render.js +1 -1
  97. package/dist/cjs/test/setup-tests.js +1 -1
  98. package/dist/cjs/test/test-plugins/bert/index.js +1 -1
  99. package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
  100. package/dist/cjs/test/test-plugins/index.js +1 -1
  101. package/dist/cjs/test/utils.js +1 -1
  102. package/dist/cjs/test-utils/index.js +1 -1
  103. package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
  104. package/dist/cjs/utils/action.js +1 -1
  105. package/dist/cjs/utils/event.js +1 -1
  106. package/dist/cjs/utils/index.js +1 -1
  107. package/dist/cjs/utils/variables.js +9 -146
  108. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  109. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  110. package/dist/components/CalculationSelector/index.js +1 -1
  111. package/dist/components/CalculationSelector/index.js.map +1 -1
  112. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -1
  113. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  114. package/dist/components/DatasourceEditorForm/index.js +1 -1
  115. package/dist/components/DatasourceEditorForm/index.js.map +1 -1
  116. package/dist/components/DatasourceSelect/DatasourceSelect.js +1 -1
  117. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
  118. package/dist/components/DatasourceSelect/index.js +1 -1
  119. package/dist/components/DatasourceSelect/index.js.map +1 -1
  120. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  121. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  122. package/dist/components/HTTPSettingsEditor/index.js +1 -1
  123. package/dist/components/HTTPSettingsEditor/index.js.map +1 -1
  124. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts +49 -0
  125. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.d.ts.map +1 -0
  126. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1154 -0
  127. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -0
  128. package/dist/components/ItemSelectionActionsOptionsEditor/index.d.ts +2 -0
  129. package/dist/components/ItemSelectionActionsOptionsEditor/index.d.ts.map +1 -0
  130. package/dist/components/ItemSelectionActionsOptionsEditor/index.js +15 -0
  131. package/dist/components/ItemSelectionActionsOptionsEditor/index.js.map +1 -0
  132. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  133. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  134. package/dist/components/LegendOptionsEditor/index.js +1 -1
  135. package/dist/components/LegendOptionsEditor/index.js.map +1 -1
  136. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  137. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  138. package/dist/components/MetricLabelInput/index.js +1 -1
  139. package/dist/components/MetricLabelInput/index.js.map +1 -1
  140. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  141. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  142. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  143. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  144. package/dist/components/MultiQueryEditor/index.js +1 -1
  145. package/dist/components/MultiQueryEditor/index.js.map +1 -1
  146. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
  147. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  148. package/dist/components/OptionsEditorRadios/index.js +1 -1
  149. package/dist/components/OptionsEditorRadios/index.js.map +1 -1
  150. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  151. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  152. package/dist/components/OptionsEditorTabPanel/index.js +1 -1
  153. package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
  154. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  155. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  156. package/dist/components/OptionsEditorTabs/index.js +1 -1
  157. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  158. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +1 -1
  159. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  160. package/dist/components/PanelSpecEditor/index.js +1 -1
  161. package/dist/components/PanelSpecEditor/index.js.map +1 -1
  162. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  163. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  164. package/dist/components/PluginEditor/index.js +1 -1
  165. package/dist/components/PluginEditor/index.js.map +1 -1
  166. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  167. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  168. package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
  169. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  170. package/dist/components/PluginKindSelect/index.js +1 -1
  171. package/dist/components/PluginKindSelect/index.js.map +1 -1
  172. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  173. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  174. package/dist/components/PluginRegistry/index.js +1 -1
  175. package/dist/components/PluginRegistry/index.js.map +1 -1
  176. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  177. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  178. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  179. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  180. package/dist/components/PluginSpecEditor/index.js +1 -1
  181. package/dist/components/PluginSpecEditor/index.js.map +1 -1
  182. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts +10 -0
  183. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.d.ts.map +1 -0
  184. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +35 -0
  185. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -0
  186. package/dist/components/SelectionOptionsEditor/index.d.ts +2 -0
  187. package/dist/components/SelectionOptionsEditor/index.d.ts.map +1 -0
  188. package/dist/components/SelectionOptionsEditor/index.js +15 -0
  189. package/dist/components/SelectionOptionsEditor/index.js.map +1 -0
  190. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +4 -2
  191. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  192. package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -4
  193. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  194. package/dist/components/TimeRangeControls/index.js +1 -1
  195. package/dist/components/TimeRangeControls/index.js.map +1 -1
  196. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +1 -1
  197. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  198. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  199. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  200. package/dist/components/Variables/VariableEditorForm/index.js +1 -1
  201. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  202. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  203. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  204. package/dist/components/Variables/index.js +1 -1
  205. package/dist/components/Variables/index.js.map +1 -1
  206. package/dist/components/Variables/variable-model.js +1 -1
  207. package/dist/components/Variables/variable-model.js.map +1 -1
  208. package/dist/components/index.d.ts +1 -0
  209. package/dist/components/index.d.ts.map +1 -1
  210. package/dist/components/index.js +2 -1
  211. package/dist/components/index.js.map +1 -1
  212. package/dist/constants/index.js +1 -1
  213. package/dist/constants/index.js.map +1 -1
  214. package/dist/constants/user-interface-text.js +1 -1
  215. package/dist/constants/user-interface-text.js.map +1 -1
  216. package/dist/context/ValidationProvider.js +1 -1
  217. package/dist/context/ValidationProvider.js.map +1 -1
  218. package/dist/context/index.js +1 -1
  219. package/dist/context/index.js.map +1 -1
  220. package/dist/index.js +1 -1
  221. package/dist/index.js.map +1 -1
  222. package/dist/model/datasource.js +1 -1
  223. package/dist/model/datasource.js.map +1 -1
  224. package/dist/model/explore.js +1 -1
  225. package/dist/model/explore.js.map +1 -1
  226. package/dist/model/index.js +1 -1
  227. package/dist/model/index.js.map +1 -1
  228. package/dist/model/legend.js +1 -1
  229. package/dist/model/legend.js.map +1 -1
  230. package/dist/model/log-queries.js +1 -1
  231. package/dist/model/log-queries.js.map +1 -1
  232. package/dist/model/panels.js +1 -1
  233. package/dist/model/panels.js.map +1 -1
  234. package/dist/model/plugin-base.js +1 -1
  235. package/dist/model/plugin-base.js.map +1 -1
  236. package/dist/model/plugin-loading.js +1 -1
  237. package/dist/model/plugin-loading.js.map +1 -1
  238. package/dist/model/plugins.js +1 -1
  239. package/dist/model/plugins.js.map +1 -1
  240. package/dist/model/profile-queries.js +1 -1
  241. package/dist/model/profile-queries.js.map +1 -1
  242. package/dist/model/time-series-queries.js +1 -1
  243. package/dist/model/time-series-queries.js.map +1 -1
  244. package/dist/model/trace-queries.js +1 -1
  245. package/dist/model/trace-queries.js.map +1 -1
  246. package/dist/model/variables.d.ts +4 -7
  247. package/dist/model/variables.d.ts.map +1 -1
  248. package/dist/model/variables.js +1 -1
  249. package/dist/model/variables.js.map +1 -1
  250. package/dist/remote/PersesPlugin.types.js +1 -1
  251. package/dist/remote/PersesPlugin.types.js.map +1 -1
  252. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
  253. package/dist/remote/PluginLoaderComponent.js +13 -1
  254. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  255. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  256. package/dist/remote/PluginRuntime.js +13 -1
  257. package/dist/remote/PluginRuntime.js.map +1 -1
  258. package/dist/remote/index.js +1 -1
  259. package/dist/remote/index.js.map +1 -1
  260. package/dist/remote/remotePluginLoader.js +1 -1
  261. package/dist/remote/remotePluginLoader.js.map +1 -1
  262. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +1 -1
  263. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  264. package/dist/runtime/DataQueriesProvider/index.js +1 -1
  265. package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
  266. package/dist/runtime/DataQueriesProvider/model.js +1 -1
  267. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  268. package/dist/runtime/QueryCountProvider.js +1 -1
  269. package/dist/runtime/QueryCountProvider.js.map +1 -1
  270. package/dist/runtime/RouterProvider.js +1 -1
  271. package/dist/runtime/RouterProvider.js.map +1 -1
  272. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  273. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  274. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
  275. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +8 -3
  276. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
  277. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
  278. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
  279. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  280. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  281. package/dist/runtime/TimeRangeProvider/query-params.d.ts +11 -0
  282. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  283. package/dist/runtime/TimeRangeProvider/query-params.js +26 -2
  284. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  285. package/dist/runtime/TimeRangeProvider/refresh-interval.js +1 -1
  286. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
  287. package/dist/runtime/UsageMetricsProvider.js +1 -1
  288. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  289. package/dist/runtime/builtin-variables.js +1 -1
  290. package/dist/runtime/builtin-variables.js.map +1 -1
  291. package/dist/runtime/datasources.js +1 -1
  292. package/dist/runtime/datasources.js.map +1 -1
  293. package/dist/runtime/index.d.ts +1 -0
  294. package/dist/runtime/index.d.ts.map +1 -1
  295. package/dist/runtime/index.js +2 -1
  296. package/dist/runtime/index.js.map +1 -1
  297. package/dist/runtime/item-actions.d.ts +35 -0
  298. package/dist/runtime/item-actions.d.ts.map +1 -0
  299. package/dist/runtime/item-actions.js +300 -0
  300. package/dist/runtime/item-actions.js.map +1 -0
  301. package/dist/runtime/log-queries.js +1 -1
  302. package/dist/runtime/log-queries.js.map +1 -1
  303. package/dist/runtime/plugin-registry.js +1 -1
  304. package/dist/runtime/plugin-registry.js.map +1 -1
  305. package/dist/runtime/profile-queries.js +1 -1
  306. package/dist/runtime/profile-queries.js.map +1 -1
  307. package/dist/runtime/time-series-queries.js +1 -1
  308. package/dist/runtime/time-series-queries.js.map +1 -1
  309. package/dist/runtime/trace-queries.js +1 -1
  310. package/dist/runtime/trace-queries.js.map +1 -1
  311. package/dist/runtime/utils.js +1 -1
  312. package/dist/runtime/utils.js.map +1 -1
  313. package/dist/runtime/variables.d.ts +2 -18
  314. package/dist/runtime/variables.d.ts.map +1 -1
  315. package/dist/runtime/variables.js +3 -3
  316. package/dist/runtime/variables.js.map +1 -1
  317. package/dist/test/index.js +1 -1
  318. package/dist/test/index.js.map +1 -1
  319. package/dist/test/mock-data.js +1 -1
  320. package/dist/test/mock-data.js.map +1 -1
  321. package/dist/test/render-hook.js +1 -1
  322. package/dist/test/render-hook.js.map +1 -1
  323. package/dist/test/render.js +1 -1
  324. package/dist/test/render.js.map +1 -1
  325. package/dist/test/setup-tests.js +1 -1
  326. package/dist/test/setup-tests.js.map +1 -1
  327. package/dist/test/test-plugins/bert/index.js +1 -1
  328. package/dist/test/test-plugins/bert/index.js.map +1 -1
  329. package/dist/test/test-plugins/ernie/index.js +1 -1
  330. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  331. package/dist/test/test-plugins/index.js +1 -1
  332. package/dist/test/test-plugins/index.js.map +1 -1
  333. package/dist/test/utils.js +1 -1
  334. package/dist/test/utils.js.map +1 -1
  335. package/dist/test-utils/index.js +1 -1
  336. package/dist/test-utils/index.js.map +1 -1
  337. package/dist/test-utils/mock-plugin-registry.js +1 -1
  338. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  339. package/dist/utils/action.js +1 -1
  340. package/dist/utils/action.js.map +1 -1
  341. package/dist/utils/event.js +1 -1
  342. package/dist/utils/event.js.map +1 -1
  343. package/dist/utils/index.js +1 -1
  344. package/dist/utils/index.js.map +1 -1
  345. package/dist/utils/variables.d.ts +2 -30
  346. package/dist/utils/variables.d.ts.map +1 -1
  347. package/dist/utils/variables.js +3 -144
  348. package/dist/utils/variables.js.map +1 -1
  349. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\ntype RemotePluginLoaderOptions = {\n /**\n * The API path for fetching available Perses plugins. Used to construct the full URL to the `/api/v1/plugins` endpoint.\n * @default ''\n **/\n apiPrefix?: string;\n /**\n * The base URL for loading plugin assets (e.g., JavaScript files). Used to construct the full URL to the `/plugins` directory\n * @default ''\n **/\n baseURL?: string;\n};\n\ntype ParsedPluginOptions = {\n pluginsApiPath: string;\n pluginsAssetsPath: string;\n};\n\nconst DEFAULT_PLUGINS_API_PATH = '/api/v1/plugins';\nconst DEFAULT_PLUGINS_ASSETS_PATH = '/plugins';\n\nconst paramToOptions = (options?: RemotePluginLoaderOptions): ParsedPluginOptions => {\n if (options === undefined) {\n return {\n pluginsApiPath: DEFAULT_PLUGINS_API_PATH,\n pluginsAssetsPath: DEFAULT_PLUGINS_ASSETS_PATH,\n };\n }\n\n return {\n pluginsApiPath: `${options?.apiPrefix ?? ''}${DEFAULT_PLUGINS_API_PATH}`,\n pluginsAssetsPath: `${options?.baseURL ?? ''}${DEFAULT_PLUGINS_ASSETS_PATH}`,\n };\n};\n\n/**\n * Get a PluginLoader that fetches the list of installed plugins from a remote server and loads them as needed.\n * @param options - Optional configuration options for the remote plugin loader.\n */\nexport function remotePluginLoader(options?: RemotePluginLoaderOptions): PluginLoader {\n const { pluginsApiPath, pluginsAssetsPath } = paramToOptions(options);\n\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(pluginsApiPath);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name, pluginsAssetsPath);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n}\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","DEFAULT_PLUGINS_API_PATH","DEFAULT_PLUGINS_ASSETS_PATH","paramToOptions","options","undefined","pluginsApiPath","pluginsAssetsPath","apiPrefix","baseURL","remotePluginLoader","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OACE,OAAOA,WAAW,YAClBA,WAAW,QACX,UAAUA,UACV,UAAUA,UACV,OAAOA,OAAOC,IAAI,KAAK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AS3B,IAAI,CAACK,OAAO,CAAE;gBAC1C,MAAM0B,qBAAqB,MAAMlC,WAAW+B,kBAAkB7B,OAAOC,IAAI,CAAC8B,IAAI,EAAEjB;gBAEhF,MAAMmB,eAAeD,oBAAoB,CAAChC,OAAOC,IAAI,CAAC8B,IAAI,CAAC;gBAC3D,IAAIE,cAAc;oBAChB9B,YAAY,CAACH,OAAOC,IAAI,CAAC8B,IAAI,CAAC,GAAGE;gBACnC,OAAO;oBACLT,QAAQC,KAAK,CAAC,CAAC,yCAAyC,EAAEzB,OAAOC,IAAI,CAAC8B,IAAI,EAAE;gBAC9E;YACF;YAEA,OAAO5B;QACT;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\ntype RemotePluginLoaderOptions = {\n /**\n * The API path for fetching available Perses plugins. Used to construct the full URL to the `/api/v1/plugins` endpoint.\n * @default ''\n **/\n apiPrefix?: string;\n /**\n * The base URL for loading plugin assets (e.g., JavaScript files). Used to construct the full URL to the `/plugins` directory\n * @default ''\n **/\n baseURL?: string;\n};\n\ntype ParsedPluginOptions = {\n pluginsApiPath: string;\n pluginsAssetsPath: string;\n};\n\nconst DEFAULT_PLUGINS_API_PATH = '/api/v1/plugins';\nconst DEFAULT_PLUGINS_ASSETS_PATH = '/plugins';\n\nconst paramToOptions = (options?: RemotePluginLoaderOptions): ParsedPluginOptions => {\n if (options === undefined) {\n return {\n pluginsApiPath: DEFAULT_PLUGINS_API_PATH,\n pluginsAssetsPath: DEFAULT_PLUGINS_ASSETS_PATH,\n };\n }\n\n return {\n pluginsApiPath: `${options?.apiPrefix ?? ''}${DEFAULT_PLUGINS_API_PATH}`,\n pluginsAssetsPath: `${options?.baseURL ?? ''}${DEFAULT_PLUGINS_ASSETS_PATH}`,\n };\n};\n\n/**\n * Get a PluginLoader that fetches the list of installed plugins from a remote server and loads them as needed.\n * @param options - Optional configuration options for the remote plugin loader.\n */\nexport function remotePluginLoader(options?: RemotePluginLoaderOptions): PluginLoader {\n const { pluginsApiPath, pluginsAssetsPath } = paramToOptions(options);\n\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(pluginsApiPath);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name, pluginsAssetsPath);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n}\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","DEFAULT_PLUGINS_API_PATH","DEFAULT_PLUGINS_ASSETS_PATH","paramToOptions","options","undefined","pluginsApiPath","pluginsAssetsPath","apiPrefix","baseURL","remotePluginLoader","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OACE,OAAOA,WAAW,YAClBA,WAAW,QACX,UAAUA,UACV,UAAUA,UACV,OAAOA,OAAOC,IAAI,KAAK,YACvBD,OAAOC,IAAI,KAAK,QAChB,UAAUD,OAAOC,IAAI;AAEzB;AAEA,MAAMC,yBAAyB,CAACC;IAC9B,OACE,OAAOA,iBAAiB,YACxBA,iBAAiB,QACjB,cAAcA,gBACd,UAAUA,gBACV,OAAOA,aAAaF,IAAI,KAAK,YAC7BE,aAAaF,IAAI,KAAK,QACtB,aAAaE,aAAaF,IAAI,IAC9BG,MAAMC,OAAO,CAACF,aAAaF,IAAI,CAACK,OAAO,KACvCH,aAAaF,IAAI,CAACK,OAAO,CAACC,KAAK,CAACR;AA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,CAAC8B,IAAI,EAAE;gBAC9E;YACF;YAEA,OAAO5B;QACT;IACF;AACF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\nimport { useProfileQueries, ProfileQueryDefinition } from '../profile-queries';\n\nimport { useUsageMetrics } from '../UsageMetricsProvider';\nimport { LogQueryDefinition, useLogQueries } from '../log-queries';\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext(): DataQueriesContextType {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps): ReactElement {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n const usageMetrics = useUsageMetrics();\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n\n const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n\n const profileQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'ProfileQuery'\n ) as ProfileQueryDefinition[];\n const profileResults = useProfileQueries(profileQueries);\n\n const logQueries = queryDefinitions.filter((definition) => definition.kind === 'LogQuery') as LogQueryDefinition[];\n const logResults = useLogQueries(logQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n profileResults.forEach((result) => result.refetch());\n logResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults, profileResults, logResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ...transformQueryResults(profileResults, profileQueries),\n ...transformQueryResults(logResults, logQueries),\n ];\n\n if (queryOptions?.enabled) {\n for (const result of mergedQueryResults) {\n if (!result.isLoading && !result.isFetching && !result.error) {\n usageMetrics.markQuery(result.definition, 'success');\n } else if (result.error) {\n usageMetrics.markQuery(result.definition, 'error');\n } else {\n usageMetrics.markQuery(result.definition, 'pending');\n }\n }\n }\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [\n timeSeriesQueries,\n timeSeriesResults,\n traceQueries,\n traceResults,\n profileQueries,\n profileResults,\n logQueries,\n logResults,\n refetchAll,\n queryOptions?.enabled,\n usageMetrics,\n ]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","useProfileQueries","useUsageMetrics","useLogQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","usageMetrics","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","profileQueries","profileResults","logQueries","logResults","forEach","refetch","mergedQueryResults","enabled","error","markQuery","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAA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AAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C,OAAO,IAAIQ,OAAO4B,KAAK,EAAE;oBACvBb,aAAac,SAAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C,OAAO;oBACLuB,aAAac,SAAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C;YACF;QACF;QAEA,OAAO;YACLH,cAAcqC;YACd5B,YAAY4B,mBAAmB3B,IAAI,CAAC,CAACC,SAAWA,OAAOF,UAAU;YACjEG,WAAWyB,mBAAmB3B,IAAI,CAAC,CAACC,SAAWA,OAAOC,SAAS;YAC/DC;YACAP,QAAQ+B,mBAAmBf,GAAG,CAAC,CAACX,SAAWA,OAAO4B,KAAK;QACzD;IACF,GAAG;QACDZ;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACArB;QACAM,cAAcmB;QACdZ;KACD;IAED,qBAAO,KAAClC,mBAAmBiD,QAAQ;QAACC,OAAO/C;kBAAMuB;;AACnD"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\nimport { useProfileQueries, ProfileQueryDefinition } from '../profile-queries';\n\nimport { useUsageMetrics } from '../UsageMetricsProvider';\nimport { LogQueryDefinition, useLogQueries } from '../log-queries';\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext(): DataQueriesContextType {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps): ReactElement {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n const usageMetrics = useUsageMetrics();\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n\n const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n\n const profileQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'ProfileQuery'\n ) as ProfileQueryDefinition[];\n const profileResults = useProfileQueries(profileQueries);\n\n const logQueries = queryDefinitions.filter((definition) => definition.kind === 'LogQuery') as LogQueryDefinition[];\n const logResults = useLogQueries(logQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n profileResults.forEach((result) => result.refetch());\n logResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults, profileResults, logResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ...transformQueryResults(profileResults, profileQueries),\n ...transformQueryResults(logResults, logQueries),\n ];\n\n if (queryOptions?.enabled) {\n for (const result of mergedQueryResults) {\n if (!result.isLoading && !result.isFetching && !result.error) {\n usageMetrics.markQuery(result.definition, 'success');\n } else if (result.error) {\n usageMetrics.markQuery(result.definition, 'error');\n } else {\n usageMetrics.markQuery(result.definition, 'pending');\n }\n }\n }\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [\n timeSeriesQueries,\n timeSeriesResults,\n traceQueries,\n traceResults,\n profileQueries,\n profileResults,\n logQueries,\n logResults,\n refetchAll,\n queryOptions?.enabled,\n usageMetrics,\n ]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","useProfileQueries","useUsageMetrics","useLogQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","usageMetrics","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","profileQueries","profileResults","logQueries","logResults","forEach","refetch","mergedQueryResults","enabled","error","markQuery","Provider","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAEtF,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,eAAe,QAA8B,mBAAmB;AACzE,SAASC,iBAAiB,QAAgC,qBAAqB;AAE/E,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAA6BC,aAAa,QAAQ,iBAAiB;AACnE,SAGEC,qBAAqB,EAGrBC,YAAY,QACP,UAAU;AAEjB,OAAO,MAAMC,mCAAqBX,cAAkDY,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAMZ,WAAWS;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,eAA0CC,SAAY;IACpE,MAAMH,MAAMD;IAEZ,6DAA6D;IAC7D,MAAMK,uBAAuBJ,IAAIK,YAAY,CAACC,MAAM,CAClD,CAACC,cAAgBA,aAAaC,YAAYC,SAASN;IAGrD,sDAAsD;IACtD,MAAMO,iBAAiBV,IAAIW,MAAM,CAACL,MAAM,CAAC,CAACK,QAAQC,QAAUZ,IAAIK,YAAY,CAACO,MAAM,EAAEJ,YAAYC,SAASN;IAE1G,mEAAmE;IACnE,MAAMU,cAAc;QAClBR,cAAcD;QACdU,YAAYV,qBAAqBW,IAAI,CAAC,CAACC,SAAWA,OAAOF,UAAU;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QAAmBE;QAAcE;QAAgBE;KAAW;IAEhE,MAAMvC,MAAMX,QAAQ;QAClB,MAAMqD,qBAAqB;eACtB/C,sBAAsBsC,mBAAmBD;eACzCrC,sBAAsBwC,cAAcD;eACpCvC,sBAAsB0C,gBAAgBD;eACtCzC,sBAAsB4C,YAAYD;SACtC;QAED,IAAId,cAAcmB,SAAS;YACzB,KAAK,MAAM3B,UAAU0B,mBAAoB;gBACvC,IAAI,CAAC1B,OAAOC,SAAS,IAAI,CAACD,OAAOF,UAAU,IAAI,CAACE,OAAO4B,KAAK,EAAE;oBAC5Db,aAAac,SAAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C,OAAO,IAAIQ,OAAO4B,KAAK,EAAE;oBACvBb,aAAac,SAAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C,OAAO;oBACLuB,aAAac,SAAS,CAAC7B,OAAOR,UAAU,EAAE;gBAC5C;YACF;QACF;QAEA,OAAO;YACLH,cAAcqC;YACd5B,YAAY4B,mBAAmB3B,IAAI,CAAC,CAACC,SAAWA,OAAOF,UAAU;YACjEG,WAAWyB,mBAAmB3B,IAAI,CAAC,CAACC,SAAWA,OAAOC,SAAS;YAC/DC;YACAP,QAAQ+B,mBAAmBf,GAAG,CAAC,CAACX,SAAWA,OAAO4B,KAAK;QACzD;IACF,GAAG;QACDZ;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACArB;QACAM,cAAcmB;QACdZ;KACD;IAED,qBAAO,KAAClC,mBAAmBiD,QAAQ;QAACC,OAAO/C;kBAAMuB;;AACnD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DataQueriesProvider';\nexport * from './model';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,UAAU"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DataQueriesProvider';\nexport * from './model';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,UAAU"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: Error;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData[] {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = useListPluginMetadata(['ProfileQuery']);\n const { data: logQueries, isLoading: isLogQueryPluginLoading } = useListPluginMetadata(['LogQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n ProfileQuery: [],\n LogQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (profileQueryPlugins) {\n profileQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (logQueries) {\n logQueries.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins, profileQueryPlugins, logQueries]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n case 'PyroscopeProfileQuery':\n return isProfileQueryPluginLoading;\n case 'LokiLogQuery':\n return isLogQueryPluginLoading;\n }\n\n return (\n isTraceQueryPluginLoading ||\n isTimeSeriesQueryLoading ||\n isProfileQueryPluginLoading ||\n isLogQueryPluginLoading\n );\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [\n queryTypeMap,\n isTimeSeriesQueryLoading,\n isTraceQueryPluginLoading,\n isProfileQueryPluginLoading,\n isLogQueryPluginLoading,\n ]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","profileQueryPlugins","isProfileQueryPluginLoading","logQueries","isLogQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","ProfileQuery","LogQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACxD,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE,EAAEC;QACnE,OAAO;YACLC,YAAYR,WAAW,CAACO,EAAE;YAC1BL;YACAC;YACAC;YACAC;YACAC;QACF;IACF;AACF;AAEA,OAAO,SAASG;IACd,MAAM,EAAEP,MAAMQ,sBAAsB,EAAEN,WAAWO,wBAAwB,EAAE,GAAGd,sBAAsB;QAClG;KACD;IACD,MAAM,EAAEK,MAAMU,iBAAiB,EAAER,WAAWS,yBAAyB,EAAE,GAAGhB,sBAAsB;QAAC;KAAa;IAC9G,MAAM,EAAEK,MAAMY,mBAAmB,EAAEV,W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,MAAMC,aAAad,aAAc;YACpC,IAAIA,YAAY,CAACc,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,YAAY;IACrE,GACA;QACEZ;QACAP;QACAE;QACAE;QACAE;KACD;IAGH,OAAOY;AACT"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: Error;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData[] {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = useListPluginMetadata(['ProfileQuery']);\n const { data: logQueries, isLoading: isLogQueryPluginLoading } = useListPluginMetadata(['LogQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n ProfileQuery: [],\n LogQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (profileQueryPlugins) {\n profileQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (logQueries) {\n logQueries.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins, profileQueryPlugins, logQueries]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n case 'PyroscopeProfileQuery':\n return isProfileQueryPluginLoading;\n case 'LokiLogQuery':\n return isLogQueryPluginLoading;\n }\n\n return (\n isTraceQueryPluginLoading ||\n isTimeSeriesQueryLoading ||\n isProfileQueryPluginLoading ||\n isLogQueryPluginLoading\n );\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [\n queryTypeMap,\n isTimeSeriesQueryLoading,\n isTraceQueryPluginLoading,\n isProfileQueryPluginLoading,\n isLogQueryPluginLoading,\n ]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","profileQueryPlugins","isProfileQueryPluginLoading","logQueries","isLogQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","ProfileQuery","LogQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACxD,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE,EAAEC;QACnE,OAAO;YACLC,YAAYR,WAAW,CAACO,EAAE;YAC1BL;YACAC;YACAC;YACAC;YACAC;QACF;IACF;AACF;AAEA,OAAO,SAASG;IACd,MAAM,EAAEP,MAAMQ,sBAA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oBACH,OAAOnB;gBACT,KAAK;oBACH,OAAOE;gBACT,KAAK;oBACH,OAAOE;gBACT,KAAK;oBACH,OAAOE;YACX;YAEA,OACEJ,6BACAF,4BACAI,+BACAE;QAEJ;QAEA,IAAIb,UAAU0B,aAAa;YACzB,OAAOC;QACT;QAEA,IAAK,MAAMC,aAAad,aAAc;YACpC,IAAIA,YAAY,CAACc,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,YAAY;IACrE,GACA;QACEZ;QACAP;QACAE;QACAE;QACAE;KACD;IAGH,OAAOY;AACT"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/QueryCountProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode } from 'react';\n\ninterface QueryCountProviderProps {\n queryCount: number;\n children: ReactNode;\n}\n\nconst QueryCountContext = createContext<number>(0);\n\nexport const QueryCountProvider: React.FC<QueryCountProviderProps> = ({ queryCount, children }) => {\n return <QueryCountContext.Provider value={queryCount}>{children}</QueryCountContext.Provider>;\n};\n\nexport const useQueryCountContext = (): number => {\n return useContext(QueryCountContext);\n};\n"],"names":["React","createContext","useContext","QueryCountContext","QueryCountProvider","queryCount","children","Provider","value","useQueryCountContext"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAEC,UAAU,QAAmB,QAAQ;AAOpE,MAAMC,kCAAoBF,cAAsB;AAEhD,OAAO,MAAMG,qBAAwD,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IAC5F,qBAAO,KAACH,kBAAkBI,QAAQ;QAACC,OAAOH;kBAAaC;;AACzD,EAAE;AAEF,OAAO,MAAMG,uBAAuB;IAClC,OAAOP,WAAWC;AACpB,EAAE"}
1
+ {"version":3,"sources":["../../src/runtime/QueryCountProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode } from 'react';\n\ninterface QueryCountProviderProps {\n queryCount: number;\n children: ReactNode;\n}\n\nconst QueryCountContext = createContext<number>(0);\n\nexport const QueryCountProvider: React.FC<QueryCountProviderProps> = ({ queryCount, children }) => {\n return <QueryCountContext.Provider value={queryCount}>{children}</QueryCountContext.Provider>;\n};\n\nexport const useQueryCountContext = (): number => {\n return useContext(QueryCountContext);\n};\n"],"names":["React","createContext","useContext","QueryCountContext","QueryCountProvider","queryCount","children","Provider","value","useQueryCountContext"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAEC,UAAU,QAAmB,QAAQ;AAOpE,MAAMC,kCAAoBF,cAAsB;AAEhD,OAAO,MAAMG,qBAAwD,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IAC5F,qBAAO,KAACH,kBAAkBI,QAAQ;QAACC,OAAOH;kBAAaC;;AACzD,EAAE;AAEF,OAAO,MAAMG,uBAAuB;IAClC,OAAOP,WAAWC;AACpB,EAAE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/RouterProvider.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode, ReactElement, useMemo } from 'react';\nimport { Link as RouterLink, useNavigate } from 'react-router-dom';\n\ninterface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string;\n}\n\nexport interface RouterContextType {\n RouterComponent?: (props: LinkProps & React.RefAttributes<HTMLAnchorElement>) => ReactNode;\n navigate?: (to: string) => void;\n}\n\nexport const RouterContext = createContext<RouterContextType | undefined>(undefined);\n\nexport function useRouterContext(): RouterContextType {\n const ctx = useContext(RouterContext);\n if (ctx === undefined) {\n console.warn('No RouterContext found. Did you forget a <RouterProvider>?');\n return {};\n }\n return ctx;\n}\n\ninterface RouterProviderProps {\n RouterComponent: RouterContextType['RouterComponent'];\n navigate: RouterContextType['navigate'];\n children?: React.ReactNode;\n}\n\n/**\n * Some panel plugins (TraceTable, ScatterPlot, TracingGanttChart) support linking to other pages,\n * e.g. clicking on a trace in the TraceTable should navigate to the TracingGanttChart.\n *\n * We can't use react-router in the panel, because panels might be embedded into React applications\n * which use a different routing library, or a different major version of react-router.\n *\n * This provider abstracts the basic routing functionality, to remove the dependency on the exact version of react-router.\n */\nexport function RouterProvider(props: RouterProviderProps): ReactElement {\n const { RouterComponent, navigate, children } = props;\n\n const ctx = useMemo(() => {\n return { RouterComponent, navigate };\n }, [RouterComponent, navigate]);\n\n return <RouterContext.Provider value={ctx}>{children}</RouterContext.Provider>;\n}\n\ninterface ReactRouterProviderProps {\n children?: React.ReactNode;\n}\n\n/** An implementation of RouterProvider for using the react-router library, shipped with Perses */\nexport function ReactRouterProvider(props: ReactRouterProviderProps): ReactElement {\n const { children } = props;\n const navigate = useNavigate();\n\n return (\n <RouterProvider RouterComponent={RouterLink} navigate={navigate}>\n {children}\n </RouterProvider>\n );\n}\n"],"names":["React","createContext","useContext","useMemo","Link","RouterLink","useNavigate","RouterContext","undefined","useRouterContext","ctx","console","warn","RouterProvider","props","RouterComponent","navigate","children","Provider","value","ReactRouterProvider"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAEC,UAAU,EAA2BC,OAAO,QAAQ,QAAQ;AAC3F,SAASC,QAAQC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAWnE,OAAO,MAAMC,8BAAgBN,cAA6CO,WAAW;AAErF,OAAO,SAASC;IACd,MAAMC,MAAMR,WAAWK;IACvB,IAAIG,QAAQF,WAAW;QACrBG,QAAQC,IAAI,CAAC;QACb,OAAO,CAAC;IACV;IACA,OAAOF;AACT;AAQA;;;;;;;;CAQC,GACD,OAAO,SAASG,eAAeC,KAA0B;IACvD,MAAM,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEhD,MAAMJ,MAAMP,QAAQ;QAClB,OAAO;YAAEY;YAAiBC;QAAS;IACrC,GAAG;QAACD;QAAiBC;KAAS;IAE9B,qBAAO,KAACT,cAAcW,QAAQ;QAACC,OAAOT;kBAAMO;;AAC9C;AAMA,gGAAgG,GAChG,OAAO,SAASG,oBAAoBN,KAA+B;IACjE,MAAM,EAAEG,QAAQ,EAAE,GAAGH;IACrB,MAAME,WAAWV;IAEjB,qBACE,KAACO;QAAeE,iBAAiBV;QAAYW,UAAUA;kBACpDC;;AAGP"}
1
+ {"version":3,"sources":["../../src/runtime/RouterProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode, ReactElement, useMemo } from 'react';\nimport { Link as RouterLink, useNavigate } from 'react-router-dom';\n\ninterface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string;\n}\n\nexport interface RouterContextType {\n RouterComponent?: (props: LinkProps & React.RefAttributes<HTMLAnchorElement>) => ReactNode;\n navigate?: (to: string) => void;\n}\n\nexport const RouterContext = createContext<RouterContextType | undefined>(undefined);\n\nexport function useRouterContext(): RouterContextType {\n const ctx = useContext(RouterContext);\n if (ctx === undefined) {\n console.warn('No RouterContext found. Did you forget a <RouterProvider>?');\n return {};\n }\n return ctx;\n}\n\ninterface RouterProviderProps {\n RouterComponent: RouterContextType['RouterComponent'];\n navigate: RouterContextType['navigate'];\n children?: React.ReactNode;\n}\n\n/**\n * Some panel plugins (TraceTable, ScatterPlot, TracingGanttChart) support linking to other pages,\n * e.g. clicking on a trace in the TraceTable should navigate to the TracingGanttChart.\n *\n * We can't use react-router in the panel, because panels might be embedded into React applications\n * which use a different routing library, or a different major version of react-router.\n *\n * This provider abstracts the basic routing functionality, to remove the dependency on the exact version of react-router.\n */\nexport function RouterProvider(props: RouterProviderProps): ReactElement {\n const { RouterComponent, navigate, children } = props;\n\n const ctx = useMemo(() => {\n return { RouterComponent, navigate };\n }, [RouterComponent, navigate]);\n\n return <RouterContext.Provider value={ctx}>{children}</RouterContext.Provider>;\n}\n\ninterface ReactRouterProviderProps {\n children?: React.ReactNode;\n}\n\n/** An implementation of RouterProvider for using the react-router library, shipped with Perses */\nexport function ReactRouterProvider(props: ReactRouterProviderProps): ReactElement {\n const { children } = props;\n const navigate = useNavigate();\n\n return (\n <RouterProvider RouterComponent={RouterLink} navigate={navigate}>\n {children}\n </RouterProvider>\n );\n}\n"],"names":["React","createContext","useContext","useMemo","Link","RouterLink","useNavigate","RouterContext","undefined","useRouterContext","ctx","console","warn","RouterProvider","props","RouterComponent","navigate","children","Provider","value","ReactRouterProvider"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAEC,UAAU,EAA2BC,OAAO,QAAQ,QAAQ;AAC3F,SAASC,QAAQC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAWnE,OAAO,MAAMC,8BAAgBN,cAA6CO,WAAW;AAErF,OAAO,SAASC;IACd,MAAMC,MAAMR,WAAWK;IACvB,IAAIG,QAAQF,WAAW;QACrBG,QAAQC,IAAI,CAAC;QACb,OAAO,CAAC;IACV;IACA,OAAOF;AACT;AAQA;;;;;;;;CAQC,GACD,OAAO,SAASG,eAAeC,KAA0B;IACvD,MAAM,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEhD,MAAMJ,MAAMP,QAAQ;QAClB,OAAO;YAAEY;YAAiBC;QAAS;IACrC,GAAG;QAACD;QAAiBC;KAAS;IAE9B,qBAAO,KAACT,cAAcW,QAAQ;QAACC,OAAOT;kBAAMO;;AAC9C;AAMA,gGAAgG,GAChG,OAAO,SAASG,oBAAoBN,KAA+B;IACjE,MAAM,EAAEG,QAAQ,EAAE,GAAGH;IACrB,MAAME,WAAWV;IAEjB,qBACE,KAACO;QAAeE,iBAAiBV;QAAYW,UAAUA;kBACpDC;;AAGP"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange: (value: TimeRangeValue) => void;\n setRefreshInterval: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const queryClient = useQueryClient();\n const [absoluteTimeRange, setAbsoluteTimeRange] = useState<AbsoluteTimeRange>(\n isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange\n );\n\n const handleSetTimeRange = useCallback(\n (value: TimeRangeValue) => {\n setTimeRange(value);\n setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);\n },\n [setTimeRange]\n );\n\n // Refresh is called when clicking on the refresh button, it refreshes all queries including variables\n const refresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient\n .invalidateQueries({ queryKey: ['query'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' }));\n queryClient\n .invalidateQueries({ queryKey: ['variable'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }));\n }, [queryClient, timeRange]);\n\n // Auto refresh is only refreshing queries of panels\n const autoRefresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient.invalidateQueries({ queryKey: ['query'] }).finally(() => {\n queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' });\n queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }); // Timerange is in queryKey, can lead to memory leak when using relative timerange\n });\n }, [queryClient, timeRange]);\n\n const refreshIntervalInMs = useMemo(() => getRefreshIntervalInMs(refreshInterval), [refreshInterval]);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n autoRefresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [autoRefresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n return {\n timeRange: timeRange,\n setTimeRange: handleSetTimeRange,\n absoluteTimeRange: absoluteTimeRange,\n refresh,\n refreshInterval: refreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval,\n };\n }, [\n absoluteTimeRange,\n handleSetTimeRange,\n refresh,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n timeRange,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","useQueryClient","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","queryClient","setAbsoluteTimeRange","handleSetTimeRange","value","refresh","invalidateQueries","queryKey","finally","removeQueries","type","autoRefresh","refreshIntervalInMs","interval","setInterval","clearInterval","Provider"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAoB5D,OAAO,MAAMC,iCAAmBX,cAAqCY,WAAW;AAEhF,OAAO,SAASC;IACd,MAAMC,MAAMZ,WAAWS;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASE;IACd,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,mBAAmBC,KAAc;IAC/C,MAAM,EAAEC,iBAAiB,EAAE,GAAGH;IAC9B,IAAIE,UAAUN,WAAW,OAAO;IAChC,OAAOJ,mBAAmBW,mBAAmBD;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASE,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,kBAAkB,EAAE,GAAGL;IAEnF,MAAMM,cAAclB;IACpB,MAAM,CAACU,mBAAmBS,qBAAqB,GAAGvB,SAChDC,oBAAoBgB,aAAaf,oBAAoBe,aAAaA;IAGpE,MAAMO,qBAAqB5B,YACz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,mBAAmBA;YACnBY;YACAR,iBAAiBA;YACjBe,qBAAqBA;YACrBZ,oBAAoBA;QACtB;IACF,GAAG;QACDP;QACAU;QACAE;QACAR;QACAe;QACAZ;QACAJ;KACD;IAED,qBAAO,KAACX,iBAAiB+B,QAAQ;QAACZ,OAAOhB;kBAAMU;;AACjD"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange: (value: TimeRangeValue) => void;\n setRefreshInterval: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const queryClient = useQueryClient();\n const [absoluteTimeRange, setAbsoluteTimeRange] = useState<AbsoluteTimeRange>(\n isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange\n );\n\n const handleSetTimeRange = useCallback(\n (value: TimeRangeValue) => {\n setTimeRange(value);\n setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);\n },\n [setTimeRange]\n );\n\n // Refresh is called when clicking on the refresh button, it refreshes all queries including variables\n const refresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient\n .invalidateQueries({ queryKey: ['query'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' }));\n queryClient\n .invalidateQueries({ queryKey: ['variable'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }));\n }, [queryClient, timeRange]);\n\n // Auto refresh is only refreshing queries of panels\n const autoRefresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient.invalidateQueries({ queryKey: ['query'] }).finally(() => {\n queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' });\n queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }); // Timerange is in queryKey, can lead to memory leak when using relative timerange\n });\n }, [queryClient, timeRange]);\n\n const refreshIntervalInMs = useMemo(() => getRefreshIntervalInMs(refreshInterval), [refreshInterval]);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n autoRefresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [autoRefresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n return {\n timeRange: timeRange,\n setTimeRange: handleSetTimeRange,\n absoluteTimeRange: absoluteTimeRange,\n refresh,\n refreshInterval: refreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval,\n };\n }, [\n absoluteTimeRange,\n handleSetTimeRange,\n refresh,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n timeRange,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","useQueryClient","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","queryClient","setAbsoluteTimeRange","handleSetTimeRange","value","refresh","invalidateQueries","queryKey","finally","removeQueries","type","autoRefresh","refreshIntervalInMs","interval","setInterval","clearInterval","Provider"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAm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MAAM;YAAW;IACxF,GAAG;QAACT;QAAaL;KAAU;IAE3B,oDAAoD;IACpD,MAAMe,cAAcpC,YAAY;QAC9B2B,qBAAqBtB,oBAAoBgB,aAAaf,oBAAoBe,aAAaA;QACvFK,YAAYK,iBAAiB,CAAC;YAAEC,UAAU;gBAAC;aAAQ;QAAC,GAAGC,OAAO,CAAC;YAC7DP,YAAYQ,aAAa,CAAC;gBAAEF,UAAU;oBAAC;iBAAQ;gBAAEG,MAAM;YAAW;YAClET,YAAYQ,aAAa,CAAC;gBAAEF,UAAU;oBAAC;iBAAW;gBAAEG,MAAM;YAAW,IAAI,kFAAkF;QAC7J;IACF,GAAG;QAACT;QAAaL;KAAU;IAE3B,MAAMgB,sBAAsBlC,QAAQ,IAAMM,uBAAuBa,kBAAkB;QAACA;KAAgB;IACpGpB,UAAU;QACR,IAAImC,sBAAsB,GAAG;YAC3B,MAAMC,WAAWC,YAAY;gBAC3BH;YACF,GAAGC;YAEH,OAAO,IAAYG,cAAcF;QACnC;IACF,GAAG;QAACF;QAAaC;KAAoB;IAErC,MAAMxB,MAAMV,QAAQ;QAClB,OAAO;YACLkB,WAAWA;YACXG,cAAcI;YACdV,mBAAmBA;YACnBY;YACAR,iBAAiBA;YACjBe,qBAAqBA;YACrBZ,oBAAoBA;QACtB;IACF,GAAG;QACDP;QACAU;QACAE;QACAR;QACAe;QACAZ;QACAJ;KACD;IAED,qBAAO,KAACX,iBAAiB+B,QAAQ;QAACZ,OAAOhB;kBAAMU;;AACjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProviders.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI5C,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,gCAAgC,CAAC,EAC/C,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAcxC;AAED,wBAAgB,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAcxC"}
1
+ {"version":3,"file":"TimeRangeProviders.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAK5C,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,gCAAgC,CAAC,EAC/C,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAexC;AAED,wBAAgB,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAcxC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -12,17 +12,22 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React from 'react';
15
+ import { TimeZoneProvider } from '@perses-dev/components';
15
16
  import { TimeRangeProvider } from './TimeRangeProvider';
16
- import { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';
17
+ import { useSetRefreshIntervalParams, useTimeRangeParams, useTimeZoneParams } from './query-params';
17
18
  export function TimeRangeProviderWithQueryParams({ initialTimeRange, initialRefreshInterval, children }) {
18
19
  const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);
19
20
  const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);
21
+ const { timeZone } = useTimeZoneParams('local');
20
22
  return /*#__PURE__*/ _jsx(TimeRangeProvider, {
21
23
  timeRange: timeRange,
22
24
  refreshInterval: refreshInterval,
23
25
  setTimeRange: setTimeRange,
24
26
  setRefreshInterval: setRefreshInterval,
25
- children: children
27
+ children: /*#__PURE__*/ _jsx(TimeZoneProvider, {
28
+ timeZone: timeZone,
29
+ children: children
30
+ })
26
31
  });
27
32
  }
28
33
  export function TimeRangeProviderBasic({ initialTimeRange, initialRefreshInterval, children }) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React, { ReactElement } from 'react';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProvidersProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n}\n\nexport function TimeRangeProviderWithQueryParams({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n\nexport function TimeRangeProviderBasic({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const [timeRange, setTimeRange] = React.useState<TimeRangeValue>(initialTimeRange);\n const [refreshInterval, setRefreshInterval] = React.useState<DurationString | undefined>(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["React","TimeRangeProvider","useSetRefreshIntervalParams","useTimeRangeParams","TimeRangeProviderWithQueryParams","initialTimeRange","initialRefreshInterval","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval","TimeRangeProviderBasic","useState"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,OAAOA,WAA6B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,QAAQ,iBAAiB;AAQjF,OAAO,SAASC,iCAAiC,EAC/CC,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGN,mBAAmBE;IACvD,MAAM,EAAEK,eAAe,EAAEC,kBAAkB,EAAE,GAAGT,4BAA4BI;IAE5E,qBACE,KAACL;QACCO,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP;AAEA,OAAO,SAASK,uBAAuB,EACrCP,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,CAACC,WAAWC,aAAa,GAAGT,MAAMa,QAAQ,CAAiBR;IACjE,MAAM,CAACK,iBAAiBC,mBAAmB,GAAGX,MAAMa,QAAQ,CAA6BP;IAEzF,qBACE,KAACL;QACCO,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviders.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React, { ReactElement } from 'react';\nimport { TimeZoneProvider } from '@perses-dev/components';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useTimeRangeParams, useTimeZoneParams } from './query-params';\n\nexport interface TimeRangeProvidersProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n}\n\nexport function TimeRangeProviderWithQueryParams({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n const { timeZone } = useTimeZoneParams('local');\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n <TimeZoneProvider timeZone={timeZone}>{children}</TimeZoneProvider>\n </TimeRangeProvider>\n );\n}\n\nexport function TimeRangeProviderBasic({\n initialTimeRange,\n initialRefreshInterval,\n children,\n}: TimeRangeProvidersProps): ReactElement {\n const [timeRange, setTimeRange] = React.useState<TimeRangeValue>(initialTimeRange);\n const [refreshInterval, setRefreshInterval] = React.useState<DurationString | undefined>(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["React","TimeZoneProvider","TimeRangeProvider","useSetRefreshIntervalParams","useTimeRangeParams","useTimeZoneParams","TimeRangeProviderWithQueryParams","initialTimeRange","initialRefreshInterval","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval","timeZone","TimeRangeProviderBasic","useState"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,OAAOA,WAA6B,QAAQ;AAC5C,SAASC,gBAAgB,QAAQ,yBAAyB;AAC1D,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,EAAEC,iBAAiB,QAAQ,iBAAiB;AAQpG,OAAO,SAASC,iCAAiC,EAC/CC,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,EAAEC,SAAS,EAAEC,YAAY,EAAE,GAAGP,mBAAmBG;IACvD,MAAM,EAAEK,eAAe,EAAEC,kBAAkB,EAAE,GAAGV,4BAA4BK;IAC5E,MAAM,EAAEM,QAAQ,EAAE,GAAGT,kBAAkB;IAEvC,qBACE,KAACH;QACCQ,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEpB,cAAA,KAACZ;YAAiBa,UAAUA;sBAAWL;;;AAG7C;AAEA,OAAO,SAASM,uBAAuB,EACrCR,gBAAgB,EAChBC,sBAAsB,EACtBC,QAAQ,EACgB;IACxB,MAAM,CAACC,WAAWC,aAAa,GAAGX,MAAMgB,QAAQ,CAAiBT;IACjE,MAAM,CAACK,iBAAiBC,mBAAmB,GAAGb,MAAMgB,QAAQ,CAA6BR;IAEzF,qBACE,KAACN;QACCQ,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useMemo } from 'react';\nimport { buildRelativeTimeOption, TimeOption } from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/core';\n\nconst DEFAULT_OPTIONS: DurationString[] = ['5m', '15m', '30m', '1h', '6h', '12h', '24h', '7d', '14d'];\nconst defaultTimeRangeSettings: TimeRangeSettings = {\n showCustom: true,\n showZoomButtons: true,\n options: DEFAULT_OPTIONS.map((duration) => buildRelativeTimeOption(duration)),\n};\n\nexport interface TimeRangeSettingsProviderProps {\n showCustom?: boolean;\n showZoomButtons?: boolean;\n options?: TimeOption[];\n children: ReactNode;\n}\n\nexport interface TimeRangeSettings {\n showCustom: boolean;\n showZoomButtons: boolean;\n options: TimeOption[];\n}\n\nexport const TimeRangeSettingsContext = createContext<TimeRangeSettings>(defaultTimeRangeSettings);\n\nexport function useTimeRangeSettingsContext(): TimeRangeSettings {\n const ctx = useContext(TimeRangeSettingsContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRangeSettings(): TimeRangeSettings {\n return useTimeRangeSettingsContext();\n}\n\n/**\n * Get the current value of the showCustom setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowCustomTimeRangeSetting(override?: boolean): boolean {\n const showCustomTimeRange = useTimeRangeSettings().showCustom;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Get the current value of the showZoomButtons setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowZoomRangeSetting(override?: boolean): boolean {\n const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;\n if (override !== undefined) {\n return override;\n }\n return showZoomTimeRange;\n}\n\n/**\n * Get the current value of the options setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useTimeRangeOptionsSetting(override?: TimeOption[]): TimeOption[] {\n const showCustomTimeRange = useTimeRangeSettings().options;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeSettingsProvider(props: TimeRangeSettingsProviderProps): ReactElement {\n const ctx = useMemo(() => {\n return {\n showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,\n showZoomButtons:\n props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,\n options: props.options === undefined ? defaultTimeRangeSettings.options : props.options,\n };\n }, [props.showCustom, props.showZoomButtons, props.options]);\n\n return <TimeRangeSettingsContext.Provider value={ctx}>{props.children}</TimeRangeSettingsContext.Provider>;\n}\n"],"names":["createContext","useContext","useMemo","buildRelativeTimeOption","DEFAULT_OPTIONS","defaultTimeRangeSettings","showCustom","showZoomButtons","options","map","duration","TimeRangeSettingsContext","useTimeRangeSettingsContext","ctx","undefined","Error","useTimeRangeSettings","useShowCustomTimeRangeSetting","override","showCustomTimeRange","useShowZoomRangeSetting","showZoomTimeRange","useTimeRangeOptionsSetting","TimeRangeSettingsProvider","props","Provider","value","children"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAAa,EAA2BC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACpF,SAASC,uBAAuB,QAAoB,yBAAyB;AAG7E,MAAMC,kBAAoC;IAAC;IAAM;IAAO;IAAO;IAAM;IAAM;IAAO;IAAO;IAAM;CAAM;AACrG,MAAMC,2BAA8C;IAClDC,YAAY;IACZC,iBAAiB;IACjBC,SAASJ,gBAAgBK,GAAG,CAAC,CAACC,WAAaP,wBAAwBO;AACrE;AAeA,OAAO,MAAMC,yCAA2BX,cAAiCK,0BAA0B;AAEnG,OAAO,SAASO;IACd,MAAMC,MAAMZ,WAAWU;IACvB,IAAIE,QAAQC,WAAW;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASK,8BAA8BC,QAAkB;IAC9D,MAAMC,sBAAsBH,uBAAuBV,UAAU;IAC7D,IAAIY,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,wBAAwBF,QAAkB;IACxD,MAAMG,oBAAoBL,uBAAuBT,eAAe;IAChE,IAAIW,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOG;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,2BAA2BJ,QAAuB;IAChE,MAAMC,sBAAsBH,uBAAuBR,OAAO;IAC1D,IAAIU,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,0BAA0BC,KAAqC;IAC7E,MAAMX,MAAMX,QAAQ;QAClB,OAAO;YACLI,YAAYkB,MAAMlB,UAAU,KAAKQ,YAAYT,yBAAyBC,UAAU,GAAGkB,MAAMlB,UAAU;YACnGC,iBACEiB,MAAMjB,eAAe,KAAKO,YAAYT,yBAAyBE,eAAe,GAAGiB,MAAMjB,eAAe;YACxGC,SAASgB,MAAMhB,OAAO,KAAKM,YAAYT,yBAAyBG,OAAO,GAAGgB,MAAMhB,OAAO;QACzF;IACF,GAAG;QAACgB,MAAMlB,UAAU;QAAEkB,MAAMjB,eAAe;QAAEiB,MAAMhB,OAAO;KAAC;IAE3D,qBAAO,KAACG,yBAAyBc,QAAQ;QAACC,OAAOb;kBAAMW,MAAMG,QAAQ;;AACvE"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useMemo } from 'react';\nimport { buildRelativeTimeOption, TimeOption } from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/core';\n\nconst DEFAULT_OPTIONS: DurationString[] = ['5m', '15m', '30m', '1h', '6h', '12h', '24h', '7d', '14d'];\nconst defaultTimeRangeSettings: TimeRangeSettings = {\n showCustom: true,\n showZoomButtons: true,\n options: DEFAULT_OPTIONS.map((duration) => buildRelativeTimeOption(duration)),\n};\n\nexport interface TimeRangeSettingsProviderProps {\n showCustom?: boolean;\n showZoomButtons?: boolean;\n options?: TimeOption[];\n children: ReactNode;\n}\n\nexport interface TimeRangeSettings {\n showCustom: boolean;\n showZoomButtons: boolean;\n options: TimeOption[];\n}\n\nexport const TimeRangeSettingsContext = createContext<TimeRangeSettings>(defaultTimeRangeSettings);\n\nexport function useTimeRangeSettingsContext(): TimeRangeSettings {\n const ctx = useContext(TimeRangeSettingsContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRangeSettings(): TimeRangeSettings {\n return useTimeRangeSettingsContext();\n}\n\n/**\n * Get the current value of the showCustom setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowCustomTimeRangeSetting(override?: boolean): boolean {\n const showCustomTimeRange = useTimeRangeSettings().showCustom;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Get the current value of the showZoomButtons setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowZoomRangeSetting(override?: boolean): boolean {\n const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;\n if (override !== undefined) {\n return override;\n }\n return showZoomTimeRange;\n}\n\n/**\n * Get the current value of the options setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useTimeRangeOptionsSetting(override?: TimeOption[]): TimeOption[] {\n const showCustomTimeRange = useTimeRangeSettings().options;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeSettingsProvider(props: TimeRangeSettingsProviderProps): ReactElement {\n const ctx = useMemo(() => {\n return {\n showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,\n showZoomButtons:\n props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,\n options: props.options === undefined ? defaultTimeRangeSettings.options : props.options,\n };\n }, [props.showCustom, props.showZoomButtons, props.options]);\n\n return <TimeRangeSettingsContext.Provider value={ctx}>{props.children}</TimeRangeSettingsContext.Provider>;\n}\n"],"names":["createContext","useContext","useMemo","buildRelativeTimeOption","DEFAULT_OPTIONS","defaultTimeRangeSettings","showCustom","showZoomButtons","options","map","duration","TimeRangeSettingsContext","useTimeRangeSettingsContext","ctx","undefined","Error","useTimeRangeSettings","useShowCustomTimeRangeSetting","override","showCustomTimeRange","useShowZoomRangeSetting","showZoomTimeRange","useTimeRangeOptionsSetting","TimeRangeSettingsProvider","props","Provider","value","children"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAAa,EAA2BC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACpF,SAASC,uBAAuB,QAAoB,yBAAyB;AAG7E,MAAMC,kBAAoC;IAAC;IAAM;IAAO;IAAO;IAAM;IAAM;IAAO;IAAO;IAAM;CAAM;AACrG,MAAMC,2BAA8C;IAClDC,YAAY;IACZC,iBAAiB;IACjBC,SAASJ,gBAAgBK,GAAG,CAAC,CAACC,WAAaP,wBAAwBO;AACrE;AAeA,OAAO,MAAMC,yCAA2BX,cAAiCK,0BAA0B;AAEnG,OAAO,SAASO;IACd,MAAMC,MAAMZ,WAAWU;IACvB,IAAIE,QAAQC,WAAW;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASK,8BAA8BC,QAAkB;IAC9D,MAAMC,sBAAsBH,uBAAuBV,UAAU;IAC7D,IAAIY,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,wBAAwBF,QAAkB;IACxD,MAAMG,oBAAoBL,uBAAuBT,eAAe;IAChE,IAAIW,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOG;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,2BAA2BJ,QAAuB;IAChE,MAAMC,sBAAsBH,uBAAuBR,OAAO;IAC1D,IAAIU,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,0BAA0BC,KAAqC;IAC7E,MAAMX,MAAMX,QAAQ;QAClB,OAAO;YACLI,YAAYkB,MAAMlB,UAAU,KAAKQ,YAAYT,yBAAyBC,UAAU,GAAGkB,MAAMlB,UAAU;YACnGC,iBACEiB,MAAMjB,eAAe,KAAKO,YAAYT,yBAAyBE,eAAe,GAAGiB,MAAMjB,eAAe;YACxGC,SAASgB,MAAMhB,OAAO,KAAKM,YAAYT,yBAAyBG,OAAO,GAAGgB,MAAMhB,OAAO;QACzF;IACF,GAAG;QAACgB,MAAMlB,UAAU;QAAEkB,MAAMjB,eAAe;QAAEiB,MAAMhB,OAAO;KAAC;IAE3D,qBAAO,KAACG,yBAAyBc,QAAQ;QAACC,OAAOb;kBAAMW,MAAMG,QAAQ;;AACvE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './TimeRangeProviders';\nexport * from './TimeRangeSettingsProvider';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,iBAAiB"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './TimeRangeProviders';\nexport * from './TimeRangeSettingsProvider';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,8BAA8B;AAC5C,cAAc,iBAAiB"}
@@ -16,6 +16,9 @@ export declare const timeRangeQueryConfig: {
16
16
  export declare const refreshIntervalQueryConfig: {
17
17
  refresh: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
18
18
  };
19
+ export declare const timeZoneQueryConfig: {
20
+ tz: QueryParamConfig<string | null | undefined, string | null | undefined>;
21
+ };
19
22
  /**
20
23
  * Gets the initial time range taking into account URL params and dashboard JSON duration
21
24
  * Sets start query param if it is empty on page load
@@ -34,4 +37,12 @@ export declare function useInitialRefreshInterval(dashboardDuration: DurationStr
34
37
  * Returns refresh interval getter and setter, taking the URL query params.
35
38
  */
36
39
  export declare function useSetRefreshIntervalParams(initialRefreshInterval?: DurationString): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'>;
40
+ /**
41
+ * Returns timezone getter and setter, taking the URL query params.
42
+ * Defaults to 'local' when not set.
43
+ */
44
+ export declare function useTimeZoneParams(initialTimeZone?: string): {
45
+ timeZone: string;
46
+ setTimeZone: (tz: string) => void;
47
+ };
37
48
  //# sourceMappingURL=query-params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAkB,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AAwBvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,K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,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAE/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAiBrF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,cAAc,GAAG,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAAC,CA6BlH;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAc3F;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,sBAAsB,CAAC,EAAE,cAAc,GACtC,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,oBAAoB,CAAC,CAyB3D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAcnH"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { useMemo, useCallback, useEffect, useState } from 'react';
14
- import { useQueryParams } from 'use-query-params';
14
+ import { useQueryParams, StringParam } from 'use-query-params';
15
15
  import { getUnixTime, isDate } from 'date-fns';
16
16
  import { isRelativeTimeRange, isDurationString } from '@perses-dev/core';
17
17
  /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
@@ -63,6 +63,9 @@ export const timeRangeQueryConfig = {
63
63
  export const refreshIntervalQueryConfig = {
64
64
  refresh: TimeRangeParam
65
65
  };
66
+ export const timeZoneQueryConfig = {
67
+ tz: StringParam
68
+ };
66
69
  /**
67
70
  * Gets the initial time range taking into account URL params and dashboard JSON duration
68
71
  * Sets start query param if it is empty on page load
@@ -195,5 +198,26 @@ export const refreshIntervalQueryConfig = {
195
198
  setRefreshInterval: setRefreshInterval
196
199
  };
197
200
  }
201
+ /**
202
+ * Returns timezone getter and setter, taking the URL query params.
203
+ * Defaults to 'local' when not set.
204
+ */ export function useTimeZoneParams(initialTimeZone) {
205
+ const [query, setQuery] = useQueryParams(timeZoneQueryConfig, {
206
+ updateType: 'replaceIn'
207
+ });
208
+ const { tz } = query;
209
+ const timeZone = tz ?? initialTimeZone ?? 'local';
210
+ const setTimeZone = useCallback((newTz)=>{
211
+ setQuery({
212
+ tz: newTz
213
+ });
214
+ }, [
215
+ setQuery
216
+ ]);
217
+ return {
218
+ timeZone,
219
+ setTimeZone
220
+ };
221
+ }
198
222
 
199
223
  //# sourceMappingURL=query-params.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo, useCallback, useEffect, useState } from 'react';\nimport { QueryParamConfig, useQueryParams } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n // '' or []\n if (!input || (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== '')))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str === null || str === undefined) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (!paramString) return null;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (!valueA || !valueB) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, taking the URL query params.\n */\nexport function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (!paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\n/**\n * Returns refresh interval getter and setter, taking the URL query params.\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard refresh interval\n if (!paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","undefined","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useTimeRangeParams","setQuery","paramsLoaded","setParamsLoaded","setTimeRange","value","timeRange","useInitialRefreshInterval","useSetRefreshIntervalParams","initialRefreshInterval","setRefreshInterval","refreshInterval"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC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"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo, useCallback, useEffect, useState } from 'react';\nimport { QueryParamConfig, useQueryParams, StringParam } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n // '' or []\n if (!input || (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== '')))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str === null || str === undefined) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (!paramString) return null;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (!valueA || !valueB) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\nexport const timeZoneQueryConfig = {\n tz: StringParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, taking the URL query params.\n */\nexport function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (!paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\n/**\n * Returns refresh interval getter and setter, taking the URL query params.\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard refresh interval\n if (!paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n };\n}\n\n/**\n * Returns timezone getter and setter, taking the URL query params.\n * Defaults to 'local' when not set.\n */\nexport function useTimeZoneParams(initialTimeZone?: string): { timeZone: string; setTimeZone: (tz: string) => void } {\n const [query, setQuery] = useQueryParams(timeZoneQueryConfig, { updateType: 'replaceIn' });\n const { tz } = query;\n\n const timeZone = (tz as string | undefined) ?? initialTimeZone ?? 'local';\n\n const setTimeZone = useCallback(\n (newTz: string) => {\n setQuery({ tz: newTz });\n },\n [setQuery]\n );\n\n return { timeZone, setTimeZone };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","StringParam","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","undefined","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","timeZoneQueryConfig","tz","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useTimeRangeParams","setQuery","paramsLoaded","setParamsLoaded","setTimeRange","value","timeRange","useInitialRefreshInterval","useSetRefreshIntervalParams","initialRefreshInterval","setRefreshInterval","refreshInterval","useTimeZoneParams","initialTimeZone","timeZone","setTimeZone","newTz"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAClE,SAA2BC,cAAc,EAAEC,WAAW,QAAQ,mBAAmB;AACjF,SAASC,WAAW,EAAEC,MAAM,QAAQ,WAAW;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,mBAAmB;AAK1B,iGAAiG,GACjG,SAASC,gBACPC,KAAuD,EACvDC,gBAA0B;IAE1B,WAAW;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IAAY;AACjC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/refresh-interval.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds } from 'date-fns';\n\n/**\n * Utils function to transform a refresh interval in {@link DurationString} format into a number of ms.\n * @param refreshInterval\n */\nexport function getRefreshIntervalInMs(refreshInterval?: DurationString): number {\n if (refreshInterval !== undefined && refreshInterval !== null) {\n return milliseconds(parseDurationString(refreshInterval));\n }\n return 0;\n}\n"],"names":["parseDurationString","milliseconds","getRefreshIntervalInMs","refreshInterval","undefined"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,mBAAmB,QAAQ,mBAAmB;AACvE,SAASC,YAAY,QAAQ,WAAW;AAExC;;;CAGC,GACD,OAAO,SAASC,uBAAuBC,eAAgC;IACrE,IAAIA,oBAAoBC,aAAaD,oBAAoB,MAAM;QAC7D,OAAOF,aAAaD,oBAAoBG;IAC1C;IACA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/refresh-interval.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds } from 'date-fns';\n\n/**\n * Utils function to transform a refresh interval in {@link DurationString} format into a number of ms.\n * @param refreshInterval\n */\nexport function getRefreshIntervalInMs(refreshInterval?: DurationString): number {\n if (refreshInterval !== undefined && refreshInterval !== null) {\n return milliseconds(parseDurationString(refreshInterval));\n }\n return 0;\n}\n"],"names":["parseDurationString","milliseconds","getRefreshIntervalInMs","refreshInterval","undefined"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,mBAAmB,QAAQ,mBAAmB;AACvE,SAASC,YAAY,QAAQ,WAAW;AAExC;;;CAGC,GACD,OAAO,SAASC,uBAAuBC,eAAgC;IACrE,IAAIA,oBAAoBC,aAAaD,oBAAoB,MAAM;QAC7D,OAAOF,aAAaD,oBAAoBG;IAC1C;IACA,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at