@barocss/kit 0.10.2 → 0.11.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.cts CHANGED
@@ -69,6 +69,8 @@ export declare type AstNode = {
69
69
  export declare function astToCss(ast: AstNode[], baseSelector?: string, opts?: {
70
70
  minify?: boolean;
71
71
  important?: boolean;
72
+ scope?: string;
73
+ nested?: boolean;
72
74
  }, _indent?: string): string;
73
75
 
74
76
  export declare function atRoot(nodes: AstNode[], source?: string): AstNode;
@@ -383,6 +385,11 @@ export declare type AstNode = {
383
385
  * Whether to support opacity values
384
386
  */
385
387
  supportsOpacity?: boolean;
388
+ /**
389
+ * #393: the handlers apply the opacity modifier of an arbitrary / custom-property value themselves (shadow
390
+ * alpha); otherwise functionalUtility mixes the emitted colour, and emits nothing if there is no colour to mix.
391
+ */
392
+ ownsOpacity?: boolean;
386
393
  /**
387
394
  * The handler function that processes values
388
395
  *
@@ -823,6 +830,14 @@ export declare type AstNode = {
823
830
 
824
831
  export declare function isSafeVariantValue(value: string, allowTopLevelComma?: boolean): boolean;
825
832
 
833
+ /**
834
+ * #392: true when every top-level comma part of an emitted selector names `escapedClass` (a class selector
835
+ * already escaped with escapeClassName, including its leading dot) as a whole class token, or, when
836
+ * `allowNesting` is set, uses the nesting selector `&`. Escapes, quoted strings and bracket groups are skipped
837
+ * when splitting. Used as a defence-in-depth serializer check: a rule scoped to no generating class is dropped.
838
+ */
839
+ export declare function isScopedSelector(selector: string, escapedClass: string, allowNesting?: boolean): boolean;
840
+
826
841
  export declare function isStructureSafeValue(value: string): boolean;
827
842
 
828
843
  /**
@@ -1005,6 +1020,9 @@ export declare type AstNode = {
1005
1020
 
1006
1021
  export declare function registerUtility(util: UtilityRegistration, ctx?: Context): void;
1007
1022
 
1023
+ /** #393: a handler result meaning "this class is invalid": the engine stops trying other registrations. */
1024
+ export declare const REJECT_CLASS: AstNode[];
1025
+
1008
1026
  export declare function resolveTheme(config: Config): Theme;
1009
1027
 
1010
1028
  export declare function rootToCss(nodes: AstNode[], opts?: {
@@ -1013,27 +1031,13 @@ export declare type AstNode = {
1013
1031
 
1014
1032
  export declare function rule(selector: string, nodes: AstNode[], source?: string): AstNode;
1015
1033
 
1034
+ export declare type RuleKey = Array<number | string>;
1035
+
1016
1036
  /**
1017
- * Tailwind-compatible cascade order for runtime-inserted rules (#254); shared by @barocss/server (#267).
1018
- *
1019
- * The runtime discovers classes in DOM order, so without sorting `lg:px-8`
1020
- * seen before `sm:px-6` would land earlier and lose at >= 1024px. Each rule
1021
- * gets a sort key derived from its leading `@media` / `@container` preludes:
1022
- *
1023
- * 0 base, negated media (`not-md:` → `@media not (…)`, as Tailwind 4.3.3 orders them, #352),
1024
- * state media (hover), motion/contrast, unknown
1025
- * 1 max-* breakpoints (larger width first)
1026
- * 2 min-* breakpoints (smaller width first)
1027
- * 3 @max-* container queries (larger width first)
1028
- * 4 @min-* container queries (smaller width first)
1029
- * 5 orientation, dark (prefers-color-scheme), print, forced-colors
1030
- *
1031
- * Nested at-rules (e.g. `sm:dark:`) contribute one key pair per level, so
1032
- * `sm:` < `sm:dark:` < `md:`. Equal keys keep discovery order.
1037
+ * Full sort key: the #254 variant pairs, then (#401) Tailwind's property sort and the class name.
1038
+ * `candidate` defaults to the rule's first class.
1033
1039
  */
1034
- export declare type RuleKey = number[];
1035
-
1036
- export declare function ruleSortKey(rule: string): RuleKey;
1040
+ export declare function ruleSortKey(rule: string, candidate?: string): RuleKey;
1037
1041
 
1038
1042
  /** Internal hook for caches owned by contexts. */
1039
1043
  export declare function setContextCacheReset(reset: () => void): void;
package/dist/index.d.ts CHANGED
@@ -69,6 +69,8 @@ export declare type AstNode = {
69
69
  export declare function astToCss(ast: AstNode[], baseSelector?: string, opts?: {
70
70
  minify?: boolean;
71
71
  important?: boolean;
72
+ scope?: string;
73
+ nested?: boolean;
72
74
  }, _indent?: string): string;
73
75
 
74
76
  export declare function atRoot(nodes: AstNode[], source?: string): AstNode;
@@ -383,6 +385,11 @@ export declare type AstNode = {
383
385
  * Whether to support opacity values
384
386
  */
385
387
  supportsOpacity?: boolean;
388
+ /**
389
+ * #393: the handlers apply the opacity modifier of an arbitrary / custom-property value themselves (shadow
390
+ * alpha); otherwise functionalUtility mixes the emitted colour, and emits nothing if there is no colour to mix.
391
+ */
392
+ ownsOpacity?: boolean;
386
393
  /**
387
394
  * The handler function that processes values
388
395
  *
@@ -823,6 +830,14 @@ export declare type AstNode = {
823
830
 
824
831
  export declare function isSafeVariantValue(value: string, allowTopLevelComma?: boolean): boolean;
825
832
 
833
+ /**
834
+ * #392: true when every top-level comma part of an emitted selector names `escapedClass` (a class selector
835
+ * already escaped with escapeClassName, including its leading dot) as a whole class token, or, when
836
+ * `allowNesting` is set, uses the nesting selector `&`. Escapes, quoted strings and bracket groups are skipped
837
+ * when splitting. Used as a defence-in-depth serializer check: a rule scoped to no generating class is dropped.
838
+ */
839
+ export declare function isScopedSelector(selector: string, escapedClass: string, allowNesting?: boolean): boolean;
840
+
826
841
  export declare function isStructureSafeValue(value: string): boolean;
827
842
 
828
843
  /**
@@ -1005,6 +1020,9 @@ export declare type AstNode = {
1005
1020
 
1006
1021
  export declare function registerUtility(util: UtilityRegistration, ctx?: Context): void;
1007
1022
 
1023
+ /** #393: a handler result meaning "this class is invalid": the engine stops trying other registrations. */
1024
+ export declare const REJECT_CLASS: AstNode[];
1025
+
1008
1026
  export declare function resolveTheme(config: Config): Theme;
1009
1027
 
1010
1028
  export declare function rootToCss(nodes: AstNode[], opts?: {
@@ -1013,27 +1031,13 @@ export declare type AstNode = {
1013
1031
 
1014
1032
  export declare function rule(selector: string, nodes: AstNode[], source?: string): AstNode;
1015
1033
 
1034
+ export declare type RuleKey = Array<number | string>;
1035
+
1016
1036
  /**
1017
- * Tailwind-compatible cascade order for runtime-inserted rules (#254); shared by @barocss/server (#267).
1018
- *
1019
- * The runtime discovers classes in DOM order, so without sorting `lg:px-8`
1020
- * seen before `sm:px-6` would land earlier and lose at >= 1024px. Each rule
1021
- * gets a sort key derived from its leading `@media` / `@container` preludes:
1022
- *
1023
- * 0 base, negated media (`not-md:` → `@media not (…)`, as Tailwind 4.3.3 orders them, #352),
1024
- * state media (hover), motion/contrast, unknown
1025
- * 1 max-* breakpoints (larger width first)
1026
- * 2 min-* breakpoints (smaller width first)
1027
- * 3 @max-* container queries (larger width first)
1028
- * 4 @min-* container queries (smaller width first)
1029
- * 5 orientation, dark (prefers-color-scheme), print, forced-colors
1030
- *
1031
- * Nested at-rules (e.g. `sm:dark:`) contribute one key pair per level, so
1032
- * `sm:` < `sm:dark:` < `md:`. Equal keys keep discovery order.
1037
+ * Full sort key: the #254 variant pairs, then (#401) Tailwind's property sort and the class name.
1038
+ * `candidate` defaults to the rule's first class.
1033
1039
  */
1034
- export declare type RuleKey = number[];
1035
-
1036
- export declare function ruleSortKey(rule: string): RuleKey;
1040
+ export declare function ruleSortKey(rule: string, candidate?: string): RuleKey;
1037
1041
 
1038
1042
  /** Internal hook for caches owned by contexts. */
1039
1043
  export declare function setContextCacheReset(reset: () => void): void;