@shellraining/dsh-plugin-updates 0.0.0-stage → 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +40 -2
- package/cordis.patch.yml +4 -0
- package/lib/client.js +2030 -0
- package/lib/index.js +10 -0
- package/package.json +61 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,2030 @@
|
|
|
1
|
+
// Generated by `pnpm run build`; edit src/, not this file.
|
|
2
|
+
window.__ModuleLoader__.load({
|
|
3
|
+
id: "@shellraining/dsh-plugin-updates",
|
|
4
|
+
factory: (require) => {
|
|
5
|
+
var module = { exports: {} };
|
|
6
|
+
var exports = module.exports;
|
|
7
|
+
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name2 in all)
|
|
23
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
32
|
+
};
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
39
|
+
mod
|
|
40
|
+
));
|
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
|
|
43
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
44
|
+
var require_debug = __commonJS({
|
|
45
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js"(exports, module2) {
|
|
46
|
+
"use strict";
|
|
47
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
48
|
+
};
|
|
49
|
+
module2.exports = debug;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
54
|
+
var require_constants = __commonJS({
|
|
55
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js"(exports, module2) {
|
|
56
|
+
"use strict";
|
|
57
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
58
|
+
var MAX_LENGTH = 256;
|
|
59
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
60
|
+
9007199254740991;
|
|
61
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
62
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
63
|
+
var RELEASE_TYPES = [
|
|
64
|
+
"major",
|
|
65
|
+
"premajor",
|
|
66
|
+
"minor",
|
|
67
|
+
"preminor",
|
|
68
|
+
"patch",
|
|
69
|
+
"prepatch",
|
|
70
|
+
"prerelease"
|
|
71
|
+
];
|
|
72
|
+
module2.exports = {
|
|
73
|
+
MAX_LENGTH,
|
|
74
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
75
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
76
|
+
MAX_SAFE_INTEGER,
|
|
77
|
+
RELEASE_TYPES,
|
|
78
|
+
SEMVER_SPEC_VERSION,
|
|
79
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
80
|
+
FLAG_LOOSE: 2
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
86
|
+
var require_re = __commonJS({
|
|
87
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js"(exports, module2) {
|
|
88
|
+
"use strict";
|
|
89
|
+
var {
|
|
90
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
91
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
92
|
+
MAX_LENGTH
|
|
93
|
+
} = require_constants();
|
|
94
|
+
var debug = require_debug();
|
|
95
|
+
exports = module2.exports = {};
|
|
96
|
+
var re = exports.re = [];
|
|
97
|
+
var safeRe = exports.safeRe = [];
|
|
98
|
+
var src = exports.src = [];
|
|
99
|
+
var safeSrc = exports.safeSrc = [];
|
|
100
|
+
var t = exports.t = {};
|
|
101
|
+
var R = 0;
|
|
102
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
103
|
+
var safeRegexReplacements = [
|
|
104
|
+
["\\s", 1],
|
|
105
|
+
["\\d", MAX_LENGTH],
|
|
106
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
107
|
+
];
|
|
108
|
+
var makeSafeRegex = (value) => {
|
|
109
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
110
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
};
|
|
114
|
+
var createToken = (name2, value, isGlobal) => {
|
|
115
|
+
const safe = makeSafeRegex(value);
|
|
116
|
+
const index = R++;
|
|
117
|
+
debug(name2, index, value);
|
|
118
|
+
t[name2] = index;
|
|
119
|
+
src[index] = value;
|
|
120
|
+
safeSrc[index] = safe;
|
|
121
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
122
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
123
|
+
};
|
|
124
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
125
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
126
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
127
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
128
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
129
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
130
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
131
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
132
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
133
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
134
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
135
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
136
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
137
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
138
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
139
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
140
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
141
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
142
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
143
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
144
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
145
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
146
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
147
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
148
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
149
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
150
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
151
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
152
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
153
|
+
exports.tildeTrimReplace = "$1~";
|
|
154
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
155
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
156
|
+
createToken("LONECARET", "(?:\\^)");
|
|
157
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
158
|
+
exports.caretTrimReplace = "$1^";
|
|
159
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
160
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
161
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
162
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
163
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
164
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
165
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
166
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
167
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
168
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
169
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
174
|
+
var require_parse_options = __commonJS({
|
|
175
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js"(exports, module2) {
|
|
176
|
+
"use strict";
|
|
177
|
+
var looseOption = Object.freeze({ loose: true });
|
|
178
|
+
var emptyOpts = Object.freeze({});
|
|
179
|
+
var parseOptions = (options) => {
|
|
180
|
+
if (!options) {
|
|
181
|
+
return emptyOpts;
|
|
182
|
+
}
|
|
183
|
+
if (typeof options !== "object") {
|
|
184
|
+
return looseOption;
|
|
185
|
+
}
|
|
186
|
+
return options;
|
|
187
|
+
};
|
|
188
|
+
module2.exports = parseOptions;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
|
|
193
|
+
var require_identifiers = __commonJS({
|
|
194
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js"(exports, module2) {
|
|
195
|
+
"use strict";
|
|
196
|
+
var numeric = /^[0-9]+$/;
|
|
197
|
+
var compareIdentifiers = (a, b) => {
|
|
198
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
199
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
200
|
+
}
|
|
201
|
+
const anum = numeric.test(a);
|
|
202
|
+
const bnum = numeric.test(b);
|
|
203
|
+
if (anum && bnum) {
|
|
204
|
+
a = +a;
|
|
205
|
+
b = +b;
|
|
206
|
+
}
|
|
207
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
208
|
+
};
|
|
209
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
210
|
+
module2.exports = {
|
|
211
|
+
compareIdentifiers,
|
|
212
|
+
rcompareIdentifiers
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
|
|
218
|
+
var require_semver = __commonJS({
|
|
219
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js"(exports, module2) {
|
|
220
|
+
"use strict";
|
|
221
|
+
var debug = require_debug();
|
|
222
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
223
|
+
var { safeRe: re, t } = require_re();
|
|
224
|
+
var parseOptions = require_parse_options();
|
|
225
|
+
var { compareIdentifiers } = require_identifiers();
|
|
226
|
+
var isPrereleaseIdentifier = (prerelease2, identifier) => {
|
|
227
|
+
const identifiers = identifier.split(".");
|
|
228
|
+
if (identifiers.length > prerelease2.length) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
for (let i = 0; i < identifiers.length; i++) {
|
|
232
|
+
if (compareIdentifiers(prerelease2[i], identifiers[i]) !== 0) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return true;
|
|
237
|
+
};
|
|
238
|
+
var SemVer = class _SemVer {
|
|
239
|
+
constructor(version, options) {
|
|
240
|
+
options = parseOptions(options);
|
|
241
|
+
if (version instanceof _SemVer) {
|
|
242
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
243
|
+
return version;
|
|
244
|
+
} else {
|
|
245
|
+
version = version.version;
|
|
246
|
+
}
|
|
247
|
+
} else if (typeof version !== "string") {
|
|
248
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
249
|
+
}
|
|
250
|
+
if (version.length > MAX_LENGTH) {
|
|
251
|
+
throw new TypeError(
|
|
252
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
debug("SemVer", version, options);
|
|
256
|
+
this.options = options;
|
|
257
|
+
this.loose = !!options.loose;
|
|
258
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
259
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
260
|
+
if (!m) {
|
|
261
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
262
|
+
}
|
|
263
|
+
this.raw = version;
|
|
264
|
+
this.major = +m[1];
|
|
265
|
+
this.minor = +m[2];
|
|
266
|
+
this.patch = +m[3];
|
|
267
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
268
|
+
throw new TypeError("Invalid major version");
|
|
269
|
+
}
|
|
270
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
271
|
+
throw new TypeError("Invalid minor version");
|
|
272
|
+
}
|
|
273
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
274
|
+
throw new TypeError("Invalid patch version");
|
|
275
|
+
}
|
|
276
|
+
if (!m[4]) {
|
|
277
|
+
this.prerelease = [];
|
|
278
|
+
} else {
|
|
279
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
280
|
+
if (/^[0-9]+$/.test(id)) {
|
|
281
|
+
const num = +id;
|
|
282
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
283
|
+
return num;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return id;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
290
|
+
this.format();
|
|
291
|
+
}
|
|
292
|
+
format() {
|
|
293
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
294
|
+
if (this.prerelease.length) {
|
|
295
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
296
|
+
}
|
|
297
|
+
return this.version;
|
|
298
|
+
}
|
|
299
|
+
toString() {
|
|
300
|
+
return this.version;
|
|
301
|
+
}
|
|
302
|
+
compare(other) {
|
|
303
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
304
|
+
if (!(other instanceof _SemVer)) {
|
|
305
|
+
if (typeof other === "string" && other === this.version) {
|
|
306
|
+
return 0;
|
|
307
|
+
}
|
|
308
|
+
other = new _SemVer(other, this.options);
|
|
309
|
+
}
|
|
310
|
+
if (other.version === this.version) {
|
|
311
|
+
return 0;
|
|
312
|
+
}
|
|
313
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
314
|
+
}
|
|
315
|
+
compareMain(other) {
|
|
316
|
+
if (!(other instanceof _SemVer)) {
|
|
317
|
+
other = new _SemVer(other, this.options);
|
|
318
|
+
}
|
|
319
|
+
if (this.major < other.major) {
|
|
320
|
+
return -1;
|
|
321
|
+
}
|
|
322
|
+
if (this.major > other.major) {
|
|
323
|
+
return 1;
|
|
324
|
+
}
|
|
325
|
+
if (this.minor < other.minor) {
|
|
326
|
+
return -1;
|
|
327
|
+
}
|
|
328
|
+
if (this.minor > other.minor) {
|
|
329
|
+
return 1;
|
|
330
|
+
}
|
|
331
|
+
if (this.patch < other.patch) {
|
|
332
|
+
return -1;
|
|
333
|
+
}
|
|
334
|
+
if (this.patch > other.patch) {
|
|
335
|
+
return 1;
|
|
336
|
+
}
|
|
337
|
+
return 0;
|
|
338
|
+
}
|
|
339
|
+
comparePre(other) {
|
|
340
|
+
if (!(other instanceof _SemVer)) {
|
|
341
|
+
other = new _SemVer(other, this.options);
|
|
342
|
+
}
|
|
343
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
344
|
+
return -1;
|
|
345
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
346
|
+
return 1;
|
|
347
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
348
|
+
return 0;
|
|
349
|
+
}
|
|
350
|
+
let i = 0;
|
|
351
|
+
do {
|
|
352
|
+
const a = this.prerelease[i];
|
|
353
|
+
const b = other.prerelease[i];
|
|
354
|
+
debug("prerelease compare", i, a, b);
|
|
355
|
+
if (a === void 0 && b === void 0) {
|
|
356
|
+
return 0;
|
|
357
|
+
} else if (b === void 0) {
|
|
358
|
+
return 1;
|
|
359
|
+
} else if (a === void 0) {
|
|
360
|
+
return -1;
|
|
361
|
+
} else if (a === b) {
|
|
362
|
+
continue;
|
|
363
|
+
} else {
|
|
364
|
+
return compareIdentifiers(a, b);
|
|
365
|
+
}
|
|
366
|
+
} while (++i);
|
|
367
|
+
}
|
|
368
|
+
compareBuild(other) {
|
|
369
|
+
if (!(other instanceof _SemVer)) {
|
|
370
|
+
other = new _SemVer(other, this.options);
|
|
371
|
+
}
|
|
372
|
+
let i = 0;
|
|
373
|
+
do {
|
|
374
|
+
const a = this.build[i];
|
|
375
|
+
const b = other.build[i];
|
|
376
|
+
debug("build compare", i, a, b);
|
|
377
|
+
if (a === void 0 && b === void 0) {
|
|
378
|
+
return 0;
|
|
379
|
+
} else if (b === void 0) {
|
|
380
|
+
return 1;
|
|
381
|
+
} else if (a === void 0) {
|
|
382
|
+
return -1;
|
|
383
|
+
} else if (a === b) {
|
|
384
|
+
continue;
|
|
385
|
+
} else {
|
|
386
|
+
return compareIdentifiers(a, b);
|
|
387
|
+
}
|
|
388
|
+
} while (++i);
|
|
389
|
+
}
|
|
390
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
391
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
392
|
+
inc(release, identifier, identifierBase) {
|
|
393
|
+
if (release.startsWith("pre")) {
|
|
394
|
+
if (!identifier && identifierBase === false) {
|
|
395
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
396
|
+
}
|
|
397
|
+
if (identifier) {
|
|
398
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
399
|
+
if (!match || match[1] !== identifier) {
|
|
400
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
switch (release) {
|
|
405
|
+
case "premajor":
|
|
406
|
+
this.prerelease.length = 0;
|
|
407
|
+
this.patch = 0;
|
|
408
|
+
this.minor = 0;
|
|
409
|
+
this.major++;
|
|
410
|
+
this.inc("pre", identifier, identifierBase);
|
|
411
|
+
break;
|
|
412
|
+
case "preminor":
|
|
413
|
+
this.prerelease.length = 0;
|
|
414
|
+
this.patch = 0;
|
|
415
|
+
this.minor++;
|
|
416
|
+
this.inc("pre", identifier, identifierBase);
|
|
417
|
+
break;
|
|
418
|
+
case "prepatch":
|
|
419
|
+
this.prerelease.length = 0;
|
|
420
|
+
this.inc("patch", identifier, identifierBase);
|
|
421
|
+
this.inc("pre", identifier, identifierBase);
|
|
422
|
+
break;
|
|
423
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
424
|
+
// prepatch.
|
|
425
|
+
case "prerelease":
|
|
426
|
+
if (this.prerelease.length === 0) {
|
|
427
|
+
this.inc("patch", identifier, identifierBase);
|
|
428
|
+
}
|
|
429
|
+
this.inc("pre", identifier, identifierBase);
|
|
430
|
+
break;
|
|
431
|
+
case "release":
|
|
432
|
+
if (this.prerelease.length === 0) {
|
|
433
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
434
|
+
}
|
|
435
|
+
this.prerelease.length = 0;
|
|
436
|
+
break;
|
|
437
|
+
case "major":
|
|
438
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
439
|
+
this.major++;
|
|
440
|
+
}
|
|
441
|
+
this.minor = 0;
|
|
442
|
+
this.patch = 0;
|
|
443
|
+
this.prerelease = [];
|
|
444
|
+
break;
|
|
445
|
+
case "minor":
|
|
446
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
447
|
+
this.minor++;
|
|
448
|
+
}
|
|
449
|
+
this.patch = 0;
|
|
450
|
+
this.prerelease = [];
|
|
451
|
+
break;
|
|
452
|
+
case "patch":
|
|
453
|
+
if (this.prerelease.length === 0) {
|
|
454
|
+
this.patch++;
|
|
455
|
+
}
|
|
456
|
+
this.prerelease = [];
|
|
457
|
+
break;
|
|
458
|
+
// This probably shouldn't be used publicly.
|
|
459
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
460
|
+
case "pre": {
|
|
461
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
462
|
+
if (this.prerelease.length === 0) {
|
|
463
|
+
this.prerelease = [base];
|
|
464
|
+
} else {
|
|
465
|
+
let i = this.prerelease.length;
|
|
466
|
+
while (--i >= 0) {
|
|
467
|
+
if (typeof this.prerelease[i] === "number") {
|
|
468
|
+
this.prerelease[i]++;
|
|
469
|
+
i = -2;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (i === -1) {
|
|
473
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
474
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
475
|
+
}
|
|
476
|
+
this.prerelease.push(base);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (identifier) {
|
|
480
|
+
let prerelease2 = [identifier, base];
|
|
481
|
+
if (identifierBase === false) {
|
|
482
|
+
prerelease2 = [identifier];
|
|
483
|
+
}
|
|
484
|
+
if (isPrereleaseIdentifier(this.prerelease, identifier)) {
|
|
485
|
+
const prereleaseBase = this.prerelease[identifier.split(".").length];
|
|
486
|
+
if (isNaN(prereleaseBase)) {
|
|
487
|
+
this.prerelease = prerelease2;
|
|
488
|
+
}
|
|
489
|
+
} else {
|
|
490
|
+
this.prerelease = prerelease2;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
default:
|
|
496
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
497
|
+
}
|
|
498
|
+
this.raw = this.format();
|
|
499
|
+
if (this.build.length) {
|
|
500
|
+
this.raw += `+${this.build.join(".")}`;
|
|
501
|
+
}
|
|
502
|
+
return this;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
module2.exports = SemVer;
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
|
|
510
|
+
var require_compare = __commonJS({
|
|
511
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js"(exports, module2) {
|
|
512
|
+
"use strict";
|
|
513
|
+
var SemVer = require_semver();
|
|
514
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
515
|
+
module2.exports = compare;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
|
|
520
|
+
var require_gt = __commonJS({
|
|
521
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js"(exports, module2) {
|
|
522
|
+
"use strict";
|
|
523
|
+
var compare = require_compare();
|
|
524
|
+
var gt2 = (a, b, loose) => compare(a, b, loose) > 0;
|
|
525
|
+
module2.exports = gt2;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
|
|
530
|
+
var require_parse = __commonJS({
|
|
531
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js"(exports, module2) {
|
|
532
|
+
"use strict";
|
|
533
|
+
var SemVer = require_semver();
|
|
534
|
+
var parse = (version, options, throwErrors = false) => {
|
|
535
|
+
if (version instanceof SemVer) {
|
|
536
|
+
return version;
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
return new SemVer(version, options);
|
|
540
|
+
} catch (er) {
|
|
541
|
+
if (!throwErrors) {
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
throw er;
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
module2.exports = parse;
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js
|
|
552
|
+
var require_prerelease = __commonJS({
|
|
553
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js"(exports, module2) {
|
|
554
|
+
"use strict";
|
|
555
|
+
var parse = require_parse();
|
|
556
|
+
var prerelease2 = (version, options) => {
|
|
557
|
+
const parsed = parse(version, options);
|
|
558
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
559
|
+
};
|
|
560
|
+
module2.exports = prerelease2;
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js
|
|
565
|
+
var require_rcompare = __commonJS({
|
|
566
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js"(exports, module2) {
|
|
567
|
+
"use strict";
|
|
568
|
+
var compare = require_compare();
|
|
569
|
+
var rcompare2 = (a, b, loose) => compare(b, a, loose);
|
|
570
|
+
module2.exports = rcompare2;
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
|
|
575
|
+
var require_lrucache = __commonJS({
|
|
576
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js"(exports, module2) {
|
|
577
|
+
"use strict";
|
|
578
|
+
var LRUCache = class {
|
|
579
|
+
constructor() {
|
|
580
|
+
this.max = 1e3;
|
|
581
|
+
this.map = /* @__PURE__ */ new Map();
|
|
582
|
+
}
|
|
583
|
+
get(key) {
|
|
584
|
+
const value = this.map.get(key);
|
|
585
|
+
if (value === void 0) {
|
|
586
|
+
return void 0;
|
|
587
|
+
} else {
|
|
588
|
+
this.map.delete(key);
|
|
589
|
+
this.map.set(key, value);
|
|
590
|
+
return value;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
delete(key) {
|
|
594
|
+
return this.map.delete(key);
|
|
595
|
+
}
|
|
596
|
+
set(key, value) {
|
|
597
|
+
const deleted = this.delete(key);
|
|
598
|
+
if (!deleted && value !== void 0) {
|
|
599
|
+
if (this.map.size >= this.max) {
|
|
600
|
+
const firstKey = this.map.keys().next().value;
|
|
601
|
+
this.delete(firstKey);
|
|
602
|
+
}
|
|
603
|
+
this.map.set(key, value);
|
|
604
|
+
}
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
module2.exports = LRUCache;
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
|
|
613
|
+
var require_eq = __commonJS({
|
|
614
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js"(exports, module2) {
|
|
615
|
+
"use strict";
|
|
616
|
+
var compare = require_compare();
|
|
617
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
618
|
+
module2.exports = eq;
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
|
|
623
|
+
var require_neq = __commonJS({
|
|
624
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js"(exports, module2) {
|
|
625
|
+
"use strict";
|
|
626
|
+
var compare = require_compare();
|
|
627
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
628
|
+
module2.exports = neq;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
|
|
633
|
+
var require_gte = __commonJS({
|
|
634
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js"(exports, module2) {
|
|
635
|
+
"use strict";
|
|
636
|
+
var compare = require_compare();
|
|
637
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
638
|
+
module2.exports = gte;
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
|
|
643
|
+
var require_lt = __commonJS({
|
|
644
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js"(exports, module2) {
|
|
645
|
+
"use strict";
|
|
646
|
+
var compare = require_compare();
|
|
647
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
648
|
+
module2.exports = lt;
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
|
|
653
|
+
var require_lte = __commonJS({
|
|
654
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js"(exports, module2) {
|
|
655
|
+
"use strict";
|
|
656
|
+
var compare = require_compare();
|
|
657
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
658
|
+
module2.exports = lte;
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
|
|
663
|
+
var require_cmp = __commonJS({
|
|
664
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js"(exports, module2) {
|
|
665
|
+
"use strict";
|
|
666
|
+
var eq = require_eq();
|
|
667
|
+
var neq = require_neq();
|
|
668
|
+
var gt2 = require_gt();
|
|
669
|
+
var gte = require_gte();
|
|
670
|
+
var lt = require_lt();
|
|
671
|
+
var lte = require_lte();
|
|
672
|
+
var cmp = (a, op, b, loose) => {
|
|
673
|
+
switch (op) {
|
|
674
|
+
case "===":
|
|
675
|
+
if (typeof a === "object") {
|
|
676
|
+
a = a.version;
|
|
677
|
+
}
|
|
678
|
+
if (typeof b === "object") {
|
|
679
|
+
b = b.version;
|
|
680
|
+
}
|
|
681
|
+
return a === b;
|
|
682
|
+
case "!==":
|
|
683
|
+
if (typeof a === "object") {
|
|
684
|
+
a = a.version;
|
|
685
|
+
}
|
|
686
|
+
if (typeof b === "object") {
|
|
687
|
+
b = b.version;
|
|
688
|
+
}
|
|
689
|
+
return a !== b;
|
|
690
|
+
case "":
|
|
691
|
+
case "=":
|
|
692
|
+
case "==":
|
|
693
|
+
return eq(a, b, loose);
|
|
694
|
+
case "!=":
|
|
695
|
+
return neq(a, b, loose);
|
|
696
|
+
case ">":
|
|
697
|
+
return gt2(a, b, loose);
|
|
698
|
+
case ">=":
|
|
699
|
+
return gte(a, b, loose);
|
|
700
|
+
case "<":
|
|
701
|
+
return lt(a, b, loose);
|
|
702
|
+
case "<=":
|
|
703
|
+
return lte(a, b, loose);
|
|
704
|
+
default:
|
|
705
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
module2.exports = cmp;
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
|
|
713
|
+
var require_comparator = __commonJS({
|
|
714
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js"(exports, module2) {
|
|
715
|
+
"use strict";
|
|
716
|
+
var ANY = /* @__PURE__ */ Symbol("SemVer ANY");
|
|
717
|
+
var Comparator = class _Comparator {
|
|
718
|
+
static get ANY() {
|
|
719
|
+
return ANY;
|
|
720
|
+
}
|
|
721
|
+
constructor(comp, options) {
|
|
722
|
+
options = parseOptions(options);
|
|
723
|
+
if (comp instanceof _Comparator) {
|
|
724
|
+
if (comp.loose === !!options.loose) {
|
|
725
|
+
return comp;
|
|
726
|
+
} else {
|
|
727
|
+
comp = comp.value;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
731
|
+
debug("comparator", comp, options);
|
|
732
|
+
this.options = options;
|
|
733
|
+
this.loose = !!options.loose;
|
|
734
|
+
this.parse(comp);
|
|
735
|
+
if (this.semver === ANY) {
|
|
736
|
+
this.value = "";
|
|
737
|
+
} else {
|
|
738
|
+
this.value = this.operator + this.semver.version;
|
|
739
|
+
}
|
|
740
|
+
debug("comp", this);
|
|
741
|
+
}
|
|
742
|
+
parse(comp) {
|
|
743
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
744
|
+
const m = comp.match(r);
|
|
745
|
+
if (!m) {
|
|
746
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
747
|
+
}
|
|
748
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
749
|
+
if (this.operator === "=") {
|
|
750
|
+
this.operator = "";
|
|
751
|
+
}
|
|
752
|
+
if (!m[2]) {
|
|
753
|
+
this.semver = ANY;
|
|
754
|
+
} else {
|
|
755
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
toString() {
|
|
759
|
+
return this.value;
|
|
760
|
+
}
|
|
761
|
+
test(version) {
|
|
762
|
+
debug("Comparator.test", version, this.options.loose);
|
|
763
|
+
if (this.semver === ANY || version === ANY) {
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
if (typeof version === "string") {
|
|
767
|
+
try {
|
|
768
|
+
version = new SemVer(version, this.options);
|
|
769
|
+
} catch (er) {
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
774
|
+
}
|
|
775
|
+
intersects(comp, options) {
|
|
776
|
+
if (!(comp instanceof _Comparator)) {
|
|
777
|
+
throw new TypeError("a Comparator is required");
|
|
778
|
+
}
|
|
779
|
+
if (this.operator === "") {
|
|
780
|
+
if (this.value === "") {
|
|
781
|
+
return true;
|
|
782
|
+
}
|
|
783
|
+
return new Range(comp.value, options).test(this.value);
|
|
784
|
+
} else if (comp.operator === "") {
|
|
785
|
+
if (comp.value === "") {
|
|
786
|
+
return true;
|
|
787
|
+
}
|
|
788
|
+
return new Range(this.value, options).test(comp.semver);
|
|
789
|
+
}
|
|
790
|
+
options = parseOptions(options);
|
|
791
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
800
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
806
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
module2.exports = Comparator;
|
|
816
|
+
var parseOptions = require_parse_options();
|
|
817
|
+
var { safeRe: re, t } = require_re();
|
|
818
|
+
var cmp = require_cmp();
|
|
819
|
+
var debug = require_debug();
|
|
820
|
+
var SemVer = require_semver();
|
|
821
|
+
var Range = require_range();
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
|
|
826
|
+
var require_range = __commonJS({
|
|
827
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js"(exports, module2) {
|
|
828
|
+
"use strict";
|
|
829
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
830
|
+
var Range = class _Range {
|
|
831
|
+
constructor(range, options) {
|
|
832
|
+
options = parseOptions(options);
|
|
833
|
+
if (range instanceof _Range) {
|
|
834
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
835
|
+
return range;
|
|
836
|
+
} else {
|
|
837
|
+
return new _Range(range.raw, options);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (range instanceof Comparator) {
|
|
841
|
+
this.raw = range.value;
|
|
842
|
+
this.set = [[range]];
|
|
843
|
+
this.formatted = void 0;
|
|
844
|
+
return this;
|
|
845
|
+
}
|
|
846
|
+
this.options = options;
|
|
847
|
+
this.loose = !!options.loose;
|
|
848
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
849
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
850
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
851
|
+
if (!this.set.length) {
|
|
852
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
853
|
+
}
|
|
854
|
+
if (this.set.length > 1) {
|
|
855
|
+
const first = this.set[0];
|
|
856
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
857
|
+
if (this.set.length === 0) {
|
|
858
|
+
this.set = [first];
|
|
859
|
+
} else if (this.set.length > 1) {
|
|
860
|
+
for (const c of this.set) {
|
|
861
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
862
|
+
this.set = [c];
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
this.formatted = void 0;
|
|
869
|
+
}
|
|
870
|
+
get range() {
|
|
871
|
+
if (this.formatted === void 0) {
|
|
872
|
+
this.formatted = "";
|
|
873
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
874
|
+
if (i > 0) {
|
|
875
|
+
this.formatted += "||";
|
|
876
|
+
}
|
|
877
|
+
const comps = this.set[i];
|
|
878
|
+
for (let k = 0; k < comps.length; k++) {
|
|
879
|
+
if (k > 0) {
|
|
880
|
+
this.formatted += " ";
|
|
881
|
+
}
|
|
882
|
+
this.formatted += comps[k].toString().trim();
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return this.formatted;
|
|
887
|
+
}
|
|
888
|
+
format() {
|
|
889
|
+
return this.range;
|
|
890
|
+
}
|
|
891
|
+
toString() {
|
|
892
|
+
return this.range;
|
|
893
|
+
}
|
|
894
|
+
parseRange(range) {
|
|
895
|
+
range = range.replace(BUILDSTRIPRE, "");
|
|
896
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
897
|
+
const memoKey = memoOpts + ":" + range;
|
|
898
|
+
const cached = cache.get(memoKey);
|
|
899
|
+
if (cached) {
|
|
900
|
+
return cached;
|
|
901
|
+
}
|
|
902
|
+
const loose = this.options.loose;
|
|
903
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
904
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
905
|
+
debug("hyphen replace", range);
|
|
906
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
907
|
+
debug("comparator trim", range);
|
|
908
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
909
|
+
debug("tilde trim", range);
|
|
910
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
911
|
+
debug("caret trim", range);
|
|
912
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
913
|
+
if (loose) {
|
|
914
|
+
rangeList = rangeList.filter((comp) => {
|
|
915
|
+
debug("loose invalid filter", comp, this.options);
|
|
916
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
debug("range list", rangeList);
|
|
920
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
921
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
922
|
+
for (const comp of comparators) {
|
|
923
|
+
if (isNullSet(comp)) {
|
|
924
|
+
return [comp];
|
|
925
|
+
}
|
|
926
|
+
rangeMap.set(comp.value, comp);
|
|
927
|
+
}
|
|
928
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
929
|
+
rangeMap.delete("");
|
|
930
|
+
}
|
|
931
|
+
const result = [...rangeMap.values()];
|
|
932
|
+
cache.set(memoKey, result);
|
|
933
|
+
return result;
|
|
934
|
+
}
|
|
935
|
+
intersects(range, options) {
|
|
936
|
+
if (!(range instanceof _Range)) {
|
|
937
|
+
throw new TypeError("a Range is required");
|
|
938
|
+
}
|
|
939
|
+
return this.set.some((thisComparators) => {
|
|
940
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
941
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
942
|
+
return rangeComparators.every((rangeComparator) => {
|
|
943
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
944
|
+
});
|
|
945
|
+
});
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
950
|
+
test(version) {
|
|
951
|
+
if (!version) {
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
if (typeof version === "string") {
|
|
955
|
+
try {
|
|
956
|
+
version = new SemVer(version, this.options);
|
|
957
|
+
} catch (er) {
|
|
958
|
+
return false;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
962
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
963
|
+
return true;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return false;
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
module2.exports = Range;
|
|
970
|
+
var LRU = require_lrucache();
|
|
971
|
+
var cache = new LRU();
|
|
972
|
+
var parseOptions = require_parse_options();
|
|
973
|
+
var Comparator = require_comparator();
|
|
974
|
+
var debug = require_debug();
|
|
975
|
+
var SemVer = require_semver();
|
|
976
|
+
var {
|
|
977
|
+
safeRe: re,
|
|
978
|
+
src,
|
|
979
|
+
t,
|
|
980
|
+
comparatorTrimReplace,
|
|
981
|
+
tildeTrimReplace,
|
|
982
|
+
caretTrimReplace
|
|
983
|
+
} = require_re();
|
|
984
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
985
|
+
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
|
986
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
987
|
+
var isAny = (c) => c.value === "";
|
|
988
|
+
var isSatisfiable = (comparators, options) => {
|
|
989
|
+
let result = true;
|
|
990
|
+
const remainingComparators = comparators.slice();
|
|
991
|
+
let testComparator = remainingComparators.pop();
|
|
992
|
+
while (result && remainingComparators.length) {
|
|
993
|
+
result = remainingComparators.every((otherComparator) => {
|
|
994
|
+
return testComparator.intersects(otherComparator, options);
|
|
995
|
+
});
|
|
996
|
+
testComparator = remainingComparators.pop();
|
|
997
|
+
}
|
|
998
|
+
return result;
|
|
999
|
+
};
|
|
1000
|
+
var parseComparator = (comp, options) => {
|
|
1001
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1002
|
+
debug("comp", comp, options);
|
|
1003
|
+
comp = replaceCarets(comp, options);
|
|
1004
|
+
debug("caret", comp);
|
|
1005
|
+
comp = replaceTildes(comp, options);
|
|
1006
|
+
debug("tildes", comp);
|
|
1007
|
+
comp = replaceXRanges(comp, options);
|
|
1008
|
+
debug("xrange", comp);
|
|
1009
|
+
comp = replaceStars(comp, options);
|
|
1010
|
+
debug("stars", comp);
|
|
1011
|
+
return comp;
|
|
1012
|
+
};
|
|
1013
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1014
|
+
var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
1015
|
+
var replaceTildes = (comp, options) => {
|
|
1016
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1017
|
+
};
|
|
1018
|
+
var replaceTilde = (comp, options) => {
|
|
1019
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1020
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1021
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1022
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1023
|
+
let ret;
|
|
1024
|
+
if (isX(M)) {
|
|
1025
|
+
ret = "";
|
|
1026
|
+
} else if (isX(m)) {
|
|
1027
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1028
|
+
} else if (isX(p)) {
|
|
1029
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1030
|
+
} else if (pr) {
|
|
1031
|
+
debug("replaceTilde pr", pr);
|
|
1032
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1033
|
+
} else {
|
|
1034
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1035
|
+
}
|
|
1036
|
+
debug("tilde return", ret);
|
|
1037
|
+
return ret;
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
var replaceCarets = (comp, options) => {
|
|
1041
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1042
|
+
};
|
|
1043
|
+
var replaceCaret = (comp, options) => {
|
|
1044
|
+
debug("caret", comp, options);
|
|
1045
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1046
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
1047
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1048
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1049
|
+
let ret;
|
|
1050
|
+
if (isX(M)) {
|
|
1051
|
+
ret = "";
|
|
1052
|
+
} else if (isX(m)) {
|
|
1053
|
+
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
1054
|
+
} else if (isX(p)) {
|
|
1055
|
+
if (M === "0") {
|
|
1056
|
+
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
1057
|
+
} else {
|
|
1058
|
+
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
|
|
1059
|
+
}
|
|
1060
|
+
} else if (pr) {
|
|
1061
|
+
debug("replaceCaret pr", pr);
|
|
1062
|
+
if (M === "0") {
|
|
1063
|
+
if (m === "0") {
|
|
1064
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1065
|
+
} else {
|
|
1066
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1067
|
+
}
|
|
1068
|
+
} else {
|
|
1069
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1070
|
+
}
|
|
1071
|
+
} else {
|
|
1072
|
+
debug("no pr");
|
|
1073
|
+
if (M === "0") {
|
|
1074
|
+
if (m === "0") {
|
|
1075
|
+
ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
1076
|
+
} else {
|
|
1077
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1078
|
+
}
|
|
1079
|
+
} else {
|
|
1080
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
debug("caret return", ret);
|
|
1084
|
+
return ret;
|
|
1085
|
+
});
|
|
1086
|
+
};
|
|
1087
|
+
var replaceXRanges = (comp, options) => {
|
|
1088
|
+
debug("replaceXRanges", comp, options);
|
|
1089
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1090
|
+
};
|
|
1091
|
+
var replaceXRange = (comp, options) => {
|
|
1092
|
+
comp = comp.trim();
|
|
1093
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1094
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1095
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1096
|
+
if (invalidXRangeOrder(M, m, p)) {
|
|
1097
|
+
return comp;
|
|
1098
|
+
}
|
|
1099
|
+
const xM = isX(M);
|
|
1100
|
+
const xm = xM || isX(m);
|
|
1101
|
+
const xp = xm || isX(p);
|
|
1102
|
+
const anyX = xp;
|
|
1103
|
+
if (gtlt === "=" && anyX) {
|
|
1104
|
+
gtlt = "";
|
|
1105
|
+
}
|
|
1106
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1107
|
+
if (xM) {
|
|
1108
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
1109
|
+
ret = "<0.0.0-0";
|
|
1110
|
+
} else {
|
|
1111
|
+
ret = "*";
|
|
1112
|
+
}
|
|
1113
|
+
} else if (gtlt && anyX) {
|
|
1114
|
+
if (xm) {
|
|
1115
|
+
m = 0;
|
|
1116
|
+
}
|
|
1117
|
+
p = 0;
|
|
1118
|
+
if (gtlt === ">") {
|
|
1119
|
+
gtlt = ">=";
|
|
1120
|
+
if (xm) {
|
|
1121
|
+
M = +M + 1;
|
|
1122
|
+
m = 0;
|
|
1123
|
+
p = 0;
|
|
1124
|
+
} else {
|
|
1125
|
+
m = +m + 1;
|
|
1126
|
+
p = 0;
|
|
1127
|
+
}
|
|
1128
|
+
} else if (gtlt === "<=") {
|
|
1129
|
+
gtlt = "<";
|
|
1130
|
+
if (xm) {
|
|
1131
|
+
M = +M + 1;
|
|
1132
|
+
} else {
|
|
1133
|
+
m = +m + 1;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
if (gtlt === "<") {
|
|
1137
|
+
pr = "-0";
|
|
1138
|
+
}
|
|
1139
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1140
|
+
} else if (xm) {
|
|
1141
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1142
|
+
} else if (xp) {
|
|
1143
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1144
|
+
}
|
|
1145
|
+
debug("xRange return", ret);
|
|
1146
|
+
return ret;
|
|
1147
|
+
});
|
|
1148
|
+
};
|
|
1149
|
+
var replaceStars = (comp, options) => {
|
|
1150
|
+
debug("replaceStars", comp, options);
|
|
1151
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1152
|
+
};
|
|
1153
|
+
var replaceGTE0 = (comp, options) => {
|
|
1154
|
+
debug("replaceGTE0", comp, options);
|
|
1155
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1156
|
+
};
|
|
1157
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1158
|
+
if (isX(fM)) {
|
|
1159
|
+
from = "";
|
|
1160
|
+
} else if (isX(fm)) {
|
|
1161
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1162
|
+
} else if (isX(fp)) {
|
|
1163
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1164
|
+
} else if (fpr) {
|
|
1165
|
+
from = `>=${from}`;
|
|
1166
|
+
} else {
|
|
1167
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1168
|
+
}
|
|
1169
|
+
if (isX(tM)) {
|
|
1170
|
+
to = "";
|
|
1171
|
+
} else if (isX(tm)) {
|
|
1172
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
1173
|
+
} else if (isX(tp)) {
|
|
1174
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
1175
|
+
} else if (tpr) {
|
|
1176
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1177
|
+
} else if (incPr) {
|
|
1178
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1179
|
+
} else {
|
|
1180
|
+
to = `<=${to}`;
|
|
1181
|
+
}
|
|
1182
|
+
return `${from} ${to}`.trim();
|
|
1183
|
+
};
|
|
1184
|
+
var testSet = (set, version, options) => {
|
|
1185
|
+
for (let i = 0; i < set.length; i++) {
|
|
1186
|
+
if (!set[i].test(version)) {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1191
|
+
for (let i = 0; i < set.length; i++) {
|
|
1192
|
+
debug(set[i].semver);
|
|
1193
|
+
if (set[i].semver === Comparator.ANY) {
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1197
|
+
const allowed = set[i].semver;
|
|
1198
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
1199
|
+
return true;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1205
|
+
return true;
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
|
|
1211
|
+
var require_satisfies = __commonJS({
|
|
1212
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js"(exports, module2) {
|
|
1213
|
+
"use strict";
|
|
1214
|
+
var Range = require_range();
|
|
1215
|
+
var satisfies2 = (version, range, options) => {
|
|
1216
|
+
try {
|
|
1217
|
+
range = new Range(range, options);
|
|
1218
|
+
} catch (er) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
return range.test(version);
|
|
1222
|
+
};
|
|
1223
|
+
module2.exports = satisfies2;
|
|
1224
|
+
}
|
|
1225
|
+
});
|
|
1226
|
+
|
|
1227
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
|
|
1228
|
+
var require_valid = __commonJS({
|
|
1229
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js"(exports, module2) {
|
|
1230
|
+
"use strict";
|
|
1231
|
+
var parse = require_parse();
|
|
1232
|
+
var valid2 = (version, options) => {
|
|
1233
|
+
const v = parse(version, options);
|
|
1234
|
+
return v ? v.version : null;
|
|
1235
|
+
};
|
|
1236
|
+
module2.exports = valid2;
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1240
|
+
// ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
|
|
1241
|
+
var require_valid2 = __commonJS({
|
|
1242
|
+
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js"(exports, module2) {
|
|
1243
|
+
"use strict";
|
|
1244
|
+
var Range = require_range();
|
|
1245
|
+
var validRange2 = (range, options) => {
|
|
1246
|
+
try {
|
|
1247
|
+
return new Range(range, options).range || "*";
|
|
1248
|
+
} catch (er) {
|
|
1249
|
+
return null;
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
module2.exports = validRange2;
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
// src/client/index.tsx
|
|
1257
|
+
var index_exports = {};
|
|
1258
|
+
__export(index_exports, {
|
|
1259
|
+
apply: () => apply,
|
|
1260
|
+
inject: () => inject,
|
|
1261
|
+
name: () => name
|
|
1262
|
+
});
|
|
1263
|
+
module.exports = __toCommonJS(index_exports);
|
|
1264
|
+
|
|
1265
|
+
// src/client/locale.ts
|
|
1266
|
+
var LOCALE_NS = "dshPluginUpdates";
|
|
1267
|
+
var ZH = {
|
|
1268
|
+
"tab": "\u66F4\u65B0",
|
|
1269
|
+
"summary.loading": "\u6B63\u5728\u68C0\u67E5\u66F4\u65B0\u2026",
|
|
1270
|
+
"summary.some": "{count} \u4E2A\u63D2\u4EF6\u53EF\u66F4\u65B0",
|
|
1271
|
+
"summary.none": "\u6240\u6709 npm \u63D2\u4EF6\u90FD\u5DF2\u662F\u6700\u65B0\u7248\u672C",
|
|
1272
|
+
"summary.empty": "\u6CA1\u6709\u4ECE npm \u5B89\u88C5\u7684\u63D2\u4EF6",
|
|
1273
|
+
"summary.skipped": "{count} \u4E2A\u63D2\u4EF6\u4E0D\u662F\u4ECE npm \u5B89\u88C5\u7684\uFF0C\u672A\u68C0\u67E5",
|
|
1274
|
+
"refresh": "\u68C0\u67E5\u66F4\u65B0",
|
|
1275
|
+
"updateAll": "\u5168\u90E8\u66F4\u65B0",
|
|
1276
|
+
"updateAllCount": "\u5168\u90E8\u66F4\u65B0\uFF08{count}\uFF09",
|
|
1277
|
+
"updateLabel": "\u628A {name} \u66F4\u65B0\u5230 {version}",
|
|
1278
|
+
"updating": "\u66F4\u65B0\u4E2D\u2026",
|
|
1279
|
+
"update": "\u66F4\u65B0",
|
|
1280
|
+
"updateTo": "\u66F4\u65B0\u5230 {version}",
|
|
1281
|
+
"install": "\u5B89\u88C5",
|
|
1282
|
+
"details": "\u8BE6\u60C5",
|
|
1283
|
+
"loadFailed": "\u8BFB\u53D6\u63D2\u4EF6\u5217\u8868\u5931\u8D25\uFF1A{reason}",
|
|
1284
|
+
"retry": "\u91CD\u8BD5",
|
|
1285
|
+
"status.update": "\u53EF\u66F4\u65B0 {version}",
|
|
1286
|
+
"status.latest": "\u5DF2\u662F\u6700\u65B0",
|
|
1287
|
+
"status.checking": "\u68C0\u67E5\u4E2D",
|
|
1288
|
+
"status.failed": "\u67E5\u8BE2\u5931\u8D25",
|
|
1289
|
+
"version.current": "\u5F53\u524D {version}",
|
|
1290
|
+
"version.arrow": "{from} \u2192 {to}",
|
|
1291
|
+
"versions.title": "\u7248\u672C",
|
|
1292
|
+
"versions.registry": "\u6765\u81EA {registry}",
|
|
1293
|
+
"versions.showAll": "\u663E\u793A\u5168\u90E8 {count} \u4E2A\u7248\u672C",
|
|
1294
|
+
"versions.empty": "\u6CA1\u6709\u53EF\u7528\u7684\u7248\u672C\u4FE1\u606F",
|
|
1295
|
+
"versions.failed": "\u65E0\u6CD5\u4ECE npm \u8BFB\u53D6\u7248\u672C\uFF1A{reason}",
|
|
1296
|
+
"tag.current": "\u5F53\u524D",
|
|
1297
|
+
"tag.prerelease": "\u9884\u53D1\u5E03",
|
|
1298
|
+
"tag.deprecated": "\u5DF2\u5E9F\u5F03",
|
|
1299
|
+
"tag.incompatible": "\u4E0D\u517C\u5BB9",
|
|
1300
|
+
"tag.fresh": "\u65B0\u53D1\u5E03",
|
|
1301
|
+
"hint.fresh": "\u53D1\u5E03\u4E0D\u8DB3 24 \u5C0F\u65F6\uFF1Apnpm \u9ED8\u8BA4\u4E0D\u5B89\u88C5\u8FD9\u4E48\u65B0\u7684\u7248\u672C\uFF0C\u5B89\u88C5\u53EF\u80FD\u5931\u8D25",
|
|
1302
|
+
"hint.incompatible": "\u4E0E\u5F53\u524D DSH \u7248\u672C\u4E0D\u517C\u5BB9\uFF0C\u5B89\u88C5\u4F1A\u88AB\u62D2\u7EDD",
|
|
1303
|
+
"self.title": "\u672C\u63D2\u4EF6\u4E0D\u80FD\u5728\u9875\u9762\u91CC\u66F4\u65B0\u81EA\u5DF1",
|
|
1304
|
+
"self.body": "\u5728\u9875\u9762\u91CC\u5378\u8F7D\u81EA\u5DF1\u4F1A\u8BA9\u8FD9\u4E2A\u754C\u9762\u4E00\u8D77\u6D88\u5931\u3002\u8BF7\u5148\u5B8C\u5168\u9000\u51FA DSH\uFF0C\u5728\u7EC8\u7AEF\u8FD0\u884C\u4E0B\u9762\u7684\u547D\u4EE4\uFF0C\u518D\u91CD\u65B0\u6253\u5F00\uFF1A",
|
|
1305
|
+
"self.copy": "\u590D\u5236\u547D\u4EE4",
|
|
1306
|
+
"self.copied": "\u5DF2\u590D\u5236",
|
|
1307
|
+
"op.removing": "\u6B63\u5728\u5378\u8F7D {name} {from}\u2026",
|
|
1308
|
+
"op.installing": "\u6B63\u5728\u5B89\u88C5 {name} {to}\u2026",
|
|
1309
|
+
"op.restoring": "\u6B63\u5728\u6062\u590D {name} {to}\u2026",
|
|
1310
|
+
"op.done": "{name} \u5DF2\u5207\u6362\u5230 {to}",
|
|
1311
|
+
"op.restart": "{name} \u5DF2\u5207\u6362\u5230 {to}\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548",
|
|
1312
|
+
"op.failed": "{name} \u5B89\u88C5 {to} \u5931\u8D25\uFF1A{reason}",
|
|
1313
|
+
"op.removeFailed": "{name} \u5378\u8F7D\u5931\u8D25\uFF0C\u6CA1\u6709\u505A\u4EFB\u4F55\u6539\u52A8\uFF1A{reason}",
|
|
1314
|
+
"op.restore": "\u6062\u590D {from}",
|
|
1315
|
+
"op.dismiss": "\u5173\u95ED",
|
|
1316
|
+
"op.log": "\u65E5\u5FD7\uFF1A{path}"
|
|
1317
|
+
};
|
|
1318
|
+
var EN = {
|
|
1319
|
+
"tab": "Updates",
|
|
1320
|
+
"summary.loading": "Checking for updates\u2026",
|
|
1321
|
+
"summary.some": "{count} plugin(s) can be updated",
|
|
1322
|
+
"summary.none": "All npm plugins are up to date",
|
|
1323
|
+
"summary.empty": "No plugins were installed from npm",
|
|
1324
|
+
"summary.skipped": "{count} plugin(s) not installed from npm were skipped",
|
|
1325
|
+
"refresh": "Check for updates",
|
|
1326
|
+
"updateAll": "Update all",
|
|
1327
|
+
"updateAllCount": "Update all ({count})",
|
|
1328
|
+
"updateLabel": "Update {name} to {version}",
|
|
1329
|
+
"updating": "Updating\u2026",
|
|
1330
|
+
"update": "Update",
|
|
1331
|
+
"updateTo": "Update to {version}",
|
|
1332
|
+
"install": "Install",
|
|
1333
|
+
"details": "Details",
|
|
1334
|
+
"loadFailed": "Could not read the plugin list: {reason}",
|
|
1335
|
+
"retry": "Retry",
|
|
1336
|
+
"status.update": "Update {version}",
|
|
1337
|
+
"status.latest": "Up to date",
|
|
1338
|
+
"status.checking": "Checking",
|
|
1339
|
+
"status.failed": "Check failed",
|
|
1340
|
+
"version.current": "Current {version}",
|
|
1341
|
+
"version.arrow": "{from} \u2192 {to}",
|
|
1342
|
+
"versions.title": "Versions",
|
|
1343
|
+
"versions.registry": "From {registry}",
|
|
1344
|
+
"versions.showAll": "Show all {count} versions",
|
|
1345
|
+
"versions.empty": "No version information",
|
|
1346
|
+
"versions.failed": "Could not read versions from npm: {reason}",
|
|
1347
|
+
"tag.current": "Current",
|
|
1348
|
+
"tag.prerelease": "Prerelease",
|
|
1349
|
+
"tag.deprecated": "Deprecated",
|
|
1350
|
+
"tag.incompatible": "Incompatible",
|
|
1351
|
+
"tag.fresh": "New",
|
|
1352
|
+
"hint.fresh": "Published less than 24 hours ago: pnpm does not install versions this new by default, so installing may fail",
|
|
1353
|
+
"hint.incompatible": "Not compatible with this DSH version; the installation would be refused",
|
|
1354
|
+
"self.title": "This plugin cannot update itself from the page",
|
|
1355
|
+
"self.body": "Uninstalling it from the page would unload this page too. Quit DSH completely, run this command in a terminal, then start DSH again:",
|
|
1356
|
+
"self.copy": "Copy command",
|
|
1357
|
+
"self.copied": "Copied",
|
|
1358
|
+
"op.removing": "Uninstalling {name} {from}\u2026",
|
|
1359
|
+
"op.installing": "Installing {name} {to}\u2026",
|
|
1360
|
+
"op.restoring": "Restoring {name} {to}\u2026",
|
|
1361
|
+
"op.done": "{name} is now at {to}",
|
|
1362
|
+
"op.restart": "{name} is now at {to}; restart DSH to apply it",
|
|
1363
|
+
"op.failed": "Could not install {name} {to}: {reason}",
|
|
1364
|
+
"op.removeFailed": "Could not uninstall {name}; nothing changed: {reason}",
|
|
1365
|
+
"op.restore": "Restore {from}",
|
|
1366
|
+
"op.dismiss": "Dismiss",
|
|
1367
|
+
"op.log": "Log: {path}"
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
// src/client/model.ts
|
|
1371
|
+
var import_gt = __toESM(require_gt(), 1);
|
|
1372
|
+
var import_prerelease = __toESM(require_prerelease(), 1);
|
|
1373
|
+
var import_rcompare = __toESM(require_rcompare(), 1);
|
|
1374
|
+
var import_satisfies = __toESM(require_satisfies(), 1);
|
|
1375
|
+
var import_valid = __toESM(require_valid(), 1);
|
|
1376
|
+
var import_valid2 = __toESM(require_valid2(), 1);
|
|
1377
|
+
var SELF = "@shellraining/dsh-plugin-updates";
|
|
1378
|
+
var DEFAULT_REGISTRY = "https://registry.npmjs.org/";
|
|
1379
|
+
var CACHE_MS = 10 * 6e4;
|
|
1380
|
+
var FRESH_MS = 24 * 60 * 6e4;
|
|
1381
|
+
function updateTarget(candidate, lookup) {
|
|
1382
|
+
if (lookup?.status !== "ready") return void 0;
|
|
1383
|
+
const best = lookup.versions.find((info) => info.compatible && !info.prerelease && !info.deprecated);
|
|
1384
|
+
return best !== void 0 && (0, import_gt.default)(best.version, candidate.version) ? best.version : void 0;
|
|
1385
|
+
}
|
|
1386
|
+
function isBusy(operation) {
|
|
1387
|
+
return operation?.phase === "removing" || operation?.phase === "installing";
|
|
1388
|
+
}
|
|
1389
|
+
function record(value) {
|
|
1390
|
+
return typeof value === "object" && value !== null ? value : {};
|
|
1391
|
+
}
|
|
1392
|
+
function errorText(error) {
|
|
1393
|
+
return error instanceof Error ? error.message : String(error);
|
|
1394
|
+
}
|
|
1395
|
+
function npmInstalled(bundle) {
|
|
1396
|
+
const prefix = `${bundle.name}@`;
|
|
1397
|
+
return bundle.installed && !bundle.official && bundle.availability === "profile" && bundle.removable && bundle.readOnlyReason === void 0 && (0, import_valid.default)(bundle.version ?? "") !== null && bundle.source?.startsWith(prefix) === true && (0, import_valid2.default)(bundle.source.slice(prefix.length)) !== null;
|
|
1398
|
+
}
|
|
1399
|
+
function compatibleWith(manifest, runtime) {
|
|
1400
|
+
if (runtime === void 0) return true;
|
|
1401
|
+
const fits = (range) => typeof range === "string" && range.trim() !== "" && (0, import_satisfies.default)(runtime, range, { includePrerelease: true });
|
|
1402
|
+
const engines = record(manifest["engines"]);
|
|
1403
|
+
if (Object.hasOwn(engines, "dsh")) return fits(engines["dsh"]);
|
|
1404
|
+
return Object.entries(record(manifest["peerDependencies"])).filter(([name2]) => name2 === "@deepseek-ai/dsh" || name2.startsWith("@deepseek-ai/dsh-")).every(([, range]) => typeof range === "string" && range.startsWith("workspace:") ? true : fits(range));
|
|
1405
|
+
}
|
|
1406
|
+
function packumentUrl(registry, name2) {
|
|
1407
|
+
return `${registry.endsWith("/") ? registry : `${registry}/`}${name2.replace("/", "%2f")}`;
|
|
1408
|
+
}
|
|
1409
|
+
function runtimeVersion(ctx) {
|
|
1410
|
+
const modules = record(ctx.get("modules"));
|
|
1411
|
+
const version = record(record(modules["manifest"])["release"])["version"];
|
|
1412
|
+
return typeof version === "string" && (0, import_valid.default)(version) !== null ? version : void 0;
|
|
1413
|
+
}
|
|
1414
|
+
var UpdatesStore = class {
|
|
1415
|
+
constructor(ctx) {
|
|
1416
|
+
this.ctx = ctx;
|
|
1417
|
+
}
|
|
1418
|
+
ctx;
|
|
1419
|
+
state = { status: "idle", candidates: [], skipped: 0, lookups: {} };
|
|
1420
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1421
|
+
generation = 0;
|
|
1422
|
+
disposed = false;
|
|
1423
|
+
registries;
|
|
1424
|
+
exemptions = {};
|
|
1425
|
+
getSnapshot = () => this.state;
|
|
1426
|
+
subscribe = (listener) => {
|
|
1427
|
+
this.listeners.add(listener);
|
|
1428
|
+
return () => {
|
|
1429
|
+
this.listeners.delete(listener);
|
|
1430
|
+
};
|
|
1431
|
+
};
|
|
1432
|
+
dispose() {
|
|
1433
|
+
this.disposed = true;
|
|
1434
|
+
this.listeners.clear();
|
|
1435
|
+
}
|
|
1436
|
+
patch(next) {
|
|
1437
|
+
if (this.disposed) return;
|
|
1438
|
+
this.state = { ...this.state, ...next };
|
|
1439
|
+
for (const listener of [...this.listeners]) listener();
|
|
1440
|
+
}
|
|
1441
|
+
setLookup(name2, lookup) {
|
|
1442
|
+
this.patch({ lookups: { ...this.state.lookups, [name2]: lookup } });
|
|
1443
|
+
}
|
|
1444
|
+
/** A page opened: read the list the first time, and again once a lookup is older than the cache. */
|
|
1445
|
+
ensure = () => {
|
|
1446
|
+
const now = Date.now();
|
|
1447
|
+
const stale = Object.values(this.state.lookups).some((lookup) => lookup.status === "ready" && now - lookup.at > CACHE_MS);
|
|
1448
|
+
if (this.state.status === "idle" || this.state.status === "ready" && stale) void this.load(false);
|
|
1449
|
+
};
|
|
1450
|
+
/** Re-read the list and every lookup. */
|
|
1451
|
+
refresh = () => {
|
|
1452
|
+
void this.load(true);
|
|
1453
|
+
};
|
|
1454
|
+
/** Re-read the list after a Host change; lookups stay cached. */
|
|
1455
|
+
bundlesChanged = () => {
|
|
1456
|
+
if (this.state.status !== "idle") void this.load(false);
|
|
1457
|
+
};
|
|
1458
|
+
async load(force) {
|
|
1459
|
+
const generation = ++this.generation;
|
|
1460
|
+
this.patch({ status: this.state.status === "ready" ? "ready" : "loading" });
|
|
1461
|
+
const pm = this.ctx.remote.pluginManager;
|
|
1462
|
+
if (force || this.registries === void 0) {
|
|
1463
|
+
const [registries, exemptions] = await Promise.all([pm.registries(), pm.listVersionExemptions()]);
|
|
1464
|
+
if (registries.ok) {
|
|
1465
|
+
const first = registries.value.registry ?? registries.value.resolved ?? DEFAULT_REGISTRY;
|
|
1466
|
+
this.registries = [.../* @__PURE__ */ new Set([first, ...registries.value.fallbackRegistries])];
|
|
1467
|
+
}
|
|
1468
|
+
if (exemptions.ok) this.exemptions = exemptions.value.exemptions;
|
|
1469
|
+
}
|
|
1470
|
+
const listed = await pm.listBundles();
|
|
1471
|
+
if (generation !== this.generation) return;
|
|
1472
|
+
if (!listed.ok) {
|
|
1473
|
+
this.patch({ status: "error", error: listed.error.message });
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
const resolve = (text) => text === void 0 ? void 0 : this.ctx.locale.resolveText(text);
|
|
1477
|
+
const npm = listed.value.filter(npmInstalled);
|
|
1478
|
+
const candidates = npm.map((bundle) => {
|
|
1479
|
+
const icon = bundle.meta?.icon;
|
|
1480
|
+
return {
|
|
1481
|
+
name: bundle.name,
|
|
1482
|
+
title: resolve(bundle.meta?.title) ?? bundle.name,
|
|
1483
|
+
version: bundle.version ?? "",
|
|
1484
|
+
enabled: bundle.enabled,
|
|
1485
|
+
...icon === void 0 ? {} : { icon }
|
|
1486
|
+
};
|
|
1487
|
+
}).sort((a, b) => a.title.localeCompare(b.title));
|
|
1488
|
+
const others = listed.value.filter((bundle) => bundle.installed && !bundle.official && bundle.availability === "profile");
|
|
1489
|
+
this.patch({ status: "ready", candidates, skipped: others.length - npm.length });
|
|
1490
|
+
const now = Date.now();
|
|
1491
|
+
for (const candidate of candidates) {
|
|
1492
|
+
const lookup = this.state.lookups[candidate.name];
|
|
1493
|
+
const stale = lookup === void 0 || lookup.status === "error" || lookup.status === "ready" && now - lookup.at > CACHE_MS;
|
|
1494
|
+
if (force || stale) void this.lookup(candidate.name);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
async lookup(name2) {
|
|
1498
|
+
this.setLookup(name2, { status: "loading" });
|
|
1499
|
+
const runtime = runtimeVersion(this.ctx);
|
|
1500
|
+
let reason = "";
|
|
1501
|
+
for (const registry of this.registries ?? [DEFAULT_REGISTRY]) {
|
|
1502
|
+
try {
|
|
1503
|
+
const response = await fetch(packumentUrl(registry, name2), { headers: { accept: "application/json" }, credentials: "omit" });
|
|
1504
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
1505
|
+
const body = record(await response.json());
|
|
1506
|
+
const times = record(body["time"]);
|
|
1507
|
+
const now = Date.now();
|
|
1508
|
+
const versions = Object.entries(record(body["versions"])).filter(([version]) => (0, import_valid.default)(version) !== null).map(([version, manifest]) => {
|
|
1509
|
+
const fields = record(manifest);
|
|
1510
|
+
const stamp = typeof times[version] === "string" ? Date.parse(times[version]) : Number.NaN;
|
|
1511
|
+
const exempted = runtime !== void 0 && this.exemptions[`${name2}@${version}`]?.includes(runtime) === true;
|
|
1512
|
+
return {
|
|
1513
|
+
version,
|
|
1514
|
+
...Number.isNaN(stamp) ? {} : { published: stamp },
|
|
1515
|
+
deprecated: typeof fields["deprecated"] === "string",
|
|
1516
|
+
prerelease: (0, import_prerelease.default)(version) !== null,
|
|
1517
|
+
compatible: exempted || compatibleWith(fields, runtime),
|
|
1518
|
+
fresh: !Number.isNaN(stamp) && now - stamp < FRESH_MS
|
|
1519
|
+
};
|
|
1520
|
+
}).sort((a, b) => (0, import_rcompare.default)(a.version, b.version));
|
|
1521
|
+
const latest = record(body["dist-tags"])["latest"];
|
|
1522
|
+
this.setLookup(name2, { status: "ready", registry, versions, at: now, ...typeof latest === "string" ? { latest } : {} });
|
|
1523
|
+
return;
|
|
1524
|
+
} catch (error) {
|
|
1525
|
+
reason = `${new URL(registry).host}: ${errorText(error)}`;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
this.setLookup(name2, { status: "error", reason });
|
|
1529
|
+
}
|
|
1530
|
+
/** Switch one plugin to `version`: uninstall it, then install that exact version with its enabled state. */
|
|
1531
|
+
install = async (name2, version) => {
|
|
1532
|
+
const candidate = this.state.candidates.find((item) => item.name === name2);
|
|
1533
|
+
if (candidate === void 0 || name2 === SELF || isBusy(this.state.operation)) return false;
|
|
1534
|
+
return this.run({ name: name2, from: candidate.version, to: version, enabled: candidate.enabled, restoring: false }, true);
|
|
1535
|
+
};
|
|
1536
|
+
/** Put back the version a failed switch removed; the plugin is no longer installed, so only install. */
|
|
1537
|
+
restore = async () => {
|
|
1538
|
+
const failed = this.state.operation;
|
|
1539
|
+
if (failed?.phase !== "failed" || failed.restoring) return;
|
|
1540
|
+
await this.run({ name: failed.name, from: failed.to, to: failed.from, enabled: failed.enabled, restoring: true }, false);
|
|
1541
|
+
};
|
|
1542
|
+
/** The outcome toast finished; the banner in the tab keeps the result. */
|
|
1543
|
+
toastDone = () => {
|
|
1544
|
+
const operation = this.state.operation;
|
|
1545
|
+
if (operation?.toast !== void 0) {
|
|
1546
|
+
const { toast: _toast, ...rest } = operation;
|
|
1547
|
+
this.patch({ operation: rest });
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
dismiss = () => {
|
|
1551
|
+
if (!isBusy(this.state.operation)) this.patch({ operation: void 0 });
|
|
1552
|
+
};
|
|
1553
|
+
/** Update every plugin with a newer version, one at a time; stops at the first failure. */
|
|
1554
|
+
updateAll = async () => {
|
|
1555
|
+
for (const candidate of this.state.candidates) {
|
|
1556
|
+
const target = updateTarget(candidate, this.state.lookups[candidate.name]);
|
|
1557
|
+
if (target === void 0 || candidate.name === SELF) continue;
|
|
1558
|
+
if (!await this.install(candidate.name, target)) return;
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
async run(base, remove) {
|
|
1562
|
+
const pm = this.ctx.remote.pluginManager;
|
|
1563
|
+
const fail = (phase, result) => {
|
|
1564
|
+
const value = result.ok ? result.value : void 0;
|
|
1565
|
+
const output = value?.packageResult?.output.trim();
|
|
1566
|
+
const logPath = value?.packageResult?.logPath;
|
|
1567
|
+
const reason = result.ok ? value?.error?.diagnostic?.split("\n")[0] ?? value?.error?.code ?? value?.application ?? "" : result.error.message;
|
|
1568
|
+
this.patch({ operation: { ...base, phase, reason, toast: Date.now(), ...output ? { output } : {}, ...logPath ? { logPath } : {} } });
|
|
1569
|
+
return false;
|
|
1570
|
+
};
|
|
1571
|
+
if (remove) {
|
|
1572
|
+
this.patch({ operation: { ...base, phase: "removing" } });
|
|
1573
|
+
const removed = await pm.removeBundle(base.name);
|
|
1574
|
+
const stopProfile = removed.ok && removed.value.error?.code === "stop-profile";
|
|
1575
|
+
if (!stopProfile && (!removed.ok || removed.value.application === "failed" || removed.value.application === "cancelled")) {
|
|
1576
|
+
return fail("remove-failed", removed);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
this.patch({ operation: { ...base, phase: "installing" } });
|
|
1580
|
+
const installed = await pm.installBundle(`${base.name}@${base.to}`, {
|
|
1581
|
+
enabled: base.enabled,
|
|
1582
|
+
saveExact: true,
|
|
1583
|
+
requestId: `${SELF}:${Date.now()}`
|
|
1584
|
+
});
|
|
1585
|
+
if (!installed.ok || installed.value.application === "failed" || installed.value.application === "cancelled") {
|
|
1586
|
+
return fail("failed", installed);
|
|
1587
|
+
}
|
|
1588
|
+
const to = installed.value.version ?? base.to;
|
|
1589
|
+
this.patch({ operation: { ...base, to, toast: Date.now(), phase: installed.value.application === "restart-required" ? "restart" : "done" } });
|
|
1590
|
+
return true;
|
|
1591
|
+
}
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
// src/client/styles.ts
|
|
1595
|
+
var STYLE_ID = "@shellraining/dsh-plugin-updates";
|
|
1596
|
+
var CSS = `
|
|
1597
|
+
.dpu-tab, .dpu-section { display: flex; flex-direction: column; gap: 12px; min-width: 0; color: var(--dsw-alias-label-primary); }
|
|
1598
|
+
.dpu-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 28px; }
|
|
1599
|
+
.dpu-summary { flex: 1; min-width: 0; color: var(--dsw-alias-label-secondary); font-size: 13px; line-height: 20px; }
|
|
1600
|
+
.dpu-caption { color: var(--dsw-alias-label-caption); font-size: 12px; line-height: 18px; }
|
|
1601
|
+
.dpu-title { margin: 0; font-size: 14px; font-weight: 500; line-height: 20px; }
|
|
1602
|
+
.dpu-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
|
|
1603
|
+
.dpu-card { display: flex; align-items: center; gap: 14px; min-width: 0; margin: 0 -8px; padding: 8px; border-radius: var(--dsw-radius-xl); }
|
|
1604
|
+
.dpu-card:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
1605
|
+
.dpu-icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; overflow: hidden; border: .5px solid var(--dsw-alias-border-l3); border-radius: var(--dsw-radius-lg); color: var(--dsw-alias-label-secondary); }
|
|
1606
|
+
.dpu-icon img { width: 100%; height: 100%; object-fit: cover; }
|
|
1607
|
+
.dpu-main { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
|
|
1608
|
+
.dpu-name-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
|
|
1609
|
+
.dpu-name { min-width: 0; padding: 0; overflow: hidden; border: 0; background: none; color: inherit; font: inherit; font-size: 14px; font-weight: 500; line-height: 20px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
|
|
1610
|
+
.dpu-name:hover { text-decoration: underline; }
|
|
1611
|
+
.dpu-name:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
|
|
1612
|
+
.dpu-meta { color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 18px; font-variant-numeric: tabular-nums; }
|
|
1613
|
+
.dpu-end { flex: none; display: inline-flex; align-items: center; gap: 8px; }
|
|
1614
|
+
.dpu-mono { font-family: var(--ds-font-family-code); font-variant-numeric: tabular-nums; }
|
|
1615
|
+
.dpu-rows { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; border-top: .5px solid var(--dsw-alias-border-l2); }
|
|
1616
|
+
.dpu-row { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 0; border-bottom: .5px solid var(--dsw-alias-border-l2); }
|
|
1617
|
+
.dpu-row-version { min-width: 96px; font-size: 13px; }
|
|
1618
|
+
.dpu-row-tags { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
|
|
1619
|
+
.dpu-banner { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: .5px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-1); font-size: 13px; line-height: 20px; }
|
|
1620
|
+
.dpu-banner[data-tone="error"] { color: var(--dsw-alias-state-error-primary); background: var(--dsw-alias-interactive-bg-hover-danger, var(--dsw-alias-bg-layer-1)); }
|
|
1621
|
+
.dpu-banner-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
|
1622
|
+
.dpu-banner-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
1623
|
+
.dpu-pre { max-height: 160px; margin: 0; padding: 8px 10px; overflow: auto; border-radius: var(--dsw-radius-md); background: var(--dsw-alias-markdown-code-block); color: var(--dsw-alias-label-secondary); font: 400 12px / 1.6 var(--ds-font-family-code); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
|
|
1624
|
+
.dpu-command { flex: 1; min-width: 0; }
|
|
1625
|
+
.dpu-error { color: var(--dsw-alias-state-error-primary); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
|
|
1626
|
+
@media (forced-colors: active) { .dpu-banner { border-color: CanvasText; } }
|
|
1627
|
+
`;
|
|
1628
|
+
function installStyle(document2) {
|
|
1629
|
+
const node = document2.createElement("style");
|
|
1630
|
+
node.dataset.plugin = STYLE_ID;
|
|
1631
|
+
node.textContent = CSS;
|
|
1632
|
+
document2.head.append(node);
|
|
1633
|
+
return () => node.remove();
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
// src/client/view.tsx
|
|
1637
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1638
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
1639
|
+
var import_react = require("react");
|
|
1640
|
+
var import_react_dom = require("react-dom");
|
|
1641
|
+
|
|
1642
|
+
// src/client/anchors.ts
|
|
1643
|
+
var GROUP = 'section[data-plugin-group="bundles"]';
|
|
1644
|
+
var MOUNT = "data-plugin-updates-mount";
|
|
1645
|
+
var NO_ANCHORS = { cards: /* @__PURE__ */ new Map() };
|
|
1646
|
+
function mountIn(parent, key, first) {
|
|
1647
|
+
for (const child of parent.children) {
|
|
1648
|
+
if (child instanceof HTMLElement && child.getAttribute(MOUNT) === key) return child;
|
|
1649
|
+
}
|
|
1650
|
+
const node = parent.ownerDocument.createElement("span");
|
|
1651
|
+
node.setAttribute(MOUNT, key);
|
|
1652
|
+
node.style.display = "contents";
|
|
1653
|
+
if (first) parent.prepend(node);
|
|
1654
|
+
else parent.append(node);
|
|
1655
|
+
return node;
|
|
1656
|
+
}
|
|
1657
|
+
function scan(document2) {
|
|
1658
|
+
const group = document2.querySelector(GROUP);
|
|
1659
|
+
if (group === null) return NO_ANCHORS;
|
|
1660
|
+
const row = group.firstElementChild;
|
|
1661
|
+
const head = row?.querySelector(":scope > h3") ? mountIn(row, "head", false) : void 0;
|
|
1662
|
+
const cards = /* @__PURE__ */ new Map();
|
|
1663
|
+
for (const card of group.querySelectorAll("li[data-plugin-package]")) {
|
|
1664
|
+
const name2 = card.getAttribute("data-plugin-package");
|
|
1665
|
+
const end = card.querySelector('[role="switch"]')?.parentElement;
|
|
1666
|
+
if (name2 && end) cards.set(name2, mountIn(end, "card", true));
|
|
1667
|
+
}
|
|
1668
|
+
return { ...head === void 0 ? {} : { head }, cards };
|
|
1669
|
+
}
|
|
1670
|
+
function same(a, b) {
|
|
1671
|
+
if (a.head !== b.head || a.cards.size !== b.cards.size) return false;
|
|
1672
|
+
for (const [name2, node] of a.cards) if (b.cards.get(name2) !== node) return false;
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
function watchAnchors(document2, onChange) {
|
|
1676
|
+
const view = document2.defaultView;
|
|
1677
|
+
if (view === null) return () => {
|
|
1678
|
+
};
|
|
1679
|
+
let current = NO_ANCHORS;
|
|
1680
|
+
let frame = 0;
|
|
1681
|
+
const run = () => {
|
|
1682
|
+
frame = 0;
|
|
1683
|
+
const next = scan(document2);
|
|
1684
|
+
if (same(current, next)) return;
|
|
1685
|
+
current = next;
|
|
1686
|
+
onChange(next);
|
|
1687
|
+
};
|
|
1688
|
+
const observer = new view.MutationObserver(() => {
|
|
1689
|
+
if (frame === 0) frame = view.requestAnimationFrame(run);
|
|
1690
|
+
});
|
|
1691
|
+
observer.observe(document2.body, { childList: true, subtree: true });
|
|
1692
|
+
run();
|
|
1693
|
+
return () => {
|
|
1694
|
+
observer.disconnect();
|
|
1695
|
+
if (frame !== 0) view.cancelAnimationFrame(frame);
|
|
1696
|
+
for (const node of document2.querySelectorAll(`[${MOUNT}]`)) node.remove();
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
// src/client/view.tsx
|
|
1701
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1702
|
+
var VISIBLE_VERSIONS = 12;
|
|
1703
|
+
function selfCommand(version) {
|
|
1704
|
+
const profile = document.documentElement.dataset["platform"] === void 0 ? "web" : "desktop";
|
|
1705
|
+
return `dsh plugin --profile ${profile} add ${SELF}@${version} --save-exact`;
|
|
1706
|
+
}
|
|
1707
|
+
function dateText(stamp) {
|
|
1708
|
+
return stamp === void 0 ? "" : new Date(stamp).toLocaleDateString();
|
|
1709
|
+
}
|
|
1710
|
+
function Artwork({ src }) {
|
|
1711
|
+
const [broken, setBroken] = (0, import_react.useState)(false);
|
|
1712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-icon", "aria-hidden": "true", children: src === void 0 || broken ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.PluginArtworkDefault, { size: 28 }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src, alt: "", onError: () => setBroken(true) }) });
|
|
1713
|
+
}
|
|
1714
|
+
function StatusTag({ t, candidate, lookup }) {
|
|
1715
|
+
if (lookup === void 0 || lookup.status === "loading") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "quiet", children: t("status.checking") });
|
|
1716
|
+
if (lookup.status === "error") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t("status.failed") });
|
|
1717
|
+
const target = updateTarget(candidate, lookup);
|
|
1718
|
+
return target === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "quiet", children: t("status.latest") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "info", children: t("status.update", { version: target }) });
|
|
1719
|
+
}
|
|
1720
|
+
function SelfNotice({ t, version }) {
|
|
1721
|
+
const [copied, setCopied] = (0, import_react.useState)(false);
|
|
1722
|
+
const command = selfCommand(version);
|
|
1723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-banner", children: [
|
|
1724
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: t("self.title") }),
|
|
1725
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("self.body") }),
|
|
1726
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-banner-row", children: [
|
|
1727
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dpu-pre dpu-command", children: command }),
|
|
1728
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", onClick: () => {
|
|
1729
|
+
void (0, import_dsh_client_ui_primitives.writeClipboard)(command).then(setCopied);
|
|
1730
|
+
}, children: copied ? t("self.copied") : t("self.copy") })
|
|
1731
|
+
] })
|
|
1732
|
+
] });
|
|
1733
|
+
}
|
|
1734
|
+
function operationText(t, operation) {
|
|
1735
|
+
const params = { name: operation.name, from: operation.from, to: operation.to, reason: operation.reason ?? "" };
|
|
1736
|
+
switch (operation.phase) {
|
|
1737
|
+
case "removing":
|
|
1738
|
+
return t("op.removing", params);
|
|
1739
|
+
case "installing":
|
|
1740
|
+
return t(operation.restoring ? "op.restoring" : "op.installing", params);
|
|
1741
|
+
case "done":
|
|
1742
|
+
return t("op.done", params);
|
|
1743
|
+
case "restart":
|
|
1744
|
+
return t("op.restart", params);
|
|
1745
|
+
case "failed":
|
|
1746
|
+
return t("op.failed", params);
|
|
1747
|
+
case "remove-failed":
|
|
1748
|
+
return t("op.removeFailed", params);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
function OperationToast({ t, useUpdates, actions }) {
|
|
1752
|
+
const operation = useUpdates((state) => state.operation);
|
|
1753
|
+
if (operation?.toast === void 0) return null;
|
|
1754
|
+
const failed = operation.phase === "failed" || operation.phase === "remove-failed";
|
|
1755
|
+
const restorable = operation.phase === "failed" && !operation.restoring;
|
|
1756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1757
|
+
import_dsh_client_ui_primitives.Toast,
|
|
1758
|
+
{
|
|
1759
|
+
text: operationText(t, operation),
|
|
1760
|
+
...failed ? { icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives2.IconWarningOutlineRegular, {}) } : { tone: "success" },
|
|
1761
|
+
holdMs: failed ? 8e3 : 4e3,
|
|
1762
|
+
...restorable ? { actions: [{ label: t("op.restore", { from: operation.from }), onClick: () => {
|
|
1763
|
+
void actions.restore();
|
|
1764
|
+
} }] } : {},
|
|
1765
|
+
onDone: actions.toastDone
|
|
1766
|
+
},
|
|
1767
|
+
operation.toast
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
function OperationBanner({ t, operation, actions }) {
|
|
1771
|
+
const params = { from: operation.from };
|
|
1772
|
+
const busy = isBusy(operation);
|
|
1773
|
+
const failed = operation.phase === "failed" || operation.phase === "remove-failed";
|
|
1774
|
+
const text = operationText(t, operation);
|
|
1775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-banner", role: failed ? "alert" : "status", ...failed ? { "data-tone": "error" } : {}, children: [
|
|
1776
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-banner-row", children: [
|
|
1777
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: text }),
|
|
1778
|
+
operation.phase === "failed" && !operation.restoring ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", onClick: () => {
|
|
1779
|
+
void actions.restore();
|
|
1780
|
+
}, children: t("op.restore", params) }) : null,
|
|
1781
|
+
busy ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "ghost", onClick: actions.dismiss, children: t("op.dismiss") })
|
|
1782
|
+
] }),
|
|
1783
|
+
failed && operation.output !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dpu-pre", children: operation.output }) : null,
|
|
1784
|
+
failed && operation.logPath !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-caption", children: t("op.log", { path: operation.logPath }) }) : null
|
|
1785
|
+
] });
|
|
1786
|
+
}
|
|
1787
|
+
function UpdatesTab({ t, useUpdates, actions, openPackage }) {
|
|
1788
|
+
const state = useUpdates((snapshot) => snapshot);
|
|
1789
|
+
(0, import_react.useEffect)(() => {
|
|
1790
|
+
actions.ensure();
|
|
1791
|
+
}, [actions]);
|
|
1792
|
+
const busy = isBusy(state.operation);
|
|
1793
|
+
const lookups = Object.values(state.lookups);
|
|
1794
|
+
const checking = state.status === "loading" || lookups.some((lookup) => lookup.status === "loading");
|
|
1795
|
+
const outdated = state.candidates.filter((item) => updateTarget(item, state.lookups[item.name]) !== void 0);
|
|
1796
|
+
const pending = outdated.filter((item) => item.name !== SELF);
|
|
1797
|
+
const self = outdated.find((item) => item.name === SELF);
|
|
1798
|
+
const selfTarget = self === void 0 ? void 0 : updateTarget(self, state.lookups[SELF]);
|
|
1799
|
+
let summary;
|
|
1800
|
+
if (state.status === "idle" || state.status === "loading" && state.candidates.length === 0) summary = t("summary.loading");
|
|
1801
|
+
else if (state.candidates.length === 0) summary = t("summary.empty");
|
|
1802
|
+
else if (outdated.length > 0) summary = t("summary.some", { count: outdated.length });
|
|
1803
|
+
else summary = checking ? t("summary.loading") : t("summary.none");
|
|
1804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dpu-tab", "aria-busy": checking, children: [
|
|
1805
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-head", children: [
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-summary", role: "status", children: summary }),
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives2.IconRefreshOutlineRegular, { size: 13 }), disabled: checking || busy, onClick: actions.refresh, children: t("refresh") }),
|
|
1808
|
+
pending.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "primary", disabled: busy, onClick: () => {
|
|
1809
|
+
void actions.updateAll();
|
|
1810
|
+
}, children: t("updateAll") }) : null
|
|
1811
|
+
] }),
|
|
1812
|
+
state.operation === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OperationBanner, { t, operation: state.operation, actions }),
|
|
1813
|
+
state.status === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dpu-banner", "data-tone": "error", role: "alert", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-banner-row", children: [
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: t("loadFailed", { reason: state.error ?? "" }) }),
|
|
1815
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", onClick: actions.refresh, children: t("retry") })
|
|
1816
|
+
] }) }) : null,
|
|
1817
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dpu-list", children: state.candidates.map((candidate) => {
|
|
1818
|
+
const lookup = state.lookups[candidate.name];
|
|
1819
|
+
const target = updateTarget(candidate, lookup);
|
|
1820
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "dpu-card", "data-plugin-updates-package": candidate.name, children: [
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Artwork, { src: candidate.icon }),
|
|
1822
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-main", children: [
|
|
1823
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-name-row", children: [
|
|
1824
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dpu-name", title: candidate.name, onClick: () => openPackage(candidate.name), children: candidate.title }),
|
|
1825
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StatusTag, { t, candidate, lookup })
|
|
1826
|
+
] }),
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dpu-meta", children: [
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-mono", children: target === void 0 ? candidate.version : t("version.arrow", { from: candidate.version, to: target }) }),
|
|
1829
|
+
lookup?.status === "error" ? ` \xB7 ${lookup.reason}` : ""
|
|
1830
|
+
] })
|
|
1831
|
+
] }),
|
|
1832
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-end", children: [
|
|
1833
|
+
target !== void 0 && candidate.name !== SELF ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives2.IconDownloadOutlineRegular, { size: 13 }), disabled: busy, onClick: () => {
|
|
1834
|
+
void actions.install(candidate.name, target);
|
|
1835
|
+
}, children: t("update") }) : null,
|
|
1836
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "ghost", onClick: () => openPackage(candidate.name), children: t("details") })
|
|
1837
|
+
] })
|
|
1838
|
+
] }, candidate.name);
|
|
1839
|
+
}) }),
|
|
1840
|
+
state.skipped > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-caption", children: t("summary.skipped", { count: state.skipped }) }) : null,
|
|
1841
|
+
selfTarget === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelfNotice, { t, version: selfTarget })
|
|
1842
|
+
] });
|
|
1843
|
+
}
|
|
1844
|
+
function useSubject({ subject, useUpdates, actions }) {
|
|
1845
|
+
const name2 = subject.kind === "bundle" ? subject.pkg.name : void 0;
|
|
1846
|
+
const candidate = useUpdates((state) => state.candidates.find((item) => item.name === name2));
|
|
1847
|
+
const lookup = useUpdates((state) => name2 === void 0 ? void 0 : state.lookups[name2]);
|
|
1848
|
+
const operation = useUpdates((state) => state.operation);
|
|
1849
|
+
(0, import_react.useEffect)(() => {
|
|
1850
|
+
if (name2 !== void 0) actions.ensure();
|
|
1851
|
+
}, [actions, name2]);
|
|
1852
|
+
return candidate === void 0 ? void 0 : { candidate, lookup, operation };
|
|
1853
|
+
}
|
|
1854
|
+
function DetailBadge(props) {
|
|
1855
|
+
const found = useSubject(props);
|
|
1856
|
+
const target = found === void 0 ? void 0 : updateTarget(found.candidate, found.lookup);
|
|
1857
|
+
return target === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "info", children: props.t("status.update", { version: target }) });
|
|
1858
|
+
}
|
|
1859
|
+
function DetailAction(props) {
|
|
1860
|
+
const found = useSubject(props);
|
|
1861
|
+
const target = found === void 0 ? void 0 : updateTarget(found.candidate, found.lookup);
|
|
1862
|
+
if (found === void 0 || target === void 0 || found.candidate.name === SELF) return null;
|
|
1863
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "primary", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives2.IconDownloadOutlineRegular, { size: 13 }), disabled: isBusy(found.operation), onClick: () => {
|
|
1864
|
+
void props.actions.install(found.candidate.name, target);
|
|
1865
|
+
}, children: props.t("updateTo", { version: target }) });
|
|
1866
|
+
}
|
|
1867
|
+
function VersionRow({ t, info, current, disabled, onInstall }) {
|
|
1868
|
+
const hint = !info.compatible ? t("hint.incompatible") : info.fresh ? t("hint.fresh") : void 0;
|
|
1869
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "dpu-row", ...hint === void 0 ? {} : { title: hint }, children: [
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-row-version dpu-mono", children: info.version }),
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dpu-row-tags", children: [
|
|
1872
|
+
current ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "success", children: t("tag.current") }) : null,
|
|
1873
|
+
info.prerelease ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "neutral", children: t("tag.prerelease") }) : null,
|
|
1874
|
+
info.deprecated ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t("tag.deprecated") }) : null,
|
|
1875
|
+
!info.compatible ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "danger", children: t("tag.incompatible") }) : null,
|
|
1876
|
+
info.fresh ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t("tag.fresh") }) : null
|
|
1877
|
+
] }),
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-caption", children: dateText(info.published) }),
|
|
1879
|
+
current || onInstall === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "ghost", disabled: disabled || !info.compatible, onClick: onInstall, children: t("install") })
|
|
1880
|
+
] });
|
|
1881
|
+
}
|
|
1882
|
+
function DetailSection(props) {
|
|
1883
|
+
const found = useSubject(props);
|
|
1884
|
+
const [all, setAll] = (0, import_react.useState)(false);
|
|
1885
|
+
if (found === void 0) return null;
|
|
1886
|
+
const { t, actions } = props;
|
|
1887
|
+
const { candidate, lookup, operation } = found;
|
|
1888
|
+
const self = candidate.name === SELF;
|
|
1889
|
+
const target = updateTarget(candidate, lookup);
|
|
1890
|
+
let body;
|
|
1891
|
+
if (lookup === void 0 || lookup.status === "loading") body = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-caption", children: t("summary.loading") });
|
|
1892
|
+
else if (lookup.status === "error") body = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-error", children: t("versions.failed", { reason: lookup.reason }) });
|
|
1893
|
+
else if (lookup.versions.length === 0) body = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dpu-caption", children: t("versions.empty") });
|
|
1894
|
+
else {
|
|
1895
|
+
const shown = all ? lookup.versions : lookup.versions.slice(0, VISIBLE_VERSIONS);
|
|
1896
|
+
body = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1897
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "dpu-rows", children: shown.map((info) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1898
|
+
VersionRow,
|
|
1899
|
+
{
|
|
1900
|
+
t,
|
|
1901
|
+
info,
|
|
1902
|
+
current: info.version === candidate.version,
|
|
1903
|
+
disabled: isBusy(operation),
|
|
1904
|
+
onInstall: self ? void 0 : () => {
|
|
1905
|
+
void actions.install(candidate.name, info.version);
|
|
1906
|
+
}
|
|
1907
|
+
},
|
|
1908
|
+
info.version
|
|
1909
|
+
)) }),
|
|
1910
|
+
shown.length < lookup.versions.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "ghost", onClick: () => setAll(true), children: t("versions.showAll", { count: lookup.versions.length }) }) }) : null
|
|
1911
|
+
] });
|
|
1912
|
+
}
|
|
1913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dpu-section", "data-plugin-updates-versions": candidate.name, children: [
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dpu-head", children: [
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "dpu-title", children: t("versions.title") }),
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dpu-summary", children: [
|
|
1917
|
+
t("version.current", { version: candidate.version }),
|
|
1918
|
+
lookup?.status === "ready" ? ` \xB7 ${t("versions.registry", { registry: new URL(lookup.registry).host })}` : ""
|
|
1919
|
+
] })
|
|
1920
|
+
] }),
|
|
1921
|
+
operation?.name === candidate.name ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OperationBanner, { t, operation, actions }) : null,
|
|
1922
|
+
self && target !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelfNotice, { t, version: target }) : null,
|
|
1923
|
+
body
|
|
1924
|
+
] });
|
|
1925
|
+
}
|
|
1926
|
+
function ListControls({ t, useUpdates, actions }) {
|
|
1927
|
+
const [anchors, setAnchors] = (0, import_react.useState)(NO_ANCHORS);
|
|
1928
|
+
(0, import_react.useEffect)(() => watchAnchors(document, setAnchors), []);
|
|
1929
|
+
const visible = anchors.head !== void 0 || anchors.cards.size > 0;
|
|
1930
|
+
(0, import_react.useEffect)(() => {
|
|
1931
|
+
if (visible) actions.ensure();
|
|
1932
|
+
}, [actions, visible]);
|
|
1933
|
+
const candidates = useUpdates((state) => state.candidates);
|
|
1934
|
+
const lookups = useUpdates((state) => state.lookups);
|
|
1935
|
+
const operation = useUpdates((state) => state.operation);
|
|
1936
|
+
const busy = isBusy(operation);
|
|
1937
|
+
const targets = /* @__PURE__ */ new Map();
|
|
1938
|
+
for (const candidate of candidates) {
|
|
1939
|
+
const target = updateTarget(candidate, lookups[candidate.name]);
|
|
1940
|
+
if (target !== void 0 && candidate.name !== SELF) targets.set(candidate.name, target);
|
|
1941
|
+
}
|
|
1942
|
+
const portals = [];
|
|
1943
|
+
if (anchors.head !== void 0 && targets.size > 0) {
|
|
1944
|
+
portals.push((0, import_react_dom.createPortal)(
|
|
1945
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives2.IconDownloadOutlineRegular, { size: 13 }), disabled: busy, onClick: () => {
|
|
1946
|
+
void actions.updateAll();
|
|
1947
|
+
}, children: t("updateAllCount", { count: targets.size }) }),
|
|
1948
|
+
anchors.head,
|
|
1949
|
+
"head"
|
|
1950
|
+
));
|
|
1951
|
+
}
|
|
1952
|
+
for (const [name2, node] of anchors.cards) {
|
|
1953
|
+
const target = targets.get(name2);
|
|
1954
|
+
if (target === void 0) continue;
|
|
1955
|
+
const running = busy && operation?.name === name2;
|
|
1956
|
+
portals.push((0, import_react_dom.createPortal)(
|
|
1957
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", disabled: busy, "aria-label": t("updateLabel", { name: name2, version: target }), onClick: () => {
|
|
1958
|
+
void actions.install(name2, target);
|
|
1959
|
+
}, children: running ? t("updating") : t("updateTo", { version: target }) }),
|
|
1960
|
+
node,
|
|
1961
|
+
name2
|
|
1962
|
+
));
|
|
1963
|
+
}
|
|
1964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: portals });
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
// src/client/index.tsx
|
|
1968
|
+
var name = "@shellraining/dsh-plugin-updates";
|
|
1969
|
+
var inject = ["slots", "locale", "remote", "remote.pluginManager"];
|
|
1970
|
+
function apply(ctx) {
|
|
1971
|
+
ctx.effect(() => ctx.locale.register(LOCALE_NS, { zh: ZH, en: EN }), `${name}: copy`);
|
|
1972
|
+
ctx.effect(() => installStyle(document), `${name}: stylesheet`);
|
|
1973
|
+
const store = new UpdatesStore(ctx);
|
|
1974
|
+
ctx.effect(() => () => store.dispose(), `${name}: store`);
|
|
1975
|
+
ctx.effect(() => {
|
|
1976
|
+
const offs = [ctx.remote.$on("plugin-manager/changed", store.bundlesChanged), ctx.on("connection/reset", store.bundlesChanged)];
|
|
1977
|
+
return () => {
|
|
1978
|
+
for (const off of offs) off();
|
|
1979
|
+
};
|
|
1980
|
+
}, `${name}: host invalidations`);
|
|
1981
|
+
const t = ctx.locale.bind(LOCALE_NS);
|
|
1982
|
+
const face = {
|
|
1983
|
+
hooks: { updates: store },
|
|
1984
|
+
actions: {
|
|
1985
|
+
ensure: store.ensure,
|
|
1986
|
+
refresh: store.refresh,
|
|
1987
|
+
install: store.install,
|
|
1988
|
+
updateAll: store.updateAll,
|
|
1989
|
+
restore: store.restore,
|
|
1990
|
+
dismiss: store.dismiss,
|
|
1991
|
+
toastDone: store.toastDone
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
ctx.slots.inject("plugins.tab", () => ctx.slots.register({
|
|
1995
|
+
name: "plugins.tab",
|
|
1996
|
+
id: "updates",
|
|
1997
|
+
order: 10,
|
|
1998
|
+
label: () => t("tab"),
|
|
1999
|
+
locale: LOCALE_NS,
|
|
2000
|
+
inject: () => face
|
|
2001
|
+
}, UpdatesTab));
|
|
2002
|
+
ctx.slots.inject("shell.overlay", () => ctx.slots.register({
|
|
2003
|
+
name: "shell.overlay",
|
|
2004
|
+
id: "plugin-updates.toast",
|
|
2005
|
+
locale: LOCALE_NS,
|
|
2006
|
+
inject: () => face
|
|
2007
|
+
}, OperationToast));
|
|
2008
|
+
ctx.slots.inject("shell.overlay", () => ctx.slots.register({
|
|
2009
|
+
name: "shell.overlay",
|
|
2010
|
+
id: "plugin-updates.list",
|
|
2011
|
+
locale: LOCALE_NS,
|
|
2012
|
+
inject: () => face
|
|
2013
|
+
}, ListControls));
|
|
2014
|
+
for (const [slot, component] of [
|
|
2015
|
+
["plugins.detail.badge", DetailBadge],
|
|
2016
|
+
["plugins.detail.actions", DetailAction],
|
|
2017
|
+
["plugins.detail.section", DetailSection]
|
|
2018
|
+
]) {
|
|
2019
|
+
ctx.slots.inject(slot, () => ctx.slots.register({
|
|
2020
|
+
name: slot,
|
|
2021
|
+
id: "plugin-updates",
|
|
2022
|
+
locale: LOCALE_NS,
|
|
2023
|
+
inject: () => face
|
|
2024
|
+
}, component));
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
return module.exports;
|
|
2029
|
+
},
|
|
2030
|
+
});
|