@wix/zero-config-implementation 1.48.0 → 1.49.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.49.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",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
]
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
-
"falconPackageHash": "
|
|
88
|
+
"falconPackageHash": "54ff02d476b1c16a5fa7e9f8dbb1eb74a6011ac62dcee23ecc6301be"
|
|
89
89
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DATA } from '@wix/react-component-schema'
|
|
2
|
+
import type { TrackingStores } from '../information-extractors/react'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Walks the known A11y attributes (from DATA.A11Y_ATTRIBUTES) in deterministic
|
|
6
|
+
* enum order and returns the subset whose `${propPath}.${attribute}` key was
|
|
7
|
+
* recorded in propUsages by the prop-tracker. When propUsages or propPath is
|
|
8
|
+
* unavailable, returns an empty array — per the schema, an empty list means
|
|
9
|
+
* "all possible A11Y values", which is a safe default.
|
|
10
|
+
*/
|
|
11
|
+
export function collectUsedA11yAttributes(
|
|
12
|
+
propUsages: TrackingStores['propUsages'] | undefined,
|
|
13
|
+
propPath: string | undefined,
|
|
14
|
+
): (typeof DATA.A11Y_ATTRIBUTES)[keyof typeof DATA.A11Y_ATTRIBUTES][] {
|
|
15
|
+
if (!propUsages || !propPath) return []
|
|
16
|
+
|
|
17
|
+
const used: (typeof DATA.A11Y_ATTRIBUTES)[keyof typeof DATA.A11Y_ATTRIBUTES][] = []
|
|
18
|
+
for (const attribute of Object.values(DATA.A11Y_ATTRIBUTES)) {
|
|
19
|
+
if (attribute === DATA.A11Y_ATTRIBUTES.Unknown_AriaAttributes) continue
|
|
20
|
+
if (propUsages.has(`${propPath}.${attribute}`)) {
|
|
21
|
+
used.push(attribute)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return used
|
|
25
|
+
}
|
|
@@ -20,6 +20,7 @@ import { ParseError } from '../errors'
|
|
|
20
20
|
import type { DOMBinding, TrackingStores } from '../information-extractors/react'
|
|
21
21
|
import type { PropInfo, ResolvedType } from '../information-extractors/ts/types'
|
|
22
22
|
import { WIX_TYPE_TO_DATA_TYPE } from '../wix-type-to-data-type'
|
|
23
|
+
import { collectUsedA11yAttributes } from './a11y-builder'
|
|
23
24
|
import { formatDisplayName } from './utils'
|
|
24
25
|
|
|
25
26
|
const { DATA_TYPE } = DATA
|
|
@@ -120,7 +121,7 @@ function applyResolvedTypeToDataItem(
|
|
|
120
121
|
return ok(undefined)
|
|
121
122
|
|
|
122
123
|
case 'semantic':
|
|
123
|
-
handleSemanticType(dataItem, resolvedType)
|
|
124
|
+
handleSemanticType({ dataItem, resolvedType, propUsages, propPath })
|
|
124
125
|
return ok(undefined)
|
|
125
126
|
|
|
126
127
|
default:
|
|
@@ -343,7 +344,17 @@ function handleUnionType(
|
|
|
343
344
|
* Handles semantic types from React and @wix/public-schemas packages.
|
|
344
345
|
* Unknown semantic sources or types silently fall back to text.
|
|
345
346
|
*/
|
|
346
|
-
function handleSemanticType(
|
|
347
|
+
function handleSemanticType({
|
|
348
|
+
dataItem,
|
|
349
|
+
resolvedType,
|
|
350
|
+
propUsages,
|
|
351
|
+
propPath,
|
|
352
|
+
}: {
|
|
353
|
+
dataItem: DataItem
|
|
354
|
+
resolvedType: ResolvedType
|
|
355
|
+
propUsages?: TrackingStores['propUsages']
|
|
356
|
+
propPath?: string
|
|
357
|
+
}): void {
|
|
347
358
|
const semanticValue = resolvedType.value as string
|
|
348
359
|
const source = resolvedType.source
|
|
349
360
|
|
|
@@ -363,7 +374,7 @@ function handleSemanticType(dataItem: DataItem, resolvedType: ResolvedType): voi
|
|
|
363
374
|
const dataTypeKey = WIX_TYPE_TO_DATA_TYPE[semanticValue]
|
|
364
375
|
if (dataTypeKey) {
|
|
365
376
|
dataItem.dataType = DATA_TYPE[dataTypeKey]
|
|
366
|
-
applyDataToBuilderType(dataItem, dataTypeKey)
|
|
377
|
+
applyDataToBuilderType({ dataItem, builderType: dataTypeKey, propUsages, propPath })
|
|
367
378
|
} else {
|
|
368
379
|
// Unknown Wix semantic type — silently fall back to text
|
|
369
380
|
dataItem.dataType = DATA_TYPE.text
|
|
@@ -414,8 +425,20 @@ function handleFunctionType(dataItem: DataItem, propInfo: PropInfo, bindings?: D
|
|
|
414
425
|
|
|
415
426
|
/**
|
|
416
427
|
* Applies special data to builder types if required (e.g., link types, image category).
|
|
428
|
+
* For `a11y`, the list of attributes is built from the prop-tracker's propUsages so
|
|
429
|
+
* only fields actually read in JSX are included.
|
|
417
430
|
*/
|
|
418
|
-
function applyDataToBuilderType(
|
|
431
|
+
function applyDataToBuilderType({
|
|
432
|
+
dataItem,
|
|
433
|
+
builderType,
|
|
434
|
+
propUsages,
|
|
435
|
+
propPath,
|
|
436
|
+
}: {
|
|
437
|
+
dataItem: DataItem
|
|
438
|
+
builderType: keyof typeof DATA_TYPE
|
|
439
|
+
propUsages?: TrackingStores['propUsages']
|
|
440
|
+
propPath?: string
|
|
441
|
+
}): void {
|
|
419
442
|
switch (builderType) {
|
|
420
443
|
case 'link':
|
|
421
444
|
dataItem.dataType = DATA_TYPE.link
|
|
@@ -442,5 +465,11 @@ function applyDataToBuilderType(dataItem: DataItem, builderType: keyof typeof DA
|
|
|
442
465
|
category: MEDIA.IMAGE_CATEGORY.IMAGE,
|
|
443
466
|
}
|
|
444
467
|
break
|
|
468
|
+
case 'a11y':
|
|
469
|
+
dataItem.dataType = DATA_TYPE.a11y
|
|
470
|
+
dataItem.a11y = {
|
|
471
|
+
attributes: collectUsedA11yAttributes(propUsages, propPath),
|
|
472
|
+
}
|
|
473
|
+
break
|
|
445
474
|
}
|
|
446
475
|
}
|
|
@@ -91,7 +91,7 @@ function generateValueFromResolvedType(
|
|
|
91
91
|
|
|
92
92
|
// Handle semantic types (from React or Wix packages) — returned as plain objects
|
|
93
93
|
if (kind === 'semantic') {
|
|
94
|
-
return generateSemanticValue(resolvedType.value as string, propName)
|
|
94
|
+
return generateSemanticValue(resolvedType.value as string, propName, path, registrar)
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// Handle structural types
|
|
@@ -129,7 +129,12 @@ function generateValueFromResolvedType(
|
|
|
129
129
|
/**
|
|
130
130
|
* Generate a mock value for semantic types (React or Wix types)
|
|
131
131
|
*/
|
|
132
|
-
function generateSemanticValue(
|
|
132
|
+
function generateSemanticValue(
|
|
133
|
+
semanticType: string,
|
|
134
|
+
propName: string,
|
|
135
|
+
path: string,
|
|
136
|
+
registrar?: PropSpyRegistrar,
|
|
137
|
+
): unknown {
|
|
133
138
|
switch (semanticType) {
|
|
134
139
|
// Wix semantic types
|
|
135
140
|
case 'Image':
|
|
@@ -141,7 +146,7 @@ function generateSemanticValue(semanticType: string, propName: string): unknown
|
|
|
141
146
|
case 'Link':
|
|
142
147
|
return generateMockLink()
|
|
143
148
|
case 'A11y':
|
|
144
|
-
return generateMockA11y()
|
|
149
|
+
return generateMockA11y(path, registrar)
|
|
145
150
|
case 'VectorArt':
|
|
146
151
|
return generateMockVectorArt()
|
|
147
152
|
case 'Audio':
|
|
@@ -378,12 +383,57 @@ function generateMockLink(): Record<string, unknown> {
|
|
|
378
383
|
}
|
|
379
384
|
}
|
|
380
385
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
+
// String fields and string-literal-union fields of @wix/public-schemas A11y.
|
|
387
|
+
// These are emitted as unique trackable strings — DOM/React will accept any
|
|
388
|
+
// string for `aria-*` attributes regardless of the TS type union, so the spy
|
|
389
|
+
// markers flow through unchanged and the prop-tracker can detect usage.
|
|
390
|
+
const A11Y_STRING_FIELDS = [
|
|
391
|
+
'ariaExpanded',
|
|
392
|
+
'ariaDisabled',
|
|
393
|
+
'ariaAtomic',
|
|
394
|
+
'ariaHidden',
|
|
395
|
+
'ariaBusy',
|
|
396
|
+
'ariaAutocomplete',
|
|
397
|
+
'ariaPressed',
|
|
398
|
+
'ariaHaspopup',
|
|
399
|
+
'ariaRelevant',
|
|
400
|
+
'role',
|
|
401
|
+
'ariaLive',
|
|
402
|
+
'ariaCurrent',
|
|
403
|
+
'ariaLabel',
|
|
404
|
+
'ariaRoledescription',
|
|
405
|
+
'ariaDescribedby',
|
|
406
|
+
'ariaLabelledby',
|
|
407
|
+
'ariaErrormessage',
|
|
408
|
+
'ariaOwns',
|
|
409
|
+
'ariaControls',
|
|
410
|
+
'tag',
|
|
411
|
+
'ariaMultiline',
|
|
412
|
+
'ariaInvalid',
|
|
413
|
+
] as const
|
|
414
|
+
|
|
415
|
+
// Numeric fields of @wix/public-schemas A11y.
|
|
416
|
+
const A11Y_NUMBER_FIELDS = ['tabIndex', 'ariaLevel'] as const
|
|
417
|
+
|
|
418
|
+
// Pure-boolean A11y fields (e.g. `multiline`) are intentionally omitted: the
|
|
419
|
+
// runtime spy tracker only registers strings, numbers and functions, so plain
|
|
420
|
+
// booleans cannot be tied back to a specific prop field.
|
|
421
|
+
function generateMockA11y(path: string, registrar?: PropSpyRegistrar): Record<string, unknown> {
|
|
422
|
+
const a11y: Record<string, unknown> = {}
|
|
423
|
+
|
|
424
|
+
for (const field of A11Y_STRING_FIELDS) {
|
|
425
|
+
const value = `mock_a11y_${field}_${faker.string.alphanumeric(6)}`
|
|
426
|
+
if (registrar) registrar.registerString(`${path}.${field}`, field, value)
|
|
427
|
+
a11y[field] = value
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
for (const field of A11Y_NUMBER_FIELDS) {
|
|
431
|
+
const value = nextTraceableNumber()
|
|
432
|
+
if (registrar) registrar.registerNumber(`${path}.${field}`, field, value)
|
|
433
|
+
a11y[field] = value
|
|
386
434
|
}
|
|
435
|
+
|
|
436
|
+
return a11y
|
|
387
437
|
}
|
|
388
438
|
|
|
389
439
|
function generateMockVectorArt(): Record<string, unknown> {
|