@barocss/kit 0.0.3 → 0.4.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/README.md CHANGED
@@ -13,10 +13,10 @@
13
13
  - **🚀 JIT Parsing** - Parse Tailwind syntax and generate CSS instantly
14
14
  - **🔍 AST Processing** - Advanced Abstract Syntax Tree manipulation
15
15
  - **⚡ Incremental Parsing** - Efficient parsing with caching
16
- - **🎯 Tailwind Compatible** - Full Tailwind CSS syntax support
16
+ - **🎯 Tailwind-style syntax** - See the [versioned compatibility baseline](docs/tailwind-compatibility.md)
17
17
  - **🌐 Universal** - Works in browsers, Node.js, and any JavaScript environment
18
- - **🎨 Complete Utility Support** - Layout, spacing, colors, typography, and more
19
- - **📱 Responsive & Interactive** - All variants work out of the box
18
+ - **🎨 Utility presets** - Layout, spacing, colors, typography, and more
19
+ - **📱 Responsive & interactive variants** - See the measured examples below
20
20
  - **🧠 Smart Caching** - Caching system for performance optimization
21
21
 
22
22
  ## 🚀 Quick Start
@@ -234,7 +234,7 @@ const stats = parser.getStats();
234
234
 
235
235
  ## 📱 Supported Utilities
236
236
 
237
- BaroCSS supports **most Tailwind CSS utilities**:
237
+ BaroCSS supports the utilities listed below. See the [compatibility baseline](docs/tailwind-compatibility.md) for measured examples.
238
238
 
239
239
  ### Layout
240
240
  - `container`, `columns`, `break-after`, `break-before`
package/dist/index.d.ts CHANGED
@@ -161,7 +161,7 @@ export declare type AstNode = {
161
161
  /**
162
162
  * Clear all AST caches (mainly for testing)
163
163
  */
164
- export declare function clearAstCache(): void;
164
+ export declare function clearAstCache(ctx?: Context): void;
165
165
 
166
166
  /**
167
167
  * collectDeclPaths
@@ -204,9 +204,8 @@ export declare type AstNode = {
204
204
  */
205
205
  preflight?: PreflightLevel;
206
206
  /**
207
- * Whether to clear all caches when context is created/changed
208
- * - true (default): Clear all caches on context change
209
- * - false: Keep existing caches
207
+ * @deprecated Contexts now own their caches. Creating a context does not
208
+ * clear caches that belong to another context.
210
209
  */
211
210
  clearCacheOnContextChange?: boolean;
212
211
  [key: string]: unknown;
@@ -251,7 +250,7 @@ export declare type AstNode = {
251
250
 
252
251
  declare type Function_2 = (...args: unknown[]) => unknown;
253
252
 
254
- export declare function functionalModifier(match: ModifierRegistration['match'], modifySelector: ModifierRegistration['modifySelector'], wrap?: ModifierRegistration['wrap'], options?: Partial<ModifierRegistration>): void;
253
+ export declare function functionalModifier(match: ModifierRegistration['match'], modifySelector: ModifierRegistration['modifySelector'], wrap?: ModifierRegistration['wrap'], options?: Partial<ModifierRegistration>, ctx?: Context): void;
255
254
 
256
255
  /**
257
256
  * functionalUtility: A helper that registers dynamic utilities (theme, arbitrary, custom, negative, fraction, etc.) directly
@@ -267,7 +266,7 @@ export declare type AstNode = {
267
266
  * category: 'layout',
268
267
  * });
269
268
  */
270
- export declare function functionalUtility(opts: FunctionalUtilityOptions): void;
269
+ export declare function functionalUtility(opts: FunctionalUtilityOptions, ctx?: Context): void;
271
270
 
272
271
  export declare type FunctionalUtilityExtra = {
273
272
  opacity?: string;
@@ -524,11 +523,18 @@ export declare type AstNode = {
524
523
  rootCssList: string[];
525
524
  };
526
525
 
527
- export declare function getModifier(): ModifierRegistration[];
526
+ /** Read AST cache statistics for one context, or the legacy global cache. */
527
+ export declare function getAstCacheStats(ctx?: Context): {
528
+ size: number;
529
+ maxSize: number;
530
+ hitRate: number;
531
+ };
532
+
533
+ export declare function getModifier(ctx?: Context): ModifierRegistration[];
528
534
 
529
535
  export declare function getPreflightCSS(level?: PreflightLevel): string;
530
536
 
531
- export declare function getUtility(): UtilityRegistration[];
537
+ export declare function getUtility(ctx?: Context): UtilityRegistration[];
532
538
 
533
539
  export declare type HasItems = {
534
540
  items?: AstNode[];
@@ -788,13 +794,7 @@ export declare type AstNode = {
788
794
  context: Context;
789
795
  variantChain?: ParsedModifier[];
790
796
  index?: number;
791
- }) => string | {
792
- selector: string;
793
- flatten?: boolean;
794
- wrappingType?: 'rule' | 'style-rule' | 'at-rule';
795
- override?: boolean;
796
- source?: string;
797
- };
797
+ }) => string | ModifierSelector | ModifierSelector[];
798
798
  wrap?: (mod: ParsedModifier, context: Context) => AstNode[];
799
799
  astHandler?: (ast: AstNode[], mod: ParsedModifier, context: Context, variantChain?: ParsedModifier[], index?: number) => AstNode[];
800
800
  sort?: number;
@@ -804,6 +804,14 @@ export declare type AstNode = {
804
804
 
805
805
  export declare const modifierRegistry: ModifierRegistration[];
806
806
 
807
+ export declare type ModifierSelector = {
808
+ selector: string;
809
+ flatten?: boolean;
810
+ wrappingType?: 'rule' | 'style-rule' | 'at-rule';
811
+ override?: boolean;
812
+ source?: string;
813
+ };
814
+
807
815
  /**
808
816
  * optimizeAst
809
817
  * Merges/organizes AST generated by parseClassToAst into an optimized AST tree based on decl-to-root path.
@@ -831,7 +839,7 @@ export declare type AstNode = {
831
839
  * @param className e.g. 'group-hover:sm:bg-[red]', 'text-[color:var(--foo)]'
832
840
  * @returns { modifiers, utility }
833
841
  */
834
- export declare function parseClassName(className: string): {
842
+ export declare function parseClassName(className: string, ctx?: Context): {
835
843
  modifiers: ParsedModifier[];
836
844
  utility: ParsedUtility | null;
837
845
  };
@@ -912,7 +920,9 @@ export declare type AstNode = {
912
920
 
913
921
  export declare function raw(value: string, source?: string): AstNode;
914
922
 
915
- export declare function registerUtility(util: UtilityRegistration): void;
923
+ export declare function registerModifier(modifier: ModifierRegistration, ctx?: Context): void;
924
+
925
+ export declare function registerUtility(util: UtilityRegistration, ctx?: Context): void;
916
926
 
917
927
  export declare function resolveTheme(config: Config): Theme;
918
928
 
@@ -920,6 +930,9 @@ export declare type AstNode = {
920
930
 
921
931
  export declare function rule(selector: string, nodes: AstNode[], source?: string): AstNode;
922
932
 
933
+ /** Internal hook for caches owned by contexts. */
934
+ export declare function setContextCacheReset(reset: () => void): void;
935
+
923
936
  /**
924
937
  * staticModifier: A helper that registers a modifier name and an array of CSS selectors directly to the registry
925
938
  *
@@ -934,7 +947,7 @@ export declare type AstNode = {
934
947
  *
935
948
  * @returns {void}
936
949
  */
937
- export declare function staticModifier(name: string, selectors: string[], options?: any): void;
950
+ export declare function staticModifier(name: string, selectors: string[], options?: any, ctx?: Context): void;
938
951
 
939
952
  /**
940
953
  * staticUtility: A helper that registers a utility name and an array of CSS declaration pairs directly to the registry
@@ -964,7 +977,7 @@ export declare type AstNode = {
964
977
  description?: string;
965
978
  category?: string;
966
979
  priority?: number;
967
- }): void;
980
+ }, ctx?: Context): void;
968
981
 
969
982
  declare type StaticUtilityValue = AstNode | [string, string] | [string, [string, string][]] | ((value: string) => AstNode);
970
983