import { Declaration, TokenOrValue } from "lightningcss"; //#region packages/core/types.d.ts type HandlerResult = string | string[] | Declaration | Declaration[] | TokenOrValue | TokenOrValue[]; /** Info about a single directive argument or computed variable. */ interface ArgInfo { /** Raw string from CSS before var() resolution. */ original: string; /** String after var() resolution and validation. */ parsed: string; /** Compiled CSS var() reference for use in value(). */ var: string; } /** Unified context passed to directive value() handlers. */ type DirectiveContext = Record; type Handler = { (args: TokenOrValue[] | null, ctx?: DirectiveContext): HandlerResult; /** When set, generates root-level CSS (e.g. @keyframes, @font-face). */ spawn?: () => string; }; type FunctionHandlers = Record; //#endregion //#region packages/core/transform.d.ts declare function transformCSS(css: string, handlers: FunctionHandlers, filename?: string): string; //#endregion //#region packages/core/utils/inlineCSS.d.ts /** * Recursively inlines CSS content from a file. * * @param filePath - The path of the CSS file * @param content - Optional CSS content; if not provided, the file will be read * @param seen - Tracks already inlined files to prevent cycles * @param addWatch - Optional callback to register watched dependencies (e.g. Vite's addWatchFile) * @returns Inlined CSS content as a string */ declare function inlineCSS(filePath: string, content?: string, seen?: Set, addWatch?: (file: string) => void): Promise; //#endregion //#region packages/core/utils/id.d.ts declare function generateId(length?: number): string; //#endregion //#region node_modules/.bun/valibot@1.4.1+7524df1edfed9f02/node_modules/valibot/dist/index.d.mts //#endregion //#region src/types/metadata.d.ts /** * Base metadata interface. */ interface BaseMetadata { /** * The object kind. */ readonly kind: "metadata"; /** * The metadata type. */ readonly type: string; /** * The metadata reference. */ readonly reference: (...args: any[]) => BaseMetadata; /** * The input, output and issue type. * * @internal */ readonly "~types"?: { readonly input: TInput$1; readonly output: TInput$1; readonly issue: never; } | undefined; } /** * Generic metadata type. */ //#endregion //#region src/types/dataset.d.ts /** * Unknown dataset interface. */ interface UnknownDataset { /** * Whether is's typed. */ typed?: false; /** * The dataset value. */ value: unknown; /** * The dataset issues. */ issues?: undefined; } /** * Success dataset interface. */ interface SuccessDataset { /** * Whether is's typed. */ typed: true; /** * The dataset value. */ value: TValue$1; /** * The dataset issues. */ issues?: undefined; } /** * Partial dataset interface. */ interface PartialDataset> { /** * Whether is's typed. */ typed: true; /** * The dataset value. */ value: TValue$1; /** * The dataset issues. */ issues: [TIssue, ...TIssue[]]; } /** * Failure dataset interface. */ interface FailureDataset> { /** * Whether is's typed. */ typed: false; /** * The dataset value. */ value: unknown; /** * The dataset issues. */ issues: [TIssue, ...TIssue[]]; } /** * Output dataset type. */ type OutputDataset> = SuccessDataset | PartialDataset | FailureDataset; //#endregion //#region src/types/standard.d.ts /** * The Standard Schema properties interface. */ interface StandardProps { /** * The version number of the standard. */ readonly version: 1; /** * The vendor name of the schema library. */ readonly vendor: "valibot"; /** * Validates unknown input values. */ readonly validate: (value: unknown) => StandardResult | Promise>; /** * Inferred types associated with the schema. */ readonly types?: StandardTypes | undefined; } /** * The result interface of the validate function. */ type StandardResult = StandardSuccessResult | StandardFailureResult; /** * The result interface if validation succeeds. */ interface StandardSuccessResult { /** * The typed output value. */ readonly value: TOutput$1; /** * The non-existent issues. */ readonly issues?: undefined; } /** * The result interface if validation fails. */ interface StandardFailureResult { /** * The issues of failed validation. */ readonly issues: readonly StandardIssue[]; } /** * The issue interface of the failure output. */ interface StandardIssue { /** * The error message of the issue. */ readonly message: string; /** * The path of the issue, if any. */ readonly path?: readonly (PropertyKey | StandardPathItem)[] | undefined; } /** * The path item interface of the issue. */ interface StandardPathItem { /** * The key of the path item. */ readonly key: PropertyKey; } /** * The Standard Schema types interface. */ interface StandardTypes { /** * The input type of the schema. */ readonly input: TInput$1; /** * The output type of the schema. */ readonly output: TOutput$1; } //#endregion //#region src/types/schema.d.ts /** * Base schema interface. */ interface BaseSchema> { /** * The object kind. */ readonly kind: "schema"; /** * The schema type. */ readonly type: string; /** * The schema reference. */ readonly reference: (...args: any[]) => BaseSchema>; /** * The expected property. */ readonly expects: string; /** * Whether it's async. */ readonly async: false; /** * The Standard Schema properties. * * @internal */ readonly "~standard": StandardProps; /** * Parses unknown input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: UnknownDataset, config: Config>) => OutputDataset; /** * The input, output and issue type. * * @internal */ readonly "~types"?: { readonly input: TInput$1; readonly output: TOutput$1; readonly issue: TIssue; } | undefined; } /** * Base schema async interface. */ interface BaseSchemaAsync> extends Omit, "reference" | "async" | "~run"> { /** * The schema reference. */ readonly reference: (...args: any[]) => BaseSchema> | BaseSchemaAsync>; /** * Whether it's async. */ readonly async: true; /** * Parses unknown input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: UnknownDataset, config: Config>) => Promise>; } /** * Generic schema type. */ //#endregion //#region src/types/transformation.d.ts /** * Base transformation interface. */ interface BaseTransformation> { /** * The object kind. */ readonly kind: "transformation"; /** * The transformation type. */ readonly type: string; /** * The transformation reference. */ readonly reference: (...args: any[]) => BaseTransformation>; /** * Whether it's async. */ readonly async: false; /** * Transforms known input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: SuccessDataset, config: Config>) => OutputDataset | TIssue>; /** * The input, output and issue type. * * @internal */ readonly "~types"?: { readonly input: TInput$1; readonly output: TOutput$1; readonly issue: TIssue; } | undefined; } /** * Base transformation async interface. */ interface BaseTransformationAsync> extends Omit, "reference" | "async" | "~run"> { /** * The transformation reference. */ readonly reference: (...args: any[]) => BaseTransformation> | BaseTransformationAsync>; /** * Whether it's async. */ readonly async: true; /** * Transforms known input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: SuccessDataset, config: Config>) => Promise | TIssue>>; } /** * Generic transformation type. */ //#endregion //#region src/types/validation.d.ts /** * Base validation interface. */ interface BaseValidation> { /** * The object kind. */ readonly kind: "validation"; /** * The validation type. */ readonly type: string; /** * The validation reference. */ readonly reference: (...args: any[]) => BaseValidation>; /** * The expected property. */ readonly expects: string | null; /** * Whether it's async. */ readonly async: false; /** * Validates known input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: OutputDataset>, config: Config>) => OutputDataset | TIssue>; /** * The input, output and issue type. * * @internal */ readonly "~types"?: { readonly input: TInput$1; readonly output: TOutput$1; readonly issue: TIssue; } | undefined; } /** * Base validation async interface. */ interface BaseValidationAsync> extends Omit, "reference" | "async" | "~run"> { /** * The validation reference. */ readonly reference: (...args: any[]) => BaseValidation> | BaseValidationAsync>; /** * Whether it's async. */ readonly async: true; /** * Validates known input values. * * @param dataset The input dataset. * @param config The configuration. * * @returns The output dataset. * * @internal */ readonly "~run": (dataset: OutputDataset>, config: Config>) => Promise | TIssue>>; } /** * Generic validation type. */ /** * Infer output type. */ type InferOutput> | BaseSchemaAsync> | BaseValidation> | BaseValidationAsync> | BaseTransformation> | BaseTransformationAsync> | BaseMetadata> = NonNullable["output"]; /** * Infer issue type. */ /** * Constructs a type that is maybe readonly. */ type MaybeReadonly = TValue$1 | Readonly; /** * Constructs a type that is deeply readonly. */ //#endregion //#region src/types/other.d.ts /** * Error message type. */ type ErrorMessage> = ((issue: TIssue) => string) | string; /** * Default type. */ //#endregion //#region src/types/issue.d.ts /** * Array path item interface. */ interface ArrayPathItem { /** * The path item type. */ readonly type: "array"; /** * The path item origin. */ readonly origin: "value"; /** * The path item input. */ readonly input: MaybeReadonly; /** * The path item key. */ readonly key: number; /** * The path item value. */ readonly value: unknown; } /** * Map path item interface. */ interface MapPathItem { /** * The path item type. */ readonly type: "map"; /** * The path item origin. */ readonly origin: "key" | "value"; /** * The path item input. */ readonly input: Map; /** * The path item key. */ readonly key: unknown; /** * The path item value. */ readonly value: unknown; } /** * Object path item interface. */ interface ObjectPathItem { /** * The path item type. */ readonly type: "object"; /** * The path item origin. */ readonly origin: "key" | "value"; /** * The path item input. */ readonly input: Record; /** * The path item key. */ readonly key: string; /** * The path item value. */ readonly value: unknown; } /** * Set path item interface. */ interface SetPathItem { /** * The path item type. */ readonly type: "set"; /** * The path item origin. */ readonly origin: "value"; /** * The path item input. */ readonly input: Set; /** * The path item key. */ readonly key: null; /** * The path item key. */ readonly value: unknown; } /** * Unknown path item interface. */ interface UnknownPathItem { /** * The path item type. */ readonly type: "unknown"; /** * The path item origin. */ readonly origin: "key" | "value"; /** * The path item input. */ readonly input: unknown; /** * The path item key. */ readonly key: unknown; /** * The path item value. */ readonly value: unknown; } /** * Issue path item type. */ type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem; /** * Base issue interface. */ interface BaseIssue extends Config> { /** * The issue kind. */ readonly kind: "schema" | "validation" | "transformation"; /** * The issue type. */ readonly type: string; /** * The raw input data. */ readonly input: TInput$1; /** * The expected property. */ readonly expected: string | null; /** * The received property. */ readonly received: string; /** * The error message. */ readonly message: string; /** * The input requirement. */ readonly requirement?: unknown | undefined; /** * The issue path. */ readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined; /** * The sub issues. */ readonly issues?: [BaseIssue, ...BaseIssue[]] | undefined; } /** * Generic issue type. */ //#endregion //#region src/types/config.d.ts /** * Config interface. */ interface Config> { /** * The selected language. */ readonly lang?: string | undefined; /** * The error message. */ readonly message?: ErrorMessage | undefined; /** * Whether it should be aborted early. */ readonly abortEarly?: boolean | undefined; /** * Whether a pipe should be aborted early. */ readonly abortPipeEarly?: boolean | undefined; } //#endregion //#region src/types/pipe.d.ts /** * Pipe action type. */ //#endregion //#region packages/core/constant.d.ts /** * Allowed directive types for tscss helpers. * Used to determine how a directive is processed at the AST level. */ declare const HELPER_TYPES: readonly ["var", "declaration", "selector", "media", "function"]; type HelperType = (typeof HELPER_TYPES)[number]; //#endregion //#region packages/core/utils/meta.d.ts interface TypedPropertyConfig { /** Optional name override (defaults to the directive's name). */ name?: string; /** CSS syntax descriptor (e.g. '', '', ''). */ syntax: string; /** Whether the property inherits. */ inherits: boolean; /** Initial value. */ initialValue: string; } //#endregion //#region packages/core/utils/defineHelper.d.ts interface DefineHelperContext { /** The CSS property this directive targets (if any). */ property?: string; } /** Single field in the schema config: a valibot rule plus an optional default. */ interface SchemaField { rule: BaseSchema>; default?: string; } /** Infer the output object shape from a schema config. */ type InferSchemaArgs> = { [K in keyof T]: T[K] extends { rule: infer R; } ? R extends BaseSchema> ? InferOutput : never : never }; interface DefineHelperOptions | undefined = undefined> { /** CSS property to auto-wrap bare at-rules with (e.g. 'background-image'). */ property?: string; /** Directive type. Defaults to 'function'. */ type?: HelperType; /** Custom property name (for type='var'). */ name?: string; /** Whether vars stay inline (default) or extract to :root. */ inline?: boolean; /** When set, generates root-level CSS via this function (not inside a selector). */ spawn?: () => string; /** Typed property configurations for generating @property rules. */ typedProperties?: TypedPropertyConfig[]; /** Alias name(s) for this directive. Allows invoking the same handler via alternate at-rule names. */ alias?: string | string[]; /** When true, var() references are passed raw (not resolved) to the handler. */ raw?: boolean; /** Schema object: each key maps to a valibot rule + optional default. * Positional args are matched to keys in insertion order. * Missing args fall back to their `default` (which goes through `rule` validation). */ schema?: TSchema; /** Optional function that returns a map of computed variable names to raw CSS values. * The framework decides whether to emit custom properties or pass `var()` through directly. * When no `schema` is set, receives raw `string[]` (backward-compat for delegators). */ vars?: (args: TSchema extends Record ? InferSchemaArgs : string[], ctx: DefineHelperContext) => Record; /** The handler function that receives a unified context with original, parsed, and var for each key. */ value: (ctx: DirectiveContext) => string | string[]; } interface Directive extends Handler { /** Raw string-level function for composition. Builds a minimal context and returns the value. */ value: (args: string[]) => string | string[]; /** Optional function that returns a map of computed variable names to raw CSS values. */ vars?: (args: string[]) => Record; /** When set, generates root-level CSS. */ spawn?: () => string; /** Builds a DirectiveContext for AST-level processing. */ buildContext: (originalArgs: string[], parsedArgs: string[], namePrefix: string | null, pushDecl?: (decl: string) => void) => DirectiveContext; } /** * Creates a tscss helper directive that works at the AST level. * * When used as a bare at-rule (`@paper;`), it auto-wraps the result * with the specified CSS `property`. * * When used as a value function (`background-image: @paper('50px');`), * it replaces the function call with the computed value. * * The returned directive exposes `.value` for string-level composition. * * @example * const paper = defineHelper({ * property: 'background-image', * schema: { size: { rule: css.length, default: '50px' } }, * value: (ctx) => `linear-gradient(${ctx.size.var} ...)`, * }); * * // AST-level * transformCSS(css, { paper }); * * // String-level composition * paper.value(['20px']); */ declare function defineHelper | undefined = undefined>(options: DefineHelperOptions): Directive; //#endregion //#region packages/core/diagnostics.d.ts /** * TSCSS diagnostic catalog. * * All errors thrown by the transform engine and helpers use these stable * codes so users can search, docs can link, and call-sites are typed. * * @example * throw diagnostics.TSCSS_INVALID_ARGUMENT({ key: 'color', issues: 'Expected a color' }); */ declare const diagnostics: import("nostics").Diagnostics<{ readonly TSCSS_INVALID_ARGUMENT: { readonly why: (p: { key: string; issues: string; }) => string; readonly fix: (p: { key: string; }) => string; }; readonly TSCSS_RESERVED_ALIAS: { readonly why: (p: { alias: string; }) => string; readonly fix: () => string; }; readonly TSCSS_UNKNOWN_DIRECTIVE: { readonly why: (p: { name: string; }) => string; readonly fix: () => string; }; readonly TSCSS_INVALID_RETURN_TYPE: { readonly why: () => string; readonly fix: () => string; }; }, readonly import("nostics").AnyDiagnosticReporter[]>; //#endregion export { type Directive, type FunctionHandlers, type Handler, type HandlerResult, type TypedPropertyConfig, defineHelper, diagnostics, generateId, inlineCSS, transformCSS };