@wix/zero-config-implementation 1.10.0 → 1.11.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/dist/index.js +6 -2
- package/package.json +2 -2
- package/src/converters/data-item-builder.ts +16 -9
- package/src/converters/to-editor-component.ts +9 -8
- package/src/information-extractors/css/parse.ts +4 -4
- package/src/information-extractors/css/selector-matcher.ts +6 -6
- package/src/information-extractors/ts/components.ts +4 -4
- package/src/manifest-pipeline.ts +9 -9
package/dist/index.js
CHANGED
|
@@ -40527,9 +40527,13 @@ function PL(e, t, r) {
|
|
|
40527
40527
|
const n = t.types.filter((A) => A.value !== "undefined" && A.value !== "null");
|
|
40528
40528
|
if (n.length === 0)
|
|
40529
40529
|
return e.dataType = $e.text, e.text = {}, mt(void 0);
|
|
40530
|
-
if (n.length <= 2 && n.every(
|
|
40530
|
+
if (n.length <= 2 && n.every(
|
|
40531
|
+
(A) => A.kind === "literal" && (A.value === !0 || A.value === !1)
|
|
40532
|
+
))
|
|
40531
40533
|
return e.dataType = $e.booleanValue, mt(void 0);
|
|
40532
|
-
if (n.every(
|
|
40534
|
+
if (n.every(
|
|
40535
|
+
(A) => A.kind === "literal" && typeof A.value == "string"
|
|
40536
|
+
))
|
|
40533
40537
|
return e.dataType = $e.textEnum, e.textEnum = {
|
|
40534
40538
|
options: n.map((A) => ({
|
|
40535
40539
|
value: String(A.value || ""),
|
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.11.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",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
]
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
-
"falconPackageHash": "
|
|
77
|
+
"falconPackageHash": "72ed033142da89f1b47261236ac0406e5d01201b896daec0491a39ff"
|
|
78
78
|
}
|
|
@@ -148,13 +148,15 @@ function handlePrimitiveType(
|
|
|
148
148
|
const typeValue = (resolvedType.value as string | undefined)?.toLowerCase() || propInfo.type.toLowerCase()
|
|
149
149
|
|
|
150
150
|
if (typeValue.includes('string')) {
|
|
151
|
-
if (bindings?.some((
|
|
151
|
+
if (bindings?.some((binding) => binding.attribute === 'dir')) {
|
|
152
152
|
dataItem.dataType = DATA_TYPE.direction
|
|
153
|
-
} else if (
|
|
153
|
+
} else if (
|
|
154
|
+
bindings?.some((binding) => binding.attribute === 'href' && binding.element === 'a' && !binding.concatenated)
|
|
155
|
+
) {
|
|
154
156
|
dataItem.dataType = DATA_TYPE.webUrl
|
|
155
|
-
} else if (bindings?.some((
|
|
157
|
+
} else if (bindings?.some((binding) => binding.attribute === 'id')) {
|
|
156
158
|
dataItem.dataType = DATA_TYPE.guid
|
|
157
|
-
} else if (bindings?.some((
|
|
159
|
+
} else if (bindings?.some((binding) => binding.attribute === 'pattern')) {
|
|
158
160
|
dataItem.dataType = DATA_TYPE.regex
|
|
159
161
|
} else {
|
|
160
162
|
dataItem.dataType = DATA_TYPE.text
|
|
@@ -299,21 +301,26 @@ function handleUnionType(
|
|
|
299
301
|
|
|
300
302
|
// Check if it's a boolean type (union of true | false literals)
|
|
301
303
|
const isBooleanLiteralUnion =
|
|
302
|
-
validTypes.length <= 2 &&
|
|
304
|
+
validTypes.length <= 2 &&
|
|
305
|
+
validTypes.every(
|
|
306
|
+
(validType) => validType.kind === 'literal' && (validType.value === true || validType.value === false),
|
|
307
|
+
)
|
|
303
308
|
if (isBooleanLiteralUnion) {
|
|
304
309
|
dataItem.dataType = DATA_TYPE.booleanValue
|
|
305
310
|
return ok(undefined)
|
|
306
311
|
}
|
|
307
312
|
|
|
308
313
|
// Check if it's a union of string literals (enum-like)
|
|
309
|
-
const allStringLiterals = validTypes.every(
|
|
314
|
+
const allStringLiterals = validTypes.every(
|
|
315
|
+
(validType) => validType.kind === 'literal' && typeof validType.value === 'string',
|
|
316
|
+
)
|
|
310
317
|
if (allStringLiterals) {
|
|
311
318
|
dataItem.dataType = DATA_TYPE.textEnum
|
|
312
319
|
dataItem.textEnum = {
|
|
313
320
|
options: validTypes
|
|
314
|
-
.map((
|
|
315
|
-
value: String(
|
|
316
|
-
displayName: formatDisplayName(String(
|
|
321
|
+
.map((validType) => ({
|
|
322
|
+
value: String(validType.value || ''),
|
|
323
|
+
displayName: formatDisplayName(String(validType.value || '')),
|
|
317
324
|
}))
|
|
318
325
|
.filter((opt) => opt.value),
|
|
319
326
|
}
|
|
@@ -78,17 +78,17 @@ function buildElements(
|
|
|
78
78
|
): Record<string, ElementItem> {
|
|
79
79
|
const result: Record<string, ElementItem> = {}
|
|
80
80
|
|
|
81
|
-
for (const
|
|
82
|
-
const elementData = innerElementProps?.get(
|
|
81
|
+
for (const element of elements) {
|
|
82
|
+
const elementData = innerElementProps?.get(element.traceId)
|
|
83
83
|
const data = elementData && propUsages ? buildData(elementData, propUsages) : undefined
|
|
84
|
-
const cssProps = buildCssProperties(
|
|
85
|
-
const cssCustomProps = buildCssCustomPropertiesForElement(
|
|
84
|
+
const cssProps = buildCssProperties(element)
|
|
85
|
+
const cssCustomProps = buildCssCustomPropertiesForElement(element)
|
|
86
86
|
|
|
87
|
-
result[
|
|
87
|
+
result[element.name] = {
|
|
88
88
|
elementType: ELEMENTS.ELEMENT_TYPE.inlineElement,
|
|
89
89
|
inlineElement: {
|
|
90
|
-
selector: buildSelector(
|
|
91
|
-
displayName: formatDisplayName(
|
|
90
|
+
selector: buildSelector(element),
|
|
91
|
+
displayName: formatDisplayName(element.name),
|
|
92
92
|
// Add data from inner element props if available
|
|
93
93
|
...(data && Object.keys(data).length > 0 && { data }),
|
|
94
94
|
// CSS properties from heuristic + matched CSS files
|
|
@@ -96,7 +96,8 @@ function buildElements(
|
|
|
96
96
|
// CSS custom properties from matched rules for this element
|
|
97
97
|
...(Object.keys(cssCustomProps).length > 0 && { cssCustomProperties: cssCustomProps }),
|
|
98
98
|
// Recursively build nested elements
|
|
99
|
-
elements:
|
|
99
|
+
elements:
|
|
100
|
+
element.children.length > 0 ? buildElements(element.children, innerElementProps, propUsages) : undefined,
|
|
100
101
|
},
|
|
101
102
|
}
|
|
102
103
|
}
|
|
@@ -140,10 +140,10 @@ function parseAllProperties(cssString: string): Map<string, CSSProperty[]> {
|
|
|
140
140
|
|
|
141
141
|
for (const keyframe of rule.value.keyframes) {
|
|
142
142
|
// Each keyframe has selectors like 'from', 'to', '50%'
|
|
143
|
-
const keyframeSelectors = keyframe.selectors.map((
|
|
144
|
-
if (typeof
|
|
145
|
-
if ('percentage' in
|
|
146
|
-
return String(
|
|
143
|
+
const keyframeSelectors = keyframe.selectors.map((selector) => {
|
|
144
|
+
if (typeof selector === 'string') return selector
|
|
145
|
+
if ('percentage' in selector) return `${selector.percentage}%`
|
|
146
|
+
return String(selector)
|
|
147
147
|
})
|
|
148
148
|
|
|
149
149
|
const properties: CSSProperty[] = []
|
|
@@ -73,16 +73,16 @@ function enrichElements(
|
|
|
73
73
|
matchesByTraceId: Map<string, CssSelectorMatch[]>,
|
|
74
74
|
customPropsByTraceId: Map<string, Record<string, string>>,
|
|
75
75
|
): ExtractedElement[] {
|
|
76
|
-
return elements.map((
|
|
76
|
+
return elements.map((element) => {
|
|
77
77
|
const data: MatchedCssData = {
|
|
78
|
-
matches: matchesByTraceId.get(
|
|
79
|
-
customProperties: customPropsByTraceId.get(
|
|
78
|
+
matches: matchesByTraceId.get(element.traceId) ?? [],
|
|
79
|
+
customProperties: customPropsByTraceId.get(element.traceId) ?? {},
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
element.extractorData.set('css-matcher', data)
|
|
82
82
|
|
|
83
83
|
return {
|
|
84
|
-
...
|
|
85
|
-
children: enrichElements(
|
|
84
|
+
...element,
|
|
85
|
+
children: enrichElements(element.children, matchesByTraceId, customPropsByTraceId),
|
|
86
86
|
}
|
|
87
87
|
})
|
|
88
88
|
}
|
|
@@ -10,7 +10,7 @@ import { resolveType } from './utils/semantic-type-resolver'
|
|
|
10
10
|
const sharedPropFilter = (prop: PropItem) => {
|
|
11
11
|
// Exclude props inherited from node_modules (e.g. HTMLAttributes)
|
|
12
12
|
if (prop.declarations && prop.declarations.length > 0) {
|
|
13
|
-
return !prop.declarations.every((
|
|
13
|
+
return !prop.declarations.every((declaration) => declaration.fileName.includes('node_modules'))
|
|
14
14
|
}
|
|
15
15
|
return true
|
|
16
16
|
}
|
|
@@ -69,7 +69,7 @@ function findDefaultExportName(program: ts.Program, filePath: string): string |
|
|
|
69
69
|
const moduleSymbol = checker.getSymbolAtLocation(sourceFile)
|
|
70
70
|
if (!moduleSymbol) return undefined
|
|
71
71
|
|
|
72
|
-
const defaultSymbol = checker.getExportsOfModule(moduleSymbol).find((
|
|
72
|
+
const defaultSymbol = checker.getExportsOfModule(moduleSymbol).find((symbol) => symbol.getName() === 'default')
|
|
73
73
|
if (!defaultSymbol) return undefined
|
|
74
74
|
|
|
75
75
|
// For `export default Foo` the symbol is an alias — resolve it to get 'Foo'
|
|
@@ -158,11 +158,11 @@ function findPropsType(
|
|
|
158
158
|
if (!moduleSymbol) return undefined
|
|
159
159
|
|
|
160
160
|
const exports = checker.getExportsOfModule(moduleSymbol)
|
|
161
|
-
let componentSymbol = exports.find((
|
|
161
|
+
let componentSymbol = exports.find((symbol) => symbol.getName() === componentName)
|
|
162
162
|
|
|
163
163
|
// If not found by name, check whether the default export resolves to the component
|
|
164
164
|
if (!componentSymbol) {
|
|
165
|
-
const defaultSymbol = exports.find((
|
|
165
|
+
const defaultSymbol = exports.find((symbol) => symbol.getName() === 'default')
|
|
166
166
|
if (defaultSymbol && (defaultSymbol.getFlags() & ts.SymbolFlags.Alias) !== 0) {
|
|
167
167
|
const resolved = checker.getAliasedSymbol(defaultSymbol)
|
|
168
168
|
if (resolved.getName() === componentName) {
|
package/src/manifest-pipeline.ts
CHANGED
|
@@ -292,21 +292,21 @@ function extractBindings(
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
function convertElements(elements: ExtractedElement[]): CoupledComponentInfo['elements'] {
|
|
295
|
-
return elements.map((
|
|
295
|
+
return elements.map((element) => {
|
|
296
296
|
// Get prop-tracker data for boundProps
|
|
297
|
-
const propTrackerData =
|
|
297
|
+
const propTrackerData = element.extractorData.get('prop-tracker') as PropTrackerData | undefined
|
|
298
298
|
|
|
299
299
|
return {
|
|
300
|
-
traceId:
|
|
301
|
-
name:
|
|
302
|
-
tag:
|
|
303
|
-
attributes:
|
|
304
|
-
extractorData:
|
|
305
|
-
children: convertElements(
|
|
300
|
+
traceId: element.traceId,
|
|
301
|
+
name: element.name,
|
|
302
|
+
tag: element.tag,
|
|
303
|
+
attributes: element.attributes,
|
|
304
|
+
extractorData: element.extractorData,
|
|
305
|
+
children: convertElements(element.children),
|
|
306
306
|
// Legacy fields
|
|
307
307
|
boundProps: propTrackerData?.boundProps ?? [],
|
|
308
308
|
role: propTrackerData?.role,
|
|
309
|
-
hasTextContent:
|
|
309
|
+
hasTextContent: element.hasTextContent,
|
|
310
310
|
}
|
|
311
311
|
})
|
|
312
312
|
}
|