import { SemVerRange } from './api/index.js'; import 'apprt-core/Types'; type TokenName = "LEFT_BRACE" | "RIGHT_BRACE" | "COMMA" | "HYPHEN" | "EQUAL" | "GREATER" | "GREATER_EQUAL" | "LESS" | "LESS_EQUAL" | "TILDE" | "CARET" | "STAR" | "OR" | "WHITESPACE" | "VERSION" | "EOL"; interface Token { readonly eol: boolean; readonly type: TokenName; readonly value: string; readonly start: number; readonly end: number; toString(): string; } /** * Parses a version range expression. * * See: * - Semantic version: * - * * The following range styles are supported: * * - `1.2.3` A specific version. Note that build metadata is still ignored, so 1.2.3+build2012 will satisfy this range. * - `>1.2.3` Greater than a specific version. * - `<1.2.3` Less than a specific version. If there is no prerelease tag on the version range then no prerelease version will be allowed either, even though these are technically ~less than~. * - `>=1.2.3` Greater then or equal to. Note that prerelease versions are NOT equal to their ~normal~ equivalents, so `1.2.3-beta` will not satisfy this range, but `2.3.0-beta` will. * - `<=1.2.3` Less than or equal to. In this case, prerelease versions are allowed, so `1.2.3-beta` would satisfy. * - `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` * - `~1.2.3` := `>=1.2.3-0 <1.3.0-0` "Reasonably close to 1.2.3". When using tilde operators, prerelease versions are supported as well, but a prerelease of the next significant digit will NOT be satisfactory, so `1.3.0-beta` will not satisfy `~1.2.3`. * - `^1.2.3` := `>=1.2.3-0 <2.0.0-0` "Compatible with 1.2.3". When using caret operators, anything from the specified version (including prerelease) will be supported up to, but not including, the next major version (or its prereleases). `1.5.1` will satisfy `^1.2.3`, while `1.2.2` and `2.0.0-beta` will not. * - `^0.1.3` := `>=0.1.3-0 <0.2.0-0` "Compatible with 0.1.3". `0.x.x` versions are special: the first non-zero component indicates potentially breaking changes, meaning the caret operator matches any version with the same first non-zero component starting at the specified version. * - `^0.0.2` := `=0.0.2` "Only the version 0.0.2 is considered compatible" * - `~1.2` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" * - `^1.2` := `>=1.2.0-0 <2.0.0-0` "Any version compatible with 1.2" * - `1.2.x` := `>=1.2.0-0 <1.3.0-0` "Any version starting with 1.2" * - `~1` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" * - `^1` := `>=1.0.0-0 <2.0.0-0` "Any version compatible with 1" * - `1.x` := `>=1.0.0-0 <2.0.0-0` "Any version starting with 1" * - `*` := `>=0.0.0` Any version will match. * * Ranges can be joined with either a space (which implies "and") or a || (which implies "or"). * * It supports the (deprecated) OSGi Format, too: * * - `[1.0,)` := `>=1.0.0` * - `(1.0,)` := `>1.0.0` * - `(,1.0]` := `<=1.0.0` * - `(,1.0)` := `<1.0.0` * - `[1.0,2.0]` := `>=1.0.0 <=2.0.0` * - `[1.0,2.0)` := `>=1.0.0 <2.0.0` * - `(1.0,2.0]` := `>1.0.0 <=2.0.0` * - `(1.0,2.0)` := `>1.0.0 <2.0.0` * - `(1.0,2.0)` := `>1.0.0 <2.0.0` * * @param input version range expression. * @returns a version range, if the range expression is not provided a range matching any is returned. */ declare function semverrange(input?: string): SemVerRange; declare namespace semverrange { var __tokenize: (input: string) => () => Token | undefined; } interface BundleRange { /** * Full name of the bundle. * Including a scope if present e.g. `@conterra/test` */ name: string; /** * Scope part, e.g. `@conterra` from `@conterra/test` */ scope: string; /** * local part, e.g. `test` from `@conterra/test` */ localname: string; /** * Version range string. */ versionRangeRaw: string; /** * version range instance. */ versionRange: SemVerRange; /** * File part if defined. * e.g. `afile` from `@conterra/test@~1.0.0/afile` */ file: string; } declare function parseBundleRange(nameWithRange: string): BundleRange; export { semverrange as default, parseBundleRange }; export type { BundleRange };