@wix/zero-config-implementation 1.93.0 → 1.94.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.93.0",
7
+ "version": "1.94.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",
@@ -39,7 +39,7 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@wix/react-component-schema": "1.8.0",
42
+ "@wix/react-component-schema": "1.9.0",
43
43
  "@wix/seo-service": "^1.9.0",
44
44
  "@wix/services-manager": "^1.0.7",
45
45
  "@wix/services-manager-react": "^1.0.8",
@@ -106,5 +106,5 @@
106
106
  ]
107
107
  }
108
108
  },
109
- "falconPackageHash": "d7c036bb07aaafe708985efa56e88c2eefb34077d2d892938112978f"
109
+ "falconPackageHash": "c359f3991c9148a6bb0473cbb1eef6bfef7fd8401e45720aaed8b44c"
110
110
  }
@@ -107,6 +107,103 @@ describe('toEditorReactComponent display conversion', () => {
107
107
  })
108
108
  })
109
109
 
110
+ // CSS display values whose spelling differs from the enum's. Emitting one
111
+ // unmapped makes DevCenter reject the whole components override, permanently
112
+ // blocking Checkpoint for the project (ECL-18531).
113
+ describe('display value enum mapping', () => {
114
+ const { DISPLAY_VALUE } = CSS_PROPERTIES
115
+ const tagDefaults: [tag: string, cssDisplay: string, enumValue: string][] = [
116
+ ['td', 'table-cell', DISPLAY_VALUE.tableCell],
117
+ ['th', 'table-cell', DISPLAY_VALUE.tableCell],
118
+ ['tr', 'table-row', DISPLAY_VALUE.tableRow],
119
+ ['tbody', 'table-row-group', DISPLAY_VALUE.tableRowGroup],
120
+ ['thead', 'table-header-group', DISPLAY_VALUE.tableHeaderGroup],
121
+ ['tfoot', 'table-footer-group', DISPLAY_VALUE.tableFooterGroup],
122
+ ['caption', 'table-caption', DISPLAY_VALUE.tableCaption],
123
+ ['col', 'table-column', DISPLAY_VALUE.tableColumn],
124
+ ['colgroup', 'table-column-group', DISPLAY_VALUE.tableColumnGroup],
125
+ ]
126
+
127
+ it.each(tagDefaults)('maps a <%s> tag default (%s) onto its enum name', (tag, _cssDisplay, expectedEnumValue) => {
128
+ const rootElement = createElementWithDisplayMatcher(tag, matcherDataFromCss(''))
129
+
130
+ const result = toEditorReactComponent(createComponent(rootElement))
131
+
132
+ expect(result.editorElement?.cssProperties?.display).toEqual({
133
+ display: {
134
+ displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, expectedEnumValue],
135
+ },
136
+ })
137
+ })
138
+
139
+ it('treats an explicit `display: table-cell` declaration the same as the tag default', () => {
140
+ const fromTag = toEditorReactComponent(
141
+ createComponent(createElementWithDisplayMatcher('td', matcherDataFromCss(''))),
142
+ )
143
+ const fromCss = toEditorReactComponent(
144
+ createComponent(createElementWithDisplayMatcher('div', matcherDataFromCss('display: table-cell'))),
145
+ )
146
+
147
+ expect(fromCss.editorElement?.cssProperties?.display).toEqual(fromTag.editorElement?.cssProperties?.display)
148
+ expect(fromCss.editorElement?.cssProperties?.display).toEqual({
149
+ display: {
150
+ displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, CSS_PROPERTIES.DISPLAY_VALUE.tableCell],
151
+ },
152
+ })
153
+ })
154
+
155
+ it('still maps kebab-case values that do have an enum representation', () => {
156
+ const rootElement = createElementWithDisplayMatcher('div', matcherDataFromCss('display: inline-block'))
157
+
158
+ const result = toEditorReactComponent(createComponent(rootElement))
159
+
160
+ expect(result.editorElement?.cssProperties?.display).toEqual({
161
+ display: {
162
+ displayValues: [CSS_PROPERTIES.DISPLAY_VALUE.none, CSS_PROPERTIES.DISPLAY_VALUE.inlineBlock],
163
+ },
164
+ })
165
+ })
166
+
167
+ it('never emits a display value outside the enum for any known tag default', () => {
168
+ const allowedValues = new Set<string>(Object.values(CSS_PROPERTIES.DISPLAY_VALUE))
169
+
170
+ for (const [tag] of tagDefaults) {
171
+ const rootElement = createElementWithDisplayMatcher(tag, matcherDataFromCss(''))
172
+ const result = toEditorReactComponent(createComponent(rootElement))
173
+ const emittedValues = result.editorElement?.cssProperties?.display?.display?.displayValues ?? []
174
+
175
+ expect(emittedValues.filter((displayValue) => !allowedValues.has(displayValue))).toEqual([])
176
+ }
177
+ })
178
+
179
+ /**
180
+ * Completeness check driven by the enum itself, so a value added in a future
181
+ * `@wix/component-protocol` bump cannot sit unmapped — which is the gap that
182
+ * made ECL-18531 possible. Values whose CSS spelling already matches the enum
183
+ * name need no entry; those that differ must be mapped.
184
+ *
185
+ * Skips names containing `_`: `UNKNOWN_DisplayValue` and the deprecated
186
+ * snake_case aliases, none of which are CSS spellings.
187
+ */
188
+ it('reaches every enum value from its CSS spelling', () => {
189
+ const toCssSpelling = (enumValue: string) => enumValue.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`)
190
+
191
+ const unreachable = Object.values(CSS_PROPERTIES.DISPLAY_VALUE)
192
+ .filter((enumValue) => !enumValue.includes('_'))
193
+ .filter((enumValue) => {
194
+ const rootElement = createElementWithDisplayMatcher(
195
+ 'div',
196
+ matcherDataFromCss(`display: ${toCssSpelling(enumValue)}`),
197
+ )
198
+ const result = toEditorReactComponent(createComponent(rootElement))
199
+
200
+ return result.editorElement?.cssProperties?.display?.display?.displayValues?.[1] !== enumValue
201
+ })
202
+
203
+ expect(unreachable).toEqual([])
204
+ })
205
+ })
206
+
110
207
  it('omits the nearest matching ancestor class prefix from inner element display names', () => {
111
208
  const rootElement = createSemanticElement({
112
209
  traceId: 'trace-root',
@@ -541,20 +541,30 @@ function getMatchedPropertyValues(element: ExtractedElement): Map<string, string
541
541
  return values
542
542
  }
543
543
 
544
- const CSS_DISPLAY_TO_ENUM: Record<string, string> = {
545
- 'inline-block': 'inlineBlock',
546
- 'inline-flex': 'inlineFlex',
547
- 'inline-grid': 'inlineGrid',
548
- 'inline-table': 'inlineTable',
549
- 'list-item': 'listItem',
550
- 'flow-root': 'flowRoot',
551
- }
544
+ const { CSS_PROPERTY_TYPE, DISPLAY_VALUE } = CSS_PROPERTIES
552
545
 
553
- function toDisplayEnumValue(cssValue: string): NonNullable<Display['displayValues']>[number] {
554
- return (CSS_DISPLAY_TO_ENUM[cssValue] ?? cssValue) as NonNullable<Display['displayValues']>[number]
546
+ type DisplayEnumValue = NonNullable<Display['displayValues']>[number]
547
+
548
+ const CSS_DISPLAY_TO_ENUM: Record<string, DisplayEnumValue> = {
549
+ 'inline-block': DISPLAY_VALUE.inlineBlock,
550
+ 'inline-flex': DISPLAY_VALUE.inlineFlex,
551
+ 'inline-grid': DISPLAY_VALUE.inlineGrid,
552
+ 'inline-table': DISPLAY_VALUE.inlineTable,
553
+ 'list-item': DISPLAY_VALUE.listItem,
554
+ 'flow-root': DISPLAY_VALUE.flowRoot,
555
+ 'table-row-group': DISPLAY_VALUE.tableRowGroup,
556
+ 'table-header-group': DISPLAY_VALUE.tableHeaderGroup,
557
+ 'table-footer-group': DISPLAY_VALUE.tableFooterGroup,
558
+ 'table-row': DISPLAY_VALUE.tableRow,
559
+ 'table-cell': DISPLAY_VALUE.tableCell,
560
+ 'table-column-group': DISPLAY_VALUE.tableColumnGroup,
561
+ 'table-column': DISPLAY_VALUE.tableColumn,
562
+ 'table-caption': DISPLAY_VALUE.tableCaption,
555
563
  }
556
564
 
557
- const { CSS_PROPERTY_TYPE, DISPLAY_VALUE } = CSS_PROPERTIES
565
+ function toDisplayEnumValue(cssValue: string): DisplayEnumValue {
566
+ return (CSS_DISPLAY_TO_ENUM[cssValue] ?? cssValue) as DisplayEnumValue
567
+ }
558
568
 
559
569
  function buildCssProperties(element: ExtractedElement | undefined): Record<string, CssPropertyItem> {
560
570
  const result: Record<string, CssPropertyItem> = {}