@salesforce/metadata-plugins 1.0.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +2 -1
  3. package/dist/plugins/flexipage/FlexipageParser.d.ts +7 -1
  4. package/dist/plugins/flexipage/FlexipageParser.d.ts.map +1 -1
  5. package/dist/plugins/flexipage/FlexipageParser.js +13 -5
  6. package/dist/plugins/flexipage/transformer/FlexipageTransformerUtils.d.ts +1 -1
  7. package/dist/plugins/flexipage/transformer/FlexipageTransformerUtils.d.ts.map +1 -1
  8. package/dist/plugins/flexipage/ui/assets/index-DT5lcUwK.js +48 -0
  9. package/dist/plugins/flexipage/ui/index.html +1 -1
  10. package/dist/plugins/schema/SchemaParser.d.ts +9 -1
  11. package/dist/plugins/schema/SchemaParser.d.ts.map +1 -1
  12. package/dist/plugins/schema/SchemaParser.js +56 -18
  13. package/dist/plugins/schema/SchemaVisualizer.d.ts.map +1 -1
  14. package/dist/plugins/schema/SchemaVisualizer.js +3 -7
  15. package/dist/plugins/schema/types/SchemaERDData.d.ts +8 -0
  16. package/dist/plugins/schema/types/SchemaERDData.d.ts.map +1 -1
  17. package/dist/plugins/schema/ui/assets/index-DCLgZby3.css +1 -0
  18. package/dist/plugins/schema/ui/assets/index-jqcasNAD.js +70 -0
  19. package/dist/plugins/schema/ui/index.html +2 -2
  20. package/dist/shared/bootstrap/createPluginApp.d.ts +86 -0
  21. package/dist/shared/bootstrap/createPluginApp.d.ts.map +1 -0
  22. package/dist/shared/bootstrap/createPluginApp.js +281 -0
  23. package/dist/shared/components/ErrorBoundary.d.ts +35 -0
  24. package/dist/shared/components/ErrorBoundary.d.ts.map +1 -0
  25. package/dist/shared/components/ErrorBoundary.js +63 -0
  26. package/dist/shared/uem/transformer/TransformerRegistry.d.ts +0 -8
  27. package/dist/shared/uem/transformer/TransformerRegistry.d.ts.map +1 -1
  28. package/dist/shared/uem/transformer/TransformerRegistry.js +2 -16
  29. package/dist/shared/uem/transformer/UemBasedVisualizer.d.ts.map +1 -1
  30. package/dist/shared/uem/transformer/UemBasedVisualizer.js +3 -7
  31. package/dist/shared/uem/types/UemMetadata.d.ts +13 -2
  32. package/dist/shared/uem/types/UemMetadata.d.ts.map +1 -1
  33. package/dist/shared/uem/ui/components/PropertyRenderer/PropertyRenderer.d.ts +16 -0
  34. package/dist/shared/uem/ui/components/PropertyRenderer/PropertyRenderer.d.ts.map +1 -0
  35. package/dist/shared/uem/ui/components/PropertyRenderer/PropertyRenderer.js +194 -0
  36. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.d.ts +20 -0
  37. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.d.ts.map +1 -0
  38. package/dist/shared/uem/ui/components/UEMVisualization/UEMVisualization.js +381 -0
  39. package/dist/shared/utils/isPluginError.d.ts +11 -0
  40. package/dist/shared/utils/isPluginError.d.ts.map +1 -0
  41. package/dist/shared/utils/isPluginError.js +18 -0
  42. package/dist/shared/utils/patternMatcher.d.ts +34 -0
  43. package/dist/shared/utils/patternMatcher.d.ts.map +1 -0
  44. package/dist/shared/utils/patternMatcher.js +44 -0
  45. package/dist/shared/utils/uemTreeUtils.d.ts +2 -1
  46. package/dist/shared/utils/uemTreeUtils.d.ts.map +1 -1
  47. package/dist/shared/utils/uemTreeUtils.js +12 -6
  48. package/dist/shared/utils/vizDependentPathsHelper.d.ts +0 -9
  49. package/dist/shared/utils/vizDependentPathsHelper.d.ts.map +1 -1
  50. package/dist/shared/utils/vizDependentPathsHelper.js +3 -19
  51. package/package.json +5 -4
  52. package/dist/plugins/flexipage/ui/assets/index-DUDC29Wu.js +0 -55
  53. package/dist/plugins/schema/ui/assets/index-BbY653nW.js +0 -62
  54. package/dist/plugins/schema/ui/assets/index-CbNHuvPl.css +0 -1
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import React, { useState } from 'react';
8
+ import './PropertyRenderer.css';
9
+ export const PropertyRenderer = ({ name, value, depth = 0, }) => {
10
+ const [isExpanded, setIsExpanded] = useState(false);
11
+ const type = getValueType(value);
12
+ const renderValue = () => {
13
+ switch (type) {
14
+ case 'null':
15
+ case 'undefined':
16
+ return React.createElement(NullRenderer, null);
17
+ case 'boolean': {
18
+ // Handle both native boolean and string "true"/"false" from XML
19
+ const boolValue = typeof value === 'string'
20
+ ? value === 'true'
21
+ : value;
22
+ return React.createElement(BooleanRenderer, { value: boolValue });
23
+ }
24
+ case 'number': {
25
+ // Handle both native number and numeric string from XML
26
+ const numValue = typeof value === 'string'
27
+ ? parseFloat(value)
28
+ : value;
29
+ return Number.isNaN(numValue) ? React.createElement(NullRenderer, null) : React.createElement(NumberRenderer, { value: numValue });
30
+ }
31
+ case 'string':
32
+ return React.createElement(StringRenderer, { value: value });
33
+ case 'binding':
34
+ return React.createElement(BindingRenderer, { value: value });
35
+ case 'array':
36
+ return (React.createElement(ArrayRenderer, { value: value, isExpanded: isExpanded, onToggle: () => setIsExpanded(!isExpanded), depth: depth }));
37
+ case 'object':
38
+ return (React.createElement(ObjectRenderer, { value: value, isExpanded: isExpanded, onToggle: () => setIsExpanded(!isExpanded), depth: depth }));
39
+ default:
40
+ return React.createElement(DefaultRenderer, { value: value });
41
+ }
42
+ };
43
+ const isExpandable = type === 'object' || type === 'array';
44
+ const isPrimitive = !isExpandable;
45
+ // Generate item count badge for arrays/objects (both collapsed and expanded)
46
+ const getItemCountBadge = () => {
47
+ if (!isExpandable)
48
+ return null;
49
+ if (type === 'array') {
50
+ const arr = value;
51
+ const count = arr.length;
52
+ return count === 1 ? `${count} item` : `${count} items`;
53
+ }
54
+ if (type === 'object') {
55
+ const obj = value;
56
+ const count = Object.keys(obj).length;
57
+ return count === 1 ? `${count} property` : `${count} properties`;
58
+ }
59
+ return null;
60
+ };
61
+ return (React.createElement("div", { className: `property-renderer depth-${depth} ${isPrimitive ? 'inline' : 'block'}`, "data-type": type }, isPrimitive ? (
62
+ // Inline layout for primitives: "key: value" on same line
63
+ React.createElement("div", { className: "property-inline" },
64
+ React.createElement("span", { className: "property-name" }, name),
65
+ React.createElement("div", { className: "property-value-inline" }, renderValue()))) : (
66
+ // Block layout for complex types: header on one line, children indented below
67
+ React.createElement(React.Fragment, null,
68
+ React.createElement("div", { className: "property-header", onClick: () => setIsExpanded(!isExpanded), role: "button", tabIndex: 0, onKeyDown: (e) => {
69
+ if (e.key === 'Enter' || e.key === ' ') {
70
+ e.preventDefault();
71
+ setIsExpanded(!isExpanded);
72
+ }
73
+ }, "aria-expanded": isExpanded, "aria-label": `${isExpanded ? 'Collapse' : 'Expand'} ${name}` },
74
+ React.createElement("button", { className: "expand-toggle", tabIndex: -1, "aria-hidden": "true" }, isExpanded ? (React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" },
75
+ React.createElement("polyline", { points: "6 9 12 15 18 9" }))) : (React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" },
76
+ React.createElement("polyline", { points: "9 18 15 12 9 6" })))),
77
+ React.createElement("span", { className: "property-name" }, name),
78
+ getItemCountBadge() && (React.createElement("span", { className: "property-item-count" }, getItemCountBadge()))),
79
+ isExpanded && (React.createElement("div", { className: "property-value-block" }, renderValue()))))));
80
+ };
81
+ // ============================================================================
82
+ // Type Detection
83
+ // ============================================================================
84
+ /**
85
+ * Helper function to evaluate raw XML string values and determine semantic type
86
+ */
87
+ function detectTypeFromString(value) {
88
+ // Check for data binding first
89
+ if (value.includes('{!$'))
90
+ return 'binding';
91
+ // Check for boolean literals
92
+ if (value === 'true' || value === 'false')
93
+ return 'boolean';
94
+ // Check for numeric values (integer or float, including negative)
95
+ if (/^-?\d+\.?\d*$/.test(value) && value !== '')
96
+ return 'number';
97
+ // Everything else is a string
98
+ return 'string';
99
+ }
100
+ function getValueType(value) {
101
+ if (value === null)
102
+ return 'null';
103
+ if (value === undefined)
104
+ return 'undefined';
105
+ const jsType = typeof value;
106
+ if (jsType === 'boolean')
107
+ return 'boolean';
108
+ if (jsType === 'number')
109
+ return 'number';
110
+ if (jsType === 'string') {
111
+ // For string values from XML, detect their semantic type
112
+ return detectTypeFromString(value);
113
+ }
114
+ if (Array.isArray(value))
115
+ return 'array';
116
+ if (jsType === 'object')
117
+ return 'object';
118
+ return jsType;
119
+ }
120
+ // ============================================================================
121
+ // Primitive Type Renderers
122
+ // ============================================================================
123
+ function NullRenderer() {
124
+ return React.createElement("span", { className: "value-null" }, "null");
125
+ }
126
+ function BooleanRenderer({ value }) {
127
+ return (React.createElement("span", { className: `syntax-boolean ${value ? 'true' : 'false'}` },
128
+ React.createElement("span", { className: "boolean-icon" }, value ? '✓' : '✗'),
129
+ value ? 'true' : 'false'));
130
+ }
131
+ function NumberRenderer({ value }) {
132
+ return React.createElement("span", { className: "syntax-number" }, value.toLocaleString());
133
+ }
134
+ function StringRenderer({ value }) {
135
+ // Handle URLs
136
+ if (value.startsWith('http://') || value.startsWith('https://')) {
137
+ return (React.createElement("a", { href: value, target: "_blank", rel: "noopener noreferrer", className: "value-url" }, value));
138
+ }
139
+ // Regular string
140
+ return React.createElement("span", { className: "syntax-string" }, value);
141
+ }
142
+ function BindingRenderer({ value }) {
143
+ // Extract the binding expression - support various formats
144
+ const match = value.match(/\{!(\$[\w.]+)\}/);
145
+ const expression = match ? match[1] : value;
146
+ return (React.createElement("span", { className: "value-binding" },
147
+ React.createElement("span", { className: "binding-icon" }, "\u26A1"),
148
+ React.createElement("span", { className: "binding-expression" }, expression)));
149
+ }
150
+ function DefaultRenderer({ value }) {
151
+ return React.createElement("span", { className: "value-default" }, String(value));
152
+ }
153
+ function ArrayRenderer({ value, isExpanded, depth }) {
154
+ if (value.length === 0) {
155
+ return React.createElement("span", { className: "value-empty-array" }, "[ ]");
156
+ }
157
+ return (React.createElement("div", { className: "value-array" }, value.map((item, index) => (React.createElement(ArrayItemRenderer, { key: index, index: index, value: item, depth: depth + 1 })))));
158
+ }
159
+ function renderPrimitiveValue(value, type) {
160
+ switch (type) {
161
+ case 'boolean':
162
+ return React.createElement(BooleanRenderer, { value: typeof value === 'string' ? value === 'true' : value });
163
+ case 'number': {
164
+ const num = typeof value === 'string' ? parseFloat(value) : value;
165
+ return Number.isNaN(num) ? React.createElement(NullRenderer, null) : React.createElement(NumberRenderer, { value: num });
166
+ }
167
+ case 'string':
168
+ return React.createElement(StringRenderer, { value: value });
169
+ case 'binding':
170
+ return React.createElement(BindingRenderer, { value: value });
171
+ case 'null':
172
+ case 'undefined':
173
+ return React.createElement(NullRenderer, null);
174
+ default:
175
+ return React.createElement(DefaultRenderer, { value: value });
176
+ }
177
+ }
178
+ function ArrayItemRenderer({ index, value, depth }) {
179
+ const type = getValueType(value);
180
+ const isComplex = type === 'object' || type === 'array';
181
+ return (React.createElement("div", { className: "array-item" }, isComplex ? (React.createElement(PropertyRenderer, { name: `[${index}]`, value: value, depth: depth })) : (React.createElement("div", { className: "array-item-inline" },
182
+ React.createElement("span", { className: "array-index" },
183
+ "[",
184
+ index,
185
+ "]:"),
186
+ renderPrimitiveValue(value, type)))));
187
+ }
188
+ function ObjectRenderer({ value, isExpanded, depth }) {
189
+ const entries = Object.entries(value);
190
+ if (entries.length === 0) {
191
+ return React.createElement("span", { className: "value-empty-object" }, '{ }');
192
+ }
193
+ return (React.createElement("div", { className: "value-object" }, entries.map(([key, val]) => (React.createElement(PropertyRenderer, { key: key, name: key, value: val, depth: depth + 1 })))));
194
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import React from 'react';
8
+ import type { UemMetadata } from '../../../types/UemMetadata';
9
+ import './UEMVisualization.css';
10
+ import '../PropertyRenderer/PropertyRenderer.css';
11
+ interface VisualizationProps {
12
+ data: UemMetadata;
13
+ context: {
14
+ filePath: string;
15
+ fileName: string;
16
+ };
17
+ }
18
+ export default function UEMVisualization({ data, context }: VisualizationProps): React.JSX.Element;
19
+ export {};
20
+ //# sourceMappingURL=UEMVisualization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UEMVisualization.d.ts","sourceRoot":"","sources":["../../../../../../src/shared/uem/ui/components/UEMVisualization/UEMVisualization.tsx"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAkE,MAAM,OAAO,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAkC,MAAM,4BAA4B,CAAC;AAG9F,OAAO,wBAAwB,CAAC;AAChC,OAAO,0CAA0C,CAAC;AAElD,UAAU,kBAAkB;IAC1B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAUD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,kBAAkB,qBA4B7E"}
@@ -0,0 +1,381 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import React, { useState, memo, useCallback, useMemo, useRef, useEffect } from 'react';
8
+ import { PropertyRenderer } from '../PropertyRenderer/PropertyRenderer';
9
+ import { convertToTreeNode, formatFieldLabel, formatFieldValue, findNodeById } from '../../../../utils/uemTreeUtils';
10
+ import './UEMVisualization.css';
11
+ import '../PropertyRenderer/PropertyRenderer.css';
12
+ export default function UEMVisualization({ data, context }) {
13
+ const [selectedNode, setSelectedNode] = useState(null);
14
+ const handleSelectNode = useCallback((node) => {
15
+ setSelectedNode(node);
16
+ }, []);
17
+ const fragment = data.fragment;
18
+ const metadata = data.metadata;
19
+ return (React.createElement("div", { className: "uem-visualizer" },
20
+ React.createElement(OverviewPanel, { fragment: fragment, metadata: metadata }),
21
+ React.createElement("div", { className: "visualizer-main" },
22
+ React.createElement(StructureTree, { fragment: fragment, selectedNode: selectedNode, onSelectNode: handleSelectNode }),
23
+ React.createElement(DetailsPanel, { selectedNode: selectedNode }))));
24
+ }
25
+ function OverviewPanel({ fragment, metadata }) {
26
+ const rootAttributes = fragment.attributes || {};
27
+ const allFields = Object.entries(rootAttributes);
28
+ const label = String(rootAttributes.label || rootAttributes.masterLabel || '');
29
+ const apiName = String(rootAttributes.apiName || rootAttributes.name || '');
30
+ const primaryFields = ['label', 'masterLabel', 'apiName', 'name', 'type'];
31
+ const secondaryFields = allFields.filter(([key]) => !primaryFields.includes(key));
32
+ if (allFields.length === 0) {
33
+ return (React.createElement("div", { className: "overview-panel", role: "banner" },
34
+ React.createElement("div", { className: "overview-header-left" },
35
+ React.createElement("svg", { className: "header-icon", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
36
+ React.createElement("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
37
+ React.createElement("line", { x1: "3", y1: "9", x2: "21", y2: "9" }),
38
+ React.createElement("line", { x1: "9", y1: "9", x2: "9", y2: "21" })),
39
+ React.createElement("div", { className: "overview-identity-stack" },
40
+ React.createElement("h2", { className: "overview-main-title" }, "FlexiPage Visualization"),
41
+ React.createElement("p", { className: "overview-subtitle" }, metadata.sourceType))),
42
+ React.createElement("div", { className: "overview-header-right" },
43
+ React.createElement("div", { className: "overview-badge" },
44
+ React.createElement("span", { className: "badge-label" }, "Components:"),
45
+ React.createElement("span", { className: "badge-value" }, metadata.blockCount)))));
46
+ }
47
+ return (React.createElement("div", { className: "overview-panel", role: "banner" },
48
+ React.createElement("div", { className: "overview-header-left" },
49
+ React.createElement("svg", { className: "header-icon", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
50
+ React.createElement("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
51
+ React.createElement("line", { x1: "3", y1: "9", x2: "21", y2: "9" }),
52
+ React.createElement("line", { x1: "9", y1: "9", x2: "9", y2: "21" })),
53
+ React.createElement("div", { className: "overview-identity-stack" },
54
+ React.createElement("h2", { className: "overview-main-title" }, label || apiName || 'FlexiPage'),
55
+ label && apiName && label !== apiName && (React.createElement("p", { className: "overview-subtitle" }, apiName)))),
56
+ secondaryFields.length > 0 && (React.createElement("div", { className: "overview-header-right" }, secondaryFields.map(([key, value]) => (React.createElement("div", { key: key, className: "overview-badge" },
57
+ React.createElement("span", { className: "badge-label" },
58
+ formatFieldLabel(key),
59
+ ":"),
60
+ React.createElement("span", { className: "badge-value mv-truncate" }, formatFieldValue(value)))))))));
61
+ }
62
+ function StructureTree({ fragment, selectedNode, onSelectNode }) {
63
+ const treeContainerRef = useRef(null);
64
+ const [collapseKey, setCollapseKey] = useState(0);
65
+ const rootNode = useMemo(() => convertToTreeNode(fragment, 'root'), [fragment]);
66
+ const dataProviderNodes = useMemo(() => (fragment.dataProviders || []).map((dp, index) => ({
67
+ id: `dp-${index}`,
68
+ type: 'dataProvider',
69
+ definition: dp.definition,
70
+ name: dp.expressionKey,
71
+ attributes: dp.attributes
72
+ })), [fragment.dataProviders]);
73
+ const [focusedNodeId, setFocusedNodeId] = useState(null);
74
+ // Select the root node by default on initial load
75
+ useEffect(() => {
76
+ if (!selectedNode && rootNode) {
77
+ onSelectNode(rootNode);
78
+ }
79
+ }, [selectedNode, rootNode, onSelectNode]);
80
+ const findNodeByIdInTree = useCallback((nodeId) => {
81
+ return findNodeById(nodeId, [...dataProviderNodes, rootNode]);
82
+ }, [dataProviderNodes, rootNode]);
83
+ const getTreeItems = useCallback(() => {
84
+ if (!treeContainerRef.current)
85
+ return [];
86
+ return Array.from(treeContainerRef.current.querySelectorAll('[role="treeitem"]'));
87
+ }, []);
88
+ useEffect(() => {
89
+ const treeItems = getTreeItems();
90
+ if (treeItems.length === 0) {
91
+ if (focusedNodeId !== null) {
92
+ setFocusedNodeId(null);
93
+ }
94
+ return;
95
+ }
96
+ if (!focusedNodeId)
97
+ return;
98
+ const stillVisible = treeItems.some(item => item.getAttribute('data-node-id') === focusedNodeId);
99
+ if (!stillVisible) {
100
+ const firstId = treeItems[0].getAttribute('data-node-id');
101
+ if (firstId) {
102
+ setFocusedNodeId(firstId);
103
+ }
104
+ }
105
+ }, [focusedNodeId, dataProviderNodes, rootNode, getTreeItems]);
106
+ const handleKeyDown = useCallback((e) => {
107
+ const treeItems = getTreeItems();
108
+ const currentIndex = focusedNodeId
109
+ ? treeItems.findIndex(item => item.getAttribute('data-node-id') === focusedNodeId)
110
+ : -1;
111
+ const currentItem = currentIndex >= 0 ? treeItems[currentIndex] : null;
112
+ switch (e.key) {
113
+ case 'ArrowDown':
114
+ e.preventDefault();
115
+ if (currentIndex >= 0 && currentIndex < treeItems.length - 1) {
116
+ const nextId = treeItems[currentIndex + 1].getAttribute('data-node-id');
117
+ if (!nextId)
118
+ break;
119
+ setFocusedNodeId(nextId);
120
+ treeItems[currentIndex + 1].focus();
121
+ }
122
+ break;
123
+ case 'ArrowUp':
124
+ e.preventDefault();
125
+ if (currentIndex > 0) {
126
+ const prevId = treeItems[currentIndex - 1].getAttribute('data-node-id');
127
+ if (!prevId)
128
+ break;
129
+ setFocusedNodeId(prevId);
130
+ treeItems[currentIndex - 1].focus();
131
+ }
132
+ break;
133
+ case 'ArrowRight':
134
+ e.preventDefault();
135
+ if (focusedNodeId && currentItem) {
136
+ const { node } = findNodeByIdInTree(focusedNodeId);
137
+ const hasChildren = !!(node && node.children && node.children.length > 0);
138
+ if (hasChildren) {
139
+ const isExpanded = currentItem.getAttribute('aria-expanded') === 'true';
140
+ if (!isExpanded) {
141
+ const expandBtn = currentItem.querySelector('.expand-button');
142
+ expandBtn?.click();
143
+ }
144
+ else {
145
+ const currentLevel = Number(currentItem.getAttribute('aria-level') || '0');
146
+ const nextItem = treeItems[currentIndex + 1];
147
+ if (!nextItem)
148
+ break;
149
+ const nextLevel = Number(nextItem.getAttribute('aria-level') || '0');
150
+ if (nextLevel === currentLevel + 1) {
151
+ const childId = nextItem.getAttribute('data-node-id');
152
+ if (!childId)
153
+ break;
154
+ setFocusedNodeId(childId);
155
+ nextItem.focus();
156
+ }
157
+ }
158
+ }
159
+ }
160
+ break;
161
+ case 'ArrowLeft':
162
+ e.preventDefault();
163
+ if (focusedNodeId && currentItem) {
164
+ const { node, parent } = findNodeByIdInTree(focusedNodeId);
165
+ const hasChildren = !!(node && node.children && node.children.length > 0);
166
+ if (hasChildren) {
167
+ const isExpanded = currentItem.getAttribute('aria-expanded') === 'true';
168
+ if (isExpanded) {
169
+ const expandBtn = currentItem.querySelector('.expand-button');
170
+ expandBtn?.click();
171
+ break;
172
+ }
173
+ }
174
+ if (parent) {
175
+ setFocusedNodeId(parent.id);
176
+ const parentElement = treeContainerRef.current?.querySelector(`[data-node-id="${parent.id}"]`);
177
+ parentElement?.focus();
178
+ }
179
+ }
180
+ break;
181
+ case 'Enter':
182
+ e.preventDefault();
183
+ if (focusedNodeId) {
184
+ const { node } = findNodeByIdInTree(focusedNodeId);
185
+ if (node) {
186
+ onSelectNode(node);
187
+ }
188
+ }
189
+ break;
190
+ case ' ':
191
+ e.preventDefault();
192
+ if (focusedNodeId) {
193
+ if (selectedNode?.id === focusedNodeId) {
194
+ onSelectNode(null);
195
+ }
196
+ else {
197
+ const { node } = findNodeByIdInTree(focusedNodeId);
198
+ if (node) {
199
+ onSelectNode(node);
200
+ }
201
+ }
202
+ }
203
+ break;
204
+ }
205
+ }, [focusedNodeId, getTreeItems, findNodeByIdInTree, onSelectNode, selectedNode]);
206
+ const handleCollapseAll = useCallback(() => {
207
+ setCollapseKey(prev => prev + 1);
208
+ }, []);
209
+ const handleTreeFocus = useCallback(() => {
210
+ if (focusedNodeId)
211
+ return;
212
+ const treeItems = getTreeItems();
213
+ if (treeItems.length === 0)
214
+ return;
215
+ const firstId = treeItems[0].getAttribute('data-node-id');
216
+ if (firstId) {
217
+ setFocusedNodeId(firstId);
218
+ }
219
+ }, [focusedNodeId, getTreeItems]);
220
+ const handleTreeBlur = useCallback((e) => {
221
+ const nextTarget = e.relatedTarget;
222
+ if (!nextTarget || !e.currentTarget.contains(nextTarget)) {
223
+ setFocusedNodeId(null);
224
+ }
225
+ }, []);
226
+ return (React.createElement("div", { className: "structure-tree" },
227
+ React.createElement("div", { className: "structure-tree-header" },
228
+ React.createElement("h3", null, "Structure"),
229
+ React.createElement("button", { className: "collapse-all-button", onClick: handleCollapseAll, "data-tooltip": "Collapse all nodes", "aria-label": "Collapse all nodes" },
230
+ React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true" },
231
+ React.createElement("path", { d: "M9 9H4v1h5V9z" }),
232
+ React.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M5 3l1-1h7l1 1v7l-1 1h-2v2l-1 1H3l-1-1V6l1-1h2V3zm1 2h4l1 1v4h2V3H6v2zm4 1H3v7h7V6z" })))),
233
+ React.createElement("div", { className: "tree-content", ref: treeContainerRef, onKeyDown: handleKeyDown, onFocus: handleTreeFocus, onBlur: handleTreeBlur, role: "tree", "aria-label": "Component structure tree", tabIndex: 0 },
234
+ React.createElement("div", { className: "tree-scroll-inner" },
235
+ dataProviderNodes.length > 0 && (React.createElement("div", { className: "data-providers-section" },
236
+ React.createElement("div", { className: "section-header" },
237
+ React.createElement("svg", { width: "9", height: "9", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", "aria-hidden": "true" },
238
+ React.createElement("ellipse", { cx: "12", cy: "5", rx: "9", ry: "3" }),
239
+ React.createElement("path", { d: "M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" }),
240
+ React.createElement("path", { d: "M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" })),
241
+ React.createElement("span", null,
242
+ "Data Providers (",
243
+ dataProviderNodes.length,
244
+ ")")),
245
+ dataProviderNodes.map((node) => (React.createElement(TreeNodeComponent, { key: node.id, node: node, depth: 1, selectedNodeId: selectedNode?.id || null, focusedNodeId: focusedNodeId, onSelectNode: onSelectNode, onFocusNode: setFocusedNodeId, collapseKey: collapseKey }))))),
246
+ React.createElement(TreeNodeComponent, { node: rootNode, depth: 0, selectedNodeId: selectedNode?.id || null, focusedNodeId: focusedNodeId, onSelectNode: onSelectNode, onFocusNode: setFocusedNodeId, collapseKey: collapseKey })))));
247
+ }
248
+ const TreeNodeComponent = memo(({ node, depth, selectedNodeId, focusedNodeId, onSelectNode, onFocusNode, collapseKey }) => {
249
+ const [isExpanded, setIsExpanded] = useState(depth < 2);
250
+ const hasChildren = node.children && node.children.length > 0;
251
+ const isSelected = node.id === selectedNodeId;
252
+ const isFocused = node.id === focusedNodeId;
253
+ const nodeRef = useRef(null);
254
+ useEffect(() => {
255
+ if (isFocused && nodeRef.current) {
256
+ nodeRef.current.focus();
257
+ }
258
+ }, [isFocused]);
259
+ useEffect(() => {
260
+ if (collapseKey > 0) {
261
+ setIsExpanded(false);
262
+ }
263
+ }, [collapseKey]);
264
+ const getIconClass = () => {
265
+ switch (node.type) {
266
+ case 'block':
267
+ return 'component';
268
+ case 'field':
269
+ return 'field';
270
+ case 'region':
271
+ case 'dataProvider':
272
+ default:
273
+ return 'structural';
274
+ }
275
+ };
276
+ const getIcon = () => {
277
+ switch (node.type) {
278
+ case 'block':
279
+ return (React.createElement("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
280
+ React.createElement("path", { d: "M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z" }),
281
+ React.createElement("path", { d: "m3.3 7 8.7 5 8.7-5" }),
282
+ React.createElement("path", { d: "M12 22V12" })));
283
+ case 'region':
284
+ return (React.createElement("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
285
+ React.createElement("path", { d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" }),
286
+ React.createElement("path", { d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" }),
287
+ React.createElement("path", { d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" })));
288
+ case 'field':
289
+ return (React.createElement("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
290
+ React.createElement("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
291
+ React.createElement("line", { x1: "7", y1: "8", x2: "17", y2: "8" }),
292
+ React.createElement("line", { x1: "7", y1: "12", x2: "17", y2: "12" }),
293
+ React.createElement("line", { x1: "7", y1: "16", x2: "13", y2: "16" })));
294
+ case 'dataProvider':
295
+ return (React.createElement("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
296
+ React.createElement("ellipse", { cx: "12", cy: "5", rx: "9", ry: "3" }),
297
+ React.createElement("path", { d: "M21 12c0 1.66-4 3-9 3s-9-1.34-9-3" }),
298
+ React.createElement("path", { d: "M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5" })));
299
+ default:
300
+ return (React.createElement("svg", { width: "11", height: "11", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" },
301
+ React.createElement("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" })));
302
+ }
303
+ };
304
+ const getLabel = () => {
305
+ if (node.definition)
306
+ return node.definition;
307
+ if (node.name)
308
+ return node.name;
309
+ return node.type;
310
+ };
311
+ const handleClick = useCallback(() => {
312
+ onSelectNode(node);
313
+ onFocusNode(node.id);
314
+ if (hasChildren) {
315
+ setIsExpanded(prev => !prev);
316
+ }
317
+ }, [node, onSelectNode, onFocusNode, hasChildren]);
318
+ const handleToggle = useCallback((e) => {
319
+ e.stopPropagation();
320
+ setIsExpanded(prev => !prev);
321
+ }, []);
322
+ const handleFocus = useCallback(() => {
323
+ onFocusNode(node.id);
324
+ }, [node.id, onFocusNode]);
325
+ const indentWidth = depth * 12;
326
+ return (React.createElement("div", { className: "tree-node-wrapper" },
327
+ React.createElement("div", { ref: nodeRef, className: `tree-node ${isSelected ? 'selected' : ''} ${isFocused ? 'focused' : ''}`, onClick: handleClick, onFocus: handleFocus, tabIndex: isFocused ? 0 : -1, role: "treeitem", "aria-level": depth + 1, "aria-selected": isSelected, "aria-expanded": hasChildren ? isExpanded : undefined, "aria-label": `${getLabel()} (${node.type})`, "data-node-id": node.id },
328
+ indentWidth > 0 && React.createElement("div", { className: "indent-spacer", style: { width: `${indentWidth}px` } }),
329
+ React.createElement("div", { className: "node-content" },
330
+ hasChildren && (React.createElement("button", { className: "expand-button", onClick: handleToggle, tabIndex: -1, "aria-label": isExpanded ? 'Collapse' : 'Expand' }, isExpanded ? (React.createElement("svg", { width: "9", height: "9", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", "aria-hidden": "true" },
331
+ React.createElement("polyline", { points: "6 9 12 15 18 9" }))) : (React.createElement("svg", { width: "9", height: "9", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", "aria-hidden": "true" },
332
+ React.createElement("polyline", { points: "9 18 15 12 9 6" }))))),
333
+ !hasChildren && React.createElement("span", { className: "expand-spacer" }),
334
+ React.createElement("span", { className: `node-icon ${getIconClass()}` }, getIcon()),
335
+ React.createElement("span", { className: "node-label" }, getLabel()))),
336
+ hasChildren && isExpanded && (React.createElement("div", { className: "tree-children", role: "group" }, node.children.map((child) => (React.createElement(TreeNodeComponent, { key: child.id, node: child, depth: depth + 1, selectedNodeId: selectedNodeId, focusedNodeId: focusedNodeId, onSelectNode: onSelectNode, onFocusNode: onFocusNode, collapseKey: collapseKey })))))));
337
+ }, (prevProps, nextProps) => {
338
+ const wasSelected = prevProps.selectedNodeId === prevProps.node.id;
339
+ const isNowSelected = nextProps.selectedNodeId === nextProps.node.id;
340
+ const wasFocused = prevProps.focusedNodeId === prevProps.node.id;
341
+ const isNowFocused = nextProps.focusedNodeId === nextProps.node.id;
342
+ if (wasSelected !== isNowSelected || wasFocused !== isNowFocused) {
343
+ return false;
344
+ }
345
+ if (prevProps.collapseKey !== nextProps.collapseKey) {
346
+ return false;
347
+ }
348
+ return prevProps.node === nextProps.node &&
349
+ prevProps.depth === nextProps.depth &&
350
+ prevProps.selectedNodeId === nextProps.selectedNodeId &&
351
+ prevProps.focusedNodeId === nextProps.focusedNodeId &&
352
+ prevProps.onSelectNode === nextProps.onSelectNode &&
353
+ prevProps.onFocusNode === nextProps.onFocusNode;
354
+ });
355
+ function DetailsPanel({ selectedNode }) {
356
+ const emptyMessage = 'Select a node to view details';
357
+ if (!selectedNode) {
358
+ return (React.createElement("div", { className: "details-panel" },
359
+ React.createElement("div", { className: "details-panel-header" },
360
+ React.createElement("h3", null, "Details")),
361
+ React.createElement("div", { className: "details-content" },
362
+ React.createElement("p", { className: "details-empty" }, emptyMessage))));
363
+ }
364
+ const getNodeTitle = () => {
365
+ if (selectedNode.definition)
366
+ return selectedNode.definition;
367
+ if (selectedNode.name)
368
+ return selectedNode.name;
369
+ return selectedNode.type;
370
+ };
371
+ const hasAttributes = selectedNode.attributes && Object.keys(selectedNode.attributes).length > 0;
372
+ return (React.createElement("div", { className: "details-panel" },
373
+ React.createElement("div", { className: "details-panel-header" },
374
+ React.createElement("h3", null, "Details"),
375
+ React.createElement("div", { className: "details-badge" },
376
+ React.createElement("span", { className: "badge-value mv-truncate" }, getNodeTitle()))),
377
+ React.createElement("div", { className: "details-content-filled" },
378
+ hasAttributes && (React.createElement("div", { className: "details-attributes" }, Object.entries(selectedNode.attributes).map(([key, value]) => (React.createElement(PropertyRenderer, { key: key, name: key, value: value, depth: 0 }))))),
379
+ !hasAttributes && (React.createElement("div", { className: "details-section" },
380
+ React.createElement("p", { className: "no-details" }, "No additional details available"))))));
381
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ /**
8
+ * Check if an error is a categorized PluginError (has a valid `category` field)
9
+ */
10
+ export declare function isPluginError(error: unknown): boolean;
11
+ //# sourceMappingURL=isPluginError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPluginError.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/isPluginError.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAMJ;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQrD"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2025, Salesforce, Inc.
3
+ * All rights reserved.
4
+ * Licensed under the BSD 3-Clause license.
5
+ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6
+ **/
7
+ import { ErrorCategory } from '@salesforce/metadata-core-sdk';
8
+ const ERROR_CATEGORY_VALUES = new Set(Object.values(ErrorCategory));
9
+ /**
10
+ * Check if an error is a categorized PluginError (has a valid `category` field)
11
+ */
12
+ export function isPluginError(error) {
13
+ return (typeof error === 'object' &&
14
+ error !== null &&
15
+ 'category' in error &&
16
+ typeof error.category === 'string' &&
17
+ ERROR_CATEGORY_VALUES.has(error.category));
18
+ }