igniteui-theming
Version:
A set of Sass variables, mixins, and functions for generating palettes, typography, and elevations used by Ignite UI components.
150 lines (149 loc) • 6.96 kB
TypeScript
import { Platform } from '../../utils/types.js';
export type { Platform } from '../../utils/types.js';
export { ANGULAR_PLATFORM, ANGULAR_USAGE_EXAMPLES, type AngularThemeTemplate, type CoreMixinOptions, generateAngularThemeSass, type ThemeMixinOptions, } from './angular.js';
export { BLAZOR_PLATFORM, BLAZOR_USAGE_EXAMPLES } from './blazor.js';
export { REACT_PLATFORM, REACT_USAGE_EXAMPLES } from './react.js';
export { generateWCHeader, generateWCImports, generateWCProgressProperties, generateWCRootVariables, generateWCRtlSupport, generateWCScrollbarCustomization, generateWCThemingMixins, generateWebComponentsThemeSass, getWCElevationPreset, WEBCOMPONENTS_PLATFORM, WEBCOMPONENTS_RUNTIME_CONFIG, WEBCOMPONENTS_USAGE_EXAMPLES, type WebComponentsThemeTemplate, } from './webcomponents.js';
/**
* Detection signal from package analysis
*/
export interface PackageDetectionSignal {
type: "ignite_package";
package: string;
confidence: number;
}
/**
* Detection signal from config file analysis
*/
export interface ConfigFileDetectionSignal {
type: "config_file";
file: string;
confidence: number;
}
/**
* Detection signal from framework package (fallback)
*/
export interface FrameworkDetectionSignal {
type: "framework_package";
package: string;
confidence: number;
}
/**
* Union type for all detection signals
*/
export type DetectionSignal = PackageDetectionSignal | ConfigFileDetectionSignal | FrameworkDetectionSignal;
/**
* Alternative platform detected during ambiguous detection
*/
export interface PlatformAlternative {
platform: Platform;
confidence: number;
signals: DetectionSignal[];
}
/**
* Platform detection result with enhanced ambiguity handling
*/
export interface PlatformDetectionResult {
/** Detected platform (null if ambiguous or not detected) */
platform: Platform | null;
/** Overall confidence level */
confidence: "high" | "medium" | "low" | "none";
/** True when multiple platforms detected with similar confidence */
ambiguous?: boolean;
/** Alternative platforms when ambiguous */
alternatives?: PlatformAlternative[];
/** All detection signals found */
signals: DetectionSignal[];
/** Human-readable reason for the detection result */
reason: string;
/** Primary detected package (for backward compatibility) */
detectedPackage?: string;
}
/**
* Internal interface for config file detection results
*/
interface ConfigFileSignal {
platform: Platform;
file: string;
confidence: number;
}
/**
* Detect platform from config files in the project root.
* Fast detection that only checks root directory, no deep scanning.
*
* @param projectRoot - Path to the project root directory
* @returns Array of detected config file signals
*/
export declare function detectConfigFiles(projectRoot?: string): ConfigFileSignal[];
/**
* Detect platform from package.json dependencies and project config files.
*
* Uses a multi-signal approach with confidence scoring:
* 1. Ignite UI packages (HIGH - 100): Definitive platform match
* 2. Config files (MEDIUM-HIGH - 80): Strong platform indicator
* 3. Framework packages (LOW - 40): Fallback when no Ignite UI found
*
* When multiple platforms are detected with significant confidence (≥60),
* returns an ambiguous result asking the user to specify explicitly.
*
* @param dependencies - package.json dependencies
* @param devDependencies - package.json devDependencies
* @param projectRoot - Project root directory for config file detection
* @returns Platform detection result with signals and confidence
*/
export declare function detectPlatformFromDependencies(dependencies?: Record<string, string>, devDependencies?: Record<string, string>, projectRoot?: string): PlatformDetectionResult;
/**
* Determine if a detected package is a licensed @infragistics package.
* Only applies to Angular - other platforms always use the free igniteui-theming package.
*
* @param detectedPackage - The package name detected from package.json
* @returns True if the package is a licensed @infragistics package
*/
export declare function isLicensedPackage(detectedPackage?: string): boolean;
/**
* Platform metadata for display purposes
*/
export declare const PLATFORM_METADATA: {
readonly angular: {
readonly id: "angular";
readonly name: "Ignite UI for Angular";
readonly shortName: "Angular";
readonly packageName: "igniteui-angular";
readonly licensedPackageName: "@infragistics/igniteui-angular";
readonly themingModule: "igniteui-angular/theming";
readonly licensedThemingModule: "@infragistics/igniteui-angular/theming";
readonly description: "Uses core() and theme() mixins from igniteui-angular/theming module. Requires ig-typography CSS class on root element. Available as OSS (igniteui-angular) or licensed (@infragistics/igniteui-angular) package.";
};
readonly webcomponents: {
readonly id: "webcomponents";
readonly name: "Ignite UI for Web Components";
readonly shortName: "Web Components";
readonly packageName: "igniteui-webcomponents";
readonly themingModule: "igniteui-theming";
readonly description: "Uses igniteui-theming directly with palette(), typography(), and elevations() mixins. Supports runtime theme switching via configureTheme(). The igniteui-theming package is always free/OSS.";
};
readonly react: {
readonly id: "react";
readonly name: "Ignite UI for React";
readonly shortName: "React";
readonly packageName: "igniteui-react";
readonly themingModule: "igniteui-theming";
readonly description: "Uses igniteui-theming directly with palette(), typography(), and elevations() mixins. Common with Vite or Next.js projects. The igniteui-theming package is always free/OSS.";
};
readonly blazor: {
readonly id: "blazor";
readonly name: "Ignite UI for Blazor";
readonly shortName: "Blazor";
readonly packageName: "IgniteUI.Blazor";
readonly themingModule: "igniteui-theming";
readonly description: "Uses igniteui-theming for Sass compilation in .NET Blazor projects. Theme styles are compiled to CSS and referenced in Blazor components. The igniteui-theming package is always free/OSS.";
};
readonly generic: {
readonly id: "generic";
readonly name: "Ignite UI Theming (Standalone)";
readonly shortName: "Generic";
readonly packageName: "igniteui-theming";
readonly themingModule: "igniteui-theming";
readonly description: "Platform-agnostic output using igniteui-theming directly. For projects that do not use a specific Ignite UI product framework (Angular, Web Components, React, or Blazor). Supports palette, typography, elevations, and theme generation. Component theming is not available in generic mode.";
};
};