@barocss/kit 0.0.3 → 0.5.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 +6 -4
- package/dist/index.cjs +8330 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +78 -20
- package/dist/index.js +1687 -1295
- package/dist/index.js.map +1 -1
- package/dist/theme/default.cjs +606 -0
- package/dist/theme/default.cjs.map +1 -0
- package/dist/theme/default.d.ts +7 -2
- package/dist/theme/default.js +20 -15
- package/dist/theme/default.js.map +1 -1
- package/package.json +11 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/** Arbitrary property class `[prop:value]` (parser sets token.property). */
|
|
2
|
+
export declare const arbitraryPropertyRegistration: UtilityRegistration;
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* AST cache management
|
|
3
6
|
*/
|
|
@@ -161,7 +164,7 @@ export declare type AstNode = {
|
|
|
161
164
|
/**
|
|
162
165
|
* Clear all AST caches (mainly for testing)
|
|
163
166
|
*/
|
|
164
|
-
export declare function clearAstCache(): void;
|
|
167
|
+
export declare function clearAstCache(ctx?: Context): void;
|
|
165
168
|
|
|
166
169
|
/**
|
|
167
170
|
* collectDeclPaths
|
|
@@ -204,9 +207,14 @@ export declare type AstNode = {
|
|
|
204
207
|
*/
|
|
205
208
|
preflight?: PreflightLevel;
|
|
206
209
|
/**
|
|
207
|
-
*
|
|
208
|
-
* -
|
|
209
|
-
*
|
|
210
|
+
* Enable kit console diagnostics (off by default).
|
|
211
|
+
* This sets a process-wide flag (see setDebug): it affects every context, and a
|
|
212
|
+
* config without this key leaves the current flag unchanged.
|
|
213
|
+
*/
|
|
214
|
+
debug?: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* @deprecated Contexts now own their caches. Creating a context does not
|
|
217
|
+
* clear caches that belong to another context.
|
|
210
218
|
*/
|
|
211
219
|
clearCacheOnContextChange?: boolean;
|
|
212
220
|
[key: string]: unknown;
|
|
@@ -249,9 +257,16 @@ export declare type AstNode = {
|
|
|
249
257
|
|
|
250
258
|
export declare function escapeClassName(className: string): string;
|
|
251
259
|
|
|
260
|
+
/**
|
|
261
|
+
* Add Tailwind-style spacing inside calc()/min()/max()/clamp():
|
|
262
|
+
* `calc(100%-2rem)` -> `calc(100% - 2rem)`. Leaves nested non-math functions
|
|
263
|
+
* (var(--x-y)), unary signs and exponents (1e-3) alone.
|
|
264
|
+
*/
|
|
265
|
+
export declare function expandThemeFunctions(value: string): string;
|
|
266
|
+
|
|
252
267
|
declare type Function_2 = (...args: unknown[]) => unknown;
|
|
253
268
|
|
|
254
|
-
export declare function functionalModifier(match: ModifierRegistration['match'], modifySelector: ModifierRegistration['modifySelector'], wrap?: ModifierRegistration['wrap'], options?: Partial<ModifierRegistration
|
|
269
|
+
export declare function functionalModifier(match: ModifierRegistration['match'], modifySelector: ModifierRegistration['modifySelector'], wrap?: ModifierRegistration['wrap'], options?: Partial<ModifierRegistration>, ctx?: Context): void;
|
|
255
270
|
|
|
256
271
|
/**
|
|
257
272
|
* functionalUtility: A helper that registers dynamic utilities (theme, arbitrary, custom, negative, fraction, etc.) directly
|
|
@@ -267,7 +282,7 @@ export declare type AstNode = {
|
|
|
267
282
|
* category: 'layout',
|
|
268
283
|
* });
|
|
269
284
|
*/
|
|
270
|
-
export declare function functionalUtility(opts: FunctionalUtilityOptions): void;
|
|
285
|
+
export declare function functionalUtility(opts: FunctionalUtilityOptions, ctx?: Context): void;
|
|
271
286
|
|
|
272
287
|
export declare type FunctionalUtilityExtra = {
|
|
273
288
|
opacity?: string;
|
|
@@ -524,11 +539,26 @@ export declare type AstNode = {
|
|
|
524
539
|
rootCssList: string[];
|
|
525
540
|
};
|
|
526
541
|
|
|
527
|
-
|
|
542
|
+
/** Read AST cache statistics for one context, or the legacy global cache. */
|
|
543
|
+
export declare function getAstCacheStats(ctx?: Context): {
|
|
544
|
+
size: number;
|
|
545
|
+
maxSize: number;
|
|
546
|
+
hitRate: number;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
export declare function getModifier(ctx?: Context): ModifierRegistration[];
|
|
528
550
|
|
|
529
551
|
export declare function getPreflightCSS(level?: PreflightLevel): string;
|
|
530
552
|
|
|
531
|
-
export declare function getUtility(): UtilityRegistration[];
|
|
553
|
+
export declare function getUtility(ctx?: Context): UtilityRegistration[];
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* #224: true when a utility value (or a whole utility token) cannot change the structure of the declaration block it
|
|
557
|
+
* is pasted into. Rejects, outside quotes: `{`, `}`, `;`, unbalanced or mismatched ()/[], and a quote left open.
|
|
558
|
+
* Commas are allowed (values are not selector lists), so this is isSafeVariantValue with top-level commas allowed.
|
|
559
|
+
*/
|
|
560
|
+
/** #248: a comment opener or closer anywhere in a variant (quoted or not) could leave a comment unclosed in the output. */
|
|
561
|
+
export declare function hasCommentToken(value: string): boolean;
|
|
532
562
|
|
|
533
563
|
export declare type HasItems = {
|
|
534
564
|
items?: AstNode[];
|
|
@@ -757,6 +787,19 @@ export declare type AstNode = {
|
|
|
757
787
|
getProcessedClasses(): string[];
|
|
758
788
|
}
|
|
759
789
|
|
|
790
|
+
export declare function isDebug(): boolean;
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* #221: isSafeVariantValue for a whole variant token, except that has-[…]/not-[…] (optionally group-/peer-) may
|
|
794
|
+
* carry a comma at the top level of their bracket value: those variants wrap the value in `:has()`/`:not()`.
|
|
795
|
+
* The value itself must still be balanced and free of `{`, `}` and `;`, so it cannot close the pseudo-class.
|
|
796
|
+
*/
|
|
797
|
+
export declare function isSafeVariantToken(value: string): boolean;
|
|
798
|
+
|
|
799
|
+
export declare function isSafeVariantValue(value: string, allowTopLevelComma?: boolean): boolean;
|
|
800
|
+
|
|
801
|
+
export declare function isStructureSafeValue(value: string): boolean;
|
|
802
|
+
|
|
760
803
|
/**
|
|
761
804
|
* Converts a single BaroJsonInput object into an AST tree.
|
|
762
805
|
* Bypasses string parsing and directly invokes utility/modifier handlers.
|
|
@@ -788,13 +831,7 @@ export declare type AstNode = {
|
|
|
788
831
|
context: Context;
|
|
789
832
|
variantChain?: ParsedModifier[];
|
|
790
833
|
index?: number;
|
|
791
|
-
}) => string |
|
|
792
|
-
selector: string;
|
|
793
|
-
flatten?: boolean;
|
|
794
|
-
wrappingType?: 'rule' | 'style-rule' | 'at-rule';
|
|
795
|
-
override?: boolean;
|
|
796
|
-
source?: string;
|
|
797
|
-
};
|
|
834
|
+
}) => string | ModifierSelector | ModifierSelector[];
|
|
798
835
|
wrap?: (mod: ParsedModifier, context: Context) => AstNode[];
|
|
799
836
|
astHandler?: (ast: AstNode[], mod: ParsedModifier, context: Context, variantChain?: ParsedModifier[], index?: number) => AstNode[];
|
|
800
837
|
sort?: number;
|
|
@@ -804,6 +841,16 @@ export declare type AstNode = {
|
|
|
804
841
|
|
|
805
842
|
export declare const modifierRegistry: ModifierRegistration[];
|
|
806
843
|
|
|
844
|
+
export declare type ModifierSelector = {
|
|
845
|
+
selector: string;
|
|
846
|
+
flatten?: boolean;
|
|
847
|
+
wrappingType?: 'rule' | 'style-rule' | 'at-rule';
|
|
848
|
+
override?: boolean;
|
|
849
|
+
source?: string;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
export declare function normalizeMathSpacing(value: string): string;
|
|
853
|
+
|
|
807
854
|
/**
|
|
808
855
|
* optimizeAst
|
|
809
856
|
* Merges/organizes AST generated by parseClassToAst into an optimized AST tree based on decl-to-root path.
|
|
@@ -831,7 +878,7 @@ export declare type AstNode = {
|
|
|
831
878
|
* @param className e.g. 'group-hover:sm:bg-[red]', 'text-[color:var(--foo)]'
|
|
832
879
|
* @returns { modifiers, utility }
|
|
833
880
|
*/
|
|
834
|
-
export declare function parseClassName(className: string): {
|
|
881
|
+
export declare function parseClassName(className: string, ctx?: Context): {
|
|
835
882
|
modifiers: ParsedModifier[];
|
|
836
883
|
utility: ParsedUtility | null;
|
|
837
884
|
};
|
|
@@ -873,6 +920,8 @@ export declare type AstNode = {
|
|
|
873
920
|
opacity?: string;
|
|
874
921
|
priority?: number;
|
|
875
922
|
important?: boolean;
|
|
923
|
+
/** Set for an arbitrary property class (`[prop:value]`); `value` holds the raw value. */
|
|
924
|
+
property?: string;
|
|
876
925
|
[key: string]: unknown;
|
|
877
926
|
}
|
|
878
927
|
|
|
@@ -912,14 +961,23 @@ export declare type AstNode = {
|
|
|
912
961
|
|
|
913
962
|
export declare function raw(value: string, source?: string): AstNode;
|
|
914
963
|
|
|
915
|
-
export declare function
|
|
964
|
+
export declare function registerModifier(modifier: ModifierRegistration, ctx?: Context): void;
|
|
965
|
+
|
|
966
|
+
export declare function registerUtility(util: UtilityRegistration, ctx?: Context): void;
|
|
916
967
|
|
|
917
968
|
export declare function resolveTheme(config: Config): Theme;
|
|
918
969
|
|
|
919
|
-
export declare function rootToCss(nodes: AstNode[]
|
|
970
|
+
export declare function rootToCss(nodes: AstNode[], opts?: {
|
|
971
|
+
minify?: boolean;
|
|
972
|
+
}): string;
|
|
920
973
|
|
|
921
974
|
export declare function rule(selector: string, nodes: AstNode[], source?: string): AstNode;
|
|
922
975
|
|
|
976
|
+
/** Internal hook for caches owned by contexts. */
|
|
977
|
+
export declare function setContextCacheReset(reset: () => void): void;
|
|
978
|
+
|
|
979
|
+
export declare function setDebug(enabled: boolean): void;
|
|
980
|
+
|
|
923
981
|
/**
|
|
924
982
|
* staticModifier: A helper that registers a modifier name and an array of CSS selectors directly to the registry
|
|
925
983
|
*
|
|
@@ -934,7 +992,7 @@ export declare type AstNode = {
|
|
|
934
992
|
*
|
|
935
993
|
* @returns {void}
|
|
936
994
|
*/
|
|
937
|
-
export declare function staticModifier(name: string, selectors: string[], options?: any): void;
|
|
995
|
+
export declare function staticModifier(name: string, selectors: string[], options?: any, ctx?: Context): void;
|
|
938
996
|
|
|
939
997
|
/**
|
|
940
998
|
* staticUtility: A helper that registers a utility name and an array of CSS declaration pairs directly to the registry
|
|
@@ -964,7 +1022,7 @@ export declare type AstNode = {
|
|
|
964
1022
|
description?: string;
|
|
965
1023
|
category?: string;
|
|
966
1024
|
priority?: number;
|
|
967
|
-
}): void;
|
|
1025
|
+
}, ctx?: Context): void;
|
|
968
1026
|
|
|
969
1027
|
declare type StaticUtilityValue = AstNode | [string, string] | [string, [string, string][]] | ((value: string) => AstNode);
|
|
970
1028
|
|