@csszyx/compiler 0.10.8 → 0.10.10

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.cts CHANGED
@@ -581,6 +581,28 @@ declare const COLOR_PROPERTIES: Set<string>;
581
581
  */
582
582
  declare function getCSSVariableName(property: string, variantPrefix?: string): string;
583
583
 
584
+ /**
585
+ * Deterministic, locale-independent ascending sort for string collections.
586
+ *
587
+ * A bare `Array.prototype.sort()` coerces elements to strings, so it silently
588
+ * mis-orders numbers (`[10, 9]` → `[10, 9]`). Every ordered collection in this
589
+ * codebase is a set of identifiers — class names, mangle tokens, filenames,
590
+ * variant names, CSS-variable references — so the correct sort is lexicographic
591
+ * AND locale-independent (a locale-aware `localeCompare` would make build output
592
+ * order depend on the runner's locale and break reproducibility).
593
+ *
594
+ * This helper encodes exactly that, and its `T extends string` bound makes the
595
+ * intent compiler-checked: passing a `number[]` (or a `(string | number)[]`) is a
596
+ * type error, so a future numeric sort cannot slip through as a bare `.sort()`.
597
+ * The `no-restricted-syntax` lint rule forbids bare `.sort()` to route every sort
598
+ * through here or an explicit comparator.
599
+ *
600
+ * @template T - the (string) element type.
601
+ * @param values - the strings to sort (any iterable; not mutated).
602
+ * @returns a new array sorted ascending by UTF-16 code unit.
603
+ */
604
+ declare function sortStrings<T extends string>(values: Iterable<T>): T[];
605
+
584
606
  /**
585
607
  * Phase D production transform — `transformOxc()` is the oxc-parser +
586
608
  * magic-string replacement for `transformSourceCode()` (Babel). The
@@ -13590,6 +13612,24 @@ type SzArrayElement = SzProps | false | null | undefined;
13590
13612
  * ```
13591
13613
  */
13592
13614
  type SzPropValue = string | SzProps | SzArrayElement[];
13615
+ /**
13616
+ * Value of the `szs` prop — a map of a component's slot names to sz values, so a
13617
+ * consumer styles the parts a compound component renders internally. The build
13618
+ * transform compiles each slot VALUE to its Tailwind class string (keeping the
13619
+ * key), safelists and mangles the classes exactly like `sz`, and the component
13620
+ * forwards `props.szs?.<slot>` into the matching child's `className`.
13621
+ *
13622
+ * Component authors declare their slot set so consumers get autocompletion and
13623
+ * typo checking:
13624
+ *
13625
+ * @example
13626
+ * ```tsx
13627
+ * type CardProps = { szs?: Szs<'header' | 'icon'> };
13628
+ * // consumer:
13629
+ * <Card szs={{ header: { bg: 'gray-100' }, icon: { color: 'red-500' } }} />
13630
+ * ```
13631
+ */
13632
+ type Szs<Slots extends string = string> = Partial<Record<Slots, SzPropValue>>;
13593
13633
 
13594
13634
  /**
13595
13635
  * @csszyx/compiler - TypeScript compiler package for csszyx.
@@ -13639,5 +13679,5 @@ declare const DEFAULT_COMPILER_OPTIONS: Required<CompilerOptions>;
13639
13679
  */
13640
13680
  declare function mergeOptions(options?: Partial<CompilerOptions>): Required<CompilerOptions>;
13641
13681
 
13642
- export { COLOR_PROPERTIES, CsszyxCompiler, DEFAULT_COMPILER_OPTIONS, ManifestBuilder, OxcNotImplementedError, OxcRustNotImplementedError, PROPERTY_CATEGORY_MAP, PropertyCategory, SzObject, VERSION, buildParentMap, createRecoveryToken, ensureRustTransformAvailable, generateRecoveryToken, getCSSVariableName, getPropertyCategory, hoistCSSVariables, injectRecoveryToken, isRustTransformAvailable, isValidRecoveryMode, mergeOptions, parseManifest, scanGlobalVarUsages, serializeManifest, transformOxc, transformRust, transformRustBatch, transformSourceCode, validateManifest, validateSzRecover };
13643
- export type { BackgroundProps, BorderProps, BorderRadiusValue, CSSVarUsage, ColorName, ColorObjectValue, ColorPropValue, ColorShade, ColorValue, CompilerOptions, ContainerSize, CssVariableMangleValue, CustomTheme, EffectsProps, FilterProps, FlexboxGridProps, FractionValue, GlobalVarAliasTableInput, GlobalVarUsageDiagnostic, GlobalVarUsageKind, GlobalVarUsageLocation, InteractivityProps, LayoutProps, NegativeSpacingValue, RecoveryManifest, RecoveryMode, RecoveryToken, ScanGlobalVarUsagesOptions, ShadowValue, SizingProps, SourceTransformResult, SpacingProps, SpacingScale, SpacingValue, SvgProps, SzPropValue, SzProps, SzPropsBase, TableProps, TokenData, TokenMetadata, TransformOxcResult, TransformProps, TransformRustFile, TransformSourceCodeOptions, TransitionAnimationProps, TypographyProps, VariantModifiers };
13682
+ export { COLOR_PROPERTIES, CsszyxCompiler, DEFAULT_COMPILER_OPTIONS, ManifestBuilder, OxcNotImplementedError, OxcRustNotImplementedError, PROPERTY_CATEGORY_MAP, PropertyCategory, SzObject, VERSION, buildParentMap, createRecoveryToken, ensureRustTransformAvailable, generateRecoveryToken, getCSSVariableName, getPropertyCategory, hoistCSSVariables, injectRecoveryToken, isRustTransformAvailable, isValidRecoveryMode, mergeOptions, parseManifest, scanGlobalVarUsages, serializeManifest, sortStrings, transformOxc, transformRust, transformRustBatch, transformSourceCode, validateManifest, validateSzRecover };
13683
+ export type { BackgroundProps, BorderProps, BorderRadiusValue, CSSVarUsage, ColorName, ColorObjectValue, ColorPropValue, ColorShade, ColorValue, CompilerOptions, ContainerSize, CssVariableMangleValue, CustomTheme, EffectsProps, FilterProps, FlexboxGridProps, FractionValue, GlobalVarAliasTableInput, GlobalVarUsageDiagnostic, GlobalVarUsageKind, GlobalVarUsageLocation, InteractivityProps, LayoutProps, NegativeSpacingValue, RecoveryManifest, RecoveryMode, RecoveryToken, ScanGlobalVarUsagesOptions, ShadowValue, SizingProps, SourceTransformResult, SpacingProps, SpacingScale, SpacingValue, SvgProps, SzPropValue, SzProps, SzPropsBase, Szs, TableProps, TokenData, TokenMetadata, TransformOxcResult, TransformProps, TransformRustFile, TransformSourceCodeOptions, TransitionAnimationProps, TypographyProps, VariantModifiers };
package/dist/index.d.mts CHANGED
@@ -581,6 +581,28 @@ declare const COLOR_PROPERTIES: Set<string>;
581
581
  */
582
582
  declare function getCSSVariableName(property: string, variantPrefix?: string): string;
583
583
 
584
+ /**
585
+ * Deterministic, locale-independent ascending sort for string collections.
586
+ *
587
+ * A bare `Array.prototype.sort()` coerces elements to strings, so it silently
588
+ * mis-orders numbers (`[10, 9]` → `[10, 9]`). Every ordered collection in this
589
+ * codebase is a set of identifiers — class names, mangle tokens, filenames,
590
+ * variant names, CSS-variable references — so the correct sort is lexicographic
591
+ * AND locale-independent (a locale-aware `localeCompare` would make build output
592
+ * order depend on the runner's locale and break reproducibility).
593
+ *
594
+ * This helper encodes exactly that, and its `T extends string` bound makes the
595
+ * intent compiler-checked: passing a `number[]` (or a `(string | number)[]`) is a
596
+ * type error, so a future numeric sort cannot slip through as a bare `.sort()`.
597
+ * The `no-restricted-syntax` lint rule forbids bare `.sort()` to route every sort
598
+ * through here or an explicit comparator.
599
+ *
600
+ * @template T - the (string) element type.
601
+ * @param values - the strings to sort (any iterable; not mutated).
602
+ * @returns a new array sorted ascending by UTF-16 code unit.
603
+ */
604
+ declare function sortStrings<T extends string>(values: Iterable<T>): T[];
605
+
584
606
  /**
585
607
  * Phase D production transform — `transformOxc()` is the oxc-parser +
586
608
  * magic-string replacement for `transformSourceCode()` (Babel). The
@@ -13590,6 +13612,24 @@ type SzArrayElement = SzProps | false | null | undefined;
13590
13612
  * ```
13591
13613
  */
13592
13614
  type SzPropValue = string | SzProps | SzArrayElement[];
13615
+ /**
13616
+ * Value of the `szs` prop — a map of a component's slot names to sz values, so a
13617
+ * consumer styles the parts a compound component renders internally. The build
13618
+ * transform compiles each slot VALUE to its Tailwind class string (keeping the
13619
+ * key), safelists and mangles the classes exactly like `sz`, and the component
13620
+ * forwards `props.szs?.<slot>` into the matching child's `className`.
13621
+ *
13622
+ * Component authors declare their slot set so consumers get autocompletion and
13623
+ * typo checking:
13624
+ *
13625
+ * @example
13626
+ * ```tsx
13627
+ * type CardProps = { szs?: Szs<'header' | 'icon'> };
13628
+ * // consumer:
13629
+ * <Card szs={{ header: { bg: 'gray-100' }, icon: { color: 'red-500' } }} />
13630
+ * ```
13631
+ */
13632
+ type Szs<Slots extends string = string> = Partial<Record<Slots, SzPropValue>>;
13593
13633
 
13594
13634
  /**
13595
13635
  * @csszyx/compiler - TypeScript compiler package for csszyx.
@@ -13639,5 +13679,5 @@ declare const DEFAULT_COMPILER_OPTIONS: Required<CompilerOptions>;
13639
13679
  */
13640
13680
  declare function mergeOptions(options?: Partial<CompilerOptions>): Required<CompilerOptions>;
13641
13681
 
13642
- export { COLOR_PROPERTIES, CsszyxCompiler, DEFAULT_COMPILER_OPTIONS, ManifestBuilder, OxcNotImplementedError, OxcRustNotImplementedError, PROPERTY_CATEGORY_MAP, PropertyCategory, SzObject, VERSION, buildParentMap, createRecoveryToken, ensureRustTransformAvailable, generateRecoveryToken, getCSSVariableName, getPropertyCategory, hoistCSSVariables, injectRecoveryToken, isRustTransformAvailable, isValidRecoveryMode, mergeOptions, parseManifest, scanGlobalVarUsages, serializeManifest, transformOxc, transformRust, transformRustBatch, transformSourceCode, validateManifest, validateSzRecover };
13643
- export type { BackgroundProps, BorderProps, BorderRadiusValue, CSSVarUsage, ColorName, ColorObjectValue, ColorPropValue, ColorShade, ColorValue, CompilerOptions, ContainerSize, CssVariableMangleValue, CustomTheme, EffectsProps, FilterProps, FlexboxGridProps, FractionValue, GlobalVarAliasTableInput, GlobalVarUsageDiagnostic, GlobalVarUsageKind, GlobalVarUsageLocation, InteractivityProps, LayoutProps, NegativeSpacingValue, RecoveryManifest, RecoveryMode, RecoveryToken, ScanGlobalVarUsagesOptions, ShadowValue, SizingProps, SourceTransformResult, SpacingProps, SpacingScale, SpacingValue, SvgProps, SzPropValue, SzProps, SzPropsBase, TableProps, TokenData, TokenMetadata, TransformOxcResult, TransformProps, TransformRustFile, TransformSourceCodeOptions, TransitionAnimationProps, TypographyProps, VariantModifiers };
13682
+ export { COLOR_PROPERTIES, CsszyxCompiler, DEFAULT_COMPILER_OPTIONS, ManifestBuilder, OxcNotImplementedError, OxcRustNotImplementedError, PROPERTY_CATEGORY_MAP, PropertyCategory, SzObject, VERSION, buildParentMap, createRecoveryToken, ensureRustTransformAvailable, generateRecoveryToken, getCSSVariableName, getPropertyCategory, hoistCSSVariables, injectRecoveryToken, isRustTransformAvailable, isValidRecoveryMode, mergeOptions, parseManifest, scanGlobalVarUsages, serializeManifest, sortStrings, transformOxc, transformRust, transformRustBatch, transformSourceCode, validateManifest, validateSzRecover };
13683
+ export type { BackgroundProps, BorderProps, BorderRadiusValue, CSSVarUsage, ColorName, ColorObjectValue, ColorPropValue, ColorShade, ColorValue, CompilerOptions, ContainerSize, CssVariableMangleValue, CustomTheme, EffectsProps, FilterProps, FlexboxGridProps, FractionValue, GlobalVarAliasTableInput, GlobalVarUsageDiagnostic, GlobalVarUsageKind, GlobalVarUsageLocation, InteractivityProps, LayoutProps, NegativeSpacingValue, RecoveryManifest, RecoveryMode, RecoveryToken, ScanGlobalVarUsagesOptions, ShadowValue, SizingProps, SourceTransformResult, SpacingProps, SpacingScale, SpacingValue, SvgProps, SzPropValue, SzProps, SzPropsBase, Szs, TableProps, TokenData, TokenMetadata, TransformOxcResult, TransformProps, TransformRustFile, TransformSourceCodeOptions, TransitionAnimationProps, TypographyProps, VariantModifiers };