@hawtio/react
Version:
A Hawtio reimplementation based on TypeScript + React.
1,252 lines (1,080 loc) • 251 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
var _chunkUB6QWSAJjs = require('./chunk-UB6QWSAJ.js');
var _chunkS4RWX7OXjs = require('./chunk-S4RWX7OX.js');
require('./chunk-URJD3F2K.js');
var _chunkTM6OCU7Kjs = require('./chunk-TM6OCU7K.js');
var _chunkZYPGXT7Qjs = require('./chunk-ZYPGXT7Q.js');
// src/plugins/camel/Camel.tsx
var _reactcore = require('@patternfly/react-core');
var _cubesicon = require('@patternfly/react-icons/dist/esm/icons/cubes-icon');
var _reactsplit = require('react-split'); var _reactsplit2 = _interopRequireDefault(_reactsplit);
// src/plugins/camel/CamelContent.tsx
var _jolokiajs = require('jolokia.js'); var _jolokiajs2 = _interopRequireDefault(_jolokiajs);
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var _reactrouterdom = require('react-router-dom');
// src/plugins/camel/context.ts
function useCamelTree() {
const [tree, setTree] = _react.useState.call(void 0, _chunkTM6OCU7Kjs.MBeanTree.createEmpty(_chunkS4RWX7OXjs.pluginName));
const [loaded, setLoaded] = _react.useState.call(void 0, false);
const { selectedNode, setSelectedNode } = _react.useContext.call(void 0, _chunkTM6OCU7Kjs.PluginNodeSelectionContext);
const { pathname } = _reactrouterdom.useLocation.call(void 0, );
const navigate = _reactrouterdom.useNavigate.call(void 0, );
const refSelectedNode = _react.useRef.call(void 0, );
refSelectedNode.current = selectedNode;
const populateTree = async () => {
const wkspTree = await _chunkTM6OCU7Kjs.workspace.getTree();
const rootNode = wkspTree.find((node) => node.name === _chunkS4RWX7OXjs.jmxDomain);
if (rootNode && rootNode.children && rootNode.children.length > 0) {
const contextsNode = rootNode.getChildren()[0];
if (!contextsNode) {
return;
}
const subTree = _chunkTM6OCU7Kjs.MBeanTree.createFromNodes(_chunkS4RWX7OXjs.pluginName, contextsNode.getChildren());
setTree(subTree);
const path = [];
if (refSelectedNode.current && _chunkS4RWX7OXjs.hasDomain.call(void 0, refSelectedNode.current) && !_chunkS4RWX7OXjs.isDomainNode.call(void 0, refSelectedNode.current)) {
path.push(...refSelectedNode.current.path());
} else {
path.push(...contextsNode.path(), "routes");
}
const parentContext = _optionalChain([contextsNode, 'access', _2 => _2.children, 'optionalAccess', _3 => _3[0]]);
if (parentContext) {
parentContext.defaultExpanded = true;
_optionalChain([parentContext, 'access', _4 => _4.children, 'optionalAccess', _5 => _5.forEach, 'call', _6 => _6((child) => {
switch (child.name) {
case "routes":
case "endpoints":
case "components":
child.defaultExpanded = true;
break;
}
})]);
}
rootNode.forEach(path, (node) => {
const tvd = node;
tvd.defaultExpanded = true;
});
const newSelected = rootNode.navigate(...path);
if (newSelected) setSelectedNode(newSelected);
if (!pathname.startsWith(_chunkS4RWX7OXjs.pluginPath)) {
navigate(_chunkS4RWX7OXjs.pluginPath);
}
} else {
setTree(wkspTree);
navigate("/jmx");
_chunkZYPGXT7Qjs.eventService.notify({
type: "warning",
message: "No Camel domain detected in target. Redirecting to back to jmx."
});
}
};
_react.useEffect.call(void 0, () => {
const loadTree = async () => {
await populateTree();
setLoaded(true);
};
const listener = () => {
setLoaded(false);
loadTree();
};
_chunkZYPGXT7Qjs.eventService.onRefresh(listener);
loadTree();
return () => _chunkZYPGXT7Qjs.eventService.removeListener(_chunkZYPGXT7Qjs.EVENT_REFRESH, listener);
}, []);
return { tree, loaded, selectedNode, setSelectedNode };
}
var CamelContext = _react.createContext.call(void 0, {
tree: _chunkTM6OCU7Kjs.MBeanTree.createEmpty(_chunkS4RWX7OXjs.pluginName),
selectedNode: null,
setSelectedNode: () => {
}
});
// src/plugins/camel/contexts/Contexts.tsx
var _infocircleicon = require('@patternfly/react-icons/dist/esm/icons/info-circle-icon');
var _reacttable = require('@patternfly/react-table');
// src/plugins/camel/contexts/ContextToolbar.tsx
var _asleepicon = require('@patternfly/react-icons/dist/esm/icons/asleep-icon');
var _playicon = require('@patternfly/react-icons/dist/esm/icons/play-icon');
var _remove2icon = require('@patternfly/react-icons/dist/esm/icons/remove2-icon');
var _ellipsisvicon = require('@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon');
// src/plugins/camel/contexts/contexts-service.ts
var CONTEXT_STATE_STARTED = "Started";
var CONTEXT_STATE_SUSPENDED = "Suspended";
var CONTEXT_OPERATIONS = {
start: "start()",
suspend: "suspend()",
stop: "stop()"
};
var ContextsService = (_class = class {constructor() { _class.prototype.__init.call(this); }
__init() {this.handles = []}
toContextState(node, attributes) {
const state = _nullishCoalesce(_optionalChain([attributes, 'optionalAccess', _7 => _7["State"]]), () => ( "Not Found"));
return { node, state };
}
async getContext(contextNode) {
if (!contextNode.objectName) return null;
const attributes = await _chunkTM6OCU7Kjs.jolokiaService.readAttributes(contextNode.objectName);
return this.toContextState(contextNode, attributes);
}
async getContexts(contextsNode) {
const contextNodes = contextsNode.getChildren();
if (contextNodes.length === 0) return [];
const ctxAttributes = [];
for (const contextNode of contextNodes) {
if (!contextNode.objectName) {
continue;
}
const attributes = await _chunkTM6OCU7Kjs.jolokiaService.readAttributes(contextNode.objectName);
ctxAttributes.push(this.toContextState(contextNode, attributes));
}
return ctxAttributes;
}
async register(request, callback) {
const handle = await _chunkTM6OCU7Kjs.jolokiaService.register(request, callback);
_chunkS4RWX7OXjs.log.debug("Register handle:", handle);
this.handles.push(handle);
}
unregisterAll() {
_chunkS4RWX7OXjs.log.debug("Unregister all handles:", this.handles);
this.handles.forEach((handle) => _chunkTM6OCU7Kjs.jolokiaService.unregister(handle));
this.handles = [];
}
async startContext(context) {
await this.executeOperation(CONTEXT_OPERATIONS.start, context);
}
async suspendContext(context) {
await this.executeOperation(CONTEXT_OPERATIONS.suspend, context);
}
async stopContext(context) {
await this.executeOperation(CONTEXT_OPERATIONS.stop, context);
}
executeOperation(operation, context) {
const { objectName } = context.node;
if (!objectName) {
throw new Error("ObjectName for the context must be provided");
}
return _chunkTM6OCU7Kjs.jolokiaService.execute(objectName, operation);
}
}, _class);
var contextsService = new ContextsService();
// src/plugins/camel/contexts/ContextToolbar.tsx
var _jsxruntime = require('react/jsx-runtime');
var ContextToolbar = ({ contexts, deleteCallback }) => {
const [isDropdownOpen, setIsDropdownOpen] = _react.useState.call(void 0, false);
const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = _react.useState.call(void 0, false);
const [isDeleting, setIsDeleting] = _react.useState.call(void 0, false);
const firstContext = contexts[0];
const onDropdownToggle = (isOpen) => {
setIsDropdownOpen(isOpen);
};
const isStartEnabled = () => {
if (contexts.length === 0) return false;
return contexts.some((ctx) => ctx.state === CONTEXT_STATE_SUSPENDED);
};
const startContexts = () => {
contexts.filter((ctx) => ctx.state === CONTEXT_STATE_SUSPENDED).forEach(
(ctx) => contextsService.startContext(ctx).then(
() => _chunkZYPGXT7Qjs.eventService.notify({
type: "success",
message: "Camel context start requested"
})
).catch(
(error) => _chunkZYPGXT7Qjs.eventService.notify({
type: "danger",
message: `Camel context start failed: ${error}`
})
)
);
};
const isSuspendEnabled = () => {
if (contexts.length === 0) return false;
return contexts.some((ctx) => ctx.state === CONTEXT_STATE_STARTED);
};
const suspendContexts = () => {
contexts.filter((ctx) => ctx.state === CONTEXT_STATE_STARTED).forEach(
(ctx) => contextsService.suspendContext(ctx).then(
() => _chunkZYPGXT7Qjs.eventService.notify({
type: "success",
message: "Camel context suspension requested"
})
).catch(
(error) => _chunkZYPGXT7Qjs.eventService.notify({
type: "danger",
message: `Camel context suspension failed: ${error}`
})
)
);
};
const isDeleteEnabled = () => {
return contexts.length > 0;
};
const handleConfirmDeleteToggle = () => {
setIsConfirmDeleteOpen(!isConfirmDeleteOpen);
};
const onDeleteClicked = () => {
if (isDeleteEnabled()) {
setIsDropdownOpen(false);
handleConfirmDeleteToggle();
}
};
const onDeleteConfirmClicked = () => {
setIsDeleting(true);
};
const deleteContexts = async () => {
for (const ctx of contexts) {
try {
await contextsService.stopContext(ctx);
_chunkZYPGXT7Qjs.eventService.notify({
type: "success",
message: "Camel context deleted."
});
} catch (error) {
_chunkZYPGXT7Qjs.eventService.notify({
type: "danger",
message: `Camel context deletion failed: ${error}`
});
}
}
deleteCallback(contexts);
setIsDeleting(false);
_chunkTM6OCU7Kjs.workspace.refreshTree();
};
if (isDeleting) {
deleteContexts();
const title = `Deleting ${contexts.length > 1 ? "Contexts" : "Context"} ...`;
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Modal, { variant: _reactcore.ModalVariant.small, title, titleIconVariant: "warning", isOpen: isDeleting, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Skeleton, { screenreaderText: title }) });
}
const toolbarButtons = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Button,
{
variant: "primary",
size: "sm",
isDisabled: !(firstContext && firstContext.node.hasInvokeRights(CONTEXT_OPERATIONS.start)) || !isStartEnabled(),
icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _playicon.PlayIcon, {}),
onClick: startContexts,
children: "Start"
}
) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Button,
{
variant: "danger",
size: "sm",
isDisabled: !(firstContext && firstContext.node.hasInvokeRights(CONTEXT_OPERATIONS.suspend)) || !isSuspendEnabled(),
icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _asleepicon.AsleepIcon, {}),
onClick: suspendContexts,
children: "Suspend"
}
) })
] });
const ConfirmDeleteModal = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_reactcore.Modal,
{
variant: _reactcore.ModalVariant.small,
title: "Delete Camel Contexts",
titleIconVariant: "danger",
isOpen: isConfirmDeleteOpen,
onClose: handleConfirmDeleteToggle,
actions: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "danger", onClick: onDeleteConfirmClicked, children: "Delete" }, "delete"),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Button, { variant: "link", onClick: handleConfirmDeleteToggle, children: "Cancel" }, "cancel")
],
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: "You are about to delete this Camel Context." }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: "This operation cannot be undone so please be careful." })
]
}
);
const dropdownItems = [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
_reactcore.DropdownItem,
{
isDisabled: !(firstContext && firstContext.node.hasInvokeRights(CONTEXT_OPERATIONS.stop)) || !isDeleteEnabled(),
onClick: onDeleteClicked,
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _remove2icon.Remove2Icon, {}),
" Delete"
]
},
"delete"
)
];
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Toolbar, { id: "camel-contexts-toolbar", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.ToolbarContent, { children: [
toolbarButtons,
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.ToolbarItem, { id: "camel-contexts-toolbar-item-dropdown", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.Dropdown,
{
onSelect: () => onDropdownToggle(!isDropdownOpen),
onOpenChange: onDropdownToggle,
toggle: (toggleRef) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactcore.MenuToggle,
{
ref: toggleRef,
variant: "plain",
id: "camel-contexts-toolbar-item-dropdown-toggle",
onClick: () => onDropdownToggle(!isDropdownOpen),
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ellipsisvicon.EllipsisVIcon, {})
}
),
isOpen: isDropdownOpen,
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.DropdownList, { children: dropdownItems })
}
) })
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ConfirmDeleteModal, {})
] });
};
// src/plugins/camel/contexts/Contexts.tsx
var Contexts = () => {
const { selectedNode } = _react.useContext.call(void 0, CamelContext);
const [isReading, setIsReading] = _react.useState.call(void 0, true);
const [contexts, setContexts] = _react.useState.call(void 0, []);
const [selectedCtx, setSelectedCtx] = _react.useState.call(void 0, []);
const onSelectContext = (ctx, isSelecting) => {
const otherSelectedCtx = selectedCtx.filter((c) => c !== ctx.node.name);
setSelectedCtx(isSelecting ? [...otherSelectedCtx, ctx.node.name] : [...otherSelectedCtx]);
};
const selectAllContexts = (isSelecting = true) => {
setSelectedCtx(isSelecting ? contexts.map((c) => c.node.name) : []);
};
const isContextSelected = (ctx) => {
return selectedCtx.includes(ctx.node.name);
};
_react.useEffect.call(void 0, () => {
if (!selectedNode) return;
setIsReading(true);
const readAttributes = async () => {
try {
const ctxs = await contextsService.getContexts(selectedNode);
setContexts(ctxs);
} catch (error) {
_chunkZYPGXT7Qjs.eventService.notify({
type: "warning",
message: error
});
}
setIsReading(false);
};
readAttributes();
}, [selectedNode]);
_react.useEffect.call(void 0, () => {
if (!contexts || contexts.length === 0) return;
contexts.forEach((ctx, idx) => {
const { objectName } = ctx.node;
if (!objectName) {
return;
}
contextsService.register(
{ type: "read", mbean: objectName },
(r) => {
if (_jolokiajs2.default.isError(r)) {
_chunkS4RWX7OXjs.log.warn("Scheduler - Contexts (error):", r.error);
return;
}
_chunkS4RWX7OXjs.log.debug("Scheduler - Contexts:", r.value);
const attrs = r.value;
const newCtx = contextsService.toContextState(ctx.node, attrs);
const newContexts = [...contexts];
newContexts.splice(idx, 1, newCtx);
setContexts(newContexts);
}
);
});
return () => contextsService.unregisterAll();
}, [selectedNode, contexts]);
if (!selectedNode) {
return null;
}
if (isReading) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkTM6OCU7Kjs.HawtioLoadingCard, {});
}
if (contexts.length === 0) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.Card, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactcore.CardBody, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactcore.Text, { component: "p", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _infocircleicon.InfoCircleIcon, {}),
" This domain has no contexts."
] }) }) });
}
const handleDeletedContexts = (deleted) => {
const ctxs = contexts.filter((ctx) => !deleted.includes(ctx));
setContexts(ctxs);
};
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react2.default.Fragment, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
ContextToolbar,
{
contexts: contexts.filter((c) => selectedCtx.includes(c.node.name)),
deleteCallback: handleDeletedContexts
}
),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Table, { "aria-label": "Contexts", variant: "compact", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Thead, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reacttable.Th,
{
"aria-label": "select-header",
select: {
onSelect: (_event, isSelecting) => selectAllContexts(isSelecting),
isSelected: contexts.length === selectedCtx.length
}
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Th, { children: "Context" }, "context-header"),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Th, { children: "State" }, "state-header")
] }) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Tbody, { children: contexts.map((ctx, idx) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reacttable.Td,
{
select: {
rowIndex: idx,
onSelect: (_event, isSelecting) => onSelectContext(ctx, isSelecting),
isSelected: isContextSelected(ctx)
}
}
),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: ctx.node.name }, "context-" + idx),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: ctx.state }, "state-" + idx)
] }, ctx.node.name)) })
] })
] });
};
// src/util/arrays.ts
function compareArrays(a, b) {
if (a.length !== b.length) return false;
for (const v of a) {
if (!b.includes(v)) return false;
}
return true;
}
// src/plugins/camel/debug/Debug.tsx
var _banicon = require('@patternfly/react-icons/dist/esm/icons/ban-icon');
var _barsicon = require('@patternfly/react-icons/dist/esm/icons/bars-icon');
var _exclamationcircleicon = require('@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon');
var _longarrowaltdownicon = require('@patternfly/react-icons/dist/esm/icons/long-arrow-alt-down-icon');
var _minusicon = require('@patternfly/react-icons/dist/esm/icons/minus-icon');
var _pluscircleicon = require('@patternfly/react-icons/dist/esm/icons/plus-circle-icon');
var _plusicon = require('@patternfly/react-icons/dist/esm/icons/plus-icon');
var _timescircleicon = require('@patternfly/react-icons/dist/esm/icons/times-circle-icon');
// src/plugins/camel/route-diagram/RouteDiagram.tsx
var _reactflow = require('reactflow');
require('reactflow/dist/style.css');
// src/plugins/camel/camel-preferences-service.ts
var DEFAULT_OPTIONS = {
ignoreIdForLabel: false,
showInflightCounter: true,
maximumLabelWidth: 34,
maximumTraceOrDebugBodyLength: 5e3,
traceOrDebugIncludeStreams: false
};
var STORAGE_KEY_CAMEL_PREFERENCES = "camel.preferences";
var CamelPreferencesService = class {
loadOptions() {
return { ...DEFAULT_OPTIONS, ...this.loadFromStorage() };
}
saveOptions(newValues) {
const toSave = { ...this.loadFromStorage(), ...newValues };
localStorage.setItem(STORAGE_KEY_CAMEL_PREFERENCES, JSON.stringify(toSave));
}
loadFromStorage() {
const item = localStorage.getItem(STORAGE_KEY_CAMEL_PREFERENCES);
return item ? JSON.parse(item) : {};
}
};
var camelPreferencesService = new CamelPreferencesService();
// src/plugins/camel/route-diagram/context.ts
var noOpAction = (nodeData) => {
};
function useRouteDiagramContext() {
const [graphNodeData, setGraphNodeData] = _react.useState.call(void 0, []);
const [graphSelection, setGraphSelection] = _react.useState.call(void 0, "");
const [showStatistics, setShowStatistics] = _react.useState.call(void 0, true);
const [doubleClickAction, setDoubleClickAction] = _react.useState.call(void 0, noOpAction);
const [annotations, setAnnotations] = _react.useState.call(void 0, []);
return {
graphNodeData,
setGraphNodeData,
graphSelection,
setGraphSelection,
showStatistics,
setShowStatistics,
doubleClickAction,
setDoubleClickAction,
annotations,
setAnnotations
};
}
var RouteDiagramContext = _react.createContext.call(void 0, {
graphNodeData: [],
setGraphNodeData: (graphNodeData) => {
},
graphSelection: "",
setGraphSelection: (graphSelection) => {
},
showStatistics: true,
setShowStatistics: (value) => {
},
doubleClickAction: (nodeData) => {
},
setDoubleClickAction: (fn) => {
},
annotations: [],
setAnnotations: (annotations) => {
}
});
// src/plugins/camel/route-diagram/visualization-service.ts
var _dagre = require('dagre'); var _dagre2 = _interopRequireDefault(_dagre);
var VisualizationService = (_class2 = class {
__init2() {this.nodeWidth = 250}
__init3() {this.nodeHeight = 80}
__init4() {this.edgeType = "smoothstep"}
__init5() {this.margin = {
left: 25,
top: 25
}}
constructor() {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
this.dagreGraph = new _dagre2.default.graphlib.Graph();
this.dagreGraph.setDefaultEdgeLabel(() => ({}));
}
getLayoutedElements(nodes, edges, direction = "TB") {
const isHorizontal = direction === "LR";
this.dagreGraph.setGraph({ rankdir: direction });
nodes.forEach((node) => {
this.dagreGraph.setNode(node.id, { width: this.nodeWidth, height: this.nodeHeight });
});
edges.forEach((edge) => {
this.dagreGraph.setEdge(edge.source, edge.target);
});
_dagre2.default.layout(this.dagreGraph, { width: this.nodeWidth, height: this.nodeHeight });
nodes.forEach((node) => {
const nodeWithPosition = this.dagreGraph.node(node.id);
node.targetPosition = isHorizontal ? _reactflow.Position.Left : _reactflow.Position.Top;
node.sourcePosition = isHorizontal ? _reactflow.Position.Right : _reactflow.Position.Bottom;
node.position = {
x: nodeWithPosition.x - this.nodeWidth / 2 + this.margin.left,
y: nodeWithPosition.y - this.nodeHeight / 2 + this.margin.top
};
});
return { layoutedNodes: nodes, layoutedEdges: edges };
}
getRouteNodeUri(node) {
if (!node) {
return null;
}
const uri = node.getAttribute("uri");
if (uri) {
return uri;
}
const ref = node.getAttribute("ref");
if (!ref) {
return null;
}
const method = node.getAttribute("method");
return method ? `${ref}.${method}()` : `ref:${ref}`;
}
async loadRouteXmlNodes(node, xml, selectedRouteId) {
const nodes = [];
const edges = [];
const doc = _chunkS4RWX7OXjs.parseXML.call(void 0, xml);
const allRoutes = doc.getElementsByTagName("route");
for (const route of Array.from(allRoutes)) {
const routeId = route.id;
if (!selectedRouteId || !routeId || selectedRouteId === routeId) {
await this.addRouteXmlChildren(node, route, nodes, edges, routeId, "");
}
}
const camelNodes = nodes.map((node2) => ({
id: node2.id,
data: node2,
position: {
x: 0,
y: 0
},
type: "camel"
}));
edges.forEach((edge) => {
edge.markerEnd = { type: _reactflow.MarkerType.Arrow };
edge.type = this.edgeType;
edge.animated = true;
});
return { camelNodes, edges };
}
updateStats(statsXml, nodes) {
const stats = _chunkS4RWX7OXjs.routesService.processRoutesStats(statsXml);
return nodes.map((node) => {
const routeStat = stats.find((s) => s.id === node.data.routeId);
if (node.data.type === "from") {
const newData2 = { ...node.data, stats: routeStat };
return { ...node, data: newData2 };
}
const pStats = _optionalChain([routeStat, 'optionalAccess', _8 => _8.processorStats, 'access', _9 => _9.find, 'call', _10 => _10((p) => node.data.cid === p.id)]);
const newData = { ...node.data, stats: pStats };
return { ...node, data: newData };
});
}
async addRouteXmlChildren(node, parent, nodeDatas, links, routeId, parentId, parentNode = null) {
let rid = parent.getAttribute("id");
let siblingNodes = [];
const parentNodeName = parent.localName;
let routeIdx = -1;
for (const routeElement of Array.from(parent.children)) {
const id = nodeDatas.length + "";
routeIdx++;
const nodeId = routeElement.localName;
if (nodeId === "from" && parentId !== "-1") {
parentId = id;
}
const nodeSettings = await _chunkS4RWX7OXjs.schemaService.getSchema(node, nodeId);
let nodeData = null;
if (nodeSettings) {
let label = nodeSettings["title"] || nodeId;
const uri = this.getRouteNodeUri(routeElement);
if (uri) {
label += ` ${uri.split("?")[0]}`;
}
let tooltip = nodeSettings["tooltip"] || nodeSettings["description"] || label;
if (uri) {
tooltip += " " + uri;
}
const { ignoreIdForLabel, maximumLabelWidth } = camelPreferencesService.loadOptions();
const elementID = routeElement.getAttribute("id");
let labelSummary = label;
if (elementID) {
const customId = routeElement.getAttribute("customId");
if (ignoreIdForLabel || !customId || customId === "false") {
labelSummary = "id: " + elementID;
} else {
label = elementID;
}
}
const length = label.length;
if (length > maximumLabelWidth) {
labelSummary = label + "\n\n" + labelSummary;
label = label.substring(0, maximumLabelWidth) + "..";
}
const imageUrl = await _chunkS4RWX7OXjs.routesService.getIcon(node, nodeSettings);
if ((nodeId === "from" || nodeId === "to") && uri) {
const uriIdx = uri.indexOf(":");
if (uriIdx > 0) {
const componentScheme = uri.substring(0, uriIdx);
if (componentScheme) {
}
}
}
let cid = routeElement.getAttribute("_cid") || routeElement.getAttribute("id");
const parallelProcessing = _optionalChain([routeElement, 'access', _11 => _11.getAttribute, 'call', _12 => _12("parallelProcessing"), 'optionalAccess', _13 => _13.toLowerCase, 'call', _14 => _14()]) === "true";
nodeData = {
id,
routeIdx,
name: nodeId,
label,
labelSummary,
group: 1,
elementId: elementID,
imageUrl,
cid: _nullishCoalesce(cid, () => ( id)),
tooltip,
type: nodeId,
uri: _nullishCoalesce(uri, () => ( "")),
routeId,
isParallel: parallelProcessing
};
if (rid) {
nodeData.cid = rid;
}
if (!cid) {
cid = nodeId + (nodeDatas.length + 1);
}
if (cid) {
nodeData.cid = cid;
}
rid = null;
nodeDatas.push(nodeData);
const isParallelMulticastParent = parentNodeName === "multicast" && _optionalChain([parentNode, 'optionalAccess', _15 => _15.isParallel]) || false;
if (parentId !== null && parentId !== id) {
if (siblingNodes.length === 0 || parentNodeName === "choice" || isParallelMulticastParent) {
links.push({ id: parentId + "-" + id, source: parentId + "", target: id });
if (isParallelMulticastParent) {
siblingNodes.push(parseInt(id));
}
} else {
siblingNodes.forEach(function(nodeId2) {
if (nodeDatas[nodeId2].type !== "stop") {
links.push({ id: nodeId2 + "-" + id, source: nodeId2 + "", target: id });
}
});
siblingNodes.length = 0;
}
}
} else {
const langSettings = { name: "sfd" };
if (langSettings && parentNode) {
const name = langSettings["name"] || nodeId;
const text = routeElement.textContent;
if (text) {
parentNode.tooltip = parentNode.label + " " + name + " " + text;
parentNode.label += ": " + this.appendLabel(routeElement, text, true);
} else {
parentNode.label += ": " + this.appendLabel(routeElement, name, false);
}
}
}
const siblings = await this.addRouteXmlChildren(node, routeElement, nodeDatas, links, routeId, id, nodeData);
if (parentNodeName === "choice" || parentNodeName === "multicast" && _optionalChain([parentNode, 'optionalAccess', _16 => _16.isParallel])) {
siblingNodes = siblingNodes.concat(siblings);
} else if (nodeId === "aggregate" || nodeId === "choice" || nodeId === "delay" || nodeId === "filter" || nodeId === "loadBalance" || nodeId === "loop" || nodeId === "multicast" || nodeId === "resequence" || nodeId === "split" || nodeId === "doTry" || nodeId === "doCatch" || nodeId === "doFinally" || nodeId === "idempotentConsumer" || nodeId === "onCompletion") {
siblingNodes = siblings;
} else {
siblingNodes = [nodeDatas.length - 1];
}
}
return siblingNodes;
}
appendLabel(route, label, text) {
switch (route.localName) {
case "method":
if (!text) {
if (route.getAttribute("bean")) {
label += " " + route.getAttribute("bean");
} else if (route.getAttribute("ref")) {
label += " " + route.getAttribute("ref");
} else if (route.getAttribute("beanType")) {
label += " " + route.getAttribute("beanType");
}
}
if (route.getAttribute("method")) {
label += " " + route.getAttribute("method");
}
break;
default:
}
return label;
}
}, _class2);
var visualizationService = new VisualizationService();
// src/plugins/camel/route-diagram/RouteDiagram.tsx
var RouteDiagram = () => {
const canvasRef = _react.useRef.call(void 0, null);
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { id: "camel-route-diagram-outer-div", ref: canvasRef, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactflow.ReactFlowProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ReactFlowRouteDiagram, { parent: canvasRef }) }) });
};
var ReactFlowRouteDiagram = (props) => {
const { selectedNode } = _react.useContext.call(void 0, CamelContext);
const { setGraphNodeData, graphSelection, setGraphSelection } = _react.useContext.call(void 0, RouteDiagramContext);
const previousSelectedNodeRef = _react.useRef.call(void 0, null);
const [nodes, setNodes, onNodesChange] = _reactflow.useNodesState.call(void 0, []);
const [edges, setEdges, onEdgesChange] = _reactflow.useEdgesState.call(void 0, []);
const nodesInitialized = _reactflow.useNodesInitialized.call(void 0, { includeHiddenNodes: false });
const [wrapperDimensions, setWrapperDimensions] = _react.useState.call(void 0, { width: 0, height: 0 });
const { fitView } = _reactflow.useReactFlow.call(void 0, );
const [statsXml, setStatsXml] = _react.useState.call(void 0, "");
const nodeTypes = _react.useMemo.call(void 0, () => ({ camel: CamelNode }), []);
const onConnect = _react.useCallback.call(void 0,
(params) => setEdges((eds) => _reactflow.addEdge.call(void 0, { ...params, type: _reactflow.ConnectionLineType.SmoothStep, animated: true }, eds)),
[setEdges]
);
_react.useEffect.call(void 0, () => {
if (props.parent.current) {
const { width, height } = props.parent.current.getBoundingClientRect();
setWrapperDimensions({ width, height });
}
}, [props.parent]);
_react.useEffect.call(void 0, () => {
let timer;
if (nodesInitialized && wrapperDimensions.width > 0 && wrapperDimensions.height > 0) {
timer = setTimeout(() => {
fitView({
padding: 0.25,
// Keep some padding around the nodes
duration: 500
// Smooth transition
});
}, 100);
return;
}
return () => clearTimeout(timer);
}, [selectedNode, nodesInitialized, fitView, wrapperDimensions.width, wrapperDimensions.height]);
_react.useEffect.call(void 0, () => {
if (selectedNode === previousSelectedNodeRef.current) {
return;
}
previousSelectedNodeRef.current = selectedNode;
const xml = _optionalChain([selectedNode, 'optionalAccess', _17 => _17.getMetadata, 'call', _18 => _18("xml")]);
if (!selectedNode || !xml) {
setNodes([]);
setEdges([]);
return;
}
visualizationService.loadRouteXmlNodes(selectedNode, xml).then(({ camelNodes, edges: edges2 }) => {
setGraphNodeData(camelNodes.map((camelNode) => camelNode.data));
const { layoutedNodes, layoutedEdges } = visualizationService.getLayoutedElements(camelNodes, edges2);
layoutedNodes.forEach((node) => {
node.selected = graphSelection === node.data.cid;
});
setEdges(layoutedEdges);
setNodes(layoutedNodes);
}).catch((error) => {
_chunkS4RWX7OXjs.log.error(`Error loading the diagram route for ${selectedNode}:`, error);
setNodes([]);
setEdges([]);
});
}, [selectedNode, setEdges, setNodes, setGraphNodeData, graphSelection]);
_react.useEffect.call(void 0, () => {
if (!selectedNode) return;
const fetchStats = async () => {
try {
const xml = await _chunkS4RWX7OXjs.routesService.dumpRoutesStatsXML(selectedNode);
if (xml) {
setStatsXml(xml);
}
} catch (error) {
_chunkS4RWX7OXjs.log.error(`Error fetching stats in the diagram route for ${selectedNode}:`, error);
}
};
fetchStats();
const interval = setInterval(fetchStats, 2e3);
return () => clearInterval(interval);
}, [selectedNode]);
_react.useEffect.call(void 0, () => {
if (statsXml && nodes.length > 0) {
setNodes((nds) => visualizationService.updateStats(statsXml, nds));
}
}, [statsXml, setNodes, nodes.length]);
if (!selectedNode) {
return null;
}
const onNodeClick = (_event, node) => {
setGraphSelection(node.data.cid);
};
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "camel-route-diagram", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
_reactflow.ReactFlow,
{
nodeTypes,
nodes,
edges,
connectionLineType: _reactflow.ConnectionLineType.SmoothStep,
onNodesChange,
onEdgesChange,
onConnect,
elementsSelectable: true,
onNodeClick
}
) });
};
var CamelNode = ({
data,
selected,
sourcePosition,
targetPosition
}) => {
const { showStatistics, doubleClickAction, annotations } = _react.useContext.call(void 0, RouteDiagramContext);
const [isVisible, setVisible] = _react.useState.call(void 0, false);
const [showFull] = _react.useState.call(void 0, false);
const [annotation, setAnnotation] = _react.useState.call(void 0, void 0);
const { showInflightCounter } = camelPreferencesService.loadOptions();
_react.useEffect.call(void 0, () => {
if (!annotations || annotations.length === 0) {
setAnnotation(void 0);
return;
}
const ann = annotations.find((a) => a.nodeId === data.cid);
setAnnotation(ann);
}, [annotations, data.cid]);
const handleDoubleClick = (e) => {
if (!doubleClickAction) return;
doubleClickAction(data);
};
const truncate = (label) => {
const newline = label.indexOf("\n");
if (label.length < 20 && newline === -1) return label;
const newLabel = label.replace("\n", " ");
return newLabel.substring(0, 17) + "...";
};
const totalExchanges = parseInt(_nullishCoalesce(_optionalChain([data, 'access', _19 => _19.stats, 'optionalAccess', _20 => _20.exchangesCompleted]), () => ( "0"))) + parseInt(_nullishCoalesce(_optionalChain([data, 'access', _21 => _21.stats, 'optionalAccess', _22 => _22.exchangesInflight]), () => ( "0")));
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
"div",
{
className: "camel-node-content" + (selected ? " highlighted" : ""),
onMouseEnter: () => {
if (showStatistics) setVisible(true);
},
onMouseLeave: () => {
if (showStatistics) setVisible(false);
},
onDoubleClick: handleDoubleClick,
children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactflow.Handle, { type: "target", position: _nullishCoalesce(targetPosition, () => ( _reactflow.Position.Top)) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactflow.Handle, { type: "source", position: _nullishCoalesce(sourcePosition, () => ( _reactflow.Position.Bottom)), id: "a" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "annotation", children: _optionalChain([annotation, 'optionalAccess', _23 => _23.element]) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "icon", children: data.imageUrl }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "inflights", children: showInflightCounter && _optionalChain([data, 'access', _24 => _24.stats, 'optionalAccess', _25 => _25.exchangesInflight]) }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "number", children: totalExchanges }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "camel-node-label", children: truncate(data.label) }),
data.cid && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "camel-node-id", children: [
" (ID: ",
data.cid,
")"
] }),
showStatistics && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactflow.NodeToolbar, { isVisible, position: _reactflow.Position.Bottom, style: { marginTop: "-30px" }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "node-tooltip", children: [
!data.stats && data.label,
data.stats && !showFull && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Table, { variant: "compact", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tbody, { style: { fontSize: "xx-small" }, children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-odd-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "ID" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: data.stats.id })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-even-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Total" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: totalExchanges })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-odd-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Completed" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: _optionalChain([data, 'access', _26 => _26.stats, 'optionalAccess', _27 => _27.exchangesCompleted]) })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-even-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Inflight" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: _optionalChain([data, 'access', _28 => _28.stats, 'optionalAccess', _29 => _29.exchangesInflight]) })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-odd-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Last" }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: [
_optionalChain([data, 'access', _30 => _30.stats, 'optionalAccess', _31 => _31.lastProcessingTime]),
" (ms)"
] })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-even-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Mean" }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: [
_optionalChain([data, 'access', _32 => _32.stats, 'optionalAccess', _33 => _33.meanProcessingTime]),
" (ms)"
] })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-odd-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Min" }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: [
_optionalChain([data, 'access', _34 => _34.stats, 'optionalAccess', _35 => _35.minProcessingTime]),
" (ms)"
] })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { className: "node-tooltip-even-row", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: "Max" }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Td, { className: "node-tooltip-value", children: [
_optionalChain([data, 'access', _36 => _36.stats, 'optionalAccess', _37 => _37.maxProcessingTime]),
" (ms)"
] })
] })
] }) }),
data.stats && showFull && //TODO finish full statistics
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Table, { variant: "compact", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Tbody, { style: { fontSize: "xx-small" }, children: Object.entries(data.stats).map((s) => {
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reacttable.Tr, { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: s[0] }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reacttable.Td, { children: s[1] })
] }, s[0]);
}) }) })
] }) })
]
}
);
};
// src/plugins/camel/debug/ConditionalBreakpointModel.tsx
// src/plugins/camel/debug/debug-service.ts
var DebugService = (_class3 = class {constructor() { _class3.prototype.__init6.call(this); }
__init6() {this.handles = []}
async register(request, callback) {
const handle = await _chunkTM6OCU7Kjs.jolokiaService.register(request, callback);
_chunkS4RWX7OXjs.log.debug("Register handle:", handle);
this.handles.push(handle);
}
unregisterAll() {
_chunkS4RWX7OXjs.log.debug("Unregister all handles:", this.handles);
this.handles.forEach((handle) => _chunkTM6OCU7Kjs.jolokiaService.unregister(handle));
this.handles = [];
}
getDebugBean(node) {
const db = _chunkS4RWX7OXjs.findDebugBean.call(void 0, node);
if (!db || !db.objectName) _chunkS4RWX7OXjs.notifyError.call(void 0, "Could not find the debug bean");
return db;
}
async isDebugging(node) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return false;
const result = await _chunkTM6OCU7Kjs.jolokiaService.readAttribute(db.objectName, "Enabled");
if (!result) return false;
return result;
}
async setDebugging(node, flag) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return false;
const options = camelPreferencesService.loadOptions();
await _chunkTM6OCU7Kjs.jolokiaService.writeAttribute(db.objectName, "BodyMaxChars", options.maximumTraceOrDebugBodyLength);
await _chunkTM6OCU7Kjs.jolokiaService.writeAttribute(db.objectName, "BodyIncludeStreams", options.traceOrDebugIncludeStreams);
await _chunkTM6OCU7Kjs.jolokiaService.writeAttribute(db.objectName, "BodyIncludeFiles", options.traceOrDebugIncludeStreams);
const method = flag ? "enableDebugger" : "disableDebugger";
await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, method);
return await this.isDebugging(node);
}
async getBreakpoints(node) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return [];
const result = await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, _chunkS4RWX7OXjs.getBreakpointsOperation.call(void 0, node));
_chunkS4RWX7OXjs.log.debug("Debug - getBreakpoints:", result);
return result;
}
async addBreakpoint(node, breakpointId) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return false;
await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, "addBreakpoint", [breakpointId]);
const breakpoints = await this.getBreakpoints(node);
const added = breakpoints.includes(breakpointId);
if (added) _chunkS4RWX7OXjs.notifyInfo.call(void 0, "breakpoint created");
else _chunkS4RWX7OXjs.notifyError.call(void 0, "breakpoint could not be added");
return added;
}
async removeBreakpoint(node, breakpointId) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return false;
await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, "removeBreakpoint", [breakpointId]);
const breakpoints = await this.getBreakpoints(node);
const removed = !breakpoints.includes(breakpointId);
if (removed) _chunkS4RWX7OXjs.notifyInfo.call(void 0, "breakpoint removed");
else _chunkS4RWX7OXjs.notifyError.call(void 0, "breakpoint could not be removed");
return removed;
}
async validateConditionalBreakpoint(node, breakpoint) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return "Error: cannot find debugger bean";
const result = await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, "validateConditionalBreakpoint", [
breakpoint.language,
breakpoint.predicate
]);
return result;
}
async addConditionalBreakpoint(node, conditionalBreakpoint) {
_chunkS4RWX7OXjs.log.info("Add conditional breakpoint");
const db = this.getDebugBean(node);
if (!db || !db.objectName) return false;
await _chunkTM6OCU7Kjs.jolokiaService.execute(db.objectName, "addConditionalBreakpoint", [
conditionalBreakpoint.nodeId,
conditionalBreakpoint.language,
conditionalBreakpoint.predicate
]);
const breakpoints = await this.getBreakpoints(node);
const added = breakpoints.includes(conditionalBreakpoint.nodeId);
if (added) _chunkS4RWX7OXjs.notifyInfo.call(void 0, "conditional breakpoint created");
else _chunkS4RWX7OXjs.notifyError.call(void 0, "conditional breakpoint could not be added");
return added;
}
/*
* Return the current node id we are stopped at
*/
async getSuspendedBreakpointIds(node) {
const db = this.getDebugBean(node);
if (!db || !db.objectName) return [];
const result = await _chunkTM6OCU7Kjs.jolokiaService.execute(
db.objectName,
_chunkS4RWX7OXjs.getSuspendedBreakpointNodeIdsOperation.call(void 0, node)
);
return result;
}
async stepBreakpoint(node, breakpointId) {
const db = this.getDebugBean(node);
if (!db || !db.objec