@stacksjs/ts-css 0.3.23 → 0.3.25
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/bin/cli.js +1 -1
- package/dist/bin/cssx.js +100 -75
- package/dist/{chunk-aj9hxvcm.js → chunk-k6ta54hd.js} +2 -2
- package/dist/{chunk-pmshwcfp.js → chunk-zn8gy7w7.js} +1 -1
- package/dist/engine/generator.d.ts +3 -1
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.js +49 -24
- package/dist/engine/safelist.d.ts +42 -0
- package/dist/engine/stylesheet.d.ts +44 -0
- package/dist/engine/types.d.ts +13 -1
- package/dist/index.js +1 -1
- package/dist/optimize/index.js +1 -1
- package/dist/select/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { SafelistEntry } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolving a safelist into class names.
|
|
4
|
+
*
|
|
5
|
+
* `safelist` took string literals only, and a pattern was rejected outright
|
|
6
|
+
* while `blocklist`, on the same config object, compiled `*` globs. The
|
|
7
|
+
* machinery existed on the exclusion side and never on the inclusion side,
|
|
8
|
+
* which left a family of classes -- a colour cross-product driven by runtime
|
|
9
|
+
* data, say -- as dozens of literals maintained by hand.
|
|
10
|
+
*
|
|
11
|
+
* The asymmetry is not quite symmetrical to fix: a blocklist pattern only has
|
|
12
|
+
* to FILTER names the scanner already found, while a safelist pattern has to
|
|
13
|
+
* PRODUCE names nothing in the source mentions. A regular expression cannot be
|
|
14
|
+
* run backwards into the names that would match it, and there is no registry
|
|
15
|
+
* of every generatable utility to test it against. So the two forms do
|
|
16
|
+
* different jobs here, and both are honest about which:
|
|
17
|
+
*
|
|
18
|
+
* - brace expansion PRODUCES names, and is how a family is written:
|
|
19
|
+
* `{bg,text,border}-{red,blue}-{100,700}` is those twelve classes;
|
|
20
|
+
* - a RegExp FILTERS the names already in play -- the expansions above and
|
|
21
|
+
* everything the scanner found -- which is how you keep a family that is
|
|
22
|
+
* used somewhere in the project present in every output.
|
|
23
|
+
*
|
|
24
|
+
* Both accept `variants`, applied as prefixes to each resolved name.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Expand `{a,b}` groups combinatorially: one group yields its alternatives,
|
|
28
|
+
* several multiply. `{}` and `{a}` are not groups worth expanding and are
|
|
29
|
+
* left alone, as is a string with no brace at all, which is the common case
|
|
30
|
+
* and must stay exactly itself.
|
|
31
|
+
*
|
|
32
|
+
* Nested braces are not expanded; the inner text is taken literally.
|
|
33
|
+
*/
|
|
34
|
+
export declare function expandBraces(entry: string): string[];
|
|
35
|
+
/**
|
|
36
|
+
* The class names a safelist asks for.
|
|
37
|
+
*
|
|
38
|
+
* `scanned` is what the extractor found, which is the pool a RegExp entry
|
|
39
|
+
* filters. Pass an empty set when there is nothing scanned yet; literal and
|
|
40
|
+
* brace entries do not depend on it.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveSafelist(safelist: readonly SafelistEntry[], scanned?: ReadonlySet<string>): Set<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CSSGenerator } from './generator';
|
|
2
|
+
import type { Theme } from './types';
|
|
3
|
+
export declare function resolveThemeCalls(css: string, theme: Theme): { css: string, unknown: string[] };
|
|
4
|
+
/**
|
|
5
|
+
* Expand every `@apply` in a stylesheet.
|
|
6
|
+
*
|
|
7
|
+
* Declarations from an unvariated utility are written where the `@apply` was,
|
|
8
|
+
* so they sit in the author's own block and keep its cascade position. A
|
|
9
|
+
* utility that carries a variant or a media query cannot go there -- it needs
|
|
10
|
+
* its own selector -- so those are collected and appended after the sheet, in
|
|
11
|
+
* the order they were applied.
|
|
12
|
+
*/
|
|
13
|
+
export declare function expandApply(css: string, generator: CSSGenerator): { css: string, unknown: string[] };
|
|
14
|
+
/** Run an authored stylesheet through `theme()` and `@apply`. */
|
|
15
|
+
export declare function processStylesheet(css: string, generator: CSSGenerator, theme: Theme): StylesheetResult;
|
|
16
|
+
/**
|
|
17
|
+
* Whether a string still carries an `@apply`.
|
|
18
|
+
*
|
|
19
|
+
* A preflight is shipped verbatim, so an `@apply` written in one reaches the
|
|
20
|
+
* browser as an unknown at-rule and is dropped without a word. Callers use
|
|
21
|
+
* this to say so.
|
|
22
|
+
*/
|
|
23
|
+
export declare function containsApply(css: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Processing an authored stylesheet.
|
|
26
|
+
*
|
|
27
|
+
* The engine only ever scanned markup for class names, so hand-written
|
|
28
|
+
* component CSS had nowhere to go but a `preflights` string or a framework
|
|
29
|
+
* `<style>` block -- neither of which the engine reads. `@apply` written in
|
|
30
|
+
* one shipped verbatim to the browser as an unknown at-rule, silently.
|
|
31
|
+
*
|
|
32
|
+
* This processes a stylesheet the author owns: `@apply` expands to the
|
|
33
|
+
* declarations the named utilities produce, and `theme()` reads the
|
|
34
|
+
* registered theme. Both are driven from the real generator, so a utility
|
|
35
|
+
* expands to exactly what it would have emitted on its own.
|
|
36
|
+
*
|
|
37
|
+
* Nesting is left as written. It is native CSS, and flattening it here would
|
|
38
|
+
* mean re-implementing a selector resolver the browser already has.
|
|
39
|
+
*/
|
|
40
|
+
export declare interface StylesheetResult {
|
|
41
|
+
css: string
|
|
42
|
+
unknownUtilities: string[]
|
|
43
|
+
unknownThemePaths: string[]
|
|
44
|
+
}
|
package/dist/engine/types.d.ts
CHANGED
|
@@ -38,14 +38,16 @@ export declare interface CssConfig {
|
|
|
38
38
|
shortcuts: Record<string, string | string[]>
|
|
39
39
|
rules: CustomRule[]
|
|
40
40
|
variants: VariantConfig
|
|
41
|
-
safelist:
|
|
41
|
+
safelist: SafelistEntry[]
|
|
42
42
|
blocklist: string[]
|
|
43
|
+
layers?: string[]
|
|
43
44
|
preflights: Preflight[]
|
|
44
45
|
presets: Preset[]
|
|
45
46
|
compileClass?: CompileClassConfig
|
|
46
47
|
attributify?: AttributifyConfig
|
|
47
48
|
bracketSyntax?: BracketSyntaxConfig
|
|
48
49
|
codeStrings?: CodeStringsConfig
|
|
50
|
+
input?: string
|
|
49
51
|
cssVariables?: boolean
|
|
50
52
|
colorVariables?: string[]
|
|
51
53
|
styles?: string[]
|
|
@@ -60,6 +62,9 @@ export declare interface Theme {
|
|
|
60
62
|
containers: Record<string, string>
|
|
61
63
|
borderRadius: Record<string, string>
|
|
62
64
|
boxShadow: Record<string, string>
|
|
65
|
+
keyframes?: Record<string, Record<string, Record<string, string>>>
|
|
66
|
+
animation?: Record<string, string>
|
|
67
|
+
modes?: Record<string, string>
|
|
63
68
|
extend?: Partial<Omit<Theme, 'extend'>>
|
|
64
69
|
}
|
|
65
70
|
export declare interface VariantConfig {
|
|
@@ -166,6 +171,7 @@ export declare interface UtilityRuleResult {
|
|
|
166
171
|
}
|
|
167
172
|
export declare interface Preflight {
|
|
168
173
|
getCSS: () => string
|
|
174
|
+
layer?: string
|
|
169
175
|
}
|
|
170
176
|
export declare interface Preset {
|
|
171
177
|
name: string
|
|
@@ -176,6 +182,12 @@ export declare interface Preset {
|
|
|
176
182
|
preflights?: Preflight[]
|
|
177
183
|
}
|
|
178
184
|
export type CustomRule = [RegExp, (_match: RegExpMatchArray) => Record<string, string> | undefined];
|
|
185
|
+
/**
|
|
186
|
+
* A safelist entry: a class name, a name with `{a,b}` groups to expand, or a
|
|
187
|
+
* pattern filtering the names already in play (the expansions plus whatever
|
|
188
|
+
* the scanner found). `variants` is applied as a prefix to each match.
|
|
189
|
+
*/
|
|
190
|
+
export type SafelistEntry = string | RegExp | { pattern: RegExp, variants?: string[] }
|
|
179
191
|
declare type DeepPartial<T> = {
|
|
180
192
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
|
181
193
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,m,e,o,n,T}from"./chunk-8h5zg4ad.js";import{r,f,x,O}from"./chunk-dbj97h19.js";import{v,R,
|
|
2
|
+
import{t,m,e,o,n,T}from"./chunk-8h5zg4ad.js";import{r,f,x,O}from"./chunk-dbj97h19.js";import{v,R,k,C}from"./chunk-zn8gy7w7.js";import{h,a,l,w,A}from"./chunk-k6ta54hd.js";var s={floatPrecision:3,verbose:!1},i=null;async function c(){if(!i){let{loadConfig:p}=await import("bunfig");i=await p({name:"ts-css",defaultConfig:s})}return i}var S=s;export{t as List,m as clone,S as config,C as cssSelect,O as cssWhat,A as csso,T as csstree,s as defaultConfig,e as generate,c as getConfig,k as is,x as isTraversal,h as minify,a as minifyBlock,o as parse,r as parseSelector,v as selectAll,R as selectOne,l as specificity,f as stringifySelector,w as syntax,n as walk};
|
package/dist/optimize/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s,u,p,h,a,l,S,
|
|
2
|
+
import{s,u,p,h,a,l,S,w}from"../chunk-k6ta54hd.js";import"../chunk-8h5zg4ad.js";import"../chunk-dbj97h19.js";export{p as compressTree,u as dedupeDeclarations,h as minify,a as minifyBlock,s as removeComments,l as specificity,S as specificityToString,w as syntax};
|
package/dist/select/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i,g,P,v,R,
|
|
2
|
+
import{i,g,P,v,R,k}from"../chunk-zn8gy7w7.js";import"../chunk-dbj97h19.js";export{P as clearSelectorCache,g as compile,k as is,i as parseAndCompile,v as selectAll,R as selectOne};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ts-css",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.25",
|
|
5
5
|
"description": "Pure-TypeScript CSS toolkit and utility-first CSS engine for Bun/Node — parser, walker, generator, selector engine, minifier, and a Tailwind-compatible utility engine. Zero runtime deps.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|