@contentful/experience-design-system-extraction 2.35.1-dev-build-236b6909.0 → 2.35.1-dev-build-b8da2525.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/package.json +1 -1
- package/dist/src/extract/services/classification/bucket-component-props.d.ts +11 -0
- package/dist/src/extract/services/classification/bucket-component-props.js +29 -0
- package/dist/src/extract/services/classification/classify-component-props.js +3 -22
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +1 -0
- package/package.json +1 -1
- package/dist/src/extract/services/classification/helpers/detect-dom-props.d.ts +0 -2
- package/dist/src/extract/services/classification/helpers/detect-dom-props.js +0 -63
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-extraction",
|
|
3
|
-
"version": "2.35.1-dev-build-
|
|
3
|
+
"version": "2.35.1-dev-build-b8da2525.0",
|
|
4
4
|
"description": "Component extraction engine for the Contentful Experience Design System SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RawComponentDefinition } from '../../types/component.js';
|
|
2
|
+
export type PropBucket = 'custom' | 'dom-passthrough' | 'other';
|
|
3
|
+
export interface PropBucketAssignment {
|
|
4
|
+
component: string;
|
|
5
|
+
source: string;
|
|
6
|
+
customPropNames: string[];
|
|
7
|
+
domPassthroughPropNames: string[];
|
|
8
|
+
otherPropNames: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function bucketComponentProps(component: RawComponentDefinition): PropBucketAssignment;
|
|
11
|
+
export declare function bucketComponentsProps(components: readonly RawComponentDefinition[]): PropBucketAssignment[];
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function bucketComponentProps(component) {
|
|
2
|
+
const customPropNames = [];
|
|
3
|
+
const domPassthroughPropNames = [];
|
|
4
|
+
const otherPropNames = [];
|
|
5
|
+
for (const prop of component.props) {
|
|
6
|
+
if (!prop.type.trim()) {
|
|
7
|
+
otherPropNames.push(prop.name);
|
|
8
|
+
}
|
|
9
|
+
else if (prop.domAttribute === true) {
|
|
10
|
+
domPassthroughPropNames.push(prop.name);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
customPropNames.push(prop.name);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const sortNames = (names) => names.toSorted((left, right) => left.localeCompare(right));
|
|
17
|
+
return {
|
|
18
|
+
component: component.name,
|
|
19
|
+
source: component.source,
|
|
20
|
+
customPropNames: sortNames(customPropNames),
|
|
21
|
+
domPassthroughPropNames: sortNames(domPassthroughPropNames),
|
|
22
|
+
otherPropNames: sortNames(otherPropNames),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function bucketComponentsProps(components) {
|
|
26
|
+
return components
|
|
27
|
+
.map(bucketComponentProps)
|
|
28
|
+
.toSorted((left, right) => `${left.component}\u0000${left.source}`.localeCompare(`${right.component}\u0000${right.source}`));
|
|
29
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isStringLiteralUnion, isBooleanType, isStringType, isNumberType, isComplexType, } from './helpers/check-prop-types.js';
|
|
2
|
-
import { isDomPassThroughProp } from './helpers/detect-dom-props.js';
|
|
3
2
|
/**
|
|
4
3
|
* Deterministic pre-classification rule engine.
|
|
5
4
|
* Applies rules in priority order and returns on the first match.
|
|
@@ -26,16 +25,6 @@ export function preClassifyProp(prop) {
|
|
|
26
25
|
if (type.includes('Dispatch<') || type.includes('SetStateAction')) {
|
|
27
26
|
return { category: 'exclude' };
|
|
28
27
|
}
|
|
29
|
-
// Rule 6: DOM / a11y / framework pass-through props
|
|
30
|
-
if (isDomPassThroughProp(name)) {
|
|
31
|
-
return { category: 'exclude' };
|
|
32
|
-
}
|
|
33
|
-
// `name` is overloaded: form controls forward it to the DOM, while icons,
|
|
34
|
-
// flags, and animations often use it as an authorable semantic selector.
|
|
35
|
-
// Exclude only when the extractor retained concrete DOM provenance.
|
|
36
|
-
if (name === 'name' && prop.domAttribute) {
|
|
37
|
-
return { category: 'exclude' };
|
|
38
|
-
}
|
|
39
28
|
// Rule 7: String literal union
|
|
40
29
|
if (isStringLiteralUnion(type)) {
|
|
41
30
|
return { category: 'design', cdfTypeHint: 'enum' };
|
|
@@ -113,21 +102,13 @@ export function preClassifyComponent(component) {
|
|
|
113
102
|
if (result?.category === 'exclude') {
|
|
114
103
|
return [];
|
|
115
104
|
}
|
|
116
|
-
// Provenance is extraction-only evidence. Do not add it to the payload
|
|
117
|
-
// presented to downstream agents.
|
|
118
|
-
const { domAttribute: _domAttribute, ...authorableProp } = prop;
|
|
119
105
|
if (prop.category) {
|
|
120
|
-
return [
|
|
106
|
+
return [prop];
|
|
121
107
|
}
|
|
122
108
|
if (!result) {
|
|
123
|
-
return [
|
|
109
|
+
return [prop];
|
|
124
110
|
}
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
...authorableProp,
|
|
128
|
-
category: result.category,
|
|
129
|
-
},
|
|
130
|
-
];
|
|
111
|
+
return [{ ...prop, category: result.category }];
|
|
131
112
|
});
|
|
132
113
|
return { ...component, props };
|
|
133
114
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export { extractAstroComponents } from './extract/framework-adapters/astro/extra
|
|
|
13
13
|
export { extractWebComponentDefinitions } from './extract/framework-adapters/web-components/extractor.js';
|
|
14
14
|
export { extractSvelteComponents } from './extract/framework-adapters/svelte/extractor.js';
|
|
15
15
|
export { extractAllowedComponentsFromTypeText, extractAllowedComponentsFromJsdoc, } from './extract/helpers/evidence/collect-allowed-component-names.js';
|
|
16
|
+
export type { PropBucket, PropBucketAssignment } from './extract/services/classification/bucket-component-props.js';
|
|
17
|
+
export { bucketComponentProps, bucketComponentsProps, } from './extract/services/classification/bucket-component-props.js';
|
|
16
18
|
export { evaluateExtractionQuality } from './extract/services/quality/evaluate-extraction-quality.js';
|
|
17
19
|
export { hasNoAuthoringSurface } from './extract/services/quality/helpers/authorability/evaluate-authorability.js';
|
|
18
20
|
export { hasNoAuthoringSurface as isNonAuthorableComponent } from './extract/services/quality/helpers/authorability/evaluate-authorability.js';
|
package/dist/src/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export { extractAstroComponents } from './extract/framework-adapters/astro/extra
|
|
|
11
11
|
export { extractWebComponentDefinitions } from './extract/framework-adapters/web-components/extractor.js';
|
|
12
12
|
export { extractSvelteComponents } from './extract/framework-adapters/svelte/extractor.js';
|
|
13
13
|
export { extractAllowedComponentsFromTypeText, extractAllowedComponentsFromJsdoc, } from './extract/helpers/evidence/collect-allowed-component-names.js';
|
|
14
|
+
export { bucketComponentProps, bucketComponentsProps, } from './extract/services/classification/bucket-component-props.js';
|
|
14
15
|
// Post-extraction filtering and scoring
|
|
15
16
|
export { evaluateExtractionQuality } from './extract/services/quality/evaluate-extraction-quality.js';
|
|
16
17
|
export { hasNoAuthoringSurface } from './extract/services/quality/helpers/authorability/evaluate-authorability.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experience-design-system-extraction",
|
|
3
|
-
"version": "2.35.1-dev-build-
|
|
3
|
+
"version": "2.35.1-dev-build-b8da2525.0",
|
|
4
4
|
"description": "Component extraction engine for the Contentful Experience Design System SDK",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const DOM_PASS_THROUGH_PROPS = new Set([
|
|
2
|
-
// Bare HTML / framework styling pass-through
|
|
3
|
-
'className',
|
|
4
|
-
'class',
|
|
5
|
-
'classes',
|
|
6
|
-
'classNames',
|
|
7
|
-
'rootClassName',
|
|
8
|
-
'prefixCls',
|
|
9
|
-
'style',
|
|
10
|
-
'styles',
|
|
11
|
-
// Bare HTML attributes
|
|
12
|
-
'id',
|
|
13
|
-
'role',
|
|
14
|
-
'tabIndex',
|
|
15
|
-
'tabindex',
|
|
16
|
-
'htmlFor',
|
|
17
|
-
'for',
|
|
18
|
-
'slot',
|
|
19
|
-
'is',
|
|
20
|
-
'lang',
|
|
21
|
-
'dir',
|
|
22
|
-
'hidden',
|
|
23
|
-
'draggable',
|
|
24
|
-
'spellCheck',
|
|
25
|
-
'spellcheck',
|
|
26
|
-
'contentEditable',
|
|
27
|
-
'contenteditable',
|
|
28
|
-
'inputMode',
|
|
29
|
-
'inputmode',
|
|
30
|
-
'autoComplete',
|
|
31
|
-
'autocomplete',
|
|
32
|
-
'autoFocus',
|
|
33
|
-
'autofocus',
|
|
34
|
-
'translate',
|
|
35
|
-
'part',
|
|
36
|
-
'exportparts',
|
|
37
|
-
'aria',
|
|
38
|
-
// Framework theming / pass-through escape hatches — dev-facing, never marketer-configurable
|
|
39
|
-
'dt',
|
|
40
|
-
'pt',
|
|
41
|
-
'ptOptions',
|
|
42
|
-
'unstyled',
|
|
43
|
-
'sx',
|
|
44
|
-
// Polymorphic component props — change rendered HTML/component, not marketer-visible behavior
|
|
45
|
-
'as',
|
|
46
|
-
'element',
|
|
47
|
-
'component',
|
|
48
|
-
// QA / vendor test attributes
|
|
49
|
-
'dataQa',
|
|
50
|
-
'data-qa',
|
|
51
|
-
// Vue v-model internals — framework wiring, never marketer-configurable
|
|
52
|
-
'modelValue',
|
|
53
|
-
'modelModifiers',
|
|
54
|
-
]);
|
|
55
|
-
/** Returns true when the prop name is a DOM attribute, a11y attribute, or framework pass-through escape hatch. */
|
|
56
|
-
export function isDomPassThroughProp(name) {
|
|
57
|
-
if (DOM_PASS_THROUGH_PROPS.has(name))
|
|
58
|
-
return true;
|
|
59
|
-
// aria-label, aria-hidden, ariaLabel, ariaHidden — both kebab and camel forms
|
|
60
|
-
if (/^aria[-A-Z]/.test(name))
|
|
61
|
-
return true;
|
|
62
|
-
return name.startsWith('data-');
|
|
63
|
-
}
|