@adguard/agtree
Version:
Tool set for working with adblock filter lists
85 lines (84 loc) • 2.71 kB
TypeScript
/**
* @file Provides platform enums.
* The difference between specific and generic platforms is that specific platforms are individual platforms
* (e.g. AdGuard for Windows, AdGuard for Android, etc.),
* while generic platforms are groups of specific platforms
* (e.g. AdGuard for any OS, AdGuard for any Chromium-based extension, etc.).
*/
/**
* Unique symbol to brand SpecificPlatform type.
*/
declare const SpecificPlatformBrand: unique symbol;
/**
* Unique symbol to brand GenericPlatform type.
*/
declare const GenericPlatformBrand: unique symbol;
/**
* Branded type for specific platform values.
*/
export type SpecificPlatform = number & {
readonly [SpecificPlatformBrand]: true;
};
/**
* List of specific platforms.
*/
export declare const SpecificPlatform: {
AdgOsWindows: SpecificPlatform;
AdgOsMac: SpecificPlatform;
AdgOsAndroid: SpecificPlatform;
AdgExtChrome: SpecificPlatform;
AdgExtOpera: SpecificPlatform;
AdgExtEdge: SpecificPlatform;
AdgExtFirefox: SpecificPlatform;
AdgCbAndroid: SpecificPlatform;
AdgCbIos: SpecificPlatform;
AdgCbSafari: SpecificPlatform;
UboExtChrome: SpecificPlatform;
UboExtOpera: SpecificPlatform;
UboExtEdge: SpecificPlatform;
UboExtFirefox: SpecificPlatform;
AbpExtChrome: SpecificPlatform;
AbpExtOpera: SpecificPlatform;
AbpExtEdge: SpecificPlatform;
AbpExtFirefox: SpecificPlatform;
};
/**
* Branded type for generic platform values.
*/
export type GenericPlatform = number & {
readonly [GenericPlatformBrand]: true;
};
/**
* List of generic platforms (combinations of specific platforms).
*/
export declare const GenericPlatform: {
AdgOsAny: GenericPlatform;
AdgSafariAny: GenericPlatform;
AdgExtChromium: GenericPlatform;
AdgExtAny: GenericPlatform;
AdgAny: GenericPlatform;
UboExtChromium: GenericPlatform;
UboExtAny: GenericPlatform;
UboAny: GenericPlatform;
AbpExtChromium: GenericPlatform;
AbpExtAny: GenericPlatform;
AbpAny: GenericPlatform;
Any: GenericPlatform;
};
/**
* Represents any platform: specific, generic, or a combination of platforms.
*
* The `number` type is included to support combined platforms created via bitwise OR operations.
* For example: `GenericPlatform.AdgAny | GenericPlatform.UboAny` results in a `number` at the type level.
*
* @example
* ```typescript
* // Single platform
* const singlePlatform: AnyPlatform = SpecificPlatform.AdgOsWindows;
*
* // Combined platforms (result is number)
* const combinedPlatforms: AnyPlatform = GenericPlatform.AdgAny | GenericPlatform.UboAny;
* ```
*/
export type AnyPlatform = SpecificPlatform | GenericPlatform | number;
export {};