semver-effect
Advanced tools
+513
-417
| /** | ||
| * **semver-effect** — Strict SemVer 2.0.0 implementation built on Effect. | ||
| * | ||
| * Effect-idiomatic API: operations are namespaced under their primary type. | ||
| * | ||
| * ## Quick start | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { SemVer, Range } from "semver-effect"; | ||
| * import { Effect, pipe } from "effect"; | ||
| * import { SemVer, Range, satisfies } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const v = SemVer.make(1, 2, 3); | ||
| * const next = SemVer.bump.minor(v); // 1.3.0 | ||
| * pipe(v, SemVer.gt(SemVer.make(0, 9, 0))); // true | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const parsed = yield* SemVer.fromString("2.0.0-rc.1"); | ||
| * const range = yield* Range.fromString("^2.0.0"); | ||
| * return Range.satisfies(parsed, range); // true | ||
| * const v = yield* SemVer.parse("1.2.3"); | ||
| * const next = v.bump.minor(); // 1.3.0 | ||
| * const range = yield* Range.parse("^1.0.0"); | ||
| * console.log(range.test(v)); // true | ||
| * console.log(v.gt(next)); // false | ||
| * }); | ||
@@ -30,63 +25,92 @@ * ``` | ||
| import { Context } from 'effect'; | ||
| import { Effect } from 'effect'; | ||
| import { Effect } from 'effect/Effect'; | ||
| import { Effect as Effect_2 } from 'effect'; | ||
| import { Equal } from 'effect'; | ||
| import { Equals } from 'effect/Types'; | ||
| import { Equivalence as Equivalence_2 } from 'effect'; | ||
| import { Hash } from 'effect'; | ||
| import { Layer } from 'effect'; | ||
| import { Option } from 'effect'; | ||
| import { Order as Order_2 } from 'effect/Order'; | ||
| import { Option } from 'effect/Option'; | ||
| import { Option as Option_2 } from 'effect'; | ||
| import { Order } from 'effect'; | ||
| import { Schema } from 'effect'; | ||
| import { VoidIfEmpty } from 'effect/Types'; | ||
| import { YieldableError } from 'effect/Cause'; | ||
| /** | ||
| * A {@link Comparator} matching any version (`>=0.0.0`). | ||
| * Increment the major version and reset minor, patch, and prerelease to zero/empty. | ||
| * | ||
| * Note: constructs SemVer inline to avoid circular dependency with SemVer module. | ||
| * @example | ||
| * ```typescript | ||
| * import { SemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.parse("1.2.3"); | ||
| * console.log(v.bump.major().toString()); // "2.0.0" | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link bumpMinor} | ||
| * @see {@link bumpPatch} | ||
| */ | ||
| declare const any: Comparator_2; | ||
| export declare const bumpMajor: (v: SemVer) => SemVer; | ||
| /** | ||
| * A {@link Range} that matches any version (`>=0.0.0`). | ||
| * Increment the minor version and reset patch and prerelease to zero/empty. | ||
| * | ||
| * Note: constructs SemVer/Comparator inline to avoid circular dependency with those modules. | ||
| * @see {@link bumpMajor} | ||
| * @see {@link bumpPatch} | ||
| */ | ||
| declare const any_2: Range_2; | ||
| export declare const bumpMinor: (v: SemVer) => SemVer; | ||
| /** | ||
| * Version bumping operations, grouped under a `bump` namespace. | ||
| * Increment the patch version and clear prerelease identifiers. | ||
| * | ||
| * @see {@link bumpMajor} | ||
| * @see {@link bumpMinor} | ||
| */ | ||
| declare const bump: { | ||
| readonly major: (v: SemVer_2) => SemVer_2; | ||
| readonly minor: (v: SemVer_2) => SemVer_2; | ||
| readonly patch: (v: SemVer_2) => SemVer_2; | ||
| readonly prerelease: (v: SemVer_2, id?: string | undefined) => SemVer_2; | ||
| readonly release: (v: SemVer_2) => SemVer_2; | ||
| }; | ||
| export declare const bumpPatch: (v: SemVer) => SemVer; | ||
| export declare namespace Comparator { | ||
| export { | ||
| Comparator_2 as Comparator, | ||
| ComparatorBase, | ||
| fromString, | ||
| any, | ||
| Instance, | ||
| FromString | ||
| } | ||
| } | ||
| /** | ||
| * Increment the prerelease portion of a version. | ||
| * | ||
| * @param v - The version to bump. | ||
| * @param id - Optional prerelease identifier prefix (e.g., `"alpha"`, `"beta"`). | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { SemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.parse("1.0.0-alpha.3"); | ||
| * console.log(v.bump.prerelease("alpha").toString()); // "1.0.0-alpha.4" | ||
| * console.log(v.bump.prerelease("beta").toString()); // "1.0.0-beta.0" | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link bumpRelease} | ||
| */ | ||
| export declare const bumpPrerelease: (v: SemVer, id?: string | undefined) => SemVer; | ||
| /** | ||
| * A single version constraint consisting of a comparison operator and a version. | ||
| * Strip prerelease and build metadata, promoting a prerelease to its release version. | ||
| * | ||
| * A comparator matches versions according to its operator: | ||
| * - `"="` — exact match (displayed as bare version in {@link Comparator.toString}) | ||
| * - `">"` — strictly greater than | ||
| * - `">="` — greater than or equal | ||
| * - `"<"` — strictly less than | ||
| * - `"<="` — less than or equal | ||
| * @example | ||
| * ```typescript | ||
| * import { SemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * Comparators are the building blocks of {@link Range} objects: a comparator set | ||
| * is an array of comparators combined with AND semantics, and a range is a union | ||
| * (OR) of comparator sets. | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.parse("1.2.3-rc.1"); | ||
| * console.log(v.bump.release().toString()); // "1.2.3" | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link bumpPrerelease} | ||
| */ | ||
| export declare const bumpRelease: (v: SemVer) => SemVer; | ||
| /** | ||
| * A single version constraint consisting of a comparison operator and a version. | ||
| * | ||
| * @example | ||
@@ -98,6 +122,6 @@ * ```typescript | ||
| * const program = Effect.gen(function* () { | ||
| * const comp = yield* Comparator.fromString(">=1.2.3"); | ||
| * console.log(comp.operator); // ">=" | ||
| * console.log(comp.version.toString()); // "1.2.3" | ||
| * console.log(comp.toString()); // ">=1.2.3" | ||
| * const comp = yield* Comparator.parse(">=1.2.3"); | ||
| * console.log(comp.operator); // ">=" | ||
| * console.log(comp.version.toString()); // "1.2.3" | ||
| * console.log(comp.test(new SemVer({ major: 2, minor: 0, patch: 0, prerelease: [], build: [] }))); // true | ||
| * }); | ||
@@ -109,13 +133,16 @@ * ``` | ||
| */ | ||
| declare class Comparator_2 extends ComparatorBase<{ | ||
| readonly operator: "=" | ">" | ">=" | "<" | "<="; | ||
| readonly version: SemVer_2; | ||
| }> { | ||
| export declare class Comparator extends Comparator_base { | ||
| /** Parse a comparator string (e.g. `">=1.2.3"`). Wired at module load by index.ts. */ | ||
| static parse: (input: string) => Effect<Comparator, InvalidComparatorError>; | ||
| /** Test whether a version satisfies this comparator. */ | ||
| test(version: SemVer): boolean; | ||
| toString(): string; | ||
| } | ||
| /** @internal */ | ||
| declare const ComparatorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & { | ||
| readonly _tag: "Comparator"; | ||
| }; | ||
| declare const Comparator_base: Schema.TaggedClass<Comparator, "Comparator", { | ||
| readonly _tag: Schema.tag<"Comparator">; | ||
| } & { | ||
| operator: Schema.Literal<["=", ">", ">=", "<", "<="]>; | ||
| version: typeof SemVer; | ||
| }>; | ||
@@ -128,3 +155,3 @@ /** | ||
| */ | ||
| declare type ComparatorSet = ReadonlyArray<Comparator_2>; | ||
| export declare type ComparatorSet = ReadonlyArray<Comparator>; | ||
@@ -137,2 +164,4 @@ /** | ||
| * | ||
| * For the instance method alternative, use `v.compare(other)`. | ||
| * | ||
| * @example | ||
@@ -144,5 +173,6 @@ * ```typescript | ||
| * const program = Effect.gen(function* () { | ||
| * const a = yield* SemVer.fromString("1.0.0"); | ||
| * const b = yield* SemVer.fromString("2.0.0"); | ||
| * console.log(SemVer.compare(a, b)); // -1 | ||
| * const a = yield* SemVer.parse("1.0.0"); | ||
| * const b = yield* SemVer.parse("2.0.0"); | ||
| * console.log(a.compare(b)); // -1 (instance method) | ||
| * console.log(compare(a, b)); // -1 (standalone function) | ||
| * }); | ||
@@ -154,5 +184,5 @@ * ``` | ||
| */ | ||
| declare const compare: { | ||
| (that: SemVer_2): (self: SemVer_2) => -1 | 0 | 1; | ||
| (self: SemVer_2, that: SemVer_2): -1 | 0 | 1; | ||
| export declare const compare: { | ||
| (that: SemVer): (self: SemVer) => -1 | 0 | 1; | ||
| (self: SemVer, that: SemVer): -1 | 0 | 1; | ||
| }; | ||
@@ -171,5 +201,5 @@ | ||
| */ | ||
| declare const compareWithBuild: { | ||
| (that: SemVer_2): (self: SemVer_2) => -1 | 0 | 1; | ||
| (self: SemVer_2, that: SemVer_2): -1 | 0 | 1; | ||
| export declare const compareWithBuild: { | ||
| (that: SemVer): (self: SemVer) => -1 | 0 | 1; | ||
| (self: SemVer, that: SemVer): -1 | 0 | 1; | ||
| }; | ||
@@ -183,2 +213,4 @@ | ||
| * | ||
| * Also available as `SemVer.diff(a, b)`. | ||
| * | ||
| * @example | ||
@@ -190,5 +222,5 @@ * ```typescript | ||
| * const program = Effect.gen(function* () { | ||
| * const a = yield* SemVer.fromString("1.2.3"); | ||
| * const b = yield* SemVer.fromString("1.3.0"); | ||
| * const d = SemVer.diff(a, b); | ||
| * const a = yield* SemVer.parse("1.2.3"); | ||
| * const b = yield* SemVer.parse("1.3.0"); | ||
| * const d = SemVer.diff(a, b); // static method | ||
| * console.log(d.type); // "minor" | ||
@@ -201,5 +233,5 @@ * console.log(d.minor); // 1 | ||
| */ | ||
| declare const diff: { | ||
| (b: SemVer_2): (a: SemVer_2) => VersionDiff_2; | ||
| (a: SemVer_2, b: SemVer_2): VersionDiff_2; | ||
| export declare const diff: { | ||
| (b: SemVer): (a: SemVer) => VersionDiff; | ||
| (a: SemVer, b: SemVer): VersionDiff; | ||
| }; | ||
@@ -229,3 +261,3 @@ | ||
| */ | ||
| export declare const EmptyCacheErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const EmptyCacheErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "EmptyCacheError"; | ||
@@ -240,13 +272,12 @@ } & Readonly<A>; | ||
| * | ||
| * For the instance method alternative, use `v.eq(other)`. | ||
| * | ||
| * @see {@link neq} | ||
| * @see {@link compare} | ||
| */ | ||
| declare const equal: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const equal: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Effect {@link Eq.Equivalence} for SemVer (ignores build metadata). */ | ||
| declare const Equivalence: Equivalence_2.Equivalence<SemVer_2>; | ||
| /** | ||
@@ -260,5 +291,5 @@ * Test whether two {@link Range}s are semantically equivalent. | ||
| */ | ||
| declare const equivalent: { | ||
| (b: Range_2): (a: Range_2) => boolean; | ||
| (a: Range_2, b: Range_2): boolean; | ||
| export declare const equivalent: { | ||
| (b: Range): (a: Range) => boolean; | ||
| (a: Range, b: Range): boolean; | ||
| }; | ||
@@ -269,50 +300,22 @@ | ||
| * | ||
| * For the instance method alternative, use `range.filter(versions)`. | ||
| * | ||
| * @see {@link satisfies} | ||
| * @see {@link maxSatisfying} | ||
| * @see {@link minSatisfying} | ||
| */ | ||
| declare const filter: { | ||
| (range: Range_2): (versions: ReadonlyArray<SemVer_2>) => Array<SemVer_2>; | ||
| (versions: ReadonlyArray<SemVer_2>, range: Range_2): Array<SemVer_2>; | ||
| export declare const filter: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => ReadonlyArray<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): ReadonlyArray<SemVer>; | ||
| }; | ||
| /** | ||
| * Schema that decodes a string into a {@link Comparator} and encodes back to string. | ||
| * Test whether `self` is strictly greater than `that`. | ||
| * | ||
| * Useful with `Schema.Config`, `Schema.decodeUnknownSync`, etc. | ||
| */ | ||
| declare const FromString: Schema.Schema<Comparator_2, string>; | ||
| /** Parse a single comparator string (e.g. `">=1.2.3"`) into a {@link Comparator}. */ | ||
| declare const fromString: (raw: string) => Effect.Effect<Comparator_2, InvalidComparatorError, never>; | ||
| /** | ||
| * Schema that decodes a string into a {@link Range} and encodes back to string. | ||
| * For the instance method alternative, use `v.gt(other)`. | ||
| * | ||
| * Useful with `Schema.Config`, `Schema.decodeUnknownSync`, etc. | ||
| */ | ||
| declare const FromString_2: Schema.Schema<Range_2, string>; | ||
| /** Parse a SemVer range expression string into a {@link Range}. */ | ||
| declare const fromString_2: (input: string) => Effect.Effect<Range_2, InvalidRangeError, never>; | ||
| /** | ||
| * Schema that decodes a string into a {@link SemVer} and encodes back to string. | ||
| * | ||
| * Useful with `Schema.Config`, `Schema.decodeUnknownSync`, etc. | ||
| */ | ||
| declare const FromString_3: Schema.Schema<SemVer_2, string>; | ||
| /** Parse a strict SemVer 2.0.0 string into a {@link SemVer}. */ | ||
| declare const fromString_3: (raw: string) => Effect.Effect<SemVer_2, InvalidVersionError, never>; | ||
| /** | ||
| * Test whether `self` is strictly greater than `that`. | ||
| * | ||
| * @see {@link gte} | ||
| * @see {@link compare} | ||
| */ | ||
| declare const gt: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const gt: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
@@ -323,22 +326,12 @@ | ||
| * | ||
| * For the instance method alternative, use `v.gte(other)`. | ||
| * | ||
| * @see {@link gt} | ||
| * @see {@link compare} | ||
| */ | ||
| declare const gte: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const gte: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Schema that validates a value is a {@link Comparator} instance. */ | ||
| declare const Instance: Schema.Schema<Comparator_2>; | ||
| /** Schema that validates a value is a {@link Range} instance. */ | ||
| declare const Instance_2: Schema.Schema<Range_2>; | ||
| /** Schema that validates a value is a {@link SemVer} instance. */ | ||
| declare const Instance_3: Schema.Schema<SemVer_2>; | ||
| /** Schema that validates a value is a {@link VersionDiff} instance. */ | ||
| declare const Instance_4: Schema.Schema<VersionDiff_2>; | ||
| /** | ||
@@ -355,9 +348,9 @@ * Compute the intersection of two {@link Range}s using a cross-product of | ||
| * ```typescript | ||
| * import { Range } from "semver-effect"; | ||
| * import { parseRange, intersect } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const a = yield* Range.fromString(">=1.0.0"); | ||
| * const b = yield* Range.fromString("<2.0.0"); | ||
| * const both = yield* Range.intersect(a, b); | ||
| * const a = yield* parseRange(">=1.0.0"); | ||
| * const b = yield* parseRange("<2.0.0"); | ||
| * const both = yield* intersect(a, b); | ||
| * // both matches >=1.0.0 AND <2.0.0 | ||
@@ -370,5 +363,5 @@ * }); | ||
| */ | ||
| declare const intersect: { | ||
| (b: Range_2): (a: Range_2) => Effect.Effect<Range_2, UnsatisfiableConstraintError>; | ||
| (a: Range_2, b: Range_2): Effect.Effect<Range_2, UnsatisfiableConstraintError>; | ||
| export declare const intersect: { | ||
| (b: Range): (a: Range) => Effect_2.Effect<Range, UnsatisfiableConstraintError>; | ||
| (a: Range, b: Range): Effect_2.Effect<Range, UnsatisfiableConstraintError>; | ||
| }; | ||
@@ -387,3 +380,3 @@ | ||
| /** The version that the bump was attempted on. */ | ||
| readonly version: SemVer_2; | ||
| readonly version: SemVer; | ||
| /** The bump type that was requested (e.g., `"major"`, `"prerelease"`). */ | ||
@@ -405,3 +398,3 @@ readonly type: string; | ||
| */ | ||
| export declare const InvalidBumpErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const InvalidBumpErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "InvalidBumpError"; | ||
@@ -413,3 +406,3 @@ } & Readonly<A>; | ||
| * | ||
| * Returned by {@link parseComparator} (and `SemVerParser.parseComparator`) when the | ||
| * Returned by {@link parseSingleComparator} (and `SemVerParser.parseComparator`) when the | ||
| * input is not a valid `[operator]major.minor.patch[-prerelease][+build]` string. | ||
@@ -439,3 +432,3 @@ * Wildcards and range syntax are not allowed in single comparator parsing. | ||
| */ | ||
| export declare const InvalidComparatorErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const InvalidComparatorErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "InvalidComparatorError"; | ||
@@ -470,3 +463,3 @@ } & Readonly<A>; | ||
| */ | ||
| export declare const InvalidPrereleaseErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const InvalidPrereleaseErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "InvalidPrereleaseError"; | ||
@@ -505,3 +498,3 @@ } & Readonly<A>; | ||
| */ | ||
| export declare const InvalidRangeErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const InvalidRangeErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "InvalidRangeError"; | ||
@@ -513,3 +506,3 @@ } & Readonly<A>; | ||
| * | ||
| * This error is returned when {@link parseVersion} (or the `SemVerParser` service) | ||
| * This error is returned when {@link parseValidSemVer} (or the `SemVerParser` service) | ||
| * encounters input that does not conform to the `major.minor.patch[-prerelease][+build]` | ||
@@ -539,3 +532,3 @@ * format. Unlike node-semver, no loose parsing or `v`-prefix coercion is performed. | ||
| */ | ||
| export declare const InvalidVersionErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const InvalidVersionErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "InvalidVersionError"; | ||
@@ -547,5 +540,7 @@ } & Readonly<A>; | ||
| * | ||
| * For the instance getter alternative, use `v.isPrerelease`. | ||
| * | ||
| * @see {@link isStable} | ||
| */ | ||
| declare const isPrerelease: (v: SemVer_2) => boolean; | ||
| export declare const isPrerelease: (v: SemVer) => boolean; | ||
@@ -555,5 +550,7 @@ /** | ||
| * | ||
| * For the instance getter alternative, use `v.isStable`. | ||
| * | ||
| * @see {@link isPrerelease} | ||
| */ | ||
| declare const isStable: (v: SemVer_2) => boolean; | ||
| export declare const isStable: (v: SemVer) => boolean; | ||
@@ -578,5 +575,5 @@ /** | ||
| */ | ||
| declare const isSubset: { | ||
| (sup: Range_2): (sub: Range_2) => boolean; | ||
| (sub: Range_2, sup: Range_2): boolean; | ||
| export declare const isSubset: { | ||
| (sup: Range): (sub: Range) => boolean; | ||
| (sub: Range, sup: Range): boolean; | ||
| }; | ||
@@ -587,8 +584,10 @@ | ||
| * | ||
| * For the instance method alternative, use `v.lt(other)`. | ||
| * | ||
| * @see {@link lte} | ||
| * @see {@link compare} | ||
| */ | ||
| declare const lt: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const lt: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
@@ -599,21 +598,13 @@ | ||
| * | ||
| * For the instance method alternative, use `v.lte(other)`. | ||
| * | ||
| * @see {@link lt} | ||
| * @see {@link compare} | ||
| */ | ||
| declare const lte: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const lte: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** | ||
| * Create a {@link SemVer} instance from individual components. | ||
| */ | ||
| declare const make: (major: number, minor: number, patch: number, prerelease?: readonly (string | number)[], build?: readonly string[]) => SemVer_2; | ||
| /** | ||
| * Create a {@link VersionDiff} from individual components. | ||
| */ | ||
| declare const make_2: (type: "build" | "major" | "minor" | "none" | "patch" | "prerelease", from: SemVer_2, to: SemVer_2, major: number, minor: number, patch: number) => VersionDiff_2; | ||
| /** | ||
| * Find the highest version in an array. | ||
@@ -626,3 +617,3 @@ * | ||
| */ | ||
| declare const max: (versions: readonly SemVer_2[]) => Option.Option<SemVer_2>; | ||
| export declare const max: (versions: readonly SemVer[]) => Option_2.Option<SemVer>; | ||
@@ -637,5 +628,5 @@ /** | ||
| */ | ||
| declare const maxSatisfying: { | ||
| (range: Range_2): (versions: ReadonlyArray<SemVer_2>) => Option.Option<SemVer_2>; | ||
| (versions: ReadonlyArray<SemVer_2>, range: Range_2): Option.Option<SemVer_2>; | ||
| export declare const maxSatisfying: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => Option_2.Option<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): Option_2.Option<SemVer>; | ||
| }; | ||
@@ -651,3 +642,3 @@ | ||
| */ | ||
| declare const min: (versions: readonly SemVer_2[]) => Option.Option<SemVer_2>; | ||
| export declare const min: (versions: readonly SemVer[]) => Option_2.Option<SemVer>; | ||
@@ -662,5 +653,5 @@ /** | ||
| */ | ||
| declare const minSatisfying: { | ||
| (range: Range_2): (versions: ReadonlyArray<SemVer_2>) => Option.Option<SemVer_2>; | ||
| (versions: ReadonlyArray<SemVer_2>, range: Range_2): Option.Option<SemVer_2>; | ||
| export declare const minSatisfying: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => Option_2.Option<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): Option_2.Option<SemVer>; | ||
| }; | ||
@@ -671,21 +662,92 @@ | ||
| * | ||
| * For the instance method alternative, use `v.neq(other)`. | ||
| * | ||
| * @see {@link equal} | ||
| */ | ||
| declare const neq: { | ||
| (that: SemVer_2): (self: SemVer_2) => boolean; | ||
| (self: SemVer_2, that: SemVer_2): boolean; | ||
| export declare const neq: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Effect `Order` for SemVer precedence (ignores build). */ | ||
| declare const Order: Order_2<SemVer_2>; | ||
| /** | ||
| * Parse a SemVer range expression string and normalize the result. | ||
| * | ||
| * This is a convenience function that performs the same parsing and normalization | ||
| * as {@link SemVerParser.parseRange} but without requiring the service in scope. | ||
| * Returns an {@link Effect.Effect} that fails with {@link InvalidRangeError} | ||
| * on invalid input. | ||
| * | ||
| * Supports hyphen ranges (`1.0.0 - 2.0.0`), X-ranges (`1.x`, `*`), tilde | ||
| * ranges (`~1.2.3`), caret ranges (`^1.2.3`), and `||`-separated unions. | ||
| * All version components must be strictly valid SemVer 2.0.0 (no loose parsing). | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { parseRange, parseValidSemVer, satisfies } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const range = yield* parseRange("^1.0.0"); | ||
| * const v = yield* parseValidSemVer("1.5.0"); | ||
| * console.log(satisfies(v, range)); // true | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link Range} | ||
| * @see {@link SemVerParser} | ||
| * @see {@link InvalidRangeError} | ||
| */ | ||
| export declare const parseRange: (input: string) => Effect_2.Effect<Range, InvalidRangeError, never>; | ||
| /** Effect `Order` for SemVer precedence including build metadata. */ | ||
| declare const OrderWithBuild: Order_2<SemVer_2>; | ||
| /** | ||
| * Parse a string into a single {@link Comparator}. | ||
| * | ||
| * Accepts an optional operator prefix (`=`, `>`, `>=`, `<`, `<=`) followed by | ||
| * a complete `major.minor.patch[-prerelease][+build]` version string. Wildcards | ||
| * and range syntax (tilde, caret, hyphen, X-range) are not allowed. | ||
| * | ||
| * If no operator is specified, `"="` (exact match) is assumed. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { parseSingleComparator } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const comp = yield* parseSingleComparator(">=1.0.0"); | ||
| * console.log(comp.operator); // ">=" | ||
| * console.log(comp.version.toString()); // "1.0.0" | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link Comparator} | ||
| * @see {@link InvalidComparatorError} | ||
| */ | ||
| export declare const parseSingleComparator: (raw: string) => Effect_2.Effect<Comparator, InvalidComparatorError, never>; | ||
| export declare namespace PrettyPrint { | ||
| export { | ||
| Printable, | ||
| prettyPrint | ||
| } | ||
| } | ||
| /** | ||
| * Parse a string into a {@link SemVer} using a strict SemVer 2.0.0 | ||
| * recursive-descent parser. | ||
| * | ||
| * Rejects `v`/`V` prefixes, `=` prefixes, leading zeros on numeric identifiers, | ||
| * and any input that does not fully consume as a valid `major.minor.patch[-prerelease][+build]` | ||
| * string. Returns an {@link Effect.Effect} that fails with {@link InvalidVersionError} | ||
| * on invalid input. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { parseValidSemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* parseValidSemVer("1.2.3-beta.1+build.42"); | ||
| * console.log(v.toString()); // "1.2.3-beta.1+build.42" | ||
| * }); | ||
| * ``` | ||
| * | ||
| * @see {@link SemVer} | ||
| * @see {@link InvalidVersionError} | ||
| * @see {@link https://semver.org | SemVer 2.0.0 Specification} | ||
| */ | ||
| export declare const parseValidSemVer: (raw: string) => Effect_2.Effect<SemVer, InvalidVersionError, never>; | ||
@@ -701,8 +763,8 @@ /** | ||
| * ```typescript | ||
| * import { PrettyPrint, SemVer } from "semver-effect"; | ||
| * import { prettyPrint, parseValidSemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.fromString("1.2.3-alpha.1"); | ||
| * console.log(PrettyPrint.prettyPrint(v)); // "1.2.3-alpha.1" | ||
| * const v = yield* parseValidSemVer("1.2.3-alpha.1"); | ||
| * console.log(prettyPrint(v)); // "1.2.3-alpha.1" | ||
| * }); | ||
@@ -713,3 +775,3 @@ * ``` | ||
| */ | ||
| declare const prettyPrint: (value: Printable) => string; | ||
| export declare const prettyPrint: (value: Printable) => string; | ||
@@ -721,42 +783,16 @@ /** | ||
| */ | ||
| declare type Printable = SemVer_2 | Comparator_2 | Range_2 | VersionDiff_2; | ||
| export declare type Printable = SemVer | Comparator | Range | VersionDiff; | ||
| export declare namespace Range { | ||
| export { | ||
| Range_2 as Range, | ||
| RangeBase, | ||
| ComparatorSet, | ||
| fromString_2 as fromString, | ||
| any_2 as any, | ||
| filter, | ||
| maxSatisfying, | ||
| minSatisfying, | ||
| satisfies, | ||
| equivalent, | ||
| intersect, | ||
| isSubset, | ||
| simplify, | ||
| union, | ||
| Instance_2 as Instance, | ||
| FromString_2 as FromString | ||
| } | ||
| } | ||
| /** | ||
| * A SemVer range expression, represented as a union (OR) of {@link ComparatorSet}s. | ||
| * | ||
| * A version satisfies a range if it satisfies at least one of the comparator sets. | ||
| * Each comparator set is an intersection (AND) of individual {@link Comparator}s. | ||
| * | ||
| * Range syntax follows node-semver conventions (hyphen ranges, X-ranges, tilde | ||
| * ranges, caret ranges) but enforcement is strict SemVer 2.0.0 only. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { Range } from "semver-effect"; | ||
| * import { Range, SemVer } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const range = yield* Range.fromString(">=1.0.0 <2.0.0 || ^3.0.0"); | ||
| * console.log(range.toString()); // ">=1.0.0 <2.0.0 || >=3.0.0 <4.0.0" | ||
| * const range = yield* Range.parse("^1.0.0"); | ||
| * const v = new SemVer({ major: 1, minor: 5, patch: 0, prerelease: [], build: [] }); | ||
| * console.log(range.test(v)); // true | ||
| * }); | ||
@@ -769,12 +805,37 @@ * ``` | ||
| */ | ||
| declare class Range_2 extends RangeBase<{ | ||
| readonly sets: ReadonlyArray<ReadonlyArray<Comparator_2>>; | ||
| }> { | ||
| export declare class Range extends Range_base { | ||
| /** Parse a SemVer range expression. Wired at module load by index.ts. */ | ||
| static parse: (input: string) => Effect<Range, InvalidRangeError>; | ||
| /** Test whether a version satisfies a range. Dual API. Wired at module load. */ | ||
| static satisfies: { | ||
| (range: Range): (version: SemVer) => boolean; | ||
| (version: SemVer, range: Range): boolean; | ||
| }; | ||
| /** Filter versions that satisfy a range. Dual API. Wired at module load. */ | ||
| static filter: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => ReadonlyArray<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): ReadonlyArray<SemVer>; | ||
| }; | ||
| /** Highest satisfying version. Dual API. Wired at module load. */ | ||
| static maxSatisfying: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => Option<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): Option<SemVer>; | ||
| }; | ||
| /** Lowest satisfying version. Dual API. Wired at module load. */ | ||
| static minSatisfying: { | ||
| (range: Range): (versions: ReadonlyArray<SemVer>) => Option<SemVer>; | ||
| (versions: ReadonlyArray<SemVer>, range: Range): Option<SemVer>; | ||
| }; | ||
| /** Test whether a version satisfies this range. */ | ||
| test(version: SemVer): boolean; | ||
| /** Filter versions that satisfy this range, preserving order. */ | ||
| filter(versions: ReadonlyArray<SemVer>): ReadonlyArray<SemVer>; | ||
| toString(): string; | ||
| } | ||
| /** @internal */ | ||
| declare const RangeBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & { | ||
| readonly _tag: "Range"; | ||
| }; | ||
| declare const Range_base: Schema.TaggedClass<Range, "Range", { | ||
| readonly _tag: Schema.tag<"Range">; | ||
| } & { | ||
| sets: Schema.Array$<Schema.Array$<typeof Comparator>>; | ||
| }>; | ||
@@ -789,3 +850,3 @@ /** | ||
| */ | ||
| declare const rsort: (versions: readonly SemVer_2[]) => SemVer_2[]; | ||
| export declare const rsort: (versions: readonly SemVer[]) => SemVer[]; | ||
@@ -795,20 +856,14 @@ /** | ||
| * | ||
| * A version satisfies a range if it matches at least one of the range's | ||
| * comparator sets (OR semantics). Within a comparator set, all comparators | ||
| * must be satisfied (AND semantics). | ||
| * For the instance method alternative, use `range.test(version)`. | ||
| * | ||
| * Prerelease versions are subject to the "tuple restriction": a prerelease | ||
| * version only matches a comparator set if at least one comparator in that set | ||
| * also has a prerelease tag on the same `major.minor.patch` tuple. This follows | ||
| * the node-semver convention for prerelease handling. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * import { Range, SemVer } from "semver-effect"; | ||
| * import { SemVer, Range } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.fromString("1.5.0"); | ||
| * const r = yield* Range.fromString("^1.0.0"); | ||
| * console.log(Range.satisfies(v, r)); // true | ||
| * const v = yield* SemVer.parse("1.5.0"); | ||
| * const r = yield* Range.parse("^1.0.0"); | ||
| * console.log(r.test(v)); // true (instance method) | ||
| * console.log(satisfies(v, r)); // true (standalone function) | ||
| * }); | ||
@@ -821,55 +876,13 @@ * ``` | ||
| */ | ||
| declare const satisfies: { | ||
| (range: Range_2): (version: SemVer_2) => boolean; | ||
| (version: SemVer_2, range: Range_2): boolean; | ||
| export declare const satisfies: { | ||
| (range: Range): (version: SemVer) => boolean; | ||
| (version: SemVer, range: Range): boolean; | ||
| }; | ||
| export declare namespace SemVer { | ||
| export { | ||
| SemVer_2 as SemVer, | ||
| SemVerBase, | ||
| make, | ||
| ZERO, | ||
| fromString_3 as fromString, | ||
| compare, | ||
| compareWithBuild, | ||
| equal, | ||
| gt, | ||
| gte, | ||
| lt, | ||
| lte, | ||
| neq, | ||
| isPrerelease, | ||
| isStable, | ||
| truncate, | ||
| max, | ||
| min, | ||
| rsort, | ||
| sort, | ||
| diff, | ||
| bump, | ||
| Order, | ||
| OrderWithBuild, | ||
| Equivalence, | ||
| Instance_3 as Instance, | ||
| FromString_3 as FromString | ||
| } | ||
| } | ||
| /** | ||
| * A parsed SemVer 2.0.0 version, represented as an Effect `Data.TaggedClass`. | ||
| * A parsed SemVer 2.0.0 version, represented as an Effect `Schema.TaggedClass`. | ||
| * | ||
| * Implements structural equality via {@link Equal.Equal} (build metadata is | ||
| * excluded from equality checks per the SemVer spec) and is hashable via | ||
| * {@link Hash.Hash}. | ||
| * Provides instance methods for comparison, bumping, and predicates, plus | ||
| * static methods for parsing and collection operations. | ||
| * | ||
| * @remarks | ||
| * All numeric fields (`major`, `minor`, `patch`) must be non-negative integers. | ||
| * Prerelease identifiers may be strings or non-negative integers. Build metadata | ||
| * identifiers are always strings. Build metadata is preserved but ignored in all | ||
| * comparison and equality operations, per SemVer 2.0.0 section 10. | ||
| * | ||
| * Unlike node-semver, this implementation does not support loose parsing or | ||
| * `v`-prefixed strings. Only strictly valid SemVer 2.0.0 strings are accepted. | ||
| * | ||
| * @example | ||
@@ -881,7 +894,6 @@ * ```typescript | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.fromString("1.2.3-alpha.1+build.42"); | ||
| * console.log(v.major); // 1 | ||
| * console.log(v.prerelease); // ["alpha", 1] | ||
| * console.log(v.build); // ["build", "42"] | ||
| * console.log(v.toString()); // "1.2.3-alpha.1+build.42" | ||
| * const v = yield* SemVer.parse("1.2.3"); | ||
| * const next = v.bump.minor(); // 1.3.0 | ||
| * console.log(v.gt(next)); // false | ||
| * console.log(next.isStable); // true | ||
| * }); | ||
@@ -892,9 +904,78 @@ * ``` | ||
| */ | ||
| declare class SemVer_2 extends SemVerBase<{ | ||
| readonly major: number; | ||
| readonly minor: number; | ||
| readonly patch: number; | ||
| readonly prerelease: ReadonlyArray<string | number>; | ||
| readonly build: ReadonlyArray<string>; | ||
| }> { | ||
| export declare class SemVer extends SemVer_base { | ||
| /** Parse a strict SemVer 2.0.0 string. @remarks Import from `"semver-effect"`, not the schema subpath. */ | ||
| static parse: (input: string) => Effect<SemVer, InvalidVersionError>; | ||
| /** Convenience positional constructor. Wired at module load by index.ts. */ | ||
| static of: (major: number, minor: number, patch: number, prerelease?: ReadonlyArray<string | number>, build?: ReadonlyArray<string>) => SemVer; | ||
| /** Compare two versions. Returns `-1`, `0`, or `1`. Dual API. */ | ||
| static compare: { | ||
| (that: SemVer): (self: SemVer) => -1 | 0 | 1; | ||
| (self: SemVer, that: SemVer): -1 | 0 | 1; | ||
| }; | ||
| /** Test whether `self > that`. Dual API. */ | ||
| static gt: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Test whether `self >= that`. Dual API. */ | ||
| static gte: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Test whether `self < that`. Dual API. */ | ||
| static lt: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Test whether `self <= that`. Dual API. */ | ||
| static lte: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Test whether `self !== that`. Dual API. */ | ||
| static neq: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Test whether two versions are equal (ignores build). Dual API. */ | ||
| static equal: { | ||
| (that: SemVer): (self: SemVer) => boolean; | ||
| (self: SemVer, that: SemVer): boolean; | ||
| }; | ||
| /** Compute diff between two versions. Dual API. */ | ||
| static diff: { | ||
| (that: SemVer): (self: SemVer) => VersionDiff; | ||
| (self: SemVer, that: SemVer): VersionDiff; | ||
| }; | ||
| /** Sort versions ascending. */ | ||
| static sort: (versions: ReadonlyArray<SemVer>) => Array<SemVer>; | ||
| /** Sort versions descending. */ | ||
| static rsort: (versions: ReadonlyArray<SemVer>) => Array<SemVer>; | ||
| /** Highest version, or `Option.none()` if empty. */ | ||
| static max: (versions: ReadonlyArray<SemVer>) => Option<SemVer>; | ||
| /** Lowest version, or `Option.none()` if empty. */ | ||
| static min: (versions: ReadonlyArray<SemVer>) => Option<SemVer>; | ||
| /** Compare `this` to `that` per SemVer 2.0.0 precedence. Returns `-1`, `0`, or `1`. */ | ||
| compare(that: SemVer): -1 | 0 | 1; | ||
| /** Test whether `this > that`. */ | ||
| gt(that: SemVer): boolean; | ||
| /** Test whether `this >= that`. */ | ||
| gte(that: SemVer): boolean; | ||
| /** Test whether `this < that`. */ | ||
| lt(that: SemVer): boolean; | ||
| /** Test whether `this <= that`. */ | ||
| lte(that: SemVer): boolean; | ||
| /** Test whether `this` equals `that` (ignores build metadata). */ | ||
| equal(that: SemVer): boolean; | ||
| /** Alias for {@link equal}. */ | ||
| eq(that: SemVer): boolean; | ||
| /** Test whether `this` does not equal `that` (ignores build metadata). */ | ||
| neq(that: SemVer): boolean; | ||
| /** Whether this is a prerelease version. */ | ||
| get isPrerelease(): boolean; | ||
| /** Whether this is a stable (non-prerelease) version. */ | ||
| get isStable(): boolean; | ||
| private _bump; | ||
| /** Version bumping operations. */ | ||
| get bump(): SemVerBump; | ||
| [Equal.symbol](that: Equal.Equal): boolean; | ||
@@ -906,8 +987,46 @@ [Hash.symbol](): number; | ||
| /** @internal */ | ||
| declare const SemVerBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & { | ||
| readonly _tag: "SemVer"; | ||
| }; | ||
| declare const SemVer_base: Schema.TaggedClass<SemVer, "SemVer", { | ||
| readonly _tag: Schema.tag<"SemVer">; | ||
| } & { | ||
| major: typeof Schema.Number; | ||
| minor: typeof Schema.Number; | ||
| patch: typeof Schema.Number; | ||
| prerelease: Schema.Array$<Schema.Union<[typeof Schema.String, typeof Schema.Number]>>; | ||
| build: Schema.Array$<typeof Schema.String>; | ||
| }>; | ||
| /** Grouped bump operations returned by {@link SemVer.bump}. */ | ||
| export declare class SemVerBump { | ||
| private readonly v; | ||
| constructor(v: SemVer); | ||
| /** Bump major (resets minor, patch, prerelease, build). */ | ||
| major(): SemVer; | ||
| /** Bump minor (resets patch, prerelease, build). */ | ||
| minor(): SemVer; | ||
| /** Bump patch (resets prerelease, build). */ | ||
| patch(): SemVer; | ||
| /** Bump prerelease, optionally with a named identifier. */ | ||
| prerelease(id?: string): SemVer; | ||
| /** Strip prerelease and build, keeping major.minor.patch. */ | ||
| release(): SemVer; | ||
| } | ||
| /** | ||
| * Effect {@link Order.Order} instance for {@link SemVer} following SemVer 2.0.0 | ||
| * precedence rules. Delegates to {@link SemVer.compare}. | ||
| * | ||
| * @see {@link SemVerOrderWithBuild} | ||
| * @see {@link https://semver.org/#spec-item-11 | SemVer 2.0.0 Section 11} | ||
| */ | ||
| export declare const SemVerOrder: Order.Order<SemVer>; | ||
| /** | ||
| * Effect {@link Order.Order} instance for {@link SemVer} that additionally | ||
| * compares build metadata when versions are otherwise equal. | ||
| * | ||
| * @see {@link SemVerOrder} | ||
| */ | ||
| export declare const SemVerOrderWithBuild: Order.Order<SemVer>; | ||
| /** | ||
| * Effect service interface for parsing SemVer 2.0.0 strings. | ||
@@ -937,19 +1056,15 @@ * | ||
| */ | ||
| export declare interface SemVerParser { | ||
| export declare class SemVerParser extends SemVerParser_base { | ||
| } | ||
| declare const SemVerParser_base: Context.TagClass<SemVerParser, "semver-effect/SemVerParser", { | ||
| /** Parse a string into a {@link SemVer}. Fails with {@link InvalidVersionError} on invalid input. */ | ||
| readonly parseVersion: (input: string) => Effect.Effect<SemVer_2, InvalidVersionError>; | ||
| readonly parseVersion: (input: string) => Effect_2.Effect<SemVer, InvalidVersionError, never>; | ||
| /** Parse a range expression into a {@link Range}. Fails with {@link InvalidRangeError} on invalid input. */ | ||
| readonly parseRange: (input: string) => Effect.Effect<Range_2, InvalidRangeError>; | ||
| readonly parseRange: (input: string) => Effect_2.Effect<Range, InvalidRangeError, never>; | ||
| /** Parse a single comparator string into a {@link Comparator}. Fails with {@link InvalidComparatorError} on invalid input. */ | ||
| readonly parseComparator: (input: string) => Effect.Effect<Comparator_2, InvalidComparatorError>; | ||
| } | ||
| readonly parseComparator: (input: string) => Effect_2.Effect<Comparator, InvalidComparatorError, never>; | ||
| }>; | ||
| /** | ||
| * Effect Context tag for the {@link SemVerParser} service. | ||
| * | ||
| * @see {@link SemVerParserLive} | ||
| */ | ||
| export declare const SemVerParser: Context.Tag<SemVerParser, SemVerParser>; | ||
| /** | ||
| * Live Effect {@link Layer} that provides the {@link SemVerParser} service. | ||
@@ -987,3 +1102,3 @@ * | ||
| */ | ||
| declare const simplify: (range: Range_2) => Range_2; | ||
| export declare const simplify: (range: Range) => Range; | ||
@@ -998,3 +1113,3 @@ /** | ||
| */ | ||
| declare const sort: (versions: readonly SemVer_2[]) => SemVer_2[]; | ||
| export declare const sort: (versions: readonly SemVer[]) => SemVer[]; | ||
@@ -1011,15 +1126,15 @@ /** | ||
| * ```typescript | ||
| * import { SemVer } from "semver-effect"; | ||
| * import { parseValidSemVer, truncate } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const v = yield* SemVer.fromString("1.2.3-alpha.1+build"); | ||
| * console.log(SemVer.truncate(v, "prerelease").toString()); // "1.2.3" | ||
| * console.log(SemVer.truncate(v, "build").toString()); // "1.2.3-alpha.1" | ||
| * const v = yield* parseValidSemVer("1.2.3-alpha.1+build"); | ||
| * console.log(truncate(v, "prerelease").toString()); // "1.2.3" | ||
| * console.log(truncate(v, "build").toString()); // "1.2.3-alpha.1" | ||
| * }); | ||
| * ``` | ||
| */ | ||
| declare const truncate: { | ||
| (level: "prerelease" | "build"): (v: SemVer_2) => SemVer_2; | ||
| (v: SemVer_2, level: "prerelease" | "build"): SemVer_2; | ||
| export declare const truncate: { | ||
| (level: "prerelease" | "build"): (v: SemVer) => SemVer; | ||
| (v: SemVer, level: "prerelease" | "build"): SemVer; | ||
| }; | ||
@@ -1035,9 +1150,9 @@ | ||
| * ```typescript | ||
| * import { Range } from "semver-effect"; | ||
| * import { parseRange, union } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const a = yield* Range.fromString("^1.0.0"); | ||
| * const b = yield* Range.fromString("^2.0.0"); | ||
| * const combined = Range.union(a, b); | ||
| * const a = yield* parseRange("^1.0.0"); | ||
| * const b = yield* parseRange("^2.0.0"); | ||
| * const combined = union(a, b); | ||
| * // combined matches versions satisfying ^1.0.0 OR ^2.0.0 | ||
@@ -1050,5 +1165,5 @@ * }); | ||
| */ | ||
| declare const union: { | ||
| (b: Range_2): (a: Range_2) => Range_2; | ||
| (a: Range_2, b: Range_2): Range_2; | ||
| export declare const union: { | ||
| (b: Range): (a: Range) => Range; | ||
| (a: Range, b: Range): Range; | ||
| }; | ||
@@ -1068,3 +1183,3 @@ | ||
| /** The ranges that were being intersected. */ | ||
| readonly constraints: ReadonlyArray<Range_2>; | ||
| readonly constraints: ReadonlyArray<Range>; | ||
| }> { | ||
@@ -1084,3 +1199,3 @@ get message(): string; | ||
| */ | ||
| export declare const UnsatisfiableConstraintErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const UnsatisfiableConstraintErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "UnsatisfiableConstraintError"; | ||
@@ -1100,5 +1215,5 @@ } & Readonly<A>; | ||
| /** The range that could not be satisfied. */ | ||
| readonly range: Range_2; | ||
| readonly range: Range; | ||
| /** The versions that were available for matching. */ | ||
| readonly available: ReadonlyArray<SemVer_2>; | ||
| readonly available: ReadonlyArray<SemVer>; | ||
| }> { | ||
@@ -1118,3 +1233,3 @@ get message(): string; | ||
| */ | ||
| export declare const UnsatisfiedRangeErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const UnsatisfiedRangeErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "UnsatisfiedRangeError"; | ||
@@ -1140,4 +1255,4 @@ } & Readonly<A>; | ||
| * const cache = yield* VersionCache; | ||
| * const v1 = yield* SemVer.fromString("1.0.0"); | ||
| * const v2 = yield* SemVer.fromString("2.0.0"); | ||
| * const v1 = new SemVer({ major: 1, minor: 0, patch: 0, prerelease: [], build: [] }); | ||
| * const v2 = new SemVer({ major: 2, minor: 0, patch: 0, prerelease: [], build: [] }); | ||
| * yield* cache.load([v1, v2]); | ||
@@ -1152,19 +1267,22 @@ * const latest = yield* cache.latest(); | ||
| */ | ||
| export declare interface VersionCache { | ||
| export declare class VersionCache extends VersionCache_base { | ||
| } | ||
| declare const VersionCache_base: Context.TagClass<VersionCache, "semver-effect/VersionCache", { | ||
| /** Replace all cached versions with the given array. */ | ||
| readonly load: (versions: ReadonlyArray<SemVer_2>) => Effect.Effect<void, never>; | ||
| readonly load: (versions: readonly SemVer[]) => Effect_2.Effect<void, never, never>; | ||
| /** Add a single version to the cache. */ | ||
| readonly add: (version: SemVer_2) => Effect.Effect<void, never>; | ||
| readonly add: (version: SemVer) => Effect_2.Effect<void, never, never>; | ||
| /** Remove a single version from the cache. */ | ||
| readonly remove: (version: SemVer_2) => Effect.Effect<void, never>; | ||
| readonly remove: (version: SemVer) => Effect_2.Effect<void, never, never>; | ||
| /** Retrieve all cached versions in sorted order. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly versions: Effect.Effect<ReadonlyArray<SemVer_2>, EmptyCacheError>; | ||
| readonly versions: Effect_2.Effect<readonly SemVer[], EmptyCacheError, never>; | ||
| /** Retrieve the highest version in the cache. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly latest: () => Effect.Effect<SemVer_2, EmptyCacheError>; | ||
| readonly latest: () => Effect_2.Effect<SemVer, EmptyCacheError, never>; | ||
| /** Retrieve the lowest version in the cache. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly oldest: () => Effect.Effect<SemVer_2, EmptyCacheError>; | ||
| readonly oldest: () => Effect_2.Effect<SemVer, EmptyCacheError, never>; | ||
| /** Find the highest version satisfying a {@link Range}. Fails with {@link UnsatisfiedRangeError} if none match. */ | ||
| readonly resolve: (range: Range_2) => Effect.Effect<SemVer_2, UnsatisfiedRangeError>; | ||
| readonly resolve: (range: Range) => Effect_2.Effect<SemVer, UnsatisfiedRangeError, never>; | ||
| /** Parse a range string and resolve it. Fails with {@link InvalidRangeError} or {@link UnsatisfiedRangeError}. */ | ||
| readonly resolveString: (input: string) => Effect.Effect<SemVer_2, InvalidRangeError | UnsatisfiedRangeError>; | ||
| readonly resolveString: (input: string) => Effect_2.Effect<SemVer, InvalidRangeError | UnsatisfiedRangeError, never>; | ||
| /** | ||
@@ -1175,25 +1293,18 @@ * Return all cached versions satisfying a {@link Range}. | ||
| */ | ||
| readonly filter: (range: Range_2) => Effect.Effect<ReadonlyArray<SemVer_2>, EmptyCacheError>; | ||
| readonly filter: (range: Range) => Effect_2.Effect<readonly SemVer[], EmptyCacheError, never>; | ||
| /** Group cached versions by major, minor, or patch level. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly groupBy: (strategy: "major" | "minor" | "patch") => Effect.Effect<Map<string, ReadonlyArray<SemVer_2>>, EmptyCacheError>; | ||
| readonly groupBy: (strategy: "major" | "minor" | "patch") => Effect_2.Effect<Map<string, readonly SemVer[]>, EmptyCacheError, never>; | ||
| /** Return the latest version for each distinct major version. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly latestByMajor: () => Effect.Effect<ReadonlyArray<SemVer_2>, EmptyCacheError>; | ||
| readonly latestByMajor: () => Effect_2.Effect<readonly SemVer[], EmptyCacheError, never>; | ||
| /** Return the latest version for each distinct major.minor pair. Fails with {@link EmptyCacheError} if empty. */ | ||
| readonly latestByMinor: () => Effect.Effect<ReadonlyArray<SemVer_2>, EmptyCacheError>; | ||
| readonly latestByMinor: () => Effect_2.Effect<readonly SemVer[], EmptyCacheError, never>; | ||
| /** Compute a {@link VersionDiff} between two versions. Fails with {@link VersionNotFoundError} if either is missing. */ | ||
| readonly diff: (a: SemVer_2, b: SemVer_2) => Effect.Effect<VersionDiff_2, VersionNotFoundError>; | ||
| readonly diff: (a: SemVer, b: SemVer) => Effect_2.Effect<VersionDiff, VersionNotFoundError, never>; | ||
| /** Get the next higher version after the given one. Fails with {@link VersionNotFoundError} if not in cache. */ | ||
| readonly next: (version: SemVer_2) => Effect.Effect<Option.Option<SemVer_2>, VersionNotFoundError>; | ||
| readonly next: (version: SemVer) => Effect_2.Effect<Option_2.Option<SemVer>, VersionNotFoundError, never>; | ||
| /** Get the next lower version before the given one. Fails with {@link VersionNotFoundError} if not in cache. */ | ||
| readonly prev: (version: SemVer_2) => Effect.Effect<Option.Option<SemVer_2>, VersionNotFoundError>; | ||
| } | ||
| readonly prev: (version: SemVer) => Effect_2.Effect<Option_2.Option<SemVer>, VersionNotFoundError, never>; | ||
| }>; | ||
| /** | ||
| * Effect Context tag for the {@link VersionCache} service. | ||
| * | ||
| * @see {@link VersionCacheLive} | ||
| */ | ||
| export declare const VersionCache: Context.Tag<VersionCache, VersionCache>; | ||
| /** | ||
| * Live Effect {@link Layer} that provides the {@link VersionCache} service. | ||
@@ -1214,3 +1325,3 @@ * | ||
| * const cache = yield* VersionCache; | ||
| * const v = yield* SemVer.fromString("1.0.0"); | ||
| * const v = new SemVer({ major: 1, minor: 0, patch: 0, prerelease: [], build: [] }); | ||
| * yield* cache.add(v); | ||
@@ -1227,11 +1338,2 @@ * const latest = yield* cache.latest(); | ||
| export declare namespace VersionDiff { | ||
| export { | ||
| VersionDiff_2 as VersionDiff, | ||
| VersionDiffBase, | ||
| make_2 as make, | ||
| Instance_4 as Instance | ||
| } | ||
| } | ||
| /** | ||
@@ -1254,9 +1356,9 @@ * The result of computing the difference between two {@link SemVer} versions. | ||
| * ```typescript | ||
| * import { SemVer } from "semver-effect"; | ||
| * import { parseValidSemVer, diff } from "semver-effect"; | ||
| * import { Effect } from "effect"; | ||
| * | ||
| * const program = Effect.gen(function* () { | ||
| * const a = yield* SemVer.fromString("1.2.3"); | ||
| * const b = yield* SemVer.fromString("2.0.0"); | ||
| * const d = SemVer.diff(a, b); | ||
| * const a = yield* parseValidSemVer("1.2.3"); | ||
| * const b = yield* parseValidSemVer("2.0.0"); | ||
| * const d = diff(a, b); | ||
| * console.log(d.type); // "major" | ||
@@ -1270,10 +1372,3 @@ * console.log(d.major); // 1 | ||
| */ | ||
| declare class VersionDiff_2 extends VersionDiffBase<{ | ||
| readonly type: "major" | "minor" | "patch" | "prerelease" | "build" | "none"; | ||
| readonly from: SemVer_2; | ||
| readonly to: SemVer_2; | ||
| readonly major: number; | ||
| readonly minor: number; | ||
| readonly patch: number; | ||
| }> { | ||
| export declare class VersionDiff extends VersionDiff_base { | ||
| toString(): string; | ||
@@ -1283,6 +1378,12 @@ toJSON(): unknown; | ||
| /** @internal */ | ||
| declare const VersionDiffBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => Readonly<A> & { | ||
| readonly _tag: "VersionDiff"; | ||
| }; | ||
| declare const VersionDiff_base: Schema.TaggedClass<VersionDiff, "VersionDiff", { | ||
| readonly _tag: Schema.tag<"VersionDiff">; | ||
| } & { | ||
| type: Schema.Literal<["major", "minor", "patch", "prerelease", "build", "none"]>; | ||
| from: typeof SemVer; | ||
| to: typeof SemVer; | ||
| major: typeof Schema.Number; | ||
| minor: typeof Schema.Number; | ||
| patch: typeof Schema.Number; | ||
| }>; | ||
@@ -1311,11 +1412,9 @@ /** | ||
| */ | ||
| export declare interface VersionFetcher { | ||
| /** Fetch all available versions for the given package name. Fails with {@link VersionFetchError} on failure. */ | ||
| readonly fetch: (packageName: string) => Effect.Effect<ReadonlyArray<SemVer_2>, VersionFetchError>; | ||
| export declare class VersionFetcher extends VersionFetcher_base { | ||
| } | ||
| /** | ||
| * Effect Context tag for the {@link VersionFetcher} service. | ||
| */ | ||
| export declare const VersionFetcher: Context.Tag<VersionFetcher, VersionFetcher>; | ||
| declare const VersionFetcher_base: Context.TagClass<VersionFetcher, "semver-effect/VersionFetcher", { | ||
| /** Fetch all available versions for the given package name. Fails with {@link VersionFetchError} on failure. */ | ||
| readonly fetch: (packageName: string) => Effect_2.Effect<readonly SemVer[], VersionFetchError, never>; | ||
| }>; | ||
@@ -1351,3 +1450,3 @@ /** | ||
| */ | ||
| export declare const VersionFetchErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const VersionFetchErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "VersionFetchError"; | ||
@@ -1366,3 +1465,3 @@ } & Readonly<A>; | ||
| /** The version that was not found in the cache. */ | ||
| readonly version: SemVer_2; | ||
| readonly version: SemVer; | ||
| }> { | ||
@@ -1382,9 +1481,6 @@ get message(): string; | ||
| */ | ||
| export declare const VersionNotFoundErrorBase: new <A extends Record<string, any> = {}>(args: Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => YieldableError & { | ||
| export declare const VersionNotFoundErrorBase: new <A extends Record<string, any> = {}>(args: VoidIfEmpty< { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => YieldableError & { | ||
| readonly _tag: "VersionNotFoundError"; | ||
| } & Readonly<A>; | ||
| /** The zero version `0.0.0`. */ | ||
| declare const ZERO: SemVer_2; | ||
| export { } |
+332
-318
@@ -1,93 +0,145 @@ | ||
| import { __webpack_require__ } from "./rslib-runtime.js"; | ||
| import { Context, Data, Effect, Equal, Equivalence, Function, Hash, Layer, Match, Option, Order, ParseResult, Ref, Schema, SortedSet } from "effect"; | ||
| var src_Comparator_namespaceObject = {}; | ||
| __webpack_require__.r(src_Comparator_namespaceObject); | ||
| __webpack_require__.d(src_Comparator_namespaceObject, { | ||
| Comparator: ()=>Comparator, | ||
| ComparatorBase: ()=>ComparatorBase, | ||
| FromString: ()=>FromString, | ||
| Instance: ()=>Instance, | ||
| any: ()=>any, | ||
| fromString: ()=>fromString | ||
| }); | ||
| var PrettyPrint_namespaceObject = {}; | ||
| __webpack_require__.r(PrettyPrint_namespaceObject); | ||
| __webpack_require__.d(PrettyPrint_namespaceObject, { | ||
| prettyPrint: ()=>prettyPrint | ||
| }); | ||
| var src_Range_namespaceObject = {}; | ||
| __webpack_require__.r(src_Range_namespaceObject); | ||
| __webpack_require__.d(src_Range_namespaceObject, { | ||
| FromString: ()=>Range_FromString, | ||
| Instance: ()=>Range_Instance, | ||
| Range: ()=>Range, | ||
| RangeBase: ()=>RangeBase, | ||
| any: ()=>Range_any, | ||
| equivalent: ()=>equivalent, | ||
| filter: ()=>filter, | ||
| fromString: ()=>Range_fromString, | ||
| intersect: ()=>intersect, | ||
| isSubset: ()=>isSubset, | ||
| maxSatisfying: ()=>maxSatisfying, | ||
| minSatisfying: ()=>minSatisfying, | ||
| satisfies: ()=>satisfies, | ||
| simplify: ()=>simplify, | ||
| union: ()=>union | ||
| }); | ||
| var src_SemVer_namespaceObject = {}; | ||
| __webpack_require__.r(src_SemVer_namespaceObject); | ||
| __webpack_require__.d(src_SemVer_namespaceObject, { | ||
| Equivalence: ()=>SemVer_Equivalence, | ||
| FromString: ()=>SemVer_FromString, | ||
| Instance: ()=>SemVer_Instance, | ||
| Order: ()=>SemVer_Order, | ||
| OrderWithBuild: ()=>OrderWithBuild, | ||
| SemVer: ()=>SemVer, | ||
| SemVerBase: ()=>SemVerBase, | ||
| ZERO: ()=>ZERO, | ||
| bump: ()=>bump, | ||
| compare: ()=>compare, | ||
| compareWithBuild: ()=>compareWithBuild, | ||
| diff: ()=>diff, | ||
| equal: ()=>equal, | ||
| fromString: ()=>SemVer_fromString, | ||
| gt: ()=>gt, | ||
| gte: ()=>gte, | ||
| isPrerelease: ()=>isPrerelease, | ||
| isStable: ()=>isStable, | ||
| lt: ()=>lt, | ||
| lte: ()=>lte, | ||
| make: ()=>make, | ||
| max: ()=>max, | ||
| min: ()=>min, | ||
| neq: ()=>neq, | ||
| rsort: ()=>rsort, | ||
| sort: ()=>sort, | ||
| truncate: ()=>truncate | ||
| }); | ||
| var src_VersionDiff_namespaceObject = {}; | ||
| __webpack_require__.r(src_VersionDiff_namespaceObject); | ||
| __webpack_require__.d(src_VersionDiff_namespaceObject, { | ||
| Instance: ()=>VersionDiff_Instance, | ||
| VersionDiff: ()=>VersionDiff, | ||
| VersionDiffBase: ()=>VersionDiffBase, | ||
| make: ()=>VersionDiff_make | ||
| }); | ||
| var _computedKey; | ||
| const ComparatorBase = Data.TaggedClass("Comparator"); | ||
| _computedKey = Symbol.for("nodejs.util.inspect.custom"); | ||
| class Comparator extends ComparatorBase { | ||
| toString() { | ||
| const op = "=" === this.operator ? "" : this.operator; | ||
| return `${op}${this.version.toString()}`; | ||
| import { Context, Data, Effect, Equal, Function, Hash, Layer, Match, Option, Order, Ref, Schema, SortedSet } from "effect"; | ||
| const EmptyCacheErrorBase = Data.TaggedError("EmptyCacheError"); | ||
| class EmptyCacheError extends EmptyCacheErrorBase { | ||
| get message() { | ||
| return "Version cache is empty"; | ||
| } | ||
| [_computedKey]() { | ||
| return this.toString(); | ||
| } | ||
| const InvalidBumpErrorBase = Data.TaggedError("InvalidBumpError"); | ||
| class InvalidBumpError extends InvalidBumpErrorBase { | ||
| get message() { | ||
| return `Cannot apply ${this.type} bump to version ${this.version.toString()}`; | ||
| } | ||
| } | ||
| var SemVer_computedKey, _computedKey1, _computedKey2; | ||
| const SemVerBase = Data.TaggedClass("SemVer"); | ||
| SemVer_computedKey = Equal.symbol, _computedKey1 = Hash.symbol, _computedKey2 = Symbol.for("nodejs.util.inspect.custom"); | ||
| class SemVer extends SemVerBase { | ||
| [SemVer_computedKey](that) { | ||
| const InvalidComparatorErrorBase = Data.TaggedError("InvalidComparatorError"); | ||
| class InvalidComparatorError extends InvalidComparatorErrorBase { | ||
| get message() { | ||
| const base = `Invalid comparator: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| } | ||
| } | ||
| const InvalidPrereleaseErrorBase = Data.TaggedError("InvalidPrereleaseError"); | ||
| class InvalidPrereleaseError extends InvalidPrereleaseErrorBase { | ||
| get message() { | ||
| return `Invalid prerelease identifier: "${this.input}"`; | ||
| } | ||
| } | ||
| const InvalidRangeErrorBase = Data.TaggedError("InvalidRangeError"); | ||
| class InvalidRangeError extends InvalidRangeErrorBase { | ||
| get message() { | ||
| const base = `Invalid range expression: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| } | ||
| } | ||
| const InvalidVersionErrorBase = Data.TaggedError("InvalidVersionError"); | ||
| class InvalidVersionError extends InvalidVersionErrorBase { | ||
| get message() { | ||
| const base = `Invalid version string: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| } | ||
| } | ||
| const UnsatisfiableConstraintErrorBase = Data.TaggedError("UnsatisfiableConstraintError"); | ||
| class UnsatisfiableConstraintError extends UnsatisfiableConstraintErrorBase { | ||
| get message() { | ||
| const count = this.constraints.length; | ||
| return `No version satisfies all ${count} constraint${1 === count ? "" : "s"}`; | ||
| } | ||
| } | ||
| const UnsatisfiedRangeErrorBase = Data.TaggedError("UnsatisfiedRangeError"); | ||
| class UnsatisfiedRangeError extends UnsatisfiedRangeErrorBase { | ||
| get message() { | ||
| const count = this.available.length; | ||
| return `No version satisfies range ${this.range.toString()} (${count} version${1 === count ? "" : "s"} available)`; | ||
| } | ||
| } | ||
| const VersionFetchErrorBase = Data.TaggedError("VersionFetchError"); | ||
| class VersionFetchError extends VersionFetchErrorBase { | ||
| } | ||
| const VersionNotFoundErrorBase = Data.TaggedError("VersionNotFoundError"); | ||
| class VersionNotFoundError extends VersionNotFoundErrorBase { | ||
| get message() { | ||
| return `Version not found in cache: ${this.version.toString()}`; | ||
| } | ||
| } | ||
| class SemVerParser extends Context.Tag("semver-effect/SemVerParser")() { | ||
| } | ||
| var _computedKey, _computedKey1, _computedKey2; | ||
| const comparePre = (a, b)=>{ | ||
| if ("number" == typeof a && "number" == typeof b) return a - b; | ||
| if ("string" == typeof a && "string" == typeof b) return a < b ? -1 : a > b ? 1 : 0; | ||
| if ("number" == typeof a) return -1; | ||
| return 1; | ||
| }; | ||
| _computedKey = Equal.symbol, _computedKey1 = Hash.symbol, _computedKey2 = Symbol.for("nodejs.util.inspect.custom"); | ||
| class SemVer extends Schema.TaggedClass()("SemVer", { | ||
| major: Schema.Number, | ||
| minor: Schema.Number, | ||
| patch: Schema.Number, | ||
| prerelease: Schema.Array(Schema.Union(Schema.String, Schema.Number)), | ||
| build: Schema.Array(Schema.String) | ||
| }) { | ||
| static parse; | ||
| static of; | ||
| static compare; | ||
| static gt; | ||
| static gte; | ||
| static lt; | ||
| static lte; | ||
| static neq; | ||
| static equal; | ||
| static diff; | ||
| static sort; | ||
| static rsort; | ||
| static max; | ||
| static min; | ||
| compare(that) { | ||
| if (this.major !== that.major) return this.major > that.major ? 1 : -1; | ||
| if (this.minor !== that.minor) return this.minor > that.minor ? 1 : -1; | ||
| if (this.patch !== that.patch) return this.patch > that.patch ? 1 : -1; | ||
| const aPre = this.prerelease; | ||
| const bPre = that.prerelease; | ||
| if (0 === aPre.length && 0 === bPre.length) return 0; | ||
| if (0 === aPre.length) return 1; | ||
| if (0 === bPre.length) return -1; | ||
| const len = Math.min(aPre.length, bPre.length); | ||
| for(let i = 0; i < len; i++){ | ||
| const cmp = comparePre(aPre[i], bPre[i]); | ||
| if (0 !== cmp) return cmp < 0 ? -1 : 1; | ||
| } | ||
| if (aPre.length !== bPre.length) return aPre.length > bPre.length ? 1 : -1; | ||
| return 0; | ||
| } | ||
| gt(that) { | ||
| return 1 === this.compare(that); | ||
| } | ||
| gte(that) { | ||
| return this.compare(that) >= 0; | ||
| } | ||
| lt(that) { | ||
| return -1 === this.compare(that); | ||
| } | ||
| lte(that) { | ||
| return this.compare(that) <= 0; | ||
| } | ||
| equal(that) { | ||
| return 0 === this.compare(that); | ||
| } | ||
| eq(that) { | ||
| return this.equal(that); | ||
| } | ||
| neq(that) { | ||
| return 0 !== this.compare(that); | ||
| } | ||
| get isPrerelease() { | ||
| return this.prerelease.length > 0; | ||
| } | ||
| get isStable() { | ||
| return 0 === this.prerelease.length; | ||
| } | ||
| _bump; | ||
| get bump() { | ||
| if (!this._bump) this._bump = new SemVerBump(this); | ||
| return this._bump; | ||
| } | ||
| [_computedKey](that) { | ||
| if (!(that instanceof SemVer)) return false; | ||
@@ -123,27 +175,143 @@ return this.major === that.major && this.minor === that.minor && this.patch === that.patch && this.prerelease.length === that.prerelease.length && this.prerelease.every((v, i)=>v === that.prerelease[i]); | ||
| } | ||
| const InvalidComparatorErrorBase = Data.TaggedError("InvalidComparatorError"); | ||
| class InvalidComparatorError extends InvalidComparatorErrorBase { | ||
| get message() { | ||
| const base = `Invalid comparator: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| class SemVerBump { | ||
| v; | ||
| constructor(v){ | ||
| this.v = v; | ||
| } | ||
| } | ||
| const InvalidRangeErrorBase = Data.TaggedError("InvalidRangeError"); | ||
| class InvalidRangeError extends InvalidRangeErrorBase { | ||
| get message() { | ||
| const base = `Invalid range expression: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| major() { | ||
| return new SemVer({ | ||
| major: this.v.major + 1, | ||
| minor: 0, | ||
| patch: 0, | ||
| prerelease: [], | ||
| build: [] | ||
| }); | ||
| } | ||
| minor() { | ||
| return new SemVer({ | ||
| major: this.v.major, | ||
| minor: this.v.minor + 1, | ||
| patch: 0, | ||
| prerelease: [], | ||
| build: [] | ||
| }); | ||
| } | ||
| patch() { | ||
| return new SemVer({ | ||
| major: this.v.major, | ||
| minor: this.v.minor, | ||
| patch: this.v.patch + 1, | ||
| prerelease: [], | ||
| build: [] | ||
| }); | ||
| } | ||
| prerelease(id) { | ||
| const { major, minor, patch } = this.v; | ||
| const pre = this.v.prerelease; | ||
| if (0 === pre.length) return new SemVer({ | ||
| major, | ||
| minor, | ||
| patch: patch + 1, | ||
| prerelease: void 0 !== id ? [ | ||
| id, | ||
| 0 | ||
| ] : [ | ||
| 0 | ||
| ], | ||
| build: [] | ||
| }); | ||
| if (void 0 !== id) { | ||
| const currentPrefix = "string" == typeof pre[0] ? pre[0] : null; | ||
| if (currentPrefix !== id) return new SemVer({ | ||
| major, | ||
| minor, | ||
| patch, | ||
| prerelease: [ | ||
| id, | ||
| 0 | ||
| ], | ||
| build: [] | ||
| }); | ||
| } | ||
| const last = pre[pre.length - 1]; | ||
| if ("number" == typeof last) { | ||
| const newPre = [ | ||
| ...pre | ||
| ]; | ||
| newPre[newPre.length - 1] = last + 1; | ||
| return new SemVer({ | ||
| major, | ||
| minor, | ||
| patch, | ||
| prerelease: newPre, | ||
| build: [] | ||
| }); | ||
| } | ||
| return new SemVer({ | ||
| major, | ||
| minor, | ||
| patch, | ||
| prerelease: [ | ||
| ...pre, | ||
| 0 | ||
| ], | ||
| build: [] | ||
| }); | ||
| } | ||
| release() { | ||
| return new SemVer({ | ||
| major: this.v.major, | ||
| minor: this.v.minor, | ||
| patch: this.v.patch, | ||
| prerelease: [], | ||
| build: [] | ||
| }); | ||
| } | ||
| } | ||
| const InvalidVersionErrorBase = Data.TaggedError("InvalidVersionError"); | ||
| class InvalidVersionError extends InvalidVersionErrorBase { | ||
| get message() { | ||
| const base = `Invalid version string: "${this.input}"`; | ||
| return void 0 !== this.position ? `${base} at position ${this.position}` : base; | ||
| var Comparator_computedKey; | ||
| Comparator_computedKey = Symbol.for("nodejs.util.inspect.custom"); | ||
| class Comparator extends Schema.TaggedClass()("Comparator", { | ||
| operator: Schema.Literal("=", ">", ">=", "<", "<="), | ||
| version: SemVer | ||
| }) { | ||
| static parse; | ||
| test(version) { | ||
| const cmp = version.compare(this.version); | ||
| switch(this.operator){ | ||
| case "=": | ||
| return 0 === cmp; | ||
| case ">": | ||
| return cmp > 0; | ||
| case ">=": | ||
| return cmp >= 0; | ||
| case "<": | ||
| return cmp < 0; | ||
| case "<=": | ||
| return cmp <= 0; | ||
| } | ||
| } | ||
| toString() { | ||
| const op = "=" === this.operator ? "" : this.operator; | ||
| return `${op}${this.version.toString()}`; | ||
| } | ||
| [Comparator_computedKey]() { | ||
| return this.toString(); | ||
| } | ||
| } | ||
| var Range_computedKey; | ||
| const RangeBase = Data.TaggedClass("Range"); | ||
| Range_computedKey = Symbol.for("nodejs.util.inspect.custom"); | ||
| class Range extends RangeBase { | ||
| class Range extends Schema.TaggedClass()("Range", { | ||
| sets: Schema.Array(Schema.Array(Comparator)) | ||
| }) { | ||
| static parse; | ||
| static satisfies; | ||
| static filter; | ||
| static maxSatisfying; | ||
| static minSatisfying; | ||
| test(version) { | ||
| return this.sets.some((set)=>satisfiesSet(version, set)); | ||
| } | ||
| filter(versions) { | ||
| return versions.filter((v)=>this.test(v)); | ||
| } | ||
| toString() { | ||
@@ -156,2 +324,10 @@ return this.sets.map((set)=>set.map((c)=>c.toString()).join(" ")).join(" || "); | ||
| } | ||
| const satisfiesSet = (version, set)=>{ | ||
| if (0 === set.length) return true; | ||
| if (version.prerelease.length > 0) { | ||
| const hasTupleMatch = set.some((c)=>c.version.prerelease.length > 0 && c.version.major === version.major && c.version.minor === version.minor && c.version.patch === version.patch); | ||
| if (!hasTupleMatch) return false; | ||
| } | ||
| return set.every((c)=>c.test(version)); | ||
| }; | ||
| const desugar_sv = (major, minor, patch, prerelease = [], build = [])=>new SemVer({ | ||
@@ -692,85 +868,5 @@ major, | ||
| }); | ||
| const fromString = parseSingleComparator; | ||
| const any = new Comparator({ | ||
| operator: ">=", | ||
| version: new SemVer({ | ||
| major: 0, | ||
| minor: 0, | ||
| patch: 0, | ||
| prerelease: [], | ||
| build: [] | ||
| }) | ||
| }); | ||
| const Instance = Schema.instanceOf(Comparator); | ||
| const FromString = Schema.transformOrFail(Schema.String, Instance, { | ||
| strict: true, | ||
| decode: (s, _, ast)=>fromString(s).pipe(Effect.mapError((e)=>new ParseResult.Type(ast, s, e.message))), | ||
| encode: (v)=>Effect.succeed(v.toString()) | ||
| }); | ||
| const EmptyCacheErrorBase = Data.TaggedError("EmptyCacheError"); | ||
| class EmptyCacheError extends EmptyCacheErrorBase { | ||
| get message() { | ||
| return "Version cache is empty"; | ||
| } | ||
| } | ||
| const InvalidBumpErrorBase = Data.TaggedError("InvalidBumpError"); | ||
| class InvalidBumpError extends InvalidBumpErrorBase { | ||
| get message() { | ||
| return `Cannot apply ${this.type} bump to version ${this.version.toString()}`; | ||
| } | ||
| } | ||
| const InvalidPrereleaseErrorBase = Data.TaggedError("InvalidPrereleaseError"); | ||
| class InvalidPrereleaseError extends InvalidPrereleaseErrorBase { | ||
| get message() { | ||
| return `Invalid prerelease identifier: "${this.input}"`; | ||
| } | ||
| } | ||
| const UnsatisfiableConstraintErrorBase = Data.TaggedError("UnsatisfiableConstraintError"); | ||
| class UnsatisfiableConstraintError extends UnsatisfiableConstraintErrorBase { | ||
| get message() { | ||
| const count = this.constraints.length; | ||
| return `No version satisfies all ${count} constraint${1 === count ? "" : "s"}`; | ||
| } | ||
| } | ||
| const UnsatisfiedRangeErrorBase = Data.TaggedError("UnsatisfiedRangeError"); | ||
| class UnsatisfiedRangeError extends UnsatisfiedRangeErrorBase { | ||
| get message() { | ||
| const count = this.available.length; | ||
| return `No version satisfies range ${this.range.toString()} (${count} version${1 === count ? "" : "s"} available)`; | ||
| } | ||
| } | ||
| const VersionFetchErrorBase = Data.TaggedError("VersionFetchError"); | ||
| class VersionFetchError extends VersionFetchErrorBase { | ||
| } | ||
| const VersionNotFoundErrorBase = Data.TaggedError("VersionNotFoundError"); | ||
| class VersionNotFoundError extends VersionNotFoundErrorBase { | ||
| get message() { | ||
| return `Version not found in cache: ${this.version.toString()}`; | ||
| } | ||
| } | ||
| const SemVerParser = Context.GenericTag("SemVerParser"); | ||
| const comparePrereleaseIdentifier = (a, b)=>{ | ||
| if ("number" == typeof a && "number" == typeof b) return a - b; | ||
| if ("string" == typeof a && "string" == typeof b) return a < b ? -1 : a > b ? 1 : 0; | ||
| if ("number" == typeof a) return -1; | ||
| return 1; | ||
| }; | ||
| const SemVerOrder = Order.make((a, b)=>{ | ||
| if (a.major !== b.major) return a.major < b.major ? -1 : 1; | ||
| if (a.minor !== b.minor) return a.minor < b.minor ? -1 : 1; | ||
| if (a.patch !== b.patch) return a.patch < b.patch ? -1 : 1; | ||
| const aHasPre = a.prerelease.length > 0; | ||
| const bHasPre = b.prerelease.length > 0; | ||
| if (!aHasPre && bHasPre) return 1; | ||
| if (aHasPre && !bHasPre) return -1; | ||
| const len = Math.min(a.prerelease.length, b.prerelease.length); | ||
| for(let i = 0; i < len; i++){ | ||
| const cmp = comparePrereleaseIdentifier(a.prerelease[i], b.prerelease[i]); | ||
| if (0 !== cmp) return cmp < 0 ? -1 : 1; | ||
| } | ||
| if (a.prerelease.length !== b.prerelease.length) return a.prerelease.length < b.prerelease.length ? -1 : 1; | ||
| return 0; | ||
| }); | ||
| const SemVerOrder = Order.make((a, b)=>a.compare(b)); | ||
| const SemVerOrderWithBuild = Order.make((a, b)=>{ | ||
| const base = SemVerOrder(a, b); | ||
| const base = a.compare(b); | ||
| if (0 !== base) return base; | ||
@@ -834,5 +930,12 @@ const aHasBuild = a.build.length > 0; | ||
| })); | ||
| const VersionCache = Context.GenericTag("VersionCache"); | ||
| const VersionDiffBase = Data.TaggedClass("VersionDiff"); | ||
| class VersionDiff extends VersionDiffBase { | ||
| class VersionCache extends Context.Tag("semver-effect/VersionCache")() { | ||
| } | ||
| class VersionDiff extends Schema.TaggedClass()("VersionDiff", { | ||
| type: Schema.Literal("major", "minor", "patch", "prerelease", "build", "none"), | ||
| from: SemVer, | ||
| to: SemVer, | ||
| major: Schema.Number, | ||
| minor: Schema.Number, | ||
| patch: Schema.Number | ||
| }) { | ||
| toString() { | ||
@@ -870,31 +973,8 @@ return `${this.type} (${this.from.toString()} → ${this.to.toString()})`; | ||
| })); | ||
| const satisfiesComparator = (version, comp)=>{ | ||
| const cmp = SemVerOrder(version, comp.version); | ||
| switch(comp.operator){ | ||
| case "=": | ||
| return 0 === cmp; | ||
| case ">": | ||
| return cmp > 0; | ||
| case ">=": | ||
| return cmp >= 0; | ||
| case "<": | ||
| return cmp < 0; | ||
| case "<=": | ||
| return cmp <= 0; | ||
| } | ||
| }; | ||
| const satisfiesComparatorSet = (version, set)=>{ | ||
| if (0 === set.length) return true; | ||
| if (version.prerelease.length > 0) { | ||
| const hasTupleMatch = set.some((c)=>c.version.prerelease.length > 0 && c.version.major === version.major && c.version.minor === version.minor && c.version.patch === version.patch); | ||
| if (!hasTupleMatch) return false; | ||
| } | ||
| return set.every((c)=>satisfiesComparator(version, c)); | ||
| }; | ||
| const satisfies = Function.dual(2, (version, range)=>range.sets.some((set)=>satisfiesComparatorSet(version, set))); | ||
| const filter = Function.dual(2, (versions, range)=>versions.filter((v)=>satisfies(v, range))); | ||
| const satisfies = Function.dual(2, (version, range)=>range.test(version)); | ||
| const filter = Function.dual(2, (versions, range)=>range.filter(versions)); | ||
| const maxSatisfying = Function.dual(2, (versions, range)=>{ | ||
| let best = null; | ||
| for (const v of versions)if (satisfies(v, range)) { | ||
| if (null === best || SemVerOrder(v, best) > 0) best = v; | ||
| for (const v of versions)if (range.test(v)) { | ||
| if (null === best || v.compare(best) > 0) best = v; | ||
| } | ||
@@ -905,4 +985,4 @@ return null === best ? Option.none() : Option.some(best); | ||
| let best = null; | ||
| for (const v of versions)if (satisfies(v, range)) { | ||
| if (null === best || SemVerOrder(v, best) < 0) best = v; | ||
| for (const v of versions)if (range.test(v)) { | ||
| if (null === best || v.compare(best) < 0) best = v; | ||
| } | ||
@@ -1015,4 +1095,4 @@ return null === best ? Option.none() : Option.some(best); | ||
| })); | ||
| const matcher = Match.type().pipe(Match.tag("SemVer", (sv)=>sv.toString()), Match.tag("Comparator", (c)=>c.toString()), Match.tag("Range", (r)=>r.toString()), Match.tag("VersionDiff", (d)=>d.toString()), Match.exhaustive); | ||
| const prettyPrint = (value)=>matcher(value); | ||
| class VersionFetcher extends Context.Tag("semver-effect/VersionFetcher")() { | ||
| } | ||
| const makeRange = (sets)=>new Range({ | ||
@@ -1132,67 +1212,7 @@ sets: sets.map((s)=>[ | ||
| }; | ||
| const parseRange = (input)=>Effect.map(parseRangeSet(input), normalizeRange); | ||
| const Range_fromString = parseRange; | ||
| const Range_any = new Range({ | ||
| sets: [ | ||
| [ | ||
| new Comparator({ | ||
| operator: ">=", | ||
| version: new SemVer({ | ||
| major: 0, | ||
| minor: 0, | ||
| patch: 0, | ||
| prerelease: [], | ||
| build: [] | ||
| }) | ||
| }) | ||
| ] | ||
| ] | ||
| }); | ||
| const Range_Instance = Schema.instanceOf(Range); | ||
| const Range_FromString = Schema.transformOrFail(Schema.String, Range_Instance, { | ||
| strict: true, | ||
| decode: (s, _, ast)=>Range_fromString(s).pipe(Effect.mapError((e)=>new ParseResult.Type(ast, s, e.message))), | ||
| encode: (v)=>Effect.succeed(v.toString()) | ||
| }); | ||
| const bump_sv = (major, minor, patch, prerelease = [])=>new SemVer({ | ||
| major, | ||
| minor, | ||
| patch, | ||
| prerelease: [ | ||
| ...prerelease | ||
| ], | ||
| build: [] | ||
| }); | ||
| const bumpMajor = (v)=>bump_sv(v.major + 1, 0, 0); | ||
| const bumpMinor = (v)=>bump_sv(v.major, v.minor + 1, 0); | ||
| const bumpPatch = (v)=>bump_sv(v.major, v.minor, v.patch + 1); | ||
| const bumpPrerelease = (v, id)=>{ | ||
| const pre = v.prerelease; | ||
| if (0 === pre.length) return void 0 !== id ? bump_sv(v.major, v.minor, v.patch + 1, [ | ||
| id, | ||
| 0 | ||
| ]) : bump_sv(v.major, v.minor, v.patch + 1, [ | ||
| 0 | ||
| ]); | ||
| if (void 0 !== id) { | ||
| const currentPrefix = "string" == typeof pre[0] ? pre[0] : null; | ||
| if (currentPrefix !== id) return bump_sv(v.major, v.minor, v.patch, [ | ||
| id, | ||
| 0 | ||
| ]); | ||
| } | ||
| const last = pre[pre.length - 1]; | ||
| if ("number" == typeof last) { | ||
| const newPre = [ | ||
| ...pre | ||
| ]; | ||
| newPre[newPre.length - 1] = last + 1; | ||
| return bump_sv(v.major, v.minor, v.patch, newPre); | ||
| } | ||
| return bump_sv(v.major, v.minor, v.patch, [ | ||
| ...pre, | ||
| 0 | ||
| ]); | ||
| }; | ||
| const bumpRelease = (v)=>bump_sv(v.major, v.minor, v.patch); | ||
| const bumpMajor = (v)=>v.bump.major(); | ||
| const bumpMinor = (v)=>v.bump.minor(); | ||
| const bumpPatch = (v)=>v.bump.patch(); | ||
| const bumpPrerelease = (v, id)=>v.bump.prerelease(id); | ||
| const bumpRelease = (v)=>v.bump.release(); | ||
| const compare = Function.dual(2, (self, that)=>SemVerOrder(self, that)); | ||
@@ -1241,3 +1261,7 @@ const equal = Function.dual(2, (self, that)=>Equal.equals(self, that)); | ||
| const compareWithBuild = Function.dual(2, (self, that)=>SemVerOrderWithBuild(self, that)); | ||
| const make = (major, minor, patch, prerelease = [], build = [])=>new SemVer({ | ||
| const parseRange = (input)=>Effect.map(parseRangeSet(input), normalizeRange); | ||
| const matcher = Match.type().pipe(Match.tag("SemVer", (sv)=>sv.toString()), Match.tag("Comparator", (c)=>c.toString()), Match.tag("Range", (r)=>r.toString()), Match.tag("VersionDiff", (d)=>d.toString()), Match.exhaustive); | ||
| const prettyPrint = (value)=>matcher(value); | ||
| SemVer.parse = parseValidSemVer; | ||
| SemVer.of = (major, minor, patch, prerelease = [], build = [])=>new SemVer({ | ||
| major, | ||
@@ -1253,30 +1277,20 @@ minor, | ||
| }); | ||
| const ZERO = make(0, 0, 0); | ||
| const SemVer_fromString = parseValidSemVer; | ||
| const bump = { | ||
| major: bumpMajor, | ||
| minor: bumpMinor, | ||
| patch: bumpPatch, | ||
| prerelease: bumpPrerelease, | ||
| release: bumpRelease | ||
| }; | ||
| const SemVer_Order = SemVerOrder; | ||
| const OrderWithBuild = SemVerOrderWithBuild; | ||
| const SemVer_Equivalence = Equivalence.make((self, that)=>equal(self, that)); | ||
| const SemVer_Instance = Schema.instanceOf(SemVer); | ||
| const SemVer_FromString = Schema.transformOrFail(Schema.String, SemVer_Instance, { | ||
| strict: true, | ||
| decode: (s, _, ast)=>SemVer_fromString(s).pipe(Effect.mapError((e)=>new ParseResult.Type(ast, s, e.message))), | ||
| encode: (v)=>Effect.succeed(v.toString()) | ||
| }); | ||
| const VersionFetcher = Context.GenericTag("VersionFetcher"); | ||
| const VersionDiff_make = (type, from, to, major, minor, patch)=>new VersionDiff({ | ||
| type, | ||
| from, | ||
| to, | ||
| major, | ||
| minor, | ||
| patch | ||
| }); | ||
| const VersionDiff_Instance = Schema.instanceOf(VersionDiff); | ||
| export { EmptyCacheError, EmptyCacheErrorBase, InvalidBumpError, InvalidBumpErrorBase, InvalidComparatorError, InvalidComparatorErrorBase, InvalidPrereleaseError, InvalidPrereleaseErrorBase, InvalidRangeError, InvalidRangeErrorBase, InvalidVersionError, InvalidVersionErrorBase, PrettyPrint_namespaceObject as PrettyPrint, SemVerParser, SemVerParserLive, UnsatisfiableConstraintError, UnsatisfiableConstraintErrorBase, UnsatisfiedRangeError, UnsatisfiedRangeErrorBase, VersionCache, VersionCacheLive, VersionFetchError, VersionFetchErrorBase, VersionFetcher, VersionNotFoundError, VersionNotFoundErrorBase, src_Comparator_namespaceObject as Comparator, src_Range_namespaceObject as Range, src_SemVer_namespaceObject as SemVer, src_VersionDiff_namespaceObject as VersionDiff }; | ||
| SemVer.compare = compare; | ||
| SemVer.equal = equal; | ||
| SemVer.gt = gt; | ||
| SemVer.gte = gte; | ||
| SemVer.lt = lt; | ||
| SemVer.lte = lte; | ||
| SemVer.neq = neq; | ||
| SemVer.diff = diff; | ||
| SemVer.sort = sort; | ||
| SemVer.rsort = rsort; | ||
| SemVer.max = max; | ||
| SemVer.min = min; | ||
| Comparator.parse = parseSingleComparator; | ||
| Range.parse = parseRange; | ||
| Range.satisfies = satisfies; | ||
| Range.filter = filter; | ||
| Range.maxSatisfying = maxSatisfying; | ||
| Range.minSatisfying = minSatisfying; | ||
| export { Comparator, EmptyCacheError, EmptyCacheErrorBase, InvalidBumpError, InvalidBumpErrorBase, InvalidComparatorError, InvalidComparatorErrorBase, InvalidPrereleaseError, InvalidPrereleaseErrorBase, InvalidRangeError, InvalidRangeErrorBase, InvalidVersionError, InvalidVersionErrorBase, Range, SemVer, SemVerBump, SemVerOrder, SemVerOrderWithBuild, SemVerParser, SemVerParserLive, UnsatisfiableConstraintError, UnsatisfiableConstraintErrorBase, UnsatisfiedRangeError, UnsatisfiedRangeErrorBase, VersionCache, VersionCacheLive, VersionDiff, VersionFetchError, VersionFetchErrorBase, VersionFetcher, VersionNotFoundError, VersionNotFoundErrorBase, bumpMajor, bumpMinor, bumpPatch, bumpPrerelease, bumpRelease, compare, compareWithBuild, diff, equal, equivalent, filter, gt, gte, intersect, isPrerelease, isStable, isSubset, lt, lte, max, maxSatisfying, min, minSatisfying, neq, parseRange, parseSingleComparator, parseValidSemVer, prettyPrint, rsort, satisfies, simplify, sort, truncate, union }; |
+3
-3
| { | ||
| "name": "semver-effect", | ||
| "version": "0.1.0", | ||
| "version": "0.2.0", | ||
| "private": false, | ||
@@ -35,2 +35,3 @@ "description": "Strict SemVer 2.0.0 implementation built on Effect, providing typed parsing, range algebra and version cache services.", | ||
| }, | ||
| "sideEffects": false, | ||
| "type": "module", | ||
@@ -44,3 +45,3 @@ "exports": { | ||
| "peerDependencies": { | ||
| "effect": "^3.19.19" | ||
| "effect": "^3.19.0" | ||
| }, | ||
@@ -56,5 +57,4 @@ "files": [ | ||
| "package.json", | ||
| "rslib-runtime.js", | ||
| "tsdoc-metadata.json" | ||
| ] | ||
| } |
+30
-14
@@ -12,7 +12,7 @@ # semver-effect | ||
| - Effect-idiomatic namespaced API (`SemVer.*`, `Range.*`) matching Effect's own conventions | ||
| - Class-based API with instance methods (`v.bump.minor()`, `range.test(v)`) and static methods (`SemVer.parse()`, `Range.parse()`) | ||
| - Standalone functions for pipe/data-last composition (`gt`, `satisfies`, `bumpMajor`, etc.) | ||
| - Strict SemVer 2.0.0 parsing with precise error positions (recursive descent, no regex) | ||
| - Typed error channel for every operation -- handle `InvalidVersionError`, `UnsatisfiedRangeError`, and others explicitly | ||
| - Range algebra: intersect, union, subset, equivalence, and simplification | ||
| - Dual-style API: all comparison and matching functions support both `pipe` and direct call | ||
@@ -28,18 +28,34 @@ ## Installation | ||
| ```typescript | ||
| import { Effect, pipe } from "effect"; | ||
| import { Effect } from "effect"; | ||
| import { SemVer, Range } from "semver-effect"; | ||
| // Direct construction -- no parsing needed | ||
| const v = SemVer.make(1, 4, 2); | ||
| const next = SemVer.bump.minor(v); // 1.5.0 | ||
| pipe(v, SemVer.gt(SemVer.make(0, 9, 0))); // true | ||
| const program = Effect.gen(function* () { | ||
| // Parse strings with static methods -- typed errors in the Effect channel | ||
| const v = yield* SemVer.parse("1.4.2"); | ||
| const range = yield* Range.parse("^1.2.0"); | ||
| // Parsing strings returns Effect with typed errors | ||
| // Instance methods for comparison, bumping, and matching | ||
| range.test(v); // true | ||
| v.gt(yield* SemVer.parse("1.3.0")); // true | ||
| v.compare(yield* SemVer.parse("2.0.0")); // -1 | ||
| v.bump.minor().toString(); // "1.5.0" | ||
| v.isStable; // true | ||
| }); | ||
| Effect.runSync(program); | ||
| ``` | ||
| Standalone functions are also available for pipe/data-last composition: | ||
| ```typescript | ||
| import { Effect, pipe } from "effect"; | ||
| import { SemVer, parseValidSemVer, parseRange, bumpMinor, gt, satisfies } from "semver-effect"; | ||
| const program = Effect.gen(function* () { | ||
| const version = yield* SemVer.fromString("1.4.2"); | ||
| const range = yield* Range.fromString("^1.2.0"); | ||
| const v = yield* parseValidSemVer("1.4.2"); | ||
| const range = yield* parseRange("^1.2.0"); | ||
| Range.satisfies(version, range); // true | ||
| SemVer.gt(version, yield* SemVer.fromString("1.3.0")); // true | ||
| SemVer.compare(version, yield* SemVer.fromString("2.0.0")); // -1 | ||
| satisfies(v, range); // true | ||
| pipe(v, gt(yield* parseValidSemVer("1.3.0"))); // true | ||
| bumpMinor(v).toString(); // "1.5.0" | ||
| }); | ||
@@ -57,2 +73,2 @@ | ||
| MIT | ||
| [MIT](LICENSE) |
| var __webpack_module_cache__ = {}; | ||
| function __webpack_require__(moduleId) { | ||
| var cachedModule = __webpack_module_cache__[moduleId]; | ||
| if (void 0 !== cachedModule) return cachedModule.exports; | ||
| var module = __webpack_module_cache__[moduleId] = { | ||
| exports: {} | ||
| }; | ||
| __webpack_modules__[moduleId](module, module.exports, __webpack_require__); | ||
| return module.exports; | ||
| } | ||
| (()=>{ | ||
| __webpack_require__.add = function(modules) { | ||
| Object.assign(__webpack_require__.m, modules); | ||
| }; | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.d = (exports, definition)=>{ | ||
| for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, { | ||
| enumerable: true, | ||
| get: definition[key] | ||
| }); | ||
| }; | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); | ||
| })(); | ||
| (()=>{ | ||
| __webpack_require__.r = (exports)=>{ | ||
| if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, { | ||
| value: 'Module' | ||
| }); | ||
| Object.defineProperty(exports, '__esModule', { | ||
| value: true | ||
| }); | ||
| }; | ||
| })(); | ||
| export { __webpack_require__ }; |
103113
3.34%2640
3.41%72
28.57%6
-14.29%