@wix/zero-config-implementation 1.106.0 → 1.107.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.d.ts +0 -17
- package/dist/index.js +6362 -6391
- package/package.json +2 -2
- package/src/converters/to-editor-component.test.ts +0 -85
- package/src/converters/to-editor-component.ts +0 -39
- package/src/information-extractors/css/parse.ts +0 -16
- package/src/information-extractors/css/types.ts +0 -17
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.107.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",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
]
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
-
"falconPackageHash": "
|
|
109
|
+
"falconPackageHash": "06e07178bd2c8944810a496429499f8a1f4a9007f694fdeb8d896363"
|
|
110
110
|
}
|
|
@@ -590,91 +590,6 @@ describe('toEditorReactComponent — @property design tokens', () => {
|
|
|
590
590
|
})
|
|
591
591
|
})
|
|
592
592
|
|
|
593
|
-
it('carries the --min / --max / --step descriptors of a number @property into number limits', () => {
|
|
594
|
-
const component = createComponentWithCss(`
|
|
595
|
-
@property --speed { syntax: "<number>"; inherits: true; initial-value: 4; --min: 1; --max: 10; --step: 0.5; }
|
|
596
|
-
`)
|
|
597
|
-
|
|
598
|
-
const customProps = toEditorReactComponent(component).editorElement?.cssCustomProperties
|
|
599
|
-
|
|
600
|
-
expect(customProps?.speed).toEqual({
|
|
601
|
-
displayName: 'Speed',
|
|
602
|
-
defaultValue: '4',
|
|
603
|
-
cssPropertyType: 'number',
|
|
604
|
-
number: { min: '1', max: '10', multiplier: '0.5' },
|
|
605
|
-
})
|
|
606
|
-
})
|
|
607
|
-
|
|
608
|
-
it('emits only the usable half of a partial range and omits the rest', () => {
|
|
609
|
-
const component = createComponentWithCss(`
|
|
610
|
-
@property --weight { syntax: "<number>"; inherits: true; initial-value: 2; --min: 0; }
|
|
611
|
-
@property --tempo { syntax: "<number>"; inherits: true; initial-value: 3; --max: 9; --step: nonsense; }
|
|
612
|
-
@property --offset { syntax: "<number>"; inherits: true; initial-value: 0; --min: ; --max: 12; }
|
|
613
|
-
`)
|
|
614
|
-
|
|
615
|
-
const customProps = toEditorReactComponent(component).editorElement?.cssCustomProperties
|
|
616
|
-
|
|
617
|
-
expect(customProps?.weight).toEqual({
|
|
618
|
-
displayName: 'Weight',
|
|
619
|
-
defaultValue: '2',
|
|
620
|
-
cssPropertyType: 'number',
|
|
621
|
-
number: { min: '0' },
|
|
622
|
-
})
|
|
623
|
-
expect(customProps?.tempo).toEqual({
|
|
624
|
-
displayName: 'Tempo',
|
|
625
|
-
defaultValue: '3',
|
|
626
|
-
cssPropertyType: 'number',
|
|
627
|
-
number: { max: '9' },
|
|
628
|
-
})
|
|
629
|
-
expect(customProps?.offset).toEqual({
|
|
630
|
-
displayName: 'Offset',
|
|
631
|
-
defaultValue: '0',
|
|
632
|
-
cssPropertyType: 'number',
|
|
633
|
-
number: { max: '12' },
|
|
634
|
-
})
|
|
635
|
-
})
|
|
636
|
-
|
|
637
|
-
it('drops an inverted range and a non-positive step, omitting `number` when nothing is usable', () => {
|
|
638
|
-
const component = createComponentWithCss(`
|
|
639
|
-
@property --span { syntax: "<number>"; inherits: true; initial-value: 5; --min: 10; --max: 2; --step: 0; }
|
|
640
|
-
@property --frozen { syntax: "<number>"; inherits: true; initial-value: 5; --min: 5; --max: 5; --step: 1; }
|
|
641
|
-
`)
|
|
642
|
-
|
|
643
|
-
const customProps = toEditorReactComponent(component).editorElement?.cssCustomProperties
|
|
644
|
-
|
|
645
|
-
expect(customProps?.span).toEqual({
|
|
646
|
-
displayName: 'Span',
|
|
647
|
-
defaultValue: '5',
|
|
648
|
-
cssPropertyType: 'number',
|
|
649
|
-
})
|
|
650
|
-
expect(customProps?.frozen).toEqual({
|
|
651
|
-
displayName: 'Frozen',
|
|
652
|
-
defaultValue: '5',
|
|
653
|
-
cssPropertyType: 'number',
|
|
654
|
-
number: { multiplier: '1' },
|
|
655
|
-
})
|
|
656
|
-
})
|
|
657
|
-
|
|
658
|
-
it('ignores range descriptors on a non-number @property', () => {
|
|
659
|
-
const component = createComponentWithCss(`
|
|
660
|
-
@property --sdf-safelight-color { syntax: "<color>"; inherits: true; initial-value: #F02011; --min: 1; --max: 10; }
|
|
661
|
-
@property --gap { syntax: "<length>"; inherits: true; initial-value: 4px; --min: 1; --max: 10; --step: 1; }
|
|
662
|
-
`)
|
|
663
|
-
|
|
664
|
-
const customProps = toEditorReactComponent(component).editorElement?.cssCustomProperties
|
|
665
|
-
|
|
666
|
-
expect(customProps?.['sdf-safelight-color']).toEqual({
|
|
667
|
-
displayName: 'Sdf Safelight Color',
|
|
668
|
-
defaultValue: '#F02011',
|
|
669
|
-
cssPropertyType: 'color',
|
|
670
|
-
})
|
|
671
|
-
expect(customProps?.gap).toEqual({
|
|
672
|
-
displayName: 'Gap',
|
|
673
|
-
defaultValue: '4px',
|
|
674
|
-
cssPropertyType: 'length',
|
|
675
|
-
})
|
|
676
|
-
})
|
|
677
|
-
|
|
678
593
|
it('emits a customEnum dropdown for a pipe-separated ident-list @property', () => {
|
|
679
594
|
const component = createComponentWithCss(`
|
|
680
595
|
@property --sdf-palette { syntax: "warm | cool | neutral"; inherits: false; initial-value: warm; }
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CssCustomPropertyItem,
|
|
3
|
-
CssNumber,
|
|
4
3
|
CssPropertyItem,
|
|
5
4
|
CustomPropertyEnum,
|
|
6
5
|
DataItem,
|
|
@@ -387,7 +386,6 @@ function buildNearestCommonAncestorCustomProps(
|
|
|
387
386
|
? registration.cssPropertyType
|
|
388
387
|
: getVarPropertyTypeFromCssInfos(varName, valueForTypeInference, component.css)
|
|
389
388
|
const customEnum = buildCustomEnum(registration)
|
|
390
|
-
const numberLimits = buildCssNumber(registration, cssPropertyType)
|
|
391
389
|
const cleanVarName = varName.startsWith('--') ? varName.slice(2) : varName
|
|
392
390
|
|
|
393
391
|
const existingProps = nearestCommonAncestorCustomProps.get(nearestCommonAncestorTraceId) ?? {}
|
|
@@ -397,7 +395,6 @@ function buildNearestCommonAncestorCustomProps(
|
|
|
397
395
|
...(statesDefaultValues && { statesDefaultValues }),
|
|
398
396
|
...(cssPropertyType !== undefined && { cssPropertyType }),
|
|
399
397
|
...(customEnum && { customEnum }),
|
|
400
|
-
...(numberLimits && { number: numberLimits }),
|
|
401
398
|
}
|
|
402
399
|
nearestCommonAncestorCustomProps.set(nearestCommonAncestorTraceId, existingProps)
|
|
403
400
|
}
|
|
@@ -493,42 +490,6 @@ function buildCustomEnum(registration: RegisteredCustomProperty | undefined): Cu
|
|
|
493
490
|
}
|
|
494
491
|
}
|
|
495
492
|
|
|
496
|
-
function parseFiniteDescriptor(rawValue: string | undefined): number | undefined {
|
|
497
|
-
const trimmed = rawValue?.trim()
|
|
498
|
-
if (!trimmed) return undefined
|
|
499
|
-
const parsed = Number(trimmed)
|
|
500
|
-
return Number.isFinite(parsed) ? parsed : undefined
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Builds the clamp the panel's number control applies, from an @property's range
|
|
505
|
-
* descriptors. Anything unusable is dropped rather than passed through.
|
|
506
|
-
*/
|
|
507
|
-
function buildCssNumber(
|
|
508
|
-
registration: RegisteredCustomProperty | undefined,
|
|
509
|
-
cssPropertyType: CssCustomPropertyItem['cssPropertyType'],
|
|
510
|
-
): CssNumber | undefined {
|
|
511
|
-
if (!registration?.range || cssPropertyType !== CSS_PROPERTIES.CSS_DATA_TYPE.number) return undefined
|
|
512
|
-
|
|
513
|
-
let min = parseFiniteDescriptor(registration.range.min)
|
|
514
|
-
let max = parseFiniteDescriptor(registration.range.max)
|
|
515
|
-
if (min !== undefined && max !== undefined && min >= max) {
|
|
516
|
-
min = undefined
|
|
517
|
-
max = undefined
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
const step = parseFiniteDescriptor(registration.range.step)
|
|
521
|
-
const multiplier = step !== undefined && step > 0 ? step : undefined
|
|
522
|
-
|
|
523
|
-
if (min === undefined && max === undefined && multiplier === undefined) return undefined
|
|
524
|
-
|
|
525
|
-
return {
|
|
526
|
-
...(min !== undefined && { min: String(min) }),
|
|
527
|
-
...(max !== undefined && { max: String(max) }),
|
|
528
|
-
...(multiplier !== undefined && { multiplier: String(multiplier) }),
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|
|
532
493
|
function getVarPropertyTypeFromCssInfos(
|
|
533
494
|
varName: string,
|
|
534
495
|
defaultValue: string,
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
CssDataType,
|
|
10
10
|
NativePseudoClass,
|
|
11
11
|
RegisteredCustomProperty,
|
|
12
|
-
RegisteredPropertyRange,
|
|
13
12
|
SelectorStateScope,
|
|
14
13
|
StateClassRule,
|
|
15
14
|
} from './types'
|
|
@@ -537,19 +536,6 @@ function extractAtruleDescriptors(block: CssNode): Map<string, string> {
|
|
|
537
536
|
return descriptors
|
|
538
537
|
}
|
|
539
538
|
|
|
540
|
-
/** Picks the range descriptors out of the block; css-tree collects them like any other declaration. */
|
|
541
|
-
function extractRangeDescriptors(descriptors: Map<string, string>): RegisteredPropertyRange | undefined {
|
|
542
|
-
const min = descriptors.get('--min')
|
|
543
|
-
const max = descriptors.get('--max')
|
|
544
|
-
const step = descriptors.get('--step')
|
|
545
|
-
if (min === undefined && max === undefined && step === undefined) return undefined
|
|
546
|
-
return {
|
|
547
|
-
...(min !== undefined && { min }),
|
|
548
|
-
...(max !== undefined && { max }),
|
|
549
|
-
...(step !== undefined && { step }),
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
|
|
553
539
|
/**
|
|
554
540
|
* Walks the stylesheet for `@property` at-rules and builds a map of registered custom
|
|
555
541
|
* properties keyed by the `--`-prefixed variable name.
|
|
@@ -577,13 +563,11 @@ function parseRegisteredProperties(cssString: string): Map<string, RegisteredCus
|
|
|
577
563
|
if (!resolved) return
|
|
578
564
|
const { cssPropertyType, enumOptions } = resolved
|
|
579
565
|
const initialValue = descriptors.get('initial-value')
|
|
580
|
-
const range = extractRangeDescriptors(descriptors)
|
|
581
566
|
|
|
582
567
|
registered.set(varName, {
|
|
583
568
|
cssPropertyType,
|
|
584
569
|
...(enumOptions && { enumOptions }),
|
|
585
570
|
...(initialValue !== undefined && { defaultValue: initialValue }),
|
|
586
|
-
...(range && { range }),
|
|
587
571
|
})
|
|
588
572
|
},
|
|
589
573
|
})
|
|
@@ -69,23 +69,6 @@ export interface RegisteredCustomProperty {
|
|
|
69
69
|
* (`a | b | c`). Present only when `cssPropertyType` is `customEnum`.
|
|
70
70
|
*/
|
|
71
71
|
enumOptions?: string[]
|
|
72
|
-
/**
|
|
73
|
-
* The numeric range for the control, as raw descriptor strings. Validated at
|
|
74
|
-
* conversion time. Meaningful only when `cssPropertyType` is `number`.
|
|
75
|
-
*/
|
|
76
|
-
range?: RegisteredPropertyRange
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* `--min` / `--max` / `--step` descriptors an importer may emit inside an `@property`
|
|
81
|
-
* block. The `--` prefix keeps them in the author namespace: browsers ignore descriptors
|
|
82
|
-
* they don't know, so the CSS stays valid and CSS can't standardise these names out from
|
|
83
|
-
* under us.
|
|
84
|
-
*/
|
|
85
|
-
export interface RegisteredPropertyRange {
|
|
86
|
-
min?: string
|
|
87
|
-
max?: string
|
|
88
|
-
step?: string
|
|
89
72
|
}
|
|
90
73
|
|
|
91
74
|
export type NativePseudoClass = 'hover' | 'focus' | 'disabled' | 'invalid'
|