@teacss/core 0.4.7 → 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 +358 -131
- package/dist/index.d.ts +274 -263
- package/dist/index.js +21 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* presets own the vocabulary.
|
|
21
21
|
*/
|
|
22
22
|
/** How an `@cond` segment is classified by its first character (after a NOT `!`). */
|
|
23
|
-
type ConditionKind =
|
|
23
|
+
export type ConditionKind =
|
|
24
24
|
/** `@.cls` / `@#id` — a class/id on the subject itself. */
|
|
25
25
|
"self" |
|
|
26
26
|
/** `@::after` — a pseudo-element on the subject. */
|
|
@@ -32,7 +32,7 @@ type ConditionKind =
|
|
|
32
32
|
/** Letter-first: a named condition (pseudo-class / media / relation / breakpoint / at-rule). Resolved by hooks. */
|
|
33
33
|
"named";
|
|
34
34
|
/** A single `@cond` segment parsed into structured form (no CSS resolved yet). */
|
|
35
|
-
interface ParsedCondition {
|
|
35
|
+
export interface ParsedCondition {
|
|
36
36
|
/** The segment without its leading `@`, exactly as written (e.g. `hover`, `.is-dragging`, `>li:hover`, `!disabled`). */
|
|
37
37
|
raw: string;
|
|
38
38
|
kind: ConditionKind;
|
|
@@ -47,16 +47,17 @@ interface ParsedCondition {
|
|
|
47
47
|
* Pure and total. A leading `!` sets `negate` and is stripped before dispatch.
|
|
48
48
|
* First-character dispatch follows the current condition grammar:
|
|
49
49
|
* `::` → pseudo-element · `.`/`#` → self · `> _ + ~` → target · `[` → arbitrary · else → named.
|
|
50
|
+
* CSS comments may separate the two pseudo-element colons.
|
|
50
51
|
*/
|
|
51
|
-
declare function parseCondition(raw: string): ParsedCondition;
|
|
52
|
+
export declare function parseCondition(raw: string): ParsedCondition;
|
|
52
53
|
/** Classify a list of condition segments (e.g. `ParsedClassToken.conditions`). */
|
|
53
|
-
declare function parseConditions(conditions: string[]): ParsedCondition[];
|
|
54
|
+
export declare function parseConditions(conditions: string[]): ParsedCondition[];
|
|
54
55
|
/**
|
|
55
56
|
* The contribution of one resolved condition to the final rule, split by role so
|
|
56
57
|
* assembly can place each part canonically (selector-first), independent of the
|
|
57
58
|
* order conditions were written in.
|
|
58
59
|
*/
|
|
59
|
-
interface ResolvedCondition {
|
|
60
|
+
export interface ResolvedCondition {
|
|
60
61
|
/** Ancestor prepended before the subject, e.g. `.group:hover `. */
|
|
61
62
|
prefix?: string;
|
|
62
63
|
/** Combinator + target appended after the subject, shifting the styled element, e.g. ` > li`. */
|
|
@@ -69,7 +70,7 @@ interface ResolvedCondition {
|
|
|
69
70
|
parent?: string;
|
|
70
71
|
}
|
|
71
72
|
/** Context handed to resolver hooks. */
|
|
72
|
-
interface ConditionResolveContext {
|
|
73
|
+
export interface ConditionResolveContext {
|
|
73
74
|
/** The full parsed condition list, for hooks that need siblings (e.g. named container). */
|
|
74
75
|
conditions: ParsedCondition[];
|
|
75
76
|
/** The resolved theme, for hooks whose vocabulary is theme-driven (e.g. breakpoints). */
|
|
@@ -80,8 +81,8 @@ interface ConditionResolveContext {
|
|
|
80
81
|
* or `undefined` to defer to the next hook. Presets register hooks for named
|
|
81
82
|
* and arbitrary conditions.
|
|
82
83
|
*/
|
|
83
|
-
type ConditionResolver = (cond: ParsedCondition, ctx: ConditionResolveContext) => ResolvedCondition | undefined;
|
|
84
|
-
interface ResolveConditionsResult {
|
|
84
|
+
export type ConditionResolver = (cond: ParsedCondition, ctx: ConditionResolveContext) => ResolvedCondition | undefined;
|
|
85
|
+
export interface ResolveConditionsResult {
|
|
85
86
|
/** Conditions resolved to structured contributions (by core or a hook). */
|
|
86
87
|
resolved: ResolvedCondition[];
|
|
87
88
|
/** Conditions no hook handled — surfaced so callers/tests can detect missing vocabulary. */
|
|
@@ -95,8 +96,8 @@ interface ResolveConditionsResult {
|
|
|
95
96
|
*
|
|
96
97
|
* Enforces at most one pseudo-element per token.
|
|
97
98
|
*/
|
|
98
|
-
declare function resolveConditions(conditions: ParsedCondition[], resolvers?: ConditionResolver[], theme?: object): ResolveConditionsResult;
|
|
99
|
-
interface BuiltConditionSelector {
|
|
99
|
+
export declare function resolveConditions(conditions: ParsedCondition[], resolvers?: ConditionResolver[], theme?: object): ResolveConditionsResult;
|
|
100
|
+
export interface BuiltConditionSelector {
|
|
100
101
|
/** The assembled selector, e.g. `.group:hover .bg\:red:hover > li`. */
|
|
101
102
|
selector: string;
|
|
102
103
|
/** At-rule parents wrapping the rule, outermost-last (e.g. `["@media (min-width: 48rem)"]`). */
|
|
@@ -111,19 +112,19 @@ interface BuiltConditionSelector {
|
|
|
111
112
|
* `a@_svg@group-hover@md` and `a@md@group-hover@_svg` produce the same selector
|
|
112
113
|
* + parents. Conditions within the same role retain their authored order.
|
|
113
114
|
*/
|
|
114
|
-
declare function buildConditionSelector(subject: string, resolved: ResolvedCondition[]): BuiltConditionSelector;
|
|
115
|
+
export declare function buildConditionSelector(subject: string, resolved: ResolvedCondition[]): BuiltConditionSelector;
|
|
115
116
|
//#endregion
|
|
116
117
|
//#region src/utils/basic.d.ts
|
|
117
|
-
type ToArrayResult<T
|
|
118
|
-
declare function toArray<T = never>(): T[];
|
|
119
|
-
declare function toArray(value: undefined): [];
|
|
120
|
-
declare function toArray<T>(value: T): ToArrayResult<T>;
|
|
121
|
-
declare function uniq<T>(value: T[]): T[];
|
|
122
|
-
declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
|
|
123
|
-
declare function isString(s: any): s is string;
|
|
118
|
+
type ToArrayResult<T, Value = Exclude<T, undefined>> = [Value] extends [never] ? [] : Value extends any[] ? Value[number][] : Value extends readonly (infer U)[] ? readonly U[] : Value[];
|
|
119
|
+
export declare function toArray<T = never>(): T[];
|
|
120
|
+
export declare function toArray(value: undefined): [];
|
|
121
|
+
export declare function toArray<T>(value: T): ToArrayResult<T>;
|
|
122
|
+
export declare function uniq<T>(value: T[]): T[];
|
|
123
|
+
export declare function uniqueBy<T>(array: readonly T[], equalFn: (a: T, b: T) => boolean): T[];
|
|
124
|
+
export declare function isString(s: any): s is string;
|
|
124
125
|
//#endregion
|
|
125
126
|
//#region src/utils/countable-set.d.ts
|
|
126
|
-
declare class CountableSet<K> extends Set<K> {
|
|
127
|
+
export declare class CountableSet<K> extends Set<K> {
|
|
127
128
|
_map: Map<K, number>;
|
|
128
129
|
constructor(values?: Iterable<K>);
|
|
129
130
|
add(key: K): this;
|
|
@@ -132,23 +133,24 @@ declare class CountableSet<K> extends Set<K> {
|
|
|
132
133
|
getCount(key: K): number;
|
|
133
134
|
setCount(key: K, count: number): this;
|
|
134
135
|
}
|
|
135
|
-
declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
|
|
136
|
+
export declare function isCountableSet<T = string>(value: any): value is CountableSet<T>;
|
|
136
137
|
//#endregion
|
|
137
138
|
//#region src/utils/escape.d.ts
|
|
138
|
-
declare function escapeRegExp(string: string): string;
|
|
139
|
+
export declare function escapeRegExp(string: string): string;
|
|
139
140
|
/**
|
|
140
141
|
* CSS Selector Escape
|
|
141
142
|
*/
|
|
142
|
-
declare function escapeSelector(str: string): string;
|
|
143
|
-
declare const e: typeof escapeSelector;
|
|
143
|
+
export declare function escapeSelector(str: string): string;
|
|
144
|
+
export declare const e: typeof escapeSelector;
|
|
144
145
|
//#endregion
|
|
145
146
|
//#region src/utils/events.d.ts
|
|
146
147
|
type EventsMap = Record<string, any>;
|
|
147
148
|
interface DefaultEvents extends EventsMap {
|
|
148
149
|
[event: string]: (...args: any) => void;
|
|
149
150
|
}
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
/** Unbind listeners; calls after a successful unsubscribe are no-ops. */
|
|
152
|
+
export type Unsubscribe = () => void;
|
|
153
|
+
export interface Emitter<Events extends EventsMap = DefaultEvents> {
|
|
152
154
|
/**
|
|
153
155
|
* Event names in keys and arrays with listeners in values.
|
|
154
156
|
*
|
|
@@ -207,30 +209,29 @@ interface Emitter<Events extends EventsMap = DefaultEvents> {
|
|
|
207
209
|
* }
|
|
208
210
|
* ```
|
|
209
211
|
*/
|
|
210
|
-
declare function createNanoEvents<Events extends EventsMap = DefaultEvents>(): Emitter<Events>;
|
|
212
|
+
export declare function createNanoEvents<Events extends EventsMap = DefaultEvents>(): Emitter<Events>;
|
|
211
213
|
//#endregion
|
|
212
214
|
//#region src/utils/helpers.d.ts
|
|
213
|
-
declare const attributifyRE: RegExp;
|
|
214
|
-
declare const cssIdRE: RegExp;
|
|
215
|
-
declare const validateFilterRE: RegExp;
|
|
216
|
-
declare function isAttributifySelector(selector: string): RegExpMatchArray | null;
|
|
217
|
-
declare function isValidSelector(selector?: string): selector is string;
|
|
218
|
-
declare function normalizeVariant(variant: Variant<
|
|
219
|
-
declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
|
|
220
|
-
declare function notNull<T>(value: T | null | undefined): value is T;
|
|
215
|
+
export declare const attributifyRE: RegExp;
|
|
216
|
+
export declare const cssIdRE: RegExp;
|
|
217
|
+
export declare const validateFilterRE: RegExp;
|
|
218
|
+
export declare function isAttributifySelector(selector: string): RegExpMatchArray | null;
|
|
219
|
+
export declare function isValidSelector(selector?: string): selector is string;
|
|
220
|
+
export declare function normalizeVariant<Theme extends object = object>(variant: Variant<Theme>): VariantObject<Theme>;
|
|
221
|
+
export declare function isRawUtil(util: ParsedUtil | RawUtil | StringifiedUtil): util is RawUtil;
|
|
222
|
+
export declare function notNull<T>(value: T | null | undefined): value is T;
|
|
221
223
|
/**
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
* `await`ed, so the common all-synchronous case never allocates a microtask.
|
|
224
|
+
* Checks for a callable `then` on an object or function, without invoking it.
|
|
225
|
+
* Primitive values are never thenables. Object getter errors propagate.
|
|
225
226
|
*/
|
|
226
|
-
declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
|
|
227
|
-
declare function noop(): void;
|
|
227
|
+
export declare function isThenable<T>(value: T | PromiseLike<T>): value is PromiseLike<T>;
|
|
228
|
+
export declare function noop(): void;
|
|
228
229
|
//#endregion
|
|
229
230
|
//#region src/utils/layer.d.ts
|
|
230
|
-
declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
231
|
+
export declare function withLayer<T extends object>(layer: string, rules: Rule<T>[]): Rule<T>[];
|
|
231
232
|
//#endregion
|
|
232
233
|
//#region src/utils/map.d.ts
|
|
233
|
-
declare class TwoKeyMap<K1, K2, V> {
|
|
234
|
+
export declare class TwoKeyMap<K1, K2, V> {
|
|
234
235
|
_map: Map<K1, Map<K2, V>>;
|
|
235
236
|
get(key1: K1, key2: K2): V | undefined;
|
|
236
237
|
getFallback(key1: K1, key2: K2, fallback: V): V;
|
|
@@ -240,26 +241,26 @@ declare class TwoKeyMap<K1, K2, V> {
|
|
|
240
241
|
deleteTop(key1: K1): boolean;
|
|
241
242
|
map<T>(fn: (v: V, k1: K1, k2: K2) => T): T[];
|
|
242
243
|
}
|
|
243
|
-
declare class BetterMap<K, V> extends Map<K, V> {
|
|
244
|
+
export declare class BetterMap<K, V> extends Map<K, V> {
|
|
244
245
|
getFallback(key: K, fallback: V): V;
|
|
245
246
|
map<R>(mapFn: (value: V, key: K) => R): R[];
|
|
246
247
|
flatMap<R extends readonly unknown[]>(mapFn: (value: V, key: K) => R): R[number][];
|
|
247
248
|
}
|
|
248
249
|
//#endregion
|
|
249
250
|
//#region src/utils/object.d.ts
|
|
250
|
-
declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntriesInput;
|
|
251
|
-
declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntriesInput)[];
|
|
252
|
-
declare function clearIdenticalEntries(entry: CSSEntriesInput): CSSEntries;
|
|
253
|
-
declare const VirtualKey = "__virtual_key__";
|
|
254
|
-
declare function entriesToCss(arr?: CSSEntriesInput): string;
|
|
255
|
-
declare function isObject(item: any): item is Record<string, any>;
|
|
251
|
+
export declare function normalizeCSSEntries(obj: string | CSSEntriesInput | CSSObjectInput): string | CSSEntriesInput;
|
|
252
|
+
export declare function normalizeCSSValues(obj: CSSValueInput | string | (CSSValueInput | string)[]): (string | CSSEntriesInput)[];
|
|
253
|
+
export declare function clearIdenticalEntries(entry: CSSEntriesInput): CSSEntries;
|
|
254
|
+
export declare const VirtualKey = "__virtual_key__";
|
|
255
|
+
export declare function entriesToCss(arr?: CSSEntriesInput): string;
|
|
256
|
+
export declare function isObject(item: any): item is Record<string, any>;
|
|
256
257
|
/**
|
|
257
258
|
* Marker key on a patch object that forces a full replacement of the
|
|
258
259
|
* corresponding original value instead of a deep merge. An explicit
|
|
259
260
|
* `{ $reset: true, … }` replaces an entire category.
|
|
260
261
|
* The marker is stripped from output.
|
|
261
262
|
*/
|
|
262
|
-
declare const RESET_KEY = "$reset";
|
|
263
|
+
export declare const RESET_KEY = "$reset";
|
|
263
264
|
/**
|
|
264
265
|
* Deep merge two objects.
|
|
265
266
|
*
|
|
@@ -268,37 +269,22 @@ declare const RESET_KEY = "$reset";
|
|
|
268
269
|
* marker) is used as-is. This applies recursively, so a single theme category can
|
|
269
270
|
* opt out of deep-merging (`theme.colors = { $reset: true, ... }`).
|
|
270
271
|
*/
|
|
271
|
-
declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
|
|
272
|
-
declare function clone<T>(val: T): T;
|
|
273
|
-
declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
|
|
274
|
-
declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
|
|
272
|
+
export declare function mergeDeep<T>(original: T, patch: DeepPartial<T>, mergeArray?: boolean): T;
|
|
273
|
+
export declare function clone<T>(val: T): T;
|
|
274
|
+
export declare function isStaticRule(rule: Rule<any>): rule is StaticRule;
|
|
275
|
+
export declare function isStaticShortcut(sc: Shortcut<any>): sc is StaticShortcut;
|
|
275
276
|
//#endregion
|
|
276
277
|
//#region src/utils/selector-target.d.ts
|
|
277
|
-
/**
|
|
278
|
-
* Structural validation for the target selector of a `@>li` / `@_p` / `@+span`
|
|
279
|
-
* condition.
|
|
280
|
-
*
|
|
281
|
-
* Core keeps the target verbatim so state written on the target survives
|
|
282
|
-
* (`@>li:hover`), which means whatever the class carries is what reaches the
|
|
283
|
-
* stylesheet. Text that cannot begin a compound selector — `@_5` produced the
|
|
284
|
-
* selector `.…\@_5 5` — makes the browser drop the whole rule, so the token
|
|
285
|
-
* must not match in the first place.
|
|
286
|
-
*
|
|
287
|
-
* This is CSS *syntax*, not preset vocabulary: it accepts one complex selector
|
|
288
|
-
* built from compounds and the three combinators a class token can spell. It
|
|
289
|
-
* deliberately does not know which type names, pseudo-classes, or attributes
|
|
290
|
-
* exist — that is the preset's business.
|
|
291
|
-
*/
|
|
292
278
|
/** True when `target` is one complex selector that can begin a compound. */
|
|
293
|
-
declare function isValidTargetSelector(target: string): boolean;
|
|
279
|
+
export declare function isValidTargetSelector(target: string): boolean;
|
|
294
280
|
//#endregion
|
|
295
281
|
//#region src/utils/source.d.ts
|
|
296
|
-
declare function getPath(id: string): string;
|
|
297
|
-
declare function isCssId(id: string): boolean;
|
|
298
|
-
declare function hash(str: string): string;
|
|
299
|
-
declare function transformSkipCode(code: string, map: Map<string, string>, SKIP_RULES_RE: RegExp, keyFlag: string): string;
|
|
300
|
-
declare function restoreSkipCode(code: string, map: Map<string, string>): string;
|
|
301
|
-
declare function replaceAsync(string: string, searchValue: RegExp, replacer: (substring: string, ...args: any[]) => Promise<string>): Promise<string>;
|
|
282
|
+
export declare function getPath(id: string): string;
|
|
283
|
+
export declare function isCssId(id: string): boolean;
|
|
284
|
+
export declare function hash(str: string): string;
|
|
285
|
+
export declare function transformSkipCode(code: string, map: Map<string, string>, SKIP_RULES_RE: RegExp, keyFlag: string): string;
|
|
286
|
+
export declare function restoreSkipCode(code: string, map: Map<string, string>): string;
|
|
287
|
+
export declare function replaceAsync(string: string, searchValue: RegExp, replacer: (substring: string, ...args: any[]) => Promise<string>): Promise<string>;
|
|
302
288
|
//#endregion
|
|
303
289
|
//#region src/utils/unmatched-diagnostics.d.ts
|
|
304
290
|
/** The structural slice of a resolved config the suggestion index reads. */
|
|
@@ -307,16 +293,15 @@ interface SuggestionSource {
|
|
|
307
293
|
rulesDynamic: readonly (readonly [RegExp, ...unknown[]])[];
|
|
308
294
|
}
|
|
309
295
|
/**
|
|
310
|
-
* Strip trailing
|
|
311
|
-
* sits outside brackets, parentheses, and quotes.
|
|
296
|
+
* Strip trailing conditions using the shared token grammar, retaining `!`.
|
|
312
297
|
*/
|
|
313
|
-
declare function tokenConditionBase(token: string): string;
|
|
298
|
+
export declare function tokenConditionBase(token: string): string;
|
|
314
299
|
/**
|
|
315
300
|
* Extracted source text is mostly not TeaCSS. Only candidates that read as a
|
|
316
301
|
* `prefix:value` token (optionally behind a condition chain) are diagnosed —
|
|
317
302
|
* plain words, framework class names, import specifiers, and URLs never are.
|
|
318
303
|
*/
|
|
319
|
-
declare function isTokenShaped(token: string): boolean;
|
|
304
|
+
export declare function isTokenShaped(token: string): boolean;
|
|
320
305
|
/**
|
|
321
306
|
* Decide whether an unmatched, token-shaped candidate deserves a diagnostic
|
|
322
307
|
* and compute its suggestions in one pass. Returns `undefined` for candidates
|
|
@@ -324,35 +309,35 @@ declare function isTokenShaped(token: string): boolean;
|
|
|
324
309
|
* full of `word:word` shapes, and silence beats noise when no known or
|
|
325
310
|
* near-known prefix is involved.
|
|
326
311
|
*/
|
|
327
|
-
declare function diagnoseUnmatchedToken(token: string, config: SuggestionSource, options?: {
|
|
312
|
+
export declare function diagnoseUnmatchedToken(token: string, config: SuggestionSource, options?: {
|
|
328
313
|
confirmedIntent?: boolean;
|
|
329
314
|
}): string[] | undefined;
|
|
330
315
|
//#endregion
|
|
331
316
|
//#region src/utils/variant-group.d.ts
|
|
332
|
-
declare function makeRegexClassGroup(separators?: string[]): RegExp;
|
|
317
|
+
export declare function makeRegexClassGroup(separators?: string[]): RegExp;
|
|
333
318
|
interface VariantGroup {
|
|
334
319
|
length: number;
|
|
335
320
|
items: HighlightAnnotation[];
|
|
336
321
|
}
|
|
337
|
-
declare function parseVariantGroup(str: string | MagicStringLike, separators?: string[], depth?: number): {
|
|
322
|
+
export declare function parseVariantGroup(str: string | MagicStringLike, separators?: string[], depth?: number): {
|
|
338
323
|
prefixes: string[];
|
|
339
324
|
hasChanged: boolean;
|
|
340
325
|
groupsByOffset: Map<number, VariantGroup>;
|
|
341
326
|
readonly expanded: string;
|
|
342
327
|
};
|
|
343
|
-
declare function collapseVariantGroup(str: string, prefixes: string[]): string;
|
|
344
|
-
declare function expandVariantGroup(str: string, separators?: string[], depth?: number): string;
|
|
345
|
-
declare function expandVariantGroup(str: MagicStringLike, separators?: string[], depth?: number): MagicStringLike;
|
|
328
|
+
export declare function collapseVariantGroup(str: string, prefixes: string[]): string;
|
|
329
|
+
export declare function expandVariantGroup(str: string, separators?: string[], depth?: number): string;
|
|
330
|
+
export declare function expandVariantGroup(str: MagicStringLike, separators?: string[], depth?: number): MagicStringLike;
|
|
346
331
|
//#endregion
|
|
347
332
|
//#region src/utils/warn.d.ts
|
|
348
|
-
declare function warnOnce(msg: string): void;
|
|
333
|
+
export declare function warnOnce(msg: string): void;
|
|
349
334
|
//#endregion
|
|
350
335
|
//#region src/generator.d.ts
|
|
351
|
-
declare const symbols: ControlSymbols;
|
|
336
|
+
export declare const symbols: ControlSymbols;
|
|
352
337
|
type ExpansionEntry<Theme extends object = object> = Shortcut<Theme>;
|
|
353
338
|
type ExpansionResult = [(string | ExpansionInlineValue)[], RuleMeta | undefined];
|
|
354
339
|
type ExpansionPrefixes = readonly (string | undefined)[];
|
|
355
|
-
interface PreparedGeneratorConfig<Theme extends object = object> {
|
|
340
|
+
export interface PreparedGeneratorConfig<Theme extends object = object> {
|
|
356
341
|
readonly config: ResolvedConfig<Theme>;
|
|
357
342
|
readonly defaults: UserConfigDefaults<Theme>;
|
|
358
343
|
/** Isolated generator for validating work against `config` before commit. */
|
|
@@ -361,22 +346,16 @@ interface PreparedGeneratorConfig<Theme extends object = object> {
|
|
|
361
346
|
readonly version: number;
|
|
362
347
|
}
|
|
363
348
|
/** A width reduced to the scale it can be compared on. @see {@link comparableWidth} */
|
|
364
|
-
interface ComparableWidth {
|
|
365
|
-
/** `"px"` for every unit with a fixed pixel ratio, else the unit as authored. */
|
|
366
|
-
unit: string;
|
|
367
|
-
/** The width on that scale. Negative reverses the direction within it. */
|
|
368
|
-
value: number;
|
|
369
|
-
}
|
|
370
|
-
/** A width reduced to the scale it can be compared on. @see {@link comparableWidth} */
|
|
371
|
-
interface ComparableWidth {
|
|
349
|
+
export interface ComparableWidth {
|
|
372
350
|
/** `"px"` for every unit with a fixed pixel ratio, else the unit as authored. */
|
|
373
351
|
unit: string;
|
|
374
352
|
/** The width on that scale. Negative reverses the direction within it. */
|
|
375
353
|
value: number;
|
|
376
354
|
}
|
|
377
355
|
/**
|
|
378
|
-
* A CSS width reduced to a comparable scale, or `null` when
|
|
379
|
-
* `calc()`, `var()`,
|
|
356
|
+
* A CSS width reduced to a comparable scale, or `null` when it cannot be represented
|
|
357
|
+
* as a finite number — including conversion overflow, `calc()`, `var()`, unknown
|
|
358
|
+
* units, and malformed values such as `..`. A
|
|
380
359
|
* non-length must never yield a number: `NaN` compares equal to everything, which marks
|
|
381
360
|
* two unequal parents equal and skips the tiebreak {@link compareParentAtRules} relies
|
|
382
361
|
* on.
|
|
@@ -387,7 +366,7 @@ interface ComparableWidth {
|
|
|
387
366
|
* has to order the same widths — the `@screen` range resolver reads them straight from
|
|
388
367
|
* `theme.breakpoint` — asks generation rather than keeping a copy that drifts.
|
|
389
368
|
*/
|
|
390
|
-
declare function comparableWidth(size: string): ComparableWidth | null;
|
|
369
|
+
export declare function comparableWidth(size: string): ComparableWidth | null;
|
|
391
370
|
/**
|
|
392
371
|
* Order two parent (at-rule) selectors for the emitted sheet: an explicit
|
|
393
372
|
* `parentOrders` delta wins; otherwise width media queries cascade numerically
|
|
@@ -399,7 +378,7 @@ declare function comparableWidth(size: string): ComparableWidth | null;
|
|
|
399
378
|
* the language service derives completion colors that way — orders parent blocks
|
|
400
379
|
* exactly as generation does, instead of keeping a copy that drifts.
|
|
401
380
|
*/
|
|
402
|
-
declare function compareParentAtRules(parentOrders: ReadonlyMap<string, number>, a: string, b: string): number;
|
|
381
|
+
export declare function compareParentAtRules(parentOrders: ReadonlyMap<string, number>, a: string, b: string): number;
|
|
403
382
|
declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
404
383
|
userConfig: UserConfig<Theme>;
|
|
405
384
|
defaults: UserConfigDefaults<Theme>;
|
|
@@ -420,6 +399,9 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
420
399
|
private _contextConfigs;
|
|
421
400
|
private _expansionPrefixes;
|
|
422
401
|
private _generationContexts;
|
|
402
|
+
private _matchedStaticContexts;
|
|
403
|
+
/** Tagged empty cache payloads retain match evidence without retaining contexts or raw token keys. */
|
|
404
|
+
private _emptyStaticPayloads;
|
|
423
405
|
private _configVersion;
|
|
424
406
|
private _collectionGeneration;
|
|
425
407
|
private _preparedConfigs;
|
|
@@ -429,6 +411,8 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
429
411
|
private _preparedConfigMutable;
|
|
430
412
|
private _preparedCacheReliable;
|
|
431
413
|
private _startingGenerationParse;
|
|
414
|
+
private _startingInputCheck;
|
|
415
|
+
private _contextInputChecks;
|
|
432
416
|
private _runtimeRevision;
|
|
433
417
|
private _variantCacheOwner;
|
|
434
418
|
private _initialization?;
|
|
@@ -455,11 +439,11 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
455
439
|
* Index one expansion-entry list so a lookup replaces the per-token scan:
|
|
456
440
|
* static names — with each configured prefix folded into the key — resolve
|
|
457
441
|
* through one map read, and only regex entries still walk in order. Bodies
|
|
458
|
-
* and metas are read from the live tuples at match time
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* also revalidated slot by slot
|
|
462
|
-
*
|
|
442
|
+
* and metas are read from the live tuples at match time. Only config-owned
|
|
443
|
+
* lists participate in cache invalidation; external lists must be reindexed
|
|
444
|
+
* on every lookup and must not replace the cached config index. Cached lists
|
|
445
|
+
* are also revalidated slot by slot, because registration flows such as
|
|
446
|
+
* compile-class splice entries into the live array between parses.
|
|
463
447
|
*/
|
|
464
448
|
private getExpansionIndex;
|
|
465
449
|
private getDynamicIndex;
|
|
@@ -472,8 +456,8 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
472
456
|
prepareConfig(userConfig: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<PreparedGeneratorConfig<Theme>>;
|
|
473
457
|
/** Commit a prepared configuration if no newer configuration request superseded it. */
|
|
474
458
|
commitConfig(prepared: PreparedGeneratorConfig<Theme>): boolean;
|
|
459
|
+
applyExtractors(code: string, id: string | undefined, extracted: CountableSet<string>): Promise<CountableSet<string>>;
|
|
475
460
|
applyExtractors(code: string, id?: string, extracted?: Set<string>): Promise<Set<string>>;
|
|
476
|
-
applyExtractors(code: string, id?: string, extracted?: CountableSet<string>): Promise<CountableSet<string>>;
|
|
477
461
|
private applyExtractorsCurrent;
|
|
478
462
|
private applyExtractorsForConfig;
|
|
479
463
|
private requireInitialized;
|
|
@@ -490,7 +474,10 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
490
474
|
*/
|
|
491
475
|
getCachedEquivalentTokens(raw: string): string[];
|
|
492
476
|
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<false>): Promise<GenerateResult<Set<string>>>;
|
|
493
|
-
generate(input: string | Set<string> | CountableSet<string> | string[], options
|
|
477
|
+
generate(input: string | Set<string> | CountableSet<string> | string[], options: GenerateOptions<true> & {
|
|
478
|
+
extendedInfo: true;
|
|
479
|
+
}): Promise<GenerateResult<Map<string, ExtendedTokenInfo<Theme>>>>;
|
|
480
|
+
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<boolean>): Promise<GenerateResult<Set<string> | Map<string, ExtendedTokenInfo<Theme>>>>;
|
|
494
481
|
private generateInternal;
|
|
495
482
|
matchVariants(raw: string, current?: string): Promise<readonly VariantMatchedResult<Theme>[]>;
|
|
496
483
|
private matchVariantsCurrent;
|
|
@@ -510,16 +497,16 @@ declare class TeacssGeneratorInternal<Theme extends object = object> {
|
|
|
510
497
|
getBlocked(raw: string): [BlocklistValue, BlocklistMeta | undefined] | undefined;
|
|
511
498
|
private matchesBlocklist;
|
|
512
499
|
}
|
|
513
|
-
declare class TeacssGenerator<Theme extends object = object> extends TeacssGeneratorInternal<Theme> {
|
|
500
|
+
export declare class TeacssGenerator<Theme extends object = object> extends TeacssGeneratorInternal<Theme> {
|
|
514
501
|
/**
|
|
515
502
|
* @deprecated `new TeacssGenerator` is deprecated, please use `createGenerator()` instead
|
|
516
503
|
*/
|
|
517
504
|
constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
518
505
|
}
|
|
519
|
-
declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<TeacssGenerator<Theme>>;
|
|
520
|
-
declare const regexScopePlaceholder: RegExp;
|
|
521
|
-
declare function hasScopePlaceholder(css: string): boolean;
|
|
522
|
-
declare function toEscapedSelector(raw: string): string;
|
|
506
|
+
export declare function createGenerator<Theme extends object = object>(config?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<TeacssGenerator<Theme>>;
|
|
507
|
+
export declare const regexScopePlaceholder: RegExp;
|
|
508
|
+
export declare function hasScopePlaceholder(css: string): boolean;
|
|
509
|
+
export declare function toEscapedSelector(raw: string): string;
|
|
523
510
|
//#endregion
|
|
524
511
|
//#region src/types.d.ts
|
|
525
512
|
/**
|
|
@@ -529,7 +516,7 @@ declare function toEscapedSelector(raw: string): string;
|
|
|
529
516
|
* so the integration layer (which constructs one) still passes it directly, but
|
|
530
517
|
* consumers of `@teacss/core` don't inherit a dependency on `magic-string`.
|
|
531
518
|
*/
|
|
532
|
-
interface MagicStringLike {
|
|
519
|
+
export interface MagicStringLike {
|
|
533
520
|
readonly original: string;
|
|
534
521
|
slice(start?: number, end?: number): string;
|
|
535
522
|
toString(): string;
|
|
@@ -540,35 +527,36 @@ interface MagicStringLike {
|
|
|
540
527
|
appendRight(index: number, content: string): MagicStringLike;
|
|
541
528
|
}
|
|
542
529
|
/** The result of resolving config from the CSS entry: the config + its source file(s). */
|
|
543
|
-
interface LoadConfigResult<Config = any> {
|
|
530
|
+
export interface LoadConfigResult<Config = any> {
|
|
544
531
|
config: Config;
|
|
545
532
|
sources: string[];
|
|
546
533
|
}
|
|
547
|
-
type Awaitable<T> = T | Promise<T>;
|
|
548
|
-
type Arrayable<T> = T | T[];
|
|
549
|
-
type ToArray<T> = T extends any[] ? T[number][] : T extends readonly (infer U)[] ? readonly U[] : T[];
|
|
550
|
-
type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
551
|
-
type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
552
|
-
type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
553
|
-
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
|
|
554
|
-
type FlatObjectTuple<T> = { [K in keyof T]: T[K]; };
|
|
555
|
-
type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
556
|
-
type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
557
|
-
type CSSObject = Record<string, string | number | undefined>;
|
|
534
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
535
|
+
export type Arrayable<T> = T | T[];
|
|
536
|
+
export type ToArray<T> = T extends any[] ? T[number][] : T extends readonly (infer U)[] ? readonly U[] : T[];
|
|
537
|
+
export type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
538
|
+
export type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
539
|
+
export type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
540
|
+
export type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
|
|
541
|
+
export type FlatObjectTuple<T> = { [K in keyof T]: T[K]; };
|
|
542
|
+
export type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
543
|
+
export type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
544
|
+
export type CSSObject = Record<string, string | number | undefined>;
|
|
558
545
|
/**
|
|
559
546
|
* [property, value, operators?]
|
|
560
547
|
*
|
|
561
|
-
*
|
|
548
|
+
* The optional third slot is retained as entry data for custom processors.
|
|
549
|
+
* Core does not execute operators; CSS serialization uses only property and value.
|
|
562
550
|
*/
|
|
563
|
-
type CSSEntry = [string, string | number | undefined, Arrayable<string>?];
|
|
564
|
-
type CSSEntries = CSSEntry[];
|
|
565
|
-
type CSSObjectInput = CSSObject | Partial<ControlSymbolsValue>;
|
|
566
|
-
type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[];
|
|
567
|
-
type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue;
|
|
568
|
-
interface PresetOptions {
|
|
551
|
+
export type CSSEntry = [string, string | number | undefined, Arrayable<string>?];
|
|
552
|
+
export type CSSEntries = CSSEntry[];
|
|
553
|
+
export type CSSObjectInput = CSSObject | Partial<ControlSymbolsValue>;
|
|
554
|
+
export type CSSEntriesInput = (CSSEntry | ControlSymbolsEntry)[];
|
|
555
|
+
export type CSSValueInput = CSSObjectInput | CSSEntriesInput | CSSValue;
|
|
556
|
+
export interface PresetOptions {
|
|
569
557
|
[key: string]: any;
|
|
570
558
|
}
|
|
571
|
-
interface RuleContext<Theme extends object = object> {
|
|
559
|
+
export interface RuleContext<Theme extends object = object> {
|
|
572
560
|
/**
|
|
573
561
|
* Unprocessed selector from user input.
|
|
574
562
|
* Useful for generating CSS rule.
|
|
@@ -576,6 +564,8 @@ interface RuleContext<Theme extends object = object> {
|
|
|
576
564
|
rawSelector: string;
|
|
577
565
|
/**
|
|
578
566
|
* Current selector for rule matching
|
|
567
|
+
* In shortcut leaf rule callbacks, this is the leaf after variant matching;
|
|
568
|
+
* rawSelector remains the outer token being styled.
|
|
579
569
|
*/
|
|
580
570
|
currentSelector: string;
|
|
581
571
|
/**
|
|
@@ -595,7 +585,7 @@ interface RuleContext<Theme extends object = object> {
|
|
|
595
585
|
*/
|
|
596
586
|
variantHandlers: VariantHandler[];
|
|
597
587
|
/**
|
|
598
|
-
* The result of variant matching.
|
|
588
|
+
* The result of variant matching for the current parse branch.
|
|
599
589
|
*/
|
|
600
590
|
variantMatch: VariantMatchedResult<Theme>;
|
|
601
591
|
/**
|
|
@@ -625,7 +615,7 @@ declare const SymbolSelector: unique symbol;
|
|
|
625
615
|
declare const SymbolLayer: unique symbol;
|
|
626
616
|
declare const SymbolSort: unique symbol;
|
|
627
617
|
declare const SymbolBody: unique symbol;
|
|
628
|
-
interface ControlSymbols {
|
|
618
|
+
export interface ControlSymbols {
|
|
629
619
|
/**
|
|
630
620
|
* Prevent merging in shortcuts
|
|
631
621
|
*/
|
|
@@ -639,7 +629,8 @@ interface ControlSymbols {
|
|
|
639
629
|
*/
|
|
640
630
|
readonly noScope: typeof SymbolNoScope;
|
|
641
631
|
/**
|
|
642
|
-
* Additional variants applied to this rule
|
|
632
|
+
* Additional variants applied to this rule output. Functional values receive
|
|
633
|
+
* a private handler list; inserting or removing handlers leaves siblings intact.
|
|
643
634
|
*/
|
|
644
635
|
readonly variants: typeof SymbolVariants;
|
|
645
636
|
/**
|
|
@@ -663,7 +654,7 @@ interface ControlSymbols {
|
|
|
663
654
|
*/
|
|
664
655
|
readonly body: typeof SymbolBody;
|
|
665
656
|
}
|
|
666
|
-
interface ControlSymbolsValue {
|
|
657
|
+
export interface ControlSymbolsValue {
|
|
667
658
|
[SymbolShortcutsNoMerge]: boolean;
|
|
668
659
|
[SymbolNoMerge]: boolean;
|
|
669
660
|
[SymbolNoScope]: boolean;
|
|
@@ -674,9 +665,9 @@ interface ControlSymbolsValue {
|
|
|
674
665
|
[SymbolSort]: number;
|
|
675
666
|
[SymbolBody]: string;
|
|
676
667
|
}
|
|
677
|
-
type ObjectToEntry<T> = { [K in keyof T]: [K, T[K]]; }[keyof T];
|
|
678
|
-
type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
|
|
679
|
-
interface VariantContext<Theme extends object = object> {
|
|
668
|
+
export type ObjectToEntry<T> = { [K in keyof T]: [K, T[K]]; }[keyof T];
|
|
669
|
+
export type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
|
|
670
|
+
export interface VariantContext<Theme extends object = object> {
|
|
680
671
|
/**
|
|
681
672
|
* Unprocessed selector from user input.
|
|
682
673
|
*/
|
|
@@ -690,14 +681,14 @@ interface VariantContext<Theme extends object = object> {
|
|
|
690
681
|
*/
|
|
691
682
|
theme: Theme;
|
|
692
683
|
}
|
|
693
|
-
interface ExtractorContext {
|
|
684
|
+
export interface ExtractorContext {
|
|
694
685
|
readonly original: string;
|
|
695
686
|
code: string;
|
|
696
687
|
id?: string;
|
|
697
688
|
extracted: Set<string> | CountableSet<string>;
|
|
698
689
|
envMode?: "dev" | "build";
|
|
699
690
|
}
|
|
700
|
-
interface BaseContext<Theme extends object = object> {
|
|
691
|
+
export interface BaseContext<Theme extends object = object> {
|
|
701
692
|
/**
|
|
702
693
|
* Generator instance
|
|
703
694
|
*/
|
|
@@ -707,12 +698,12 @@ interface BaseContext<Theme extends object = object> {
|
|
|
707
698
|
*/
|
|
708
699
|
theme: Theme;
|
|
709
700
|
}
|
|
710
|
-
interface PreflightContext<Theme extends object = object> extends BaseContext<Theme> {
|
|
701
|
+
export interface PreflightContext<Theme extends object = object> extends BaseContext<Theme> {
|
|
711
702
|
/** Utilities produced for this generate() call after postprocessing, including cache hits and excluding preflights. */
|
|
712
703
|
generated?: readonly StringifiedUtil<Theme>[];
|
|
713
704
|
}
|
|
714
|
-
interface SafeListContext<Theme extends object = object> extends BaseContext<Theme> {}
|
|
715
|
-
interface Extractor {
|
|
705
|
+
export interface SafeListContext<Theme extends object = object> extends BaseContext<Theme> {}
|
|
706
|
+
export interface Extractor {
|
|
716
707
|
name: string;
|
|
717
708
|
order?: number;
|
|
718
709
|
/**
|
|
@@ -722,7 +713,7 @@ interface Extractor {
|
|
|
722
713
|
*/
|
|
723
714
|
extract?: (ctx: ExtractorContext) => Awaitable<Set<string> | CountableSet<string> | string[] | undefined | void>;
|
|
724
715
|
}
|
|
725
|
-
interface RuleMeta {
|
|
716
|
+
export interface RuleMeta {
|
|
726
717
|
/**
|
|
727
718
|
* The layer name of this rule.
|
|
728
719
|
* @default 'default'
|
|
@@ -773,40 +764,40 @@ interface RuleMeta {
|
|
|
773
764
|
*/
|
|
774
765
|
custom?: Record<string, any>;
|
|
775
766
|
}
|
|
776
|
-
type CSSValue = CSSObject | CSSEntries;
|
|
777
|
-
type CSSValues = CSSValue | CSSValue[];
|
|
778
|
-
type DynamicMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValueInput | string | (CSSValueInput | string)[] | undefined> | Generator<CSSValueInput | string | undefined> | AsyncGenerator<CSSValueInput | string | undefined>;
|
|
779
|
-
type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>, RuleMeta?];
|
|
780
|
-
type StaticRule = [string, CSSObjectInput | CSSEntriesInput | (CSSValueInput | string)[], RuleMeta?];
|
|
781
|
-
type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
|
|
782
|
-
type ExpansionValue = string | CSSValue;
|
|
783
|
-
interface ExpansionInlineValue {
|
|
767
|
+
export type CSSValue = CSSObject | CSSEntries;
|
|
768
|
+
export type CSSValues = CSSValue | CSSValue[];
|
|
769
|
+
export type DynamicMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => Awaitable<CSSValueInput | string | (CSSValueInput | string)[] | undefined> | Generator<CSSValueInput | string | undefined> | AsyncGenerator<CSSValueInput | string | undefined>;
|
|
770
|
+
export type DynamicRule<Theme extends object = object> = [RegExp, DynamicMatcher<Theme>, RuleMeta?];
|
|
771
|
+
export type StaticRule = [string, CSSObjectInput | CSSEntriesInput | (CSSValueInput | string)[], RuleMeta?];
|
|
772
|
+
export type Rule<Theme extends object = object> = DynamicRule<Theme> | StaticRule;
|
|
773
|
+
export type ExpansionValue = string | CSSValue;
|
|
774
|
+
export interface ExpansionInlineValue {
|
|
784
775
|
handles: VariantHandler[];
|
|
785
776
|
value: ExpansionValue;
|
|
786
777
|
}
|
|
787
|
-
type DynamicExpansionMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => string | ExpansionValue[] | undefined;
|
|
788
|
-
type DynamicShortcutMatcher<Theme extends object = object> = DynamicExpansionMatcher<Theme>;
|
|
789
|
-
type StaticShortcut = [string, string | ExpansionValue[], RuleMeta?];
|
|
790
|
-
type StaticShortcutMap = Record<string, string | ExpansionValue[]>;
|
|
791
|
-
type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta?];
|
|
792
|
-
type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
793
|
-
type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
|
|
794
|
-
type ShortcutInlineValue = ExpansionInlineValue;
|
|
795
|
-
type ShortcutValue = ExpansionValue;
|
|
796
|
-
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
797
|
-
interface Preflight<Theme extends object = object> {
|
|
778
|
+
export type DynamicExpansionMatcher<Theme extends object = object> = (match: RegExpMatchArray, context: Readonly<RuleContext<Theme>>) => string | ExpansionValue[] | undefined;
|
|
779
|
+
export type DynamicShortcutMatcher<Theme extends object = object> = DynamicExpansionMatcher<Theme>;
|
|
780
|
+
export type StaticShortcut = [string, string | ExpansionValue[], RuleMeta?];
|
|
781
|
+
export type StaticShortcutMap = Record<string, string | ExpansionValue[]>;
|
|
782
|
+
export type DynamicShortcut<Theme extends object = object> = [RegExp, DynamicShortcutMatcher<Theme>, RuleMeta?];
|
|
783
|
+
export type UserShortcuts<Theme extends object = object> = StaticShortcutMap | (StaticShortcut | DynamicShortcut<Theme> | StaticShortcutMap)[];
|
|
784
|
+
export type Shortcut<Theme extends object = object> = StaticShortcut | DynamicShortcut<Theme>;
|
|
785
|
+
export type ShortcutInlineValue = ExpansionInlineValue;
|
|
786
|
+
export type ShortcutValue = ExpansionValue;
|
|
787
|
+
export type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
788
|
+
export interface Preflight<Theme extends object = object> {
|
|
798
789
|
getCSS: (context: PreflightContext<Theme>) => Promise<string | undefined> | string | undefined;
|
|
799
790
|
layer?: string;
|
|
800
791
|
}
|
|
801
|
-
interface BlocklistMeta {
|
|
792
|
+
export interface BlocklistMeta {
|
|
802
793
|
/**
|
|
803
794
|
* Custom message to show why this selector is blocked.
|
|
804
795
|
*/
|
|
805
796
|
message?: string | ((selector: string) => string);
|
|
806
797
|
}
|
|
807
|
-
type BlocklistValue = string | RegExp | ((selector: string) => boolean | null | undefined);
|
|
808
|
-
type BlocklistRule = BlocklistValue | [BlocklistValue, BlocklistMeta];
|
|
809
|
-
interface VariantHandlerContext {
|
|
798
|
+
export type BlocklistValue = string | RegExp | ((selector: string) => boolean | null | undefined);
|
|
799
|
+
export type BlocklistRule = BlocklistValue | [BlocklistValue, BlocklistMeta];
|
|
800
|
+
export interface VariantHandlerContext {
|
|
810
801
|
/**
|
|
811
802
|
* Rewrite the output selector. Often be used to append parents.
|
|
812
803
|
*/
|
|
@@ -845,7 +836,7 @@ interface VariantHandlerContext {
|
|
|
845
836
|
*/
|
|
846
837
|
noMerge?: boolean;
|
|
847
838
|
}
|
|
848
|
-
interface VariantHandler {
|
|
839
|
+
export interface VariantHandler {
|
|
849
840
|
/**
|
|
850
841
|
* Callback to process the handler.
|
|
851
842
|
*/
|
|
@@ -879,8 +870,8 @@ interface VariantHandler {
|
|
|
879
870
|
*/
|
|
880
871
|
layer?: string | undefined;
|
|
881
872
|
}
|
|
882
|
-
type VariantFunction<Theme extends object = object> = (matcher: string, context: Readonly<VariantContext<Theme>>) => Awaitable<string | VariantHandler | VariantHandler[] | undefined>;
|
|
883
|
-
interface VariantObject<Theme extends object = object> {
|
|
873
|
+
export type VariantFunction<Theme extends object = object> = (matcher: string, context: Readonly<VariantContext<Theme>>) => Awaitable<string | VariantHandler | VariantHandler[] | undefined>;
|
|
874
|
+
export interface VariantObject<Theme extends object = object> {
|
|
884
875
|
/**
|
|
885
876
|
* The name of the variant.
|
|
886
877
|
*/
|
|
@@ -904,11 +895,11 @@ interface VariantObject<Theme extends object = object> {
|
|
|
904
895
|
*/
|
|
905
896
|
autocomplete?: Arrayable<AutoCompleteFunction | AutoCompleteTemplate>;
|
|
906
897
|
}
|
|
907
|
-
type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
|
|
908
|
-
type Preprocessor = (matcher: string) => string | undefined;
|
|
909
|
-
type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[];
|
|
910
|
-
type ThemeExtender<Theme extends object = object> = (theme: Theme, config: Readonly<ResolvedConfig<Theme>>) => Theme | void;
|
|
911
|
-
interface ConfigBase<Theme extends object = object> {
|
|
898
|
+
export type Variant<Theme extends object = object> = VariantFunction<Theme> | VariantObject<Theme>;
|
|
899
|
+
export type Preprocessor = (matcher: string) => string | undefined;
|
|
900
|
+
export type Postprocessor = (util: UtilObject) => void | UtilObject | (UtilObject | null | undefined)[];
|
|
901
|
+
export type ThemeExtender<Theme extends object = object> = (theme: Theme, config: Readonly<ResolvedConfig<Theme>>) => Theme | void;
|
|
902
|
+
export interface ConfigBase<Theme extends object = object> {
|
|
912
903
|
/**
|
|
913
904
|
* Rules to generate CSS utilities.
|
|
914
905
|
*
|
|
@@ -939,7 +930,8 @@ interface ConfigBase<Theme extends object = object> {
|
|
|
939
930
|
*/
|
|
940
931
|
blocklist?: BlocklistRule[];
|
|
941
932
|
/**
|
|
942
|
-
* Utilities
|
|
933
|
+
* Utilities always included in generation, unless `safelist: false` is passed.
|
|
934
|
+
* Static entries and callback results support `{a;b}@condition` groups.
|
|
943
935
|
*/
|
|
944
936
|
safelist?: (string | ((context: SafeListContext<Theme>) => Arrayable<string>))[];
|
|
945
937
|
/**
|
|
@@ -1019,7 +1011,11 @@ interface ConfigBase<Theme extends object = object> {
|
|
|
1019
1011
|
/**
|
|
1020
1012
|
* Hook to modify the resolved config.
|
|
1021
1013
|
*
|
|
1022
|
-
*
|
|
1014
|
+
* Hooks run sequentially in resolved preset order, then the user hook.
|
|
1015
|
+
* Returned promises are awaited; a throw or rejection aborts resolution.
|
|
1016
|
+
* Rule indexes are rebuilt after all hooks finish. Return values are ignored.
|
|
1017
|
+
* The void callback type accepts async functions while preserving existing
|
|
1018
|
+
* synchronous callbacks that return an ignored value.
|
|
1023
1019
|
*/
|
|
1024
1020
|
configResolved?: (config: ResolvedConfig<Theme>) => void;
|
|
1025
1021
|
/**
|
|
@@ -1042,7 +1038,7 @@ interface ConfigBase<Theme extends object = object> {
|
|
|
1042
1038
|
*/
|
|
1043
1039
|
transformers?: SourceCodeTransformer[];
|
|
1044
1040
|
}
|
|
1045
|
-
interface OutputCssLayersOptions {
|
|
1041
|
+
export interface OutputCssLayersOptions {
|
|
1046
1042
|
/**
|
|
1047
1043
|
* Specify the css layer that the internal layer should be output to.
|
|
1048
1044
|
*
|
|
@@ -1056,13 +1052,13 @@ interface OutputCssLayersOptions {
|
|
|
1056
1052
|
*/
|
|
1057
1053
|
allLayers?: boolean;
|
|
1058
1054
|
}
|
|
1059
|
-
type AutoCompleteTemplate = string;
|
|
1060
|
-
type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
1061
|
-
interface AutoCompleteExtractorContext {
|
|
1055
|
+
export type AutoCompleteTemplate = string;
|
|
1056
|
+
export type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
1057
|
+
export interface AutoCompleteExtractorContext {
|
|
1062
1058
|
content: string;
|
|
1063
1059
|
cursor: number;
|
|
1064
1060
|
}
|
|
1065
|
-
interface Replacement {
|
|
1061
|
+
export interface Replacement {
|
|
1066
1062
|
/**
|
|
1067
1063
|
* The range of the original text
|
|
1068
1064
|
*/
|
|
@@ -1073,7 +1069,7 @@ interface Replacement {
|
|
|
1073
1069
|
*/
|
|
1074
1070
|
replacement: string;
|
|
1075
1071
|
}
|
|
1076
|
-
interface SuggestResult {
|
|
1072
|
+
export interface SuggestResult {
|
|
1077
1073
|
/**
|
|
1078
1074
|
* The generated suggestions
|
|
1079
1075
|
*
|
|
@@ -1086,7 +1082,7 @@ interface SuggestResult {
|
|
|
1086
1082
|
*/
|
|
1087
1083
|
resolveReplacement: (suggestion: string) => Replacement;
|
|
1088
1084
|
}
|
|
1089
|
-
interface AutoCompleteExtractorResult {
|
|
1085
|
+
export interface AutoCompleteExtractorResult {
|
|
1090
1086
|
/**
|
|
1091
1087
|
* The extracted string
|
|
1092
1088
|
*/
|
|
@@ -1100,12 +1096,12 @@ interface AutoCompleteExtractorResult {
|
|
|
1100
1096
|
*/
|
|
1101
1097
|
transformSuggestions?: (suggestions: string[]) => string[];
|
|
1102
1098
|
}
|
|
1103
|
-
interface AutoCompleteExtractor {
|
|
1099
|
+
export interface AutoCompleteExtractor {
|
|
1104
1100
|
name: string;
|
|
1105
1101
|
extract: (context: AutoCompleteExtractorContext) => Awaitable<AutoCompleteExtractorResult | null>;
|
|
1106
1102
|
order?: number;
|
|
1107
1103
|
}
|
|
1108
|
-
interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
|
|
1104
|
+
export interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
|
|
1109
1105
|
name: string;
|
|
1110
1106
|
/**
|
|
1111
1107
|
* Enforce the preset to be applied before or after other presets
|
|
@@ -1132,11 +1128,11 @@ interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
|
|
|
1132
1128
|
*/
|
|
1133
1129
|
meta?: Record<string, any>;
|
|
1134
1130
|
}
|
|
1135
|
-
type PresetFactory<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Preset<Theme>;
|
|
1136
|
-
type PresetFactoryAwaitable<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Awaitable<Preset<Theme>>;
|
|
1137
|
-
type PresetOrFactory<Theme extends object = object> = Preset<Theme> | PresetFactory<Theme, any>;
|
|
1138
|
-
type PresetOrFactoryAwaitable<Theme extends object = object> = PresetOrFactory<Theme> | Promise<Preset<Theme>> | PresetFactoryAwaitable<Theme>;
|
|
1139
|
-
interface GeneratorOptions {
|
|
1131
|
+
export type PresetFactory<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Preset<Theme>;
|
|
1132
|
+
export type PresetFactoryAwaitable<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Awaitable<Preset<Theme>>;
|
|
1133
|
+
export type PresetOrFactory<Theme extends object = object> = Preset<Theme> | PresetFactory<Theme, any>;
|
|
1134
|
+
export type PresetOrFactoryAwaitable<Theme extends object = object> = PresetOrFactory<Theme> | Promise<Preset<Theme>> | PresetFactoryAwaitable<Theme>;
|
|
1135
|
+
export interface GeneratorOptions {
|
|
1140
1136
|
/**
|
|
1141
1137
|
* Merge utilities with the exact same body to save the file size
|
|
1142
1138
|
*
|
|
@@ -1150,7 +1146,7 @@ interface GeneratorOptions {
|
|
|
1150
1146
|
*/
|
|
1151
1147
|
warn?: boolean;
|
|
1152
1148
|
}
|
|
1153
|
-
interface UserOnlyOptions<Theme extends object = object> {
|
|
1149
|
+
export interface UserOnlyOptions<Theme extends object = object> {
|
|
1154
1150
|
/**
|
|
1155
1151
|
* Opt-in reporting for token-shaped candidates that match no rule. With the
|
|
1156
1152
|
* default `"off"`, unmatched tokens stay silent, nothing is collected, and
|
|
@@ -1190,12 +1186,12 @@ interface UserOnlyOptions<Theme extends object = object> {
|
|
|
1190
1186
|
/**
|
|
1191
1187
|
* For cli config
|
|
1192
1188
|
*/
|
|
1193
|
-
interface CliOptions {
|
|
1189
|
+
export interface CliOptions {
|
|
1194
1190
|
cli?: {
|
|
1195
1191
|
entry?: Arrayable<CliEntryItem>;
|
|
1196
1192
|
};
|
|
1197
1193
|
}
|
|
1198
|
-
interface TeacssPluginContext<Config extends UserConfig = UserConfig> {
|
|
1194
|
+
export interface TeacssPluginContext<Config extends UserConfig = UserConfig> {
|
|
1199
1195
|
/**
|
|
1200
1196
|
* Singleton promise for config loading
|
|
1201
1197
|
*/
|
|
@@ -1228,16 +1224,18 @@ interface TeacssPluginContext<Config extends UserConfig = UserConfig> {
|
|
|
1228
1224
|
extract: (code: string, id?: string) => Promise<void>;
|
|
1229
1225
|
reloadConfig: () => Promise<LoadConfigResult<Config>>;
|
|
1230
1226
|
getConfig: () => Promise<Config>;
|
|
1231
|
-
/** Subscribe to config reloads.
|
|
1227
|
+
/** Subscribe to config reloads. Async failures are reported without delaying publication. Returns a disposer. */
|
|
1232
1228
|
onReload: (fn: () => void) => () => void;
|
|
1233
1229
|
invalidate: () => void;
|
|
1234
|
-
/** Subscribe to generated-output invalidations.
|
|
1230
|
+
/** Subscribe to generated-output invalidations. Async failures are reported without delaying notification. Returns a disposer. */
|
|
1235
1231
|
onInvalidate: (fn: () => void) => () => void;
|
|
1236
1232
|
root: string;
|
|
1237
1233
|
updateRoot: (root: string) => Promise<LoadConfigResult<Config>>;
|
|
1238
1234
|
getConfigFileList: () => string[];
|
|
1239
1235
|
/**
|
|
1240
1236
|
* Get regexes to match virtual module ids
|
|
1237
|
+
* Full matches include directory prefixes; layer/query captures are preserved.
|
|
1238
|
+
* Virtual names in query or fragment suffixes are not matched as filenames.
|
|
1241
1239
|
*/
|
|
1242
1240
|
getVMPRegexes: () => Promise<{
|
|
1243
1241
|
prefix: string;
|
|
@@ -1245,7 +1243,7 @@ interface TeacssPluginContext<Config extends UserConfig = UserConfig> {
|
|
|
1245
1243
|
RESOLVED_ID_RE: RegExp;
|
|
1246
1244
|
}>;
|
|
1247
1245
|
}
|
|
1248
|
-
interface SourceMap {
|
|
1246
|
+
export interface SourceMap {
|
|
1249
1247
|
file?: string;
|
|
1250
1248
|
mappings?: string;
|
|
1251
1249
|
names?: string[];
|
|
@@ -1253,13 +1251,13 @@ interface SourceMap {
|
|
|
1253
1251
|
sourcesContent?: string[];
|
|
1254
1252
|
version?: number;
|
|
1255
1253
|
}
|
|
1256
|
-
interface HighlightAnnotation {
|
|
1254
|
+
export interface HighlightAnnotation {
|
|
1257
1255
|
offset: number;
|
|
1258
1256
|
length: number;
|
|
1259
1257
|
className: string;
|
|
1260
1258
|
}
|
|
1261
|
-
type SourceCodeTransformerEnforce = "pre" | "post" | "default";
|
|
1262
|
-
interface SourceCodeTransformer {
|
|
1259
|
+
export type SourceCodeTransformerEnforce = "pre" | "post" | "default";
|
|
1260
|
+
export interface SourceCodeTransformer {
|
|
1263
1261
|
name: string;
|
|
1264
1262
|
/**
|
|
1265
1263
|
* The order of transformer
|
|
@@ -1280,7 +1278,7 @@ interface SourceCodeTransformer {
|
|
|
1280
1278
|
*/
|
|
1281
1279
|
onModuleRemoved?: (id: string, ctx: TeacssPluginContext) => Awaitable<void>;
|
|
1282
1280
|
}
|
|
1283
|
-
interface ContentOptions {
|
|
1281
|
+
export interface ContentOptions {
|
|
1284
1282
|
/**
|
|
1285
1283
|
* Glob patterns to extract from the file system, in addition to other content sources.
|
|
1286
1284
|
*
|
|
@@ -1314,7 +1312,7 @@ interface ContentOptions {
|
|
|
1314
1312
|
* By default, `.ts` and `.js` files are NOT extracted.
|
|
1315
1313
|
*
|
|
1316
1314
|
* @see https://www.npmjs.com/package/picomatch
|
|
1317
|
-
* @default [/\.(vue|svelte|[jt]sx|vine
|
|
1315
|
+
* @default [/\.(vue|svelte|[jt]sx|vine\.ts|mdx?|astro|elm|php|phtml|marko|html)($|\?)/]
|
|
1318
1316
|
*/
|
|
1319
1317
|
include?: FilterPattern;
|
|
1320
1318
|
/**
|
|
@@ -1332,7 +1330,7 @@ interface ContentOptions {
|
|
|
1332
1330
|
/**
|
|
1333
1331
|
* For other modules to aggregate the options
|
|
1334
1332
|
*/
|
|
1335
|
-
interface PluginOptions {
|
|
1333
|
+
export interface PluginOptions {
|
|
1336
1334
|
/**
|
|
1337
1335
|
* Custom transformers to the source code
|
|
1338
1336
|
*/
|
|
@@ -1349,9 +1347,9 @@ interface PluginOptions {
|
|
|
1349
1347
|
*/
|
|
1350
1348
|
content?: ContentOptions;
|
|
1351
1349
|
}
|
|
1352
|
-
interface UserConfig<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {}
|
|
1353
|
-
interface UserConfigDefaults<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {}
|
|
1354
|
-
interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByKey<UserConfig<Theme>, "mergeSelectors" | "theme" | "rules" | "variants" | "layers" | "extractors" | "blocklist" | "safelist" | "preflights" | "sortLayers">, "rules" | "shortcuts" | "autocomplete" | "presets"> {
|
|
1350
|
+
export interface UserConfig<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme>, GeneratorOptions, PluginOptions, CliOptions {}
|
|
1351
|
+
export interface UserConfigDefaults<Theme extends object = object> extends ConfigBase<Theme>, UserOnlyOptions<Theme> {}
|
|
1352
|
+
export interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByKey<UserConfig<Theme>, "mergeSelectors" | "theme" | "rules" | "variants" | "layers" | "extractors" | "blocklist" | "safelist" | "preflights" | "sortLayers">, "rules" | "shortcuts" | "autocomplete" | "presets"> {
|
|
1355
1353
|
presets: Preset<Theme>[];
|
|
1356
1354
|
shortcuts: Shortcut<Theme>[];
|
|
1357
1355
|
variants: VariantObject<Theme>[];
|
|
@@ -1368,14 +1366,14 @@ interface ResolvedConfig<Theme extends object = object> extends Omit<RequiredByK
|
|
|
1368
1366
|
};
|
|
1369
1367
|
separators: string[];
|
|
1370
1368
|
}
|
|
1371
|
-
interface UnmatchedTokenDiagnostic {
|
|
1369
|
+
export interface UnmatchedTokenDiagnostic {
|
|
1372
1370
|
token: string;
|
|
1373
1371
|
suggestions: string[];
|
|
1374
1372
|
}
|
|
1375
|
-
interface GenerateDiagnostics {
|
|
1373
|
+
export interface GenerateDiagnostics {
|
|
1376
1374
|
unmatched: UnmatchedTokenDiagnostic[];
|
|
1377
1375
|
}
|
|
1378
|
-
interface GenerateResult<T = Set<string>> {
|
|
1376
|
+
export interface GenerateResult<T = Set<string>> {
|
|
1379
1377
|
css: string;
|
|
1380
1378
|
layers: string[];
|
|
1381
1379
|
getLayer: (name?: string) => string | undefined;
|
|
@@ -1385,12 +1383,12 @@ interface GenerateResult<T = Set<string>> {
|
|
|
1385
1383
|
/** Token-shaped candidates that matched no rule; populated only when the opt-in `unmatched` option is enabled, suggestions compute lazily on first read. */
|
|
1386
1384
|
diagnostics: GenerateDiagnostics;
|
|
1387
1385
|
}
|
|
1388
|
-
type VariantMatchedResult<Theme extends object = object> = [raw: string, current: string, variantHandlers: VariantHandler[], variants: Set<Variant<Theme>>];
|
|
1389
|
-
type ParsedUtil = readonly [index: number, raw: string, entries: CSSEntriesInput, meta: RuleMeta | undefined, variantHandlers: VariantHandler[]];
|
|
1390
|
-
type RawUtil = readonly [index: number, rawCSS: string, meta: RuleMeta | undefined];
|
|
1391
|
-
type StringifiedUtil<Theme extends object = object> = readonly [index: number, selector: string | undefined, body: string, parent: string | undefined, meta: RuleMeta | undefined, context: RuleContext<Theme> | undefined, noMerge: boolean | undefined];
|
|
1392
|
-
type PreparedRule = readonly [selector: [string, number][], body: string, noMerge: boolean];
|
|
1393
|
-
interface CliEntryItem {
|
|
1386
|
+
export type VariantMatchedResult<Theme extends object = object> = [raw: string, current: string, variantHandlers: VariantHandler[], variants: Set<Variant<Theme>>];
|
|
1387
|
+
export type ParsedUtil = readonly [index: number, raw: string, entries: CSSEntriesInput, meta: RuleMeta | undefined, variantHandlers: VariantHandler[]];
|
|
1388
|
+
export type RawUtil = readonly [index: number, rawCSS: string, meta: RuleMeta | undefined];
|
|
1389
|
+
export type StringifiedUtil<Theme extends object = object> = readonly [index: number, selector: string | undefined, body: string, parent: string | undefined, meta: RuleMeta | undefined, context: RuleContext<Theme> | undefined, noMerge: boolean | undefined];
|
|
1390
|
+
export type PreparedRule = readonly [selector: [string, number][], body: string, noMerge: boolean];
|
|
1391
|
+
export interface CliEntryItem {
|
|
1394
1392
|
patterns: string[];
|
|
1395
1393
|
outFile: string;
|
|
1396
1394
|
/**
|
|
@@ -1414,7 +1412,7 @@ interface CliEntryItem {
|
|
|
1414
1412
|
*/
|
|
1415
1413
|
splitCss?: boolean | "multi" | "single";
|
|
1416
1414
|
}
|
|
1417
|
-
interface UtilObject {
|
|
1415
|
+
export interface UtilObject {
|
|
1418
1416
|
selector: string;
|
|
1419
1417
|
entries: CSSEntriesInput;
|
|
1420
1418
|
parent: string | undefined;
|
|
@@ -1425,7 +1423,7 @@ interface UtilObject {
|
|
|
1425
1423
|
/**
|
|
1426
1424
|
* Returned from `tea.generate()` when `extendedInfo` option is enabled.
|
|
1427
1425
|
*/
|
|
1428
|
-
interface ExtendedTokenInfo<Theme extends object = object> {
|
|
1426
|
+
export interface ExtendedTokenInfo<Theme extends object = object> {
|
|
1429
1427
|
/**
|
|
1430
1428
|
* Stringified util data
|
|
1431
1429
|
*/
|
|
@@ -1435,7 +1433,7 @@ interface ExtendedTokenInfo<Theme extends object = object> {
|
|
|
1435
1433
|
*/
|
|
1436
1434
|
count: number;
|
|
1437
1435
|
}
|
|
1438
|
-
interface GenerateOptions<T extends boolean> {
|
|
1436
|
+
export interface GenerateOptions<T extends boolean> {
|
|
1439
1437
|
/**
|
|
1440
1438
|
* Filepath of the file being processed.
|
|
1441
1439
|
*/
|
|
@@ -1461,6 +1459,18 @@ interface GenerateOptions<T extends boolean> {
|
|
|
1461
1459
|
*/
|
|
1462
1460
|
tokenConcurrency?: number;
|
|
1463
1461
|
/**
|
|
1462
|
+
* Synchronous, side-effect-free check for externally extracted input.
|
|
1463
|
+
* Called repeatedly across generation boundaries and before diagnostics.
|
|
1464
|
+
* Returning false rejects generation; thrown errors propagate. Omit to
|
|
1465
|
+
* preserve normal config retries. This does not cancel running hooks or
|
|
1466
|
+
* undo previously published diagnostics.
|
|
1467
|
+
*/
|
|
1468
|
+
isInputCurrent?: () => boolean;
|
|
1469
|
+
/**
|
|
1470
|
+
* Scope generated selectors to a CSS selector or selector list. Each scope
|
|
1471
|
+
* arm is applied independently, preserving its own specificity.
|
|
1472
|
+
* An empty string disables scoping; empty or comment-only list arms reject
|
|
1473
|
+
* generation rather than emitting unscoped selectors.
|
|
1464
1474
|
* @experimental
|
|
1465
1475
|
*/
|
|
1466
1476
|
scope?: string;
|
|
@@ -1471,7 +1481,7 @@ interface GenerateOptions<T extends boolean> {
|
|
|
1471
1481
|
}
|
|
1472
1482
|
//#endregion
|
|
1473
1483
|
//#region src/condition-variant.d.ts
|
|
1474
|
-
interface ConditionVariantOptions {
|
|
1484
|
+
export interface ConditionVariantOptions {
|
|
1475
1485
|
/**
|
|
1476
1486
|
* Variant name (for debugging / `details`).
|
|
1477
1487
|
* @default "at-condition"
|
|
@@ -1490,32 +1500,32 @@ interface ConditionVariantOptions {
|
|
|
1490
1500
|
* If any condition is unrecognized by the resolvers, the token is left unclaimed
|
|
1491
1501
|
* (`undefined`), preserving the generator's behavior for unknown tokens.
|
|
1492
1502
|
*/
|
|
1493
|
-
declare function createConditionVariant<Theme extends object = object>(resolvers: ConditionResolver[], options?: ConditionVariantOptions): VariantObject<Theme>;
|
|
1503
|
+
export declare function createConditionVariant<Theme extends object = object>(resolvers: ConditionResolver[], options?: ConditionVariantOptions): VariantObject<Theme>;
|
|
1494
1504
|
//#endregion
|
|
1495
1505
|
//#region src/config.d.ts
|
|
1496
|
-
declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
|
|
1506
|
+
export declare function resolveShortcuts<Theme extends object = object>(shortcuts: UserShortcuts<Theme>): Shortcut<Theme>[];
|
|
1497
1507
|
/**
|
|
1498
1508
|
* Resolve a single preset, nested presets are ignored
|
|
1499
1509
|
*/
|
|
1500
|
-
declare function resolvePreset<Theme extends object = object>(presetInput: PresetOrFactoryAwaitable<Theme>): Promise<Preset<Theme>>;
|
|
1510
|
+
export declare function resolvePreset<Theme extends object = object>(presetInput: PresetOrFactoryAwaitable<Theme>): Promise<Preset<Theme>>;
|
|
1501
1511
|
/**
|
|
1502
1512
|
* Resolve presets with nested presets
|
|
1503
1513
|
*/
|
|
1504
|
-
declare function resolvePresets<Theme extends object = object>(preset: PresetOrFactoryAwaitable<Theme>): Promise<Preset<Theme>[]>;
|
|
1505
|
-
declare function resolveConfig<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<ResolvedConfig<Theme>>;
|
|
1506
|
-
declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
|
|
1507
|
-
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
|
|
1508
|
-
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactoryAwaitable<Theme, Options>): PresetFactoryAwaitable<Theme, Options>;
|
|
1509
|
-
declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
|
|
1514
|
+
export declare function resolvePresets<Theme extends object = object>(preset: PresetOrFactoryAwaitable<Theme>): Promise<Preset<Theme>[]>;
|
|
1515
|
+
export declare function resolveConfig<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<ResolvedConfig<Theme>>;
|
|
1516
|
+
export declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
|
|
1517
|
+
export declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
|
|
1518
|
+
export declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactoryAwaitable<Theme, Options>): PresetFactoryAwaitable<Theme, Options>;
|
|
1519
|
+
export declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
|
|
1510
1520
|
//#endregion
|
|
1511
1521
|
//#region src/constants.d.ts
|
|
1512
|
-
declare const LAYER_IMPORTS = "imports";
|
|
1513
|
-
declare const LAYER_PRIMITIVES = "primitives";
|
|
1514
|
-
declare const LAYER_PROPERTIES = "properties";
|
|
1515
|
-
declare const LAYER_PREFLIGHTS = "preflights";
|
|
1516
|
-
declare const LAYER_SHORTCUTS = "shortcuts";
|
|
1517
|
-
declare const LAYER_UTILITIES = "utilities";
|
|
1518
|
-
declare const DEFAULT_LAYERS: Readonly<{
|
|
1522
|
+
export declare const LAYER_IMPORTS = "imports";
|
|
1523
|
+
export declare const LAYER_PRIMITIVES = "primitives";
|
|
1524
|
+
export declare const LAYER_PROPERTIES = "properties";
|
|
1525
|
+
export declare const LAYER_PREFLIGHTS = "preflights";
|
|
1526
|
+
export declare const LAYER_SHORTCUTS = "shortcuts";
|
|
1527
|
+
export declare const LAYER_UTILITIES = "utilities";
|
|
1528
|
+
export declare const DEFAULT_LAYERS: Readonly<{
|
|
1519
1529
|
imports: -200;
|
|
1520
1530
|
properties: -150;
|
|
1521
1531
|
preflights: -100;
|
|
@@ -1525,25 +1535,25 @@ declare const DEFAULT_LAYERS: Readonly<{
|
|
|
1525
1535
|
}>;
|
|
1526
1536
|
//#endregion
|
|
1527
1537
|
//#region src/env.d.ts
|
|
1528
|
-
declare function getEnvFlags(): {
|
|
1538
|
+
export declare function getEnvFlags(): {
|
|
1529
1539
|
isNode: boolean;
|
|
1530
1540
|
isVSCode: boolean;
|
|
1531
1541
|
isESLint: boolean;
|
|
1532
1542
|
};
|
|
1533
1543
|
//#endregion
|
|
1534
1544
|
//#region src/extractors/split.d.ts
|
|
1535
|
-
declare const defaultSplitRE: RegExp;
|
|
1536
|
-
declare const splitWithVariantGroupRE: RegExp;
|
|
1537
|
-
declare const extractorSplit: Extractor;
|
|
1545
|
+
export declare const defaultSplitRE: RegExp;
|
|
1546
|
+
export declare const splitWithVariantGroupRE: RegExp;
|
|
1547
|
+
export declare const extractorSplit: Extractor;
|
|
1538
1548
|
//#endregion
|
|
1539
1549
|
//#region src/group.d.ts
|
|
1540
1550
|
/** Expand groups in host source, including groups nested in strings/arrays. */
|
|
1541
|
-
declare function expandGroups(code: string): string;
|
|
1551
|
+
export declare function expandGroups(code: string): string;
|
|
1542
1552
|
/** Expand groups in a class list while preserving braces inside attached literals. */
|
|
1543
|
-
declare function expandClassGroups(code: string): string;
|
|
1553
|
+
export declare function expandClassGroups(code: string): string;
|
|
1544
1554
|
//#endregion
|
|
1545
1555
|
//#region src/hash.d.ts
|
|
1546
|
-
declare function getHash(input: string, length?: number): string;
|
|
1556
|
+
export declare function getHash(input: string, length?: number): string;
|
|
1547
1557
|
//#endregion
|
|
1548
1558
|
//#region src/literal.d.ts
|
|
1549
1559
|
/**
|
|
@@ -1570,7 +1580,7 @@ declare function getHash(input: string, length?: number): string;
|
|
|
1570
1580
|
* or backticks as delimiters. It is for already-isolated class-list surfaces
|
|
1571
1581
|
* such as shortcuts, `cn()`, and `@apply`.
|
|
1572
1582
|
*/
|
|
1573
|
-
declare function splitClassTokens(input: string): string[];
|
|
1583
|
+
export declare function splitClassTokens(input: string): string[];
|
|
1574
1584
|
/**
|
|
1575
1585
|
* Expand `_` to a space inside an arbitrary `[]` region.
|
|
1576
1586
|
*
|
|
@@ -1578,16 +1588,16 @@ declare function splitClassTokens(input: string): string[];
|
|
|
1578
1588
|
* - `_` at paren depth 0 → a space.
|
|
1579
1589
|
* - `_` inside `(…)` → kept literal (so `var(--my_var)` survives).
|
|
1580
1590
|
*/
|
|
1581
|
-
declare function expandUnderscores(content: string): string;
|
|
1591
|
+
export declare function expandUnderscores(content: string): string;
|
|
1582
1592
|
/**
|
|
1583
1593
|
* Add surrounding spaces to `+ - * /` operators inside balanced `calc()` /
|
|
1584
1594
|
* `clamp()` / `min()` / `max()` functions without rewriting adjacent values,
|
|
1585
1595
|
* quoted text, URLs, custom-property names, or numeric exponent signs.
|
|
1586
1596
|
*/
|
|
1587
|
-
declare function spaceCalcOperators(str: string): string;
|
|
1597
|
+
export declare function spaceCalcOperators(str: string): string;
|
|
1588
1598
|
/** True when `value` is a single `[…]` arbitrary region. */
|
|
1589
|
-
declare function isArbitrary(value: string): boolean;
|
|
1590
|
-
interface NormalizeArbitraryOptions {
|
|
1599
|
+
export declare function isArbitrary(value: string): boolean;
|
|
1600
|
+
export interface NormalizeArbitraryOptions {
|
|
1591
1601
|
/**
|
|
1592
1602
|
* Apply `calc` / `clamp` / `min` / `max` operator spacing.
|
|
1593
1603
|
* @default true
|
|
@@ -1610,18 +1620,18 @@ interface NormalizeArbitraryOptions {
|
|
|
1610
1620
|
* @example normalizeArbitraryValue("calc(100%-1rem)") // "calc(100% - 1rem)"
|
|
1611
1621
|
* @example normalizeArbitraryValue("var(--my_var)") // "var(--my_var)"
|
|
1612
1622
|
*/
|
|
1613
|
-
declare function normalizeArbitraryValue(value: string, options?: NormalizeArbitraryOptions): string;
|
|
1623
|
+
export declare function normalizeArbitraryValue(value: string, options?: NormalizeArbitraryOptions): string;
|
|
1614
1624
|
//#endregion
|
|
1615
1625
|
//#region src/markers.d.ts
|
|
1616
|
-
declare const INCLUDE_COMMENT = "@teacss-include";
|
|
1617
|
-
declare const IGNORE_COMMENT = "@teacss-ignore";
|
|
1618
|
-
declare const INCLUDE_COMMENT_IDE = "@teacss-ide-include";
|
|
1619
|
-
declare const CSS_PLACEHOLDER = "@teacss-placeholder";
|
|
1620
|
-
declare const SKIP_START_COMMENT = "@teacss-skip-start";
|
|
1621
|
-
declare const SKIP_END_COMMENT = "@teacss-skip-end";
|
|
1622
|
-
declare const SKIP_COMMENT_RE: RegExp;
|
|
1623
|
-
declare const VIRTUAL_ENTRY_ALIAS: RegExp[];
|
|
1624
|
-
declare const LAYER_MARK_ALL = "__ALL__";
|
|
1626
|
+
export declare const INCLUDE_COMMENT = "@teacss-include";
|
|
1627
|
+
export declare const IGNORE_COMMENT = "@teacss-ignore";
|
|
1628
|
+
export declare const INCLUDE_COMMENT_IDE = "@teacss-ide-include";
|
|
1629
|
+
export declare const CSS_PLACEHOLDER = "@teacss-placeholder";
|
|
1630
|
+
export declare const SKIP_START_COMMENT = "@teacss-skip-start";
|
|
1631
|
+
export declare const SKIP_END_COMMENT = "@teacss-skip-end";
|
|
1632
|
+
export declare const SKIP_COMMENT_RE: RegExp;
|
|
1633
|
+
export declare const VIRTUAL_ENTRY_ALIAS: RegExp[];
|
|
1634
|
+
export declare const LAYER_MARK_ALL = "__ALL__";
|
|
1625
1635
|
//#endregion
|
|
1626
1636
|
//#region src/token.d.ts
|
|
1627
1637
|
/**
|
|
@@ -1644,12 +1654,13 @@ declare const LAYER_MARK_ALL = "__ALL__";
|
|
|
1644
1654
|
* - `()` and `[]` are literal regions; operators inside them (`:` `!` `@` …) do
|
|
1645
1655
|
* not participate in parsing.
|
|
1646
1656
|
* - `!` immediately after the value (before any `@`) is `!important`.
|
|
1647
|
-
* - The
|
|
1657
|
+
* - The declaration ends at the first depth-0 `@` or the token's end. Only a
|
|
1658
|
+
* trailing depth-0 `!` is stripped; other bangs remain for later validation.
|
|
1648
1659
|
* - Zero or more `@cond` segments follow; each is captured verbatim (without its
|
|
1649
1660
|
* leading `@`). Interpreting a condition (pseudo / target / media / NOT `!…` …)
|
|
1650
1661
|
* belongs to the condition pipeline.
|
|
1651
1662
|
*/
|
|
1652
|
-
interface ParsedClassToken {
|
|
1663
|
+
export interface ParsedClassToken {
|
|
1653
1664
|
/** The full original token, unchanged. */
|
|
1654
1665
|
raw: string;
|
|
1655
1666
|
/** Declaration body without the trailing `!` or any `@cond` (e.g. `bg:red`, `d:flex`, `content:[""]`). */
|
|
@@ -1672,6 +1683,6 @@ interface ParsedClassToken {
|
|
|
1672
1683
|
* unbalanced brackets) are parsed leniently rather than throwing — validation is
|
|
1673
1684
|
* left to the rule layer.
|
|
1674
1685
|
*/
|
|
1675
|
-
declare function parseClassToken(raw: string): ParsedClassToken;
|
|
1686
|
+
export declare function parseClassToken(raw: string): ParsedClassToken;
|
|
1676
1687
|
//#endregion
|
|
1677
|
-
export {
|
|
1688
|
+
export { extractorSplit as extractorDefault };
|