@wix/zero-config-implementation 1.38.0 → 1.39.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.39.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": "7a722b2c0d3a2401e9c24708c061591e14e588d2901397bab2ddb304"
|
|
88
88
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { CSS_PROPERTIES } from '@wix/zero-config-schema'
|
|
9
|
+
import type { CssSelectorMatch, MatchedCssData } from '../../css/types'
|
|
10
|
+
import type { ExtractedElement } from './core/tree-builder'
|
|
9
11
|
import type { CreateElementEvent, ReactExtractor } from './core/types'
|
|
10
12
|
|
|
11
13
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -199,6 +201,56 @@ export function addTextProperties(existing: string[]): string[] {
|
|
|
199
201
|
return result
|
|
200
202
|
}
|
|
201
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Adds gap CSS property to an existing property list if not already present.
|
|
206
|
+
*/
|
|
207
|
+
export function addGapProperty(existing: string[]): string[] {
|
|
208
|
+
if (existing.includes(CSS_PROPERTY_TYPE.gap)) return existing
|
|
209
|
+
return [...existing, CSS_PROPERTY_TYPE.gap]
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
213
|
+
// Gap Enrichment
|
|
214
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
215
|
+
|
|
216
|
+
const FLEX_GRID_DISPLAY_VALUES = new Set(['flex', 'grid', 'inline-flex', 'inline-grid'])
|
|
217
|
+
|
|
218
|
+
function hasFlexOrGridDisplay(matches: CssSelectorMatch[]): boolean {
|
|
219
|
+
for (const match of matches) {
|
|
220
|
+
for (const property of match.properties) {
|
|
221
|
+
if (property.name === 'display' && FLEX_GRID_DISPLAY_VALUES.has(property.value)) {
|
|
222
|
+
return true
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return false
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Walks the element tree and adds `gap` to relevant CSS properties
|
|
231
|
+
* for elements that have display: flex|grid and more than 1 child.
|
|
232
|
+
* Must be called after CSS selector matching (requires css-matcher data).
|
|
233
|
+
*/
|
|
234
|
+
export function enrichGapProperties(elements: ExtractedElement[]): ExtractedElement[] {
|
|
235
|
+
return elements.map((element) => {
|
|
236
|
+
if (element.children.length > 1) {
|
|
237
|
+
const matcherData = element.extractorData.get('css-matcher') as MatchedCssData | undefined
|
|
238
|
+
if (matcherData && hasFlexOrGridDisplay(matcherData.matches)) {
|
|
239
|
+
const cssData = element.extractorData.get('css-properties') as CssPropertiesData | undefined
|
|
240
|
+
if (cssData) {
|
|
241
|
+
element.extractorData.set('css-properties', {
|
|
242
|
+
relevant: addGapProperty(cssData.relevant),
|
|
243
|
+
})
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
...element,
|
|
249
|
+
children: enrichGapProperties(element.children),
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
202
254
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
203
255
|
// Factory
|
|
204
256
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
@@ -24,5 +24,5 @@ export type {
|
|
|
24
24
|
export { createPropTrackerExtractor } from './prop-tracker'
|
|
25
25
|
export type { PropTrackerData, PropTrackerExtractorState } from './prop-tracker'
|
|
26
26
|
|
|
27
|
-
export { createCssPropertiesExtractor } from './css-properties'
|
|
27
|
+
export { createCssPropertiesExtractor, enrichGapProperties } from './css-properties'
|
|
28
28
|
export type { CssPropertiesData } from './css-properties'
|
package/src/manifest-pipeline.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type RunExtractorsOptions,
|
|
10
10
|
createCssPropertiesExtractor,
|
|
11
11
|
createPropTrackerExtractor,
|
|
12
|
+
enrichGapProperties,
|
|
12
13
|
runExtractors,
|
|
13
14
|
} from './information-extractors/react'
|
|
14
15
|
import type { CoupledComponentInfo, CoupledProp, DOMBinding, TrackingStores } from './information-extractors/react'
|
|
@@ -154,9 +155,10 @@ export function processComponent(
|
|
|
154
155
|
if (html && extractedElements.length > 0 && css.length > 0) {
|
|
155
156
|
try {
|
|
156
157
|
const matchResult = matchCssSelectors(html, extractedElements, css)
|
|
158
|
+
const gapEnrichedElements = enrichGapProperties(matchResult.elements)
|
|
157
159
|
enhancedInfo = {
|
|
158
160
|
...enhancedInfo,
|
|
159
|
-
elements: convertElements(
|
|
161
|
+
elements: convertElements(gapEnrichedElements),
|
|
160
162
|
}
|
|
161
163
|
varUsedByTraceId = matchResult.varUsedByTraceId
|
|
162
164
|
} catch (thrownError) {
|