import type { IClientSideComponentManifest } from '@microsoft/sp-module-interfaces'; /** * Represents a version number with two, three, or four parts. * * @remarks * This class represents versions that follow the string format of `MAJOR.MINOR[.PATCH[.REVISION]]` * where the MAJOR, MINOR, PATCH and REVISION parts are integers. PATCH and REVISION are optional. * Leading zero digits are allowed, but they are discarded. Missing parts are treated * as zeroes for comparisons. * * Examples: `1.0`, `1.0.0`, `1.0.0.0`, `1.01`, `01.02.03`, `001.002.003.004` * * @public */ export default class Version { private _major; private _minor; private _patch; private _revision; /** * Test whether a string is a valid version specifier. * * @param versionString - The version string * @returns true if the versionString is a valid version specifier */ static isValid(versionString: string | undefined | null): boolean; /** * Constructs a new Version instance using the version string. An exception is thrown * if the string cannot be parsed. * * @param versionString - A version string * @returns a new Version object */ static parse(versionString: string | undefined | null): Version; /** * Attempts to parse the input string to construct a new Version object. * If the string cannot be parsed, then undefined is returned. * * @param versionString - A version string * @returns The Version object, or undefined if the string could not be parsed. */ static tryParse(versionString: string | undefined | null): Version | undefined; /** * Compares two Version objects to determine which version is newer. * * @param v1 - The first version class for comparison * @param v2 - The second version class for comparison * @returns -1 if the first input is less than the second input; * 0 if the first input is equal to the second input; * 1 if the first input is greater than the second input. */ static compare(v1: Version, v2: Version): number; /** * Get the version from given manifest. * @param manifest - The manifest where to get version. * @returns - The version of the manifest or undefined if version cannot be obtained. * @internal */ static _tryParseSPFxVersion(manifest: IClientSideComponentManifest): Version | undefined; /** * Returns the first component of the version string. * * @remarks * Typically a change in the major version number indicates a compatibility * break with previous versions. */ get major(): number; /** * Returns the second component of the version string. * * @remarks * Typically a change in the minor version number indicates that new features * were added, while remaining backwards compatible with previous releases. */ get minor(): number; /** * The third number in the version string, or undefined if unspecified. * * @remarks * Typically a change in the patch version number indicates a small fix that * does not affect the compatibility contract for the library. For a .NET * System.Version object, this is referred to as the "build" number. */ get patch(): number | undefined; /** * The fourth number in the version string, or undefined if unspecified. * * @remarks * This number is not part of the Semantic Versioning (SemVer) standard used * in JavaScript, but it is used by .NET version numbers. */ get revision(): number | undefined; /** * Tests whether this version is less than (i.e. older than) the input parameter. * * @remarks * * Examples: * * ``` * 0.9.9 lessThan 1.0.0 -> true; * 2.0 lessThan 2.0.0 -> false; * 3.0 lessThan 3.0.1 -> true; * 04.01 lessThan 4.1 -> false * ``` * * @param compareWith - The version to compare with * @returns A boolean indicating if this version is less than the input parameter */ lessThan(compareWith: Version): boolean; /** * Tests whether this version is greater than (i.e. newer than) the input parameter. * * @remarks * * Examples: * * ``` * 1.0.0 greaterThan 0.0.9 -> true; * 2.0 greaterThan 2.0.0 -> false; * 3.0.1 greaterThan 3.0 -> true * ``` * * @param compareWith - The version to compare with * @returns A boolean indicating if this version is greater than the input parameter */ greaterThan(compareWith: Version): boolean; /** * Tests whether this version is equal to the input parameter. * * @remarks * * Examples: * * ``` * 1.0.0 equals 1.0.0 -> true; * 2.0.1 equals 2.0.0 -> false; * 3.0 equals 3.0.0 -> true; * 04.01 equals 4.1 -> true * ``` * * @param compareWith - The version to compare with * @returns A boolean indicating if this version is equal to the input parameter */ equals(compareWith: Version): boolean; /** * Tests whether this version satisfies the compatibility requirements of the input version, * i.e. is backwards compatible. * * @remarks * In order to satisfy the compatibility requirements, this object must have the same * major version number as the input parameter, and it must NOT be older than the * input parameter. * * Examples: * * ``` * 1.0.0 satisfies 1.0.0 -> true; * 1.1.0 satisfies 1.0.0 -> true; * 2.0.0 satisfies 1.0.0 -> false; * 1.0.0 satisfies 1.1.0 -> false * ``` * * @param compareWith - The version to compare with * @returns A boolean indicating if this version is compatible with the input parameter */ satisfies(compareWith: Version): boolean; /** * Returns a string representation of the version. * * @remarks * The value is normalized and may be different from the original string (e.g. leading zeroes * may be removed). However, the number of version parts will be unchanged. */ toString(): string; /** * WARNING: Use Version.tryParse instead of the constructor. The constructor does not do any validation. * * @param major - the major version * @param minor - the minor version * @param patch - the patch number * @param revision - the revision number */ private constructor(); } //# sourceMappingURL=Version.d.ts.map