@barocss/kit 0.4.0 → 0.6.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 +2 -0
- package/dist/index.cjs +8433 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +92 -15
- package/dist/index.js +1439 -999
- 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.js +20 -15
- package/dist/theme/default.js.map +1 -1
- package/package.json +3 -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
|
*/
|
|
@@ -178,6 +181,8 @@ export declare type AstNode = {
|
|
|
178
181
|
|
|
179
182
|
export declare function comment(text: string, source?: string): AstNode;
|
|
180
183
|
|
|
184
|
+
export declare function compareKeys(a: RuleKey, b: RuleKey): number;
|
|
185
|
+
|
|
181
186
|
export declare interface Config {
|
|
182
187
|
prefix?: string;
|
|
183
188
|
cssVarPrefix?: string;
|
|
@@ -203,6 +208,12 @@ export declare type AstNode = {
|
|
|
203
208
|
* default: true (full preflight)
|
|
204
209
|
*/
|
|
205
210
|
preflight?: PreflightLevel;
|
|
211
|
+
/**
|
|
212
|
+
* Enable kit console diagnostics (off by default).
|
|
213
|
+
* This sets a process-wide flag (see setDebug): it affects every context, and a
|
|
214
|
+
* config without this key leaves the current flag unchanged.
|
|
215
|
+
*/
|
|
216
|
+
debug?: boolean;
|
|
206
217
|
/**
|
|
207
218
|
* @deprecated Contexts now own their caches. Creating a context does not
|
|
208
219
|
* clear caches that belong to another context.
|
|
@@ -248,24 +259,17 @@ export declare type AstNode = {
|
|
|
248
259
|
|
|
249
260
|
export declare function escapeClassName(className: string): string;
|
|
250
261
|
|
|
262
|
+
/**
|
|
263
|
+
* Add Tailwind-style spacing inside calc()/min()/max()/clamp():
|
|
264
|
+
* `calc(100%-2rem)` -> `calc(100% - 2rem)`. Leaves nested non-math functions
|
|
265
|
+
* (var(--x-y)), unary signs and exponents (1e-3) alone.
|
|
266
|
+
*/
|
|
267
|
+
export declare function expandThemeFunctions(value: string): string;
|
|
268
|
+
|
|
251
269
|
declare type Function_2 = (...args: unknown[]) => unknown;
|
|
252
270
|
|
|
253
271
|
export declare function functionalModifier(match: ModifierRegistration['match'], modifySelector: ModifierRegistration['modifySelector'], wrap?: ModifierRegistration['wrap'], options?: Partial<ModifierRegistration>, ctx?: Context): void;
|
|
254
272
|
|
|
255
|
-
/**
|
|
256
|
-
* functionalUtility: A helper that registers dynamic utilities (theme, arbitrary, custom, negative, fraction, etc.) directly
|
|
257
|
-
*
|
|
258
|
-
* Example:
|
|
259
|
-
* functionalUtility({
|
|
260
|
-
* name: 'z',
|
|
261
|
-
* supportsNegative: true,
|
|
262
|
-
* themeKeys: ['--z-index'],
|
|
263
|
-
* handleBareValue: ({ value }) => isPositiveInteger(value) ? value : null,
|
|
264
|
-
* handle: (value) => [decl('z-index', value)],
|
|
265
|
-
* description: 'z-index utility',
|
|
266
|
-
* category: 'layout',
|
|
267
|
-
* });
|
|
268
|
-
*/
|
|
269
273
|
export declare function functionalUtility(opts: FunctionalUtilityOptions, ctx?: Context): void;
|
|
270
274
|
|
|
271
275
|
export declare type FunctionalUtilityExtra = {
|
|
@@ -404,6 +408,12 @@ export declare type AstNode = {
|
|
|
404
408
|
* handleNegativeBareValue: ({ value }) => isPositiveInteger(value) ? value : null,
|
|
405
409
|
* ```
|
|
406
410
|
*/
|
|
411
|
+
/**
|
|
412
|
+
* #261: the utility uses the spacing scale, so a named `theme.spacing` key (`p-gutter`) resolves to
|
|
413
|
+
* `var(--spacing-<key>)` (negative: `calc(var(--spacing-<key>) * -1)`), as in Tailwind 4. Only tried
|
|
414
|
+
* after the bare-value handler rejects the value, so built-in keywords keep precedence.
|
|
415
|
+
*/
|
|
416
|
+
spacingKeys?: boolean;
|
|
407
417
|
handleNegativeBareValue?: (args: {
|
|
408
418
|
value: string;
|
|
409
419
|
ctx: Context;
|
|
@@ -536,6 +546,21 @@ export declare type AstNode = {
|
|
|
536
546
|
|
|
537
547
|
export declare function getUtility(ctx?: Context): UtilityRegistration[];
|
|
538
548
|
|
|
549
|
+
/**
|
|
550
|
+
* #273: true when an emitted selector or at-rule prelude contains a comment opener or closer outside a CSS escape.
|
|
551
|
+
* Backslash-escape pairs are skipped, so an escaped `\/` or `\*` from a class name never counts. Used by the
|
|
552
|
+
* serializer on the final, composed string, where adjacent pieces that were each safe alone can join into one.
|
|
553
|
+
*/
|
|
554
|
+
export declare function hasCommentDelimiter(text: string): boolean;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* #224: true when a utility value (or a whole utility token) cannot change the structure of the declaration block it
|
|
558
|
+
* is pasted into. Rejects, outside quotes: `{`, `}`, `;`, unbalanced or mismatched ()/[], and a quote left open.
|
|
559
|
+
* Commas are allowed (values are not selector lists), so this is isSafeVariantValue with top-level commas allowed.
|
|
560
|
+
*/
|
|
561
|
+
/** #248: a comment opener or closer anywhere in a variant (quoted or not) could leave a comment unclosed in the output. */
|
|
562
|
+
export declare function hasCommentToken(value: string): boolean;
|
|
563
|
+
|
|
539
564
|
export declare type HasItems = {
|
|
540
565
|
items?: AstNode[];
|
|
541
566
|
};
|
|
@@ -747,6 +772,13 @@ export declare type AstNode = {
|
|
|
747
772
|
* @param cls - The CSS class name to mark as processed
|
|
748
773
|
*/
|
|
749
774
|
markProcessed(cls: string): void;
|
|
775
|
+
/**
|
|
776
|
+
* Forgets that a class was processed, so a later request generates it again
|
|
777
|
+
* (used when the browser runtime reclaims an unused class's rules, #269).
|
|
778
|
+
*
|
|
779
|
+
* @param cls - The CSS class name to forget
|
|
780
|
+
*/
|
|
781
|
+
unmarkProcessed(cls: string): void;
|
|
750
782
|
/**
|
|
751
783
|
* Process classes synchronously and update BrowserRuntime cache
|
|
752
784
|
* This method is used by ChangeDetector for scan operations
|
|
@@ -763,6 +795,19 @@ export declare type AstNode = {
|
|
|
763
795
|
getProcessedClasses(): string[];
|
|
764
796
|
}
|
|
765
797
|
|
|
798
|
+
export declare function isDebug(): boolean;
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* #221: isSafeVariantValue for a whole variant token, except that has-[…]/not-[…] (optionally group-/peer-) may
|
|
802
|
+
* carry a comma at the top level of their bracket value: those variants wrap the value in `:has()`/`:not()`.
|
|
803
|
+
* The value itself must still be balanced and free of `{`, `}` and `;`, so it cannot close the pseudo-class.
|
|
804
|
+
*/
|
|
805
|
+
export declare function isSafeVariantToken(value: string): boolean;
|
|
806
|
+
|
|
807
|
+
export declare function isSafeVariantValue(value: string, allowTopLevelComma?: boolean): boolean;
|
|
808
|
+
|
|
809
|
+
export declare function isStructureSafeValue(value: string): boolean;
|
|
810
|
+
|
|
766
811
|
/**
|
|
767
812
|
* Converts a single BaroJsonInput object into an AST tree.
|
|
768
813
|
* Bypasses string parsing and directly invokes utility/modifier handlers.
|
|
@@ -812,6 +857,8 @@ export declare type AstNode = {
|
|
|
812
857
|
source?: string;
|
|
813
858
|
};
|
|
814
859
|
|
|
860
|
+
export declare function normalizeMathSpacing(value: string): string;
|
|
861
|
+
|
|
815
862
|
/**
|
|
816
863
|
* optimizeAst
|
|
817
864
|
* Merges/organizes AST generated by parseClassToAst into an optimized AST tree based on decl-to-root path.
|
|
@@ -881,6 +928,8 @@ export declare type AstNode = {
|
|
|
881
928
|
opacity?: string;
|
|
882
929
|
priority?: number;
|
|
883
930
|
important?: boolean;
|
|
931
|
+
/** Set for an arbitrary property class (`[prop:value]`); `value` holds the raw value. */
|
|
932
|
+
property?: string;
|
|
884
933
|
[key: string]: unknown;
|
|
885
934
|
}
|
|
886
935
|
|
|
@@ -926,13 +975,38 @@ export declare type AstNode = {
|
|
|
926
975
|
|
|
927
976
|
export declare function resolveTheme(config: Config): Theme;
|
|
928
977
|
|
|
929
|
-
export declare function rootToCss(nodes: AstNode[]
|
|
978
|
+
export declare function rootToCss(nodes: AstNode[], opts?: {
|
|
979
|
+
minify?: boolean;
|
|
980
|
+
}): string;
|
|
930
981
|
|
|
931
982
|
export declare function rule(selector: string, nodes: AstNode[], source?: string): AstNode;
|
|
932
983
|
|
|
984
|
+
/**
|
|
985
|
+
* Tailwind-compatible cascade order for runtime-inserted rules (#254); shared by @barocss/server (#267).
|
|
986
|
+
*
|
|
987
|
+
* The runtime discovers classes in DOM order, so without sorting `lg:px-8`
|
|
988
|
+
* seen before `sm:px-6` would land earlier and lose at >= 1024px. Each rule
|
|
989
|
+
* gets a sort key derived from its leading `@media` / `@container` preludes:
|
|
990
|
+
*
|
|
991
|
+
* 0 base, state media (hover), motion/contrast, unknown
|
|
992
|
+
* 1 max-* breakpoints (larger width first)
|
|
993
|
+
* 2 min-* breakpoints (smaller width first)
|
|
994
|
+
* 3 @max-* container queries (larger width first)
|
|
995
|
+
* 4 @min-* container queries (smaller width first)
|
|
996
|
+
* 5 orientation, dark (prefers-color-scheme), print, forced-colors
|
|
997
|
+
*
|
|
998
|
+
* Nested at-rules (e.g. `sm:dark:`) contribute one key pair per level, so
|
|
999
|
+
* `sm:` < `sm:dark:` < `md:`. Equal keys keep discovery order.
|
|
1000
|
+
*/
|
|
1001
|
+
export declare type RuleKey = number[];
|
|
1002
|
+
|
|
1003
|
+
export declare function ruleSortKey(rule: string): RuleKey;
|
|
1004
|
+
|
|
933
1005
|
/** Internal hook for caches owned by contexts. */
|
|
934
1006
|
export declare function setContextCacheReset(reset: () => void): void;
|
|
935
1007
|
|
|
1008
|
+
export declare function setDebug(enabled: boolean): void;
|
|
1009
|
+
|
|
936
1010
|
/**
|
|
937
1011
|
* staticModifier: A helper that registers a modifier name and an array of CSS selectors directly to the registry
|
|
938
1012
|
*
|
|
@@ -1042,6 +1116,9 @@ export declare type AstNode = {
|
|
|
1042
1116
|
*/
|
|
1043
1117
|
export declare function tokenize(className: string): Token[];
|
|
1044
1118
|
|
|
1119
|
+
/** Index after the last key <= `key` (stable upper bound) in sorted `keys`. */
|
|
1120
|
+
export declare function upperBound(keys: RuleKey[], key: RuleKey): number;
|
|
1121
|
+
|
|
1045
1122
|
/**
|
|
1046
1123
|
* Utility cache management
|
|
1047
1124
|
*/
|