@localstack/appinspector-ui 1.0.7 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3496,11 +3496,11 @@ var SpansListPage = () => {
3496
3496
  };
3497
3497
 
3498
3498
  // src/pages/trace-graph-page.tsx
3499
- var import_icons_material6 = require("@mui/icons-material");
3500
- var import_material14 = require("@mui/material");
3499
+ var import_icons_material7 = require("@mui/icons-material");
3500
+ var import_material15 = require("@mui/material");
3501
3501
  var import_styles = require("@mui/material/styles");
3502
- var import_react16 = require("@xyflow/react");
3503
- var import_react17 = require("react");
3502
+ var import_react18 = require("@xyflow/react");
3503
+ var import_react19 = require("react");
3504
3504
  var import_react_router_dom2 = require("react-router-dom");
3505
3505
 
3506
3506
  // src/components/event-details/event-details.tsx
@@ -3652,9 +3652,9 @@ var EventDetails = ({ selectedEvent }) => {
3652
3652
 
3653
3653
  // src/components/trace-graph/trace-graph.tsx
3654
3654
  var import_base = require("@xyflow/react/dist/base.css");
3655
- var import_material13 = require("@mui/material");
3656
- var import_react14 = require("@xyflow/react");
3657
- var import_react15 = require("react");
3655
+ var import_material14 = require("@mui/material");
3656
+ var import_react16 = require("@xyflow/react");
3657
+ var import_react17 = require("react");
3658
3658
 
3659
3659
  // src/components/trace-graph/service-node.tsx
3660
3660
  var import_material12 = require("@mui/material");
@@ -3909,8 +3909,127 @@ var calculateCenterX = (focusNodeX, viewPortPixelWidth, minX, maxX) => {
3909
3909
  return Math.min(Math.max(desiredCenter, minX + viewPortPixelWidth / 2), maxX - viewPortPixelWidth / 2 + nodeWidth);
3910
3910
  };
3911
3911
 
3912
- // src/components/trace-graph/trace-graph.tsx
3912
+ // src/components/trace-graph/xyflow/controls.tsx
3913
+ var import_icons_material6 = require("@mui/icons-material");
3914
+ var import_material13 = require("@mui/material");
3915
+ var import_react14 = require("@xyflow/react");
3916
+ var import_react15 = require("react");
3917
+
3918
+ // node_modules/zustand/esm/shallow.mjs
3919
+ function shallow$1(objA, objB) {
3920
+ if (Object.is(objA, objB)) {
3921
+ return true;
3922
+ }
3923
+ if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
3924
+ return false;
3925
+ }
3926
+ if (objA instanceof Map && objB instanceof Map) {
3927
+ if (objA.size !== objB.size) return false;
3928
+ for (const [key, value] of objA) {
3929
+ if (!Object.is(value, objB.get(key))) {
3930
+ return false;
3931
+ }
3932
+ }
3933
+ return true;
3934
+ }
3935
+ if (objA instanceof Set && objB instanceof Set) {
3936
+ if (objA.size !== objB.size) return false;
3937
+ for (const value of objA) {
3938
+ if (!objB.has(value)) {
3939
+ return false;
3940
+ }
3941
+ }
3942
+ return true;
3943
+ }
3944
+ const keysA = Object.keys(objA);
3945
+ if (keysA.length !== Object.keys(objB).length) {
3946
+ return false;
3947
+ }
3948
+ for (const keyA of keysA) {
3949
+ if (!Object.prototype.hasOwnProperty.call(objB, keyA) || !Object.is(objA[keyA], objB[keyA])) {
3950
+ return false;
3951
+ }
3952
+ }
3953
+ return true;
3954
+ }
3955
+
3956
+ // src/components/trace-graph/xyflow/controls.tsx
3913
3957
  var import_jsx_runtime134 = require("react/jsx-runtime");
3958
+ var selector = (s) => ({
3959
+ ariaLabelConfig: s.ariaLabelConfig,
3960
+ isInteractive: s.nodesDraggable || s.nodesConnectable || s.elementsSelectable,
3961
+ maxZoomReached: s.transform[2] >= s.maxZoom,
3962
+ minZoomReached: s.transform[2] <= s.minZoom
3963
+ });
3964
+ var Controls = (0, import_react15.memo)(() => {
3965
+ const { ariaLabelConfig, maxZoomReached, minZoomReached } = (0, import_react14.useStore)(selector, shallow$1);
3966
+ const { fitView, zoomIn, zoomOut } = (0, import_react14.useReactFlow)();
3967
+ const onZoomInHandler = () => {
3968
+ void zoomIn();
3969
+ };
3970
+ const onZoomOutHandler = () => {
3971
+ void zoomOut();
3972
+ };
3973
+ const onFitViewHandler = () => {
3974
+ void fitView();
3975
+ };
3976
+ return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
3977
+ import_material13.Box,
3978
+ {
3979
+ "aria-label": ariaLabelConfig["controls.ariaLabel"],
3980
+ sx: {
3981
+ bottom: 0,
3982
+ display: "flex",
3983
+ flexDirection: "column",
3984
+ gap: 1,
3985
+ left: 0,
3986
+ m: 2,
3987
+ position: "absolute",
3988
+ zIndex: 5
3989
+ },
3990
+ children: [
3991
+ /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
3992
+ import_material13.IconButton,
3993
+ {
3994
+ "aria-label": ariaLabelConfig["controls.zoomIn.ariaLabel"],
3995
+ className: "react-flow__controls-zoomin",
3996
+ disabled: maxZoomReached,
3997
+ onClick: onZoomInHandler,
3998
+ size: "small",
3999
+ title: ariaLabelConfig["controls.zoomIn.ariaLabel"],
4000
+ children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_icons_material6.Add, {})
4001
+ }
4002
+ ),
4003
+ /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
4004
+ import_material13.IconButton,
4005
+ {
4006
+ "aria-label": ariaLabelConfig["controls.zoomOut.ariaLabel"],
4007
+ className: "react-flow__controls-zoomout",
4008
+ disabled: minZoomReached,
4009
+ onClick: onZoomOutHandler,
4010
+ size: "small",
4011
+ title: ariaLabelConfig["controls.zoomOut.ariaLabel"],
4012
+ children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_icons_material6.Remove, {})
4013
+ }
4014
+ ),
4015
+ /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
4016
+ import_material13.IconButton,
4017
+ {
4018
+ "aria-label": ariaLabelConfig["controls.fitView.ariaLabel"],
4019
+ className: "react-flow__controls-fitview",
4020
+ onClick: onFitViewHandler,
4021
+ size: "small",
4022
+ title: ariaLabelConfig["controls.fitView.ariaLabel"],
4023
+ children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_icons_material6.FitScreen, {})
4024
+ }
4025
+ )
4026
+ ]
4027
+ }
4028
+ );
4029
+ });
4030
+
4031
+ // src/components/trace-graph/trace-graph.tsx
4032
+ var import_jsx_runtime135 = require("react/jsx-runtime");
3914
4033
  var nodeTypes = {
3915
4034
  service: ServiceNode
3916
4035
  };
@@ -3921,12 +4040,12 @@ var TraceGraph = ({
3921
4040
  spans,
3922
4041
  viewPortPixelWidth
3923
4042
  }) => {
3924
- const [nodes, setNodes] = (0, import_react15.useState)([]);
3925
- const [edges, setEdges] = (0, import_react15.useState)([]);
3926
- const [initialViewSet, setInitialViewSet] = (0, import_react15.useState)(false);
3927
- const { fitView, setCenter } = (0, import_react14.useReactFlow)();
3928
- const store = (0, import_react14.useStoreApi)();
3929
- const updateSelectedNode = (0, import_react15.useCallback)(
4043
+ const [nodes, setNodes] = (0, import_react17.useState)([]);
4044
+ const [edges, setEdges] = (0, import_react17.useState)([]);
4045
+ const [initialViewSet, setInitialViewSet] = (0, import_react17.useState)(false);
4046
+ const { fitView, setCenter } = (0, import_react16.useReactFlow)();
4047
+ const store = (0, import_react16.useStoreApi)();
4048
+ const updateSelectedNode = (0, import_react17.useCallback)(
3930
4049
  (nodeId) => {
3931
4050
  const { addSelectedNodes } = store.getState();
3932
4051
  if (nodeId) {
@@ -3938,7 +4057,7 @@ var TraceGraph = ({
3938
4057
  },
3939
4058
  [nodes, store]
3940
4059
  );
3941
- (0, import_react15.useEffect)(() => {
4060
+ (0, import_react17.useEffect)(() => {
3942
4061
  const spansMap = /* @__PURE__ */ new Map();
3943
4062
  const rootSpans = [];
3944
4063
  for (const span of spans.data ?? []) {
@@ -3970,7 +4089,7 @@ var TraceGraph = ({
3970
4089
  setNodes(layoutedNodes);
3971
4090
  setEdges(layoutedEdges);
3972
4091
  }, [onEventSelect, spans.data]);
3973
- (0, import_react15.useEffect)(() => {
4092
+ (0, import_react17.useEffect)(() => {
3974
4093
  const shouldSetInitialView = !spans.loading && nodes.length > 0 && !initialViewSet;
3975
4094
  if (shouldSetInitialView) {
3976
4095
  if (initialFocusEventId) {
@@ -3990,20 +4109,20 @@ var TraceGraph = ({
3990
4109
  setInitialViewSet(true);
3991
4110
  }
3992
4111
  }, [spans.loading, nodes, initialFocusEventId, viewPortPixelWidth, setCenter, fitView, onEventSelect, initialViewSet]);
3993
- (0, import_react15.useEffect)(() => {
4112
+ (0, import_react17.useEffect)(() => {
3994
4113
  if (initialFocusEventId) {
3995
4114
  updateSelectedNode(initialFocusEventId);
3996
4115
  }
3997
4116
  }, [initialFocusEventId, updateSelectedNode]);
3998
- const onNodeClick = (0, import_react15.useCallback)((_event, node) => {
4117
+ const onNodeClick = (0, import_react17.useCallback)((_event, node) => {
3999
4118
  onEventSelect(node.data.event);
4000
4119
  updateSelectedNode(node.id);
4001
4120
  }, [onEventSelect, updateSelectedNode]);
4002
- return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(import_jsx_runtime134.Fragment, { children: [
4003
- spans.error && /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
4004
- import_material13.Alert,
4121
+ return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
4122
+ spans.error && /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
4123
+ import_material14.Alert,
4005
4124
  {
4006
- action: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_material13.Button, { onClick: () => {
4125
+ action: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_material14.Button, { onClick: () => {
4007
4126
  onRefresh();
4008
4127
  }, children: "Retry" }),
4009
4128
  severity: "error",
@@ -4014,8 +4133,8 @@ var TraceGraph = ({
4014
4133
  ]
4015
4134
  }
4016
4135
  ),
4017
- /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
4018
- import_react14.ReactFlow,
4136
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
4137
+ import_react16.ReactFlow,
4019
4138
  {
4020
4139
  "data-testid": "trace-graph",
4021
4140
  defaultViewport: { x: 0, y: 0, zoom: 1 },
@@ -4028,8 +4147,8 @@ var TraceGraph = ({
4028
4147
  onNodeClick,
4029
4148
  selectNodesOnDrag: false,
4030
4149
  children: [
4031
- /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_react14.Controls, { showInteractive: false }),
4032
- /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_react14.Background, {})
4150
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Controls, {}),
4151
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_react16.Background, {})
4033
4152
  ]
4034
4153
  }
4035
4154
  )
@@ -4037,7 +4156,7 @@ var TraceGraph = ({
4037
4156
  };
4038
4157
 
4039
4158
  // src/pages/trace-graph-page.tsx
4040
- var import_jsx_runtime135 = require("react/jsx-runtime");
4159
+ var import_jsx_runtime136 = require("react/jsx-runtime");
4041
4160
  var HEADER_HEIGHT = 56;
4042
4161
  var DRAWER_WIDTH = "35%";
4043
4162
  var Main = (0, import_styles.styled)("main", { shouldForwardProp: (property) => property !== "open" })(({ open, theme }) => ({
@@ -4055,7 +4174,7 @@ var Main = (0, import_styles.styled)("main", { shouldForwardProp: (property) =>
4055
4174
  })
4056
4175
  }
4057
4176
  }));
4058
- var StyledDrawer = (0, import_styles.styled)(import_material14.Drawer)(() => ({
4177
+ var StyledDrawer = (0, import_styles.styled)(import_material15.Drawer)(() => ({
4059
4178
  "& .MuiDrawer-paper": {
4060
4179
  bottom: 0,
4061
4180
  boxSizing: "border-box",
@@ -4073,10 +4192,10 @@ var TraceGraphPage = () => {
4073
4192
  const [searchParameters] = (0, import_react_router_dom2.useSearchParams)();
4074
4193
  const spanId = searchParameters.get("spanId");
4075
4194
  const api = useAppInspectorApi();
4076
- const [spans, setSpans] = (0, import_react17.useState)();
4077
- const [loading, setLoading] = (0, import_react17.useState)(false);
4078
- const [fetchError, setFetchError] = (0, import_react17.useState)();
4079
- const fetchSpans = (0, import_react17.useCallback)(async () => {
4195
+ const [spans, setSpans] = (0, import_react19.useState)();
4196
+ const [loading, setLoading] = (0, import_react19.useState)(false);
4197
+ const [fetchError, setFetchError] = (0, import_react19.useState)();
4198
+ const fetchSpans = (0, import_react19.useCallback)(async () => {
4080
4199
  setLoading(true);
4081
4200
  try {
4082
4201
  const response = await api.getSpans({
@@ -4091,14 +4210,14 @@ var TraceGraphPage = () => {
4091
4210
  setLoading(false);
4092
4211
  }
4093
4212
  }, [api, traceId]);
4094
- (0, import_react17.useEffect)(() => {
4213
+ (0, import_react19.useEffect)(() => {
4095
4214
  void fetchSpans();
4096
4215
  }, [fetchSpans]);
4097
- const [open, setOpen] = (0, import_react17.useState)(true);
4098
- const [selectedEvent, setSelectedEvent] = (0, import_react17.useState)();
4099
- const [viewPortPixelWidth, setViewPortPixelWidth] = (0, import_react17.useState)(0);
4216
+ const [open, setOpen] = (0, import_react19.useState)(true);
4217
+ const [selectedEvent, setSelectedEvent] = (0, import_react19.useState)();
4218
+ const [viewPortPixelWidth, setViewPortPixelWidth] = (0, import_react19.useState)(0);
4100
4219
  const { checkStatus, error: statusError, status } = useStatus();
4101
- const calculateDrawerWidth = (0, import_react17.useCallback)(() => {
4220
+ const calculateDrawerWidth = (0, import_react19.useCallback)(() => {
4102
4221
  const percentageMatch = /(\d+)%/.exec(DRAWER_WIDTH);
4103
4222
  if (percentageMatch && open) {
4104
4223
  const percentage = Number.parseInt(percentageMatch[1], 10);
@@ -4106,7 +4225,7 @@ var TraceGraphPage = () => {
4106
4225
  }
4107
4226
  return 0;
4108
4227
  }, [open]);
4109
- (0, import_react17.useEffect)(() => {
4228
+ (0, import_react19.useEffect)(() => {
4110
4229
  const updateViewportWidth = () => {
4111
4230
  const totalWidth = window.innerWidth;
4112
4231
  const drawerPixelWidth = open ? calculateDrawerWidth() : 0;
@@ -4120,22 +4239,22 @@ var TraceGraphPage = () => {
4120
4239
  clearTimeout(timeoutId);
4121
4240
  };
4122
4241
  }, [open, calculateDrawerWidth]);
4123
- const handleEventSelect = (0, import_react17.useCallback)((event) => {
4242
+ const handleEventSelect = (0, import_react19.useCallback)((event) => {
4124
4243
  setSelectedEvent(event);
4125
4244
  setOpen(true);
4126
4245
  }, []);
4127
- const handleRetry = (0, import_react17.useCallback)(() => {
4246
+ const handleRetry = (0, import_react19.useCallback)(() => {
4128
4247
  void checkStatus();
4129
4248
  }, [checkStatus]);
4130
4249
  const shouldShowStatusMessage = Boolean(statusError) || status?.status === "DISABLED";
4131
4250
  const navigate = (0, import_react_router_dom2.useNavigate)();
4132
4251
  const { resolveLink } = useAppInspector();
4133
- const navigateToSpansList = (0, import_react17.useCallback)(() => {
4252
+ const navigateToSpansList = (0, import_react19.useCallback)(() => {
4134
4253
  const url = resolveLink({ to: "spans-list" });
4135
4254
  navigate(url);
4136
4255
  }, [navigate, resolveLink]);
4137
- return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(
4138
- import_material14.Box,
4256
+ return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(
4257
+ import_material15.Box,
4139
4258
  {
4140
4259
  "data-testid": "trace-graph-page",
4141
4260
  sx: {
@@ -4147,14 +4266,14 @@ var TraceGraphPage = () => {
4147
4266
  overflow: "hidden"
4148
4267
  },
4149
4268
  children: [
4150
- /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_material14.Box, { sx: { display: "flex", width: "100%" }, children: [
4151
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_material14.Button, { onClick: () => {
4269
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_material15.Box, { sx: { display: "flex", width: "100%" }, children: [
4270
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_material15.Button, { onClick: () => {
4152
4271
  navigateToSpansList();
4153
- }, startIcon: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_icons_material6.ArrowBack, {}), children: "Go back" }),
4154
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_material14.Box, { sx: { flexGrow: 1 } })
4272
+ }, startIcon: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_icons_material7.ArrowBack, {}), children: "Go back" }),
4273
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_material15.Box, { sx: { flexGrow: 1 } })
4155
4274
  ] }),
4156
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
4157
- import_material14.Paper,
4275
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
4276
+ import_material15.Paper,
4158
4277
  {
4159
4278
  sx: {
4160
4279
  display: "flex",
@@ -4163,22 +4282,22 @@ var TraceGraphPage = () => {
4163
4282
  position: "relative",
4164
4283
  width: "100%"
4165
4284
  },
4166
- children: shouldShowStatusMessage ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
4285
+ children: shouldShowStatusMessage ? /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
4167
4286
  StatusMessage,
4168
4287
  {
4169
4288
  error: statusError,
4170
4289
  onRetry: handleRetry,
4171
4290
  status
4172
4291
  }
4173
- ) : /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
4174
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Main, { open, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
4175
- import_material14.Box,
4292
+ ) : /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)(import_jsx_runtime136.Fragment, { children: [
4293
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(Main, { open, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
4294
+ import_material15.Box,
4176
4295
  {
4177
4296
  sx: {
4178
4297
  height: "100%",
4179
4298
  overflow: "auto"
4180
4299
  },
4181
- children: traceId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_react16.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
4300
+ children: traceId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(import_react18.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(
4182
4301
  TraceGraph,
4183
4302
  {
4184
4303
  initialFocusEventId: spanId,
@@ -4196,7 +4315,7 @@ var TraceGraphPage = () => {
4196
4315
  ) })
4197
4316
  }
4198
4317
  ) }),
4199
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(StyledDrawer, { anchor: "right", open, variant: "persistent", children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(EventDetails, { selectedEvent }) })
4318
+ /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(StyledDrawer, { anchor: "right", open, variant: "persistent", children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(EventDetails, { selectedEvent }) })
4200
4319
  ] })
4201
4320
  }
4202
4321
  )