weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
70 lines (69 loc) • 4.22 kB
TypeScript
import type { TailwindInlineSourceCandidates, TailwindSourceEntry } from '../../../tailwindcss/source-scan.js';
import type { ICustomAttributesEntities } from '../../../types/index.js';
import type { IArbitraryValues } from '../../../types/shared.js';
import { LRUCache } from 'lru-cache';
export interface SourceCandidateStore {
syncSource: (id: string, source: string) => Promise<void>;
sync: (id: string, source: string) => Promise<void>;
syncCss: (id: string, source: string) => Promise<void>;
merge: (id: string, source: string) => Promise<void>;
syncFile: (id: string) => Promise<void>;
syncCurrentSource: (id: string, source: string) => Promise<SourceCandidateChange>;
syncCurrentFile: (id: string) => Promise<SourceCandidateChange>;
scanRoot: (options: ScanSourceCandidateRootOptions) => Promise<void>;
syncInline: (inlineCandidates: TailwindInlineSourceCandidates | undefined) => void;
remove: (id: string) => SourceCandidateChange;
source: (id: string) => string | undefined;
sources: () => IterableIterator<[string, string]>;
values: () => Set<string>;
valuesForEntries: (entries: TailwindSourceEntry[] | undefined, options?: SourceCandidateFilterOptions) => Set<string>;
sourcesForEntries: (entries: TailwindSourceEntry[] | undefined, options?: SourceCandidateFilterOptions) => Map<string, Set<string>>;
snapshot: () => SourceCandidateCollectorSnapshot;
restore: (snapshot: SourceCandidateCollectorSnapshot) => void;
clearScan: () => void;
resetScan: () => void;
clear: () => void;
}
export interface SourceCandidateCollector extends SourceCandidateStore {
}
export interface SourceCandidateChange {
addedCandidates: Set<string>;
removedCandidates: Set<string>;
}
export interface SourceCandidateCollectorSnapshot {
candidatesById: Array<[string, string[]]>;
cssCandidatesById?: Array<[string, string[]]> | undefined;
cssSourceById?: Array<[string, string]> | undefined;
scanCandidatesById?: Array<[string, string[]]> | undefined;
scanSourceById?: Array<[string, string]> | undefined;
sourceById?: Array<[string, string]> | undefined;
transformCandidatesById?: Array<[string, string[]]> | undefined;
transformSourceById?: Array<[string, string]> | undefined;
inlineExcludedCandidates: string[];
inlineIncludedCandidates: string[];
}
export interface SourceCandidateFilterOptions {
excludeEntries?: TailwindSourceEntry[] | undefined;
}
export interface ScanSourceCandidateRootOptions {
root: string;
outDir?: string | undefined;
entries?: TailwindSourceEntry[] | undefined;
explicit?: boolean | undefined;
}
export interface SourceCandidateCollectorOptions {
bareArbitraryValues?: IArbitraryValues['bareArbitraryValues'] | undefined;
customAttributesEntities?: ICustomAttributesEntities | undefined;
disabledDefaultTemplateHandler?: boolean | undefined;
extractor?: ((source: string, extension: string) => Promise<Iterable<string>> | Iterable<string>) | undefined;
}
export declare const SOURCE_CANDIDATE_CONTENT_CACHE_MAX = 128;
export declare const sourceCandidateContentCache: LRUCache<string, string[], unknown>;
export declare function cleanUrl(id: string): string;
export declare function resolveSourceCandidateExtension(id: string): string;
export declare function createSourceCandidateContentCacheKey(extension: string, source: string, bareArbitraryValues: IArbitraryValues['bareArbitraryValues'] | undefined, customAttributesEntities: ICustomAttributesEntities | undefined, disabledDefaultTemplateHandler: boolean | undefined, extractor: SourceCandidateCollectorOptions['extractor']): string;
export declare function extractCandidates(source: string, extension: string, options: SourceCandidateCollectorOptions): Promise<Set<string>>;
export declare function isSourceCandidateRequest(id: string): boolean;
export declare function removeCandidateSet(candidateCount: Map<string, number>, candidates: Set<string>): void;
export declare function addCandidateSet(candidateCount: Map<string, number>, candidates: Set<string>): void;
export declare function diffCandidateSets(previous: Set<string>, next: Set<string>): SourceCandidateChange;