bricks-builder-mcp 3.6.3 → 3.6.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/server.js +52 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "bricks-builder-mcp",
4
- "version": "3.6.3",
4
+ "version": "3.6.4",
5
5
  "description": "Serveur MCP pour piloter Bricks Builder (WordPress) depuis Claude — édition de pages, gestion d'éléments, réordonnancement des sections, vérification visuelle + technique (verify_element).",
6
6
  "main": "server.js",
7
7
  "bin": {
package/server.js CHANGED
@@ -83,12 +83,49 @@ process.on('SIGINT', () => {
83
83
  process.exit(0);
84
84
  });
85
85
 
86
- // Normaliser les valeurs CSS pour comparaison (rgba/spaces/units)
86
+ // Hex rgb/rgba pour matcher getComputedStyle qui renvoie toujours rgb()
87
+ function hexToRgb(hex) {
88
+ hex = hex.replace('#', '');
89
+ if (hex.length === 3) {
90
+ hex = hex.split('').map(c => c + c).join('');
91
+ }
92
+ if (hex.length !== 6 && hex.length !== 8) return null;
93
+ const r = parseInt(hex.substring(0, 2), 16);
94
+ const g = parseInt(hex.substring(2, 4), 16);
95
+ const b = parseInt(hex.substring(4, 6), 16);
96
+ if (isNaN(r) || isNaN(g) || isNaN(b)) return null;
97
+ if (hex.length === 8) {
98
+ const a = parseInt(hex.substring(6, 8), 16) / 255;
99
+ return `rgba(${r},${g},${b},${a.toFixed(2)})`;
100
+ }
101
+ return `rgb(${r},${g},${b})`;
102
+ }
103
+
104
+ // Normaliser une valeur rgba/rgb (supprime espaces, arrondit alpha)
105
+ function normaliseColor(s) {
106
+ s = s.replace(/\s+/g, '');
107
+ // rgba(0,0,0,0) → transparent
108
+ if (s === 'rgba(0,0,0,0)' || s === 'transparent') return 'transparent';
109
+ return s;
110
+ }
111
+
112
+ // Normaliser les valeurs CSS pour comparaison (rgba/spaces/units/hex)
87
113
  function normaliseCssValue(val) {
88
114
  if (val == null) return '';
89
115
  let s = String(val).trim().toLowerCase();
90
- // Supprime espaces internes (rgba(0, 0, 0) → rgba(0,0,0))
91
116
  s = s.replace(/\s+/g, '');
117
+
118
+ // Hex → rgb pour matcher getComputedStyle
119
+ if (/^#[0-9a-f]{3,8}$/.test(s)) {
120
+ const rgb = hexToRgb(s);
121
+ if (rgb) return normaliseColor(rgb);
122
+ }
123
+
124
+ // Couleurs rgb/rgba : normaliser pour comparer
125
+ if (s.startsWith('rgb')) {
126
+ return normaliseColor(s);
127
+ }
128
+
92
129
  // Normalise "0px" et "0" et "0%"
93
130
  if (s === '0' || s === '0px' || s === '0%') return '0';
94
131
  // Si valeur sans unité fournie (ex "32") et getComputedStyle renvoie "32px"
@@ -1468,6 +1505,16 @@ mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
1468
1505
  computed = await element.evaluate(el => {
1469
1506
  const cs = getComputedStyle(el);
1470
1507
  const rect = el.getBoundingClientRect();
1508
+ // Enfants "réels" = ceux qui ont une classe brxe-{id} ou id brxe-*
1509
+ // Exclut les <video>, <picture> et autres ajoutés par Bricks (bg vidéo, overlay auto, etc.)
1510
+ const realChildren = Array.from(el.children).filter(child => {
1511
+ if (child.id && child.id.startsWith('brxe-')) return true;
1512
+ return Array.from(child.classList).some(cls => cls.startsWith('brxe-'));
1513
+ });
1514
+ const bricksInternalChildren = Array.from(el.children).filter(child => {
1515
+ return !((child.id && child.id.startsWith('brxe-')) ||
1516
+ Array.from(child.classList).some(cls => cls.startsWith('brxe-')));
1517
+ }).map(c => c.tagName.toLowerCase() + (c.className ? '.' + c.className.split(' ').join('.') : ''));
1471
1518
  return {
1472
1519
  display: cs.display,
1473
1520
  'flex-direction': cs.flexDirection,
@@ -1500,7 +1547,9 @@ mcpServer.setRequestHandler(CallToolRequestSchema, async (request) => {
1500
1547
  'border-bottom-left-radius': cs.borderBottomLeftRadius,
1501
1548
  visibility: cs.visibility,
1502
1549
  opacity: cs.opacity,
1503
- childrenInDom: el.children.length,
1550
+ childrenInDom: realChildren.length,
1551
+ childrenTotalDom: el.children.length,
1552
+ bricksInternalChildren: bricksInternalChildren,
1504
1553
  isVisible: rect.width > 0 && rect.height > 0 && cs.visibility !== 'hidden' && cs.opacity !== '0',
1505
1554
  hasOverflowX: el.scrollWidth > el.clientWidth,
1506
1555
  };