@wix/zero-config-implementation 1.39.0 → 1.41.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.
|
|
7
|
+
"version": "1.41.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",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
]
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"falconPackageHash": "
|
|
87
|
+
"falconPackageHash": "ddb29001681fab5fe2cdf61a3df6d062898ed82539a5c841e9a45c39"
|
|
88
88
|
}
|
|
@@ -170,6 +170,7 @@ function buildNearestCommonAncestorCustomProps(
|
|
|
170
170
|
|
|
171
171
|
const existingProps = nearestCommonAncestorCustomProps.get(nearestCommonAncestorTraceId) ?? {}
|
|
172
172
|
existingProps[cleanVarName] = {
|
|
173
|
+
displayName: formatDisplayName(cleanVarName),
|
|
173
174
|
defaultValue,
|
|
174
175
|
...(cssPropertyType !== undefined && { cssPropertyType }),
|
|
175
176
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Build Element Tree
|
|
3
3
|
*
|
|
4
4
|
* Parses HTML to get hierarchy and merges with ExtractorStore data.
|
|
5
|
-
* Each element gets a semantic name
|
|
5
|
+
* Each element gets a semantic local name from semantic selectors/attributes.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { camelCase
|
|
8
|
+
import { camelCase } from 'case-anything'
|
|
9
9
|
import { type DefaultTreeAdapterMap, parseFragment } from 'parse5'
|
|
10
10
|
import { TRACE_ATTR } from '../../../../component-renderer'
|
|
11
11
|
import { findPreferredSemanticClass } from '../../../../utils/css-class'
|
|
@@ -229,7 +229,7 @@ function unwrapPresetsWrappers(nodes: Node[]): Node[] {
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* Builds an element tree from HTML, merging with store data.
|
|
232
|
-
* Each element gets a semantic name
|
|
232
|
+
* Each element gets a semantic local name.
|
|
233
233
|
*/
|
|
234
234
|
export function buildElementTree(html: string, store: ExtractorStore): ExtractedElement[] {
|
|
235
235
|
const fragment = parseFragment(html)
|
|
@@ -252,12 +252,12 @@ export function buildElementTree(html: string, store: ExtractorStore): Extracted
|
|
|
252
252
|
/**
|
|
253
253
|
* Recursively walks the tree, building ExtractedElements.
|
|
254
254
|
* @param node - The current parse5 node
|
|
255
|
-
* @param ancestorPath - The concatenated name path from ancestors (empty for root's children)
|
|
256
255
|
* @param isRoot - Whether this is the root element (first traced element)
|
|
257
256
|
*/
|
|
258
|
-
const walkTree = (node: Node,
|
|
257
|
+
const walkTree = (node: Node, isRoot: boolean): ExtractedElement[] => {
|
|
259
258
|
if (!isElement(node)) return []
|
|
260
259
|
|
|
260
|
+
const children = node.childNodes.flatMap((childNode) => walkTree(childNode, false))
|
|
261
261
|
const traceId = getAttribute(node, TRACE_ATTR)
|
|
262
262
|
|
|
263
263
|
// If this element has a traceId, it's a traced element
|
|
@@ -267,16 +267,10 @@ export function buildElementTree(html: string, store: ExtractorStore): Extracted
|
|
|
267
267
|
|
|
268
268
|
// Filter: only include non-root elements with semantic or propagated className
|
|
269
269
|
if (!isRoot && !hasClassNameCriteria(node, extractorData)) {
|
|
270
|
-
return
|
|
270
|
+
return children
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
|
|
274
|
-
const namePart = isRoot ? 'root' : getElementNamePart(node, getElementById)
|
|
275
|
-
|
|
276
|
-
// Full name is ancestor path + this element's name (no separator).
|
|
277
|
-
// Use pascalCase on namePart when appending so that
|
|
278
|
-
// e.g. "mediaSection" + "vectorArt" → "mediaSectionVectorArt".
|
|
279
|
-
const name = isRoot ? 'root' : ancestorPath.length > 0 ? ancestorPath + pascalCase(namePart) : namePart
|
|
273
|
+
const name = isRoot ? 'root' : getElementNamePart(node, getElementById)
|
|
280
274
|
|
|
281
275
|
// Check for text content
|
|
282
276
|
const hasText = hasDirectTextContent(node)
|
|
@@ -292,11 +286,6 @@ export function buildElementTree(html: string, store: ExtractorStore): Extracted
|
|
|
292
286
|
}
|
|
293
287
|
}
|
|
294
288
|
|
|
295
|
-
// Recursively process children
|
|
296
|
-
// Children use this element's full name as their ancestor path
|
|
297
|
-
const childPath = isRoot ? '' : name
|
|
298
|
-
const children = node.childNodes.flatMap((child) => walkTree(child, childPath, false))
|
|
299
|
-
|
|
300
289
|
// Build attributes (excluding trace-id)
|
|
301
290
|
const attributes = getAttributes(node)
|
|
302
291
|
delete attributes[TRACE_ATTR]
|
|
@@ -314,18 +303,18 @@ export function buildElementTree(html: string, store: ExtractorStore): Extracted
|
|
|
314
303
|
]
|
|
315
304
|
}
|
|
316
305
|
|
|
317
|
-
// No traceId - just pass through to children
|
|
318
|
-
return
|
|
306
|
+
// No traceId - just pass through to children
|
|
307
|
+
return children
|
|
319
308
|
}
|
|
320
309
|
|
|
321
|
-
//
|
|
310
|
+
// The first traced element is root.
|
|
322
311
|
const topLevelNodes = unwrapPresetsWrappers([...fragment.childNodes])
|
|
323
312
|
|
|
324
313
|
let isFirst = true
|
|
325
314
|
const result: ExtractedElement[] = []
|
|
326
315
|
|
|
327
316
|
for (const node of topLevelNodes) {
|
|
328
|
-
const elements = walkTree(node,
|
|
317
|
+
const elements = walkTree(node, isFirst)
|
|
329
318
|
if (elements.length > 0) {
|
|
330
319
|
result.push(...elements)
|
|
331
320
|
isFirst = false // Only the first traced element is root
|