@agentxm/extension-model 0.28.8 → 0.28.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,22 +82,69 @@ export const parseVersionRange = (sourceString) => {
82
82
  export const isValidVersionRange = (range) => semver.validRange(range) !== null;
83
83
  /** Return one range representing the complete intersection, or undefined when unsatisfiable. */
84
84
  export const intersectVersionConstraints = (constraints) => {
85
- let intersections = [""];
85
+ // A comparator conjunction admits a prerelease when *any* comparator names
86
+ // its version tuple. Intersection instead requires *every contributor* to
87
+ // admit that tuple, so preserve this information before flattening the sets.
88
+ let intersections = [{ comparators: [], prereleaseBases: undefined }];
86
89
  for (const constraint of constraints) {
87
90
  const validRange = semver.validRange(constraint);
88
91
  if (validRange === null)
89
92
  return undefined;
90
93
  const range = new semver.Range(validRange);
91
94
  intersections = intersections.flatMap((current) => range.set.flatMap((comparators) => {
92
- const candidate = [current, ...comparators.map((comparator) => comparator.value)]
93
- .filter((part) => part.length > 0)
95
+ const combined = [...current.comparators, ...comparators];
96
+ const candidate = combined
97
+ .map((comparator) => comparator.value)
98
+ .filter((value) => value.length > 0)
94
99
  .join(" ");
95
- return semver.minVersion(candidate) === null ? [] : [candidate];
100
+ if (semver.minVersion(candidate) === null)
101
+ return [];
102
+ const bases = new Set(comparators.flatMap((comparator) => comparator.value !== "" && comparator.semver.prerelease.length > 0
103
+ ? [`${comparator.semver.major}.${comparator.semver.minor}.${comparator.semver.patch}`]
104
+ : []));
105
+ return [
106
+ {
107
+ comparators: combined,
108
+ prereleaseBases: current.prereleaseBases === undefined
109
+ ? bases
110
+ : new Set([...current.prereleaseBases].filter((base) => bases.has(base))),
111
+ },
112
+ ];
96
113
  }));
97
114
  if (intersections.length === 0)
98
115
  return undefined;
99
116
  }
100
- return intersections.join(" || ");
117
+ const ranges = intersections.flatMap(({ comparators, prereleaseBases }) => {
118
+ const original = comparators
119
+ .map((comparator) => comparator.value)
120
+ .filter((value) => value.length > 0)
121
+ .join(" ");
122
+ const stable = comparators
123
+ .map((comparator) => {
124
+ if (comparator.value === "" || comparator.semver.prerelease.length === 0)
125
+ return comparator.value;
126
+ const base = `${comparator.semver.major}.${comparator.semver.minor}.${comparator.semver.patch}`;
127
+ switch (comparator.operator) {
128
+ case ">":
129
+ case ">=":
130
+ return `>=${base}`;
131
+ case "<":
132
+ case "<=":
133
+ return `<${base}`;
134
+ // An exact prerelease admits no stable version.
135
+ default:
136
+ return "<0.0.0-0";
137
+ }
138
+ })
139
+ .filter((value) => value.length > 0)
140
+ .join(" ") || "*";
141
+ const candidates = [
142
+ stable,
143
+ ...[...(prereleaseBases ?? [])].map((base) => `${original} >=${base}-0 <${base}`),
144
+ ];
145
+ return candidates.filter((candidate) => semver.minVersion(candidate) !== null);
146
+ });
147
+ return ranges.length === 0 ? undefined : [...new Set(ranges)].join(" || ");
101
148
  };
102
149
  /**
103
150
  * Check whether moving from `previousVersion` to `currentVersion` includes at
package/package.json CHANGED
@@ -333,5 +333,5 @@
333
333
  },
334
334
  "sideEffects": false,
335
335
  "type": "module",
336
- "version": "0.28.8"
336
+ "version": "0.28.10"
337
337
  }