@wix/zero-config-implementation 1.27.0 → 1.28.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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.27.0",
7
+ "version": "1.28.0",
8
8
  "description": "Core library for extracting component manifests from JS and CSS files",
9
9
  "type": "module",
10
10
  "main": "dist/index.js",
@@ -83,5 +83,5 @@
83
83
  ]
84
84
  }
85
85
  },
86
- "falconPackageHash": "2e095856ec4492a70d52bef24a3f7ac22639454039660a7869423748"
86
+ "falconPackageHash": "b9b7aa47b7618d7b031628208f9fb26661e34ddb5fe300679306084e"
87
87
  }
@@ -12,6 +12,7 @@ import { findPreferredSemanticClass } from '../../../../utils/css-class'
12
12
  import { PRESETS_WRAPPER_CLASS_NAME } from '../../utils/mock-generator'
13
13
  import type { CssPropertiesData } from '../css-properties'
14
14
  import { addTextProperties } from '../css-properties'
15
+ import type { PropTrackerData } from '../prop-tracker'
15
16
  import type { ExtractorStore } from './store'
16
17
 
17
18
  // ─────────────────────────────────────────────────────────────────────────────
@@ -150,7 +151,7 @@ function getElementNamePart(element: Element, getElementById: (id: string) => El
150
151
  const id = getAttribute(element, 'id')
151
152
  // Skip spy-instrumented ids (mock_propName_XXXXXX) — they are runtime mock values,
152
153
  // not semantic identifiers, and would produce garbage element names.
153
- if (id && !id.startsWith('mock_')) {
154
+ if (id && !id.includes('mock_')) {
154
155
  return pascalCase(id)
155
156
  }
156
157
 
@@ -179,6 +180,28 @@ function getElementNamePart(element: Element, getElementById: (id: string) => El
179
180
  return normalizeTagName(element.tagName)
180
181
  }
181
182
 
183
+ // ─────────────────────────────────────────────────────────────────────────────
184
+ // Element Filtering
185
+ // ─────────────────────────────────────────────────────────────────────────────
186
+
187
+ /**
188
+ * Returns true if the element should be included in the tree:
189
+ * - has a BEM-semantic CSS class, OR
190
+ * - has a className prop propagated from the component's props
191
+ */
192
+ function hasClassNameCriteria(element: Element, extractorData: Map<string, unknown>): boolean {
193
+ const classAttr = getAttribute(element, 'class')
194
+ if (classAttr) {
195
+ const semanticClass = findPreferredSemanticClass(classAttr.split(' '))
196
+ if (semanticClass) return true
197
+ }
198
+
199
+ const propTrackerData = extractorData.get('prop-tracker') as PropTrackerData | undefined
200
+ if (propTrackerData?.boundProps.includes('className')) return true
201
+
202
+ return false
203
+ }
204
+
182
205
  // ─────────────────────────────────────────────────────────────────────────────
183
206
  // Tree Building
184
207
  // ─────────────────────────────────────────────────────────────────────────────
@@ -234,15 +257,20 @@ export function buildElementTree(html: string, store: ExtractorStore): Extracted
234
257
 
235
258
  // If this element has a traceId, it's a traced element
236
259
  if (traceId) {
260
+ // Get extractor data from store
261
+ const extractorData = store.getAll(traceId) ?? new Map()
262
+
263
+ // Filter: only include non-root elements with semantic or propagated className
264
+ if (!isRoot && !hasClassNameCriteria(node, extractorData)) {
265
+ return node.childNodes.flatMap((child) => walkTree(child, ancestorPath, false))
266
+ }
267
+
237
268
  // Compute this element's name part
238
269
  const namePart = isRoot ? 'root' : getElementNamePart(node, getElementById)
239
270
 
240
271
  // Full name is ancestor path + this element's name (no separator)
241
272
  const name = isRoot ? 'root' : ancestorPath + namePart
242
273
 
243
- // Get extractor data from store
244
- const extractorData = store.getAll(traceId) ?? new Map()
245
-
246
274
  // Check for text content
247
275
  const hasText = hasDirectTextContent(node)
248
276