@sonicjs-cms/core 1.0.0-alpha.1 → 1.0.0-alpha.2
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/dist/chunk-24PWAFUT.cjs +776 -0
- package/dist/chunk-24PWAFUT.cjs.map +1 -0
- package/dist/chunk-4URGXJP7.js +3 -0
- package/dist/{chunk-PZ5AY32C.js.map → chunk-4URGXJP7.js.map} +1 -1
- package/dist/chunk-ALTMI5Y2.cjs +4 -0
- package/dist/{chunk-Q7SFCCGT.cjs.map → chunk-ALTMI5Y2.cjs.map} +1 -1
- package/dist/chunk-CXZDAR6S.js +2360 -0
- package/dist/chunk-CXZDAR6S.js.map +1 -0
- package/dist/chunk-EMMSS5I5.cjs +37 -0
- package/dist/chunk-EMMSS5I5.cjs.map +1 -0
- package/dist/chunk-G3PMV62Z.js +33 -0
- package/dist/chunk-G3PMV62Z.js.map +1 -0
- package/dist/chunk-L3NXO7Y4.cjs +3093 -0
- package/dist/chunk-L3NXO7Y4.cjs.map +1 -0
- package/dist/chunk-NRSL6BQI.js +3086 -0
- package/dist/chunk-NRSL6BQI.js.map +1 -0
- package/dist/chunk-PTQZ5FEI.js +755 -0
- package/dist/chunk-PTQZ5FEI.js.map +1 -0
- package/dist/chunk-WJ7QYVR2.cjs +2416 -0
- package/dist/chunk-WJ7QYVR2.cjs.map +1 -0
- package/dist/collection-config-FLlGtsh9.d.cts +107 -0
- package/dist/collection-config-FLlGtsh9.d.ts +107 -0
- package/dist/index-BlsY5XNH.d.ts +8333 -0
- package/dist/index-D45jaIlr.d.cts +8333 -0
- package/dist/index.cjs +327 -630
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7961
- package/dist/index.d.ts +13 -7961
- package/dist/index.js +8 -592
- package/dist/index.js.map +1 -1
- package/dist/middleware.cjs +84 -4
- package/dist/middleware.cjs.map +1 -1
- package/dist/middleware.d.cts +203 -5
- package/dist/middleware.d.ts +203 -5
- package/dist/middleware.js +3 -6
- package/dist/middleware.js.map +1 -1
- package/dist/plugin-UzmDImQc.d.cts +357 -0
- package/dist/plugin-UzmDImQc.d.ts +357 -0
- package/dist/plugins.cjs +28 -4
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +326 -4
- package/dist/plugins.d.ts +326 -4
- package/dist/plugins.js +3 -6
- package/dist/plugins.js.map +1 -1
- package/dist/routes.cjs +1 -1
- package/dist/routes.js +1 -1
- package/dist/services.cjs +68 -4
- package/dist/services.cjs.map +1 -1
- package/dist/services.d.cts +5 -8
- package/dist/services.d.ts +5 -8
- package/dist/services.js +3 -6
- package/dist/services.js.map +1 -1
- package/dist/templates.cjs +1 -1
- package/dist/templates.js +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +6 -462
- package/dist/types.d.ts +6 -462
- package/dist/types.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-Q7SFCCGT.cjs +0 -11
|
@@ -0,0 +1,3086 @@
|
|
|
1
|
+
import { HOOKS } from './chunk-LOUJRBXV.js';
|
|
2
|
+
import { __commonJS, __toESM } from './chunk-G3PMV62Z.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
|
|
6
|
+
// node_modules/semver/internal/constants.js
|
|
7
|
+
var require_constants = __commonJS({
|
|
8
|
+
"node_modules/semver/internal/constants.js"(exports, module) {
|
|
9
|
+
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
10
|
+
var MAX_LENGTH = 256;
|
|
11
|
+
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
12
|
+
9007199254740991;
|
|
13
|
+
var MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
14
|
+
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
15
|
+
var RELEASE_TYPES = [
|
|
16
|
+
"major",
|
|
17
|
+
"premajor",
|
|
18
|
+
"minor",
|
|
19
|
+
"preminor",
|
|
20
|
+
"patch",
|
|
21
|
+
"prepatch",
|
|
22
|
+
"prerelease"
|
|
23
|
+
];
|
|
24
|
+
module.exports = {
|
|
25
|
+
MAX_LENGTH,
|
|
26
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
27
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
28
|
+
MAX_SAFE_INTEGER,
|
|
29
|
+
RELEASE_TYPES,
|
|
30
|
+
SEMVER_SPEC_VERSION,
|
|
31
|
+
FLAG_INCLUDE_PRERELEASE: 1,
|
|
32
|
+
FLAG_LOOSE: 2
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// node_modules/semver/internal/debug.js
|
|
38
|
+
var require_debug = __commonJS({
|
|
39
|
+
"node_modules/semver/internal/debug.js"(exports, module) {
|
|
40
|
+
var debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
41
|
+
};
|
|
42
|
+
module.exports = debug;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// node_modules/semver/internal/re.js
|
|
47
|
+
var require_re = __commonJS({
|
|
48
|
+
"node_modules/semver/internal/re.js"(exports, module) {
|
|
49
|
+
var {
|
|
50
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
51
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
52
|
+
MAX_LENGTH
|
|
53
|
+
} = require_constants();
|
|
54
|
+
var debug = require_debug();
|
|
55
|
+
exports = module.exports = {};
|
|
56
|
+
var re = exports.re = [];
|
|
57
|
+
var safeRe = exports.safeRe = [];
|
|
58
|
+
var src = exports.src = [];
|
|
59
|
+
var safeSrc = exports.safeSrc = [];
|
|
60
|
+
var t = exports.t = {};
|
|
61
|
+
var R = 0;
|
|
62
|
+
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
63
|
+
var safeRegexReplacements = [
|
|
64
|
+
["\\s", 1],
|
|
65
|
+
["\\d", MAX_LENGTH],
|
|
66
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
67
|
+
];
|
|
68
|
+
var makeSafeRegex = (value) => {
|
|
69
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
70
|
+
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
};
|
|
74
|
+
var createToken = (name, value, isGlobal) => {
|
|
75
|
+
const safe = makeSafeRegex(value);
|
|
76
|
+
const index = R++;
|
|
77
|
+
debug(name, index, value);
|
|
78
|
+
t[name] = index;
|
|
79
|
+
src[index] = value;
|
|
80
|
+
safeSrc[index] = safe;
|
|
81
|
+
re[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
82
|
+
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
83
|
+
};
|
|
84
|
+
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
85
|
+
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
86
|
+
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
87
|
+
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
88
|
+
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
89
|
+
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
90
|
+
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
91
|
+
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
92
|
+
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
93
|
+
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
94
|
+
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
95
|
+
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
96
|
+
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
97
|
+
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
98
|
+
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
99
|
+
createToken("GTLT", "((?:<|>)?=?)");
|
|
100
|
+
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
101
|
+
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
102
|
+
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
103
|
+
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
104
|
+
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
105
|
+
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
106
|
+
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
107
|
+
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
108
|
+
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
109
|
+
createToken("COERCERTL", src[t.COERCE], true);
|
|
110
|
+
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
111
|
+
createToken("LONETILDE", "(?:~>?)");
|
|
112
|
+
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
113
|
+
exports.tildeTrimReplace = "$1~";
|
|
114
|
+
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
115
|
+
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
116
|
+
createToken("LONECARET", "(?:\\^)");
|
|
117
|
+
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
118
|
+
exports.caretTrimReplace = "$1^";
|
|
119
|
+
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
120
|
+
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
121
|
+
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
122
|
+
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
123
|
+
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
124
|
+
exports.comparatorTrimReplace = "$1$2$3";
|
|
125
|
+
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
126
|
+
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
127
|
+
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
128
|
+
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
129
|
+
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// node_modules/semver/internal/parse-options.js
|
|
134
|
+
var require_parse_options = __commonJS({
|
|
135
|
+
"node_modules/semver/internal/parse-options.js"(exports, module) {
|
|
136
|
+
var looseOption = Object.freeze({ loose: true });
|
|
137
|
+
var emptyOpts = Object.freeze({});
|
|
138
|
+
var parseOptions = (options) => {
|
|
139
|
+
if (!options) {
|
|
140
|
+
return emptyOpts;
|
|
141
|
+
}
|
|
142
|
+
if (typeof options !== "object") {
|
|
143
|
+
return looseOption;
|
|
144
|
+
}
|
|
145
|
+
return options;
|
|
146
|
+
};
|
|
147
|
+
module.exports = parseOptions;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// node_modules/semver/internal/identifiers.js
|
|
152
|
+
var require_identifiers = __commonJS({
|
|
153
|
+
"node_modules/semver/internal/identifiers.js"(exports, module) {
|
|
154
|
+
var numeric = /^[0-9]+$/;
|
|
155
|
+
var compareIdentifiers = (a, b) => {
|
|
156
|
+
if (typeof a === "number" && typeof b === "number") {
|
|
157
|
+
return a === b ? 0 : a < b ? -1 : 1;
|
|
158
|
+
}
|
|
159
|
+
const anum = numeric.test(a);
|
|
160
|
+
const bnum = numeric.test(b);
|
|
161
|
+
if (anum && bnum) {
|
|
162
|
+
a = +a;
|
|
163
|
+
b = +b;
|
|
164
|
+
}
|
|
165
|
+
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
|
|
166
|
+
};
|
|
167
|
+
var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
|
|
168
|
+
module.exports = {
|
|
169
|
+
compareIdentifiers,
|
|
170
|
+
rcompareIdentifiers
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// node_modules/semver/classes/semver.js
|
|
176
|
+
var require_semver = __commonJS({
|
|
177
|
+
"node_modules/semver/classes/semver.js"(exports, module) {
|
|
178
|
+
var debug = require_debug();
|
|
179
|
+
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
180
|
+
var { safeRe: re, t } = require_re();
|
|
181
|
+
var parseOptions = require_parse_options();
|
|
182
|
+
var { compareIdentifiers } = require_identifiers();
|
|
183
|
+
var SemVer = class _SemVer {
|
|
184
|
+
constructor(version, options) {
|
|
185
|
+
options = parseOptions(options);
|
|
186
|
+
if (version instanceof _SemVer) {
|
|
187
|
+
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
188
|
+
return version;
|
|
189
|
+
} else {
|
|
190
|
+
version = version.version;
|
|
191
|
+
}
|
|
192
|
+
} else if (typeof version !== "string") {
|
|
193
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
194
|
+
}
|
|
195
|
+
if (version.length > MAX_LENGTH) {
|
|
196
|
+
throw new TypeError(
|
|
197
|
+
`version is longer than ${MAX_LENGTH} characters`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
debug("SemVer", version, options);
|
|
201
|
+
this.options = options;
|
|
202
|
+
this.loose = !!options.loose;
|
|
203
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
204
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
|
205
|
+
if (!m) {
|
|
206
|
+
throw new TypeError(`Invalid Version: ${version}`);
|
|
207
|
+
}
|
|
208
|
+
this.raw = version;
|
|
209
|
+
this.major = +m[1];
|
|
210
|
+
this.minor = +m[2];
|
|
211
|
+
this.patch = +m[3];
|
|
212
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
213
|
+
throw new TypeError("Invalid major version");
|
|
214
|
+
}
|
|
215
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
216
|
+
throw new TypeError("Invalid minor version");
|
|
217
|
+
}
|
|
218
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
219
|
+
throw new TypeError("Invalid patch version");
|
|
220
|
+
}
|
|
221
|
+
if (!m[4]) {
|
|
222
|
+
this.prerelease = [];
|
|
223
|
+
} else {
|
|
224
|
+
this.prerelease = m[4].split(".").map((id) => {
|
|
225
|
+
if (/^[0-9]+$/.test(id)) {
|
|
226
|
+
const num = +id;
|
|
227
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
228
|
+
return num;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return id;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
this.build = m[5] ? m[5].split(".") : [];
|
|
235
|
+
this.format();
|
|
236
|
+
}
|
|
237
|
+
format() {
|
|
238
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
239
|
+
if (this.prerelease.length) {
|
|
240
|
+
this.version += `-${this.prerelease.join(".")}`;
|
|
241
|
+
}
|
|
242
|
+
return this.version;
|
|
243
|
+
}
|
|
244
|
+
toString() {
|
|
245
|
+
return this.version;
|
|
246
|
+
}
|
|
247
|
+
compare(other) {
|
|
248
|
+
debug("SemVer.compare", this.version, this.options, other);
|
|
249
|
+
if (!(other instanceof _SemVer)) {
|
|
250
|
+
if (typeof other === "string" && other === this.version) {
|
|
251
|
+
return 0;
|
|
252
|
+
}
|
|
253
|
+
other = new _SemVer(other, this.options);
|
|
254
|
+
}
|
|
255
|
+
if (other.version === this.version) {
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
return this.compareMain(other) || this.comparePre(other);
|
|
259
|
+
}
|
|
260
|
+
compareMain(other) {
|
|
261
|
+
if (!(other instanceof _SemVer)) {
|
|
262
|
+
other = new _SemVer(other, this.options);
|
|
263
|
+
}
|
|
264
|
+
if (this.major < other.major) {
|
|
265
|
+
return -1;
|
|
266
|
+
}
|
|
267
|
+
if (this.major > other.major) {
|
|
268
|
+
return 1;
|
|
269
|
+
}
|
|
270
|
+
if (this.minor < other.minor) {
|
|
271
|
+
return -1;
|
|
272
|
+
}
|
|
273
|
+
if (this.minor > other.minor) {
|
|
274
|
+
return 1;
|
|
275
|
+
}
|
|
276
|
+
if (this.patch < other.patch) {
|
|
277
|
+
return -1;
|
|
278
|
+
}
|
|
279
|
+
if (this.patch > other.patch) {
|
|
280
|
+
return 1;
|
|
281
|
+
}
|
|
282
|
+
return 0;
|
|
283
|
+
}
|
|
284
|
+
comparePre(other) {
|
|
285
|
+
if (!(other instanceof _SemVer)) {
|
|
286
|
+
other = new _SemVer(other, this.options);
|
|
287
|
+
}
|
|
288
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
|
289
|
+
return -1;
|
|
290
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
291
|
+
return 1;
|
|
292
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
295
|
+
let i = 0;
|
|
296
|
+
do {
|
|
297
|
+
const a = this.prerelease[i];
|
|
298
|
+
const b = other.prerelease[i];
|
|
299
|
+
debug("prerelease compare", i, a, b);
|
|
300
|
+
if (a === void 0 && b === void 0) {
|
|
301
|
+
return 0;
|
|
302
|
+
} else if (b === void 0) {
|
|
303
|
+
return 1;
|
|
304
|
+
} else if (a === void 0) {
|
|
305
|
+
return -1;
|
|
306
|
+
} else if (a === b) {
|
|
307
|
+
continue;
|
|
308
|
+
} else {
|
|
309
|
+
return compareIdentifiers(a, b);
|
|
310
|
+
}
|
|
311
|
+
} while (++i);
|
|
312
|
+
}
|
|
313
|
+
compareBuild(other) {
|
|
314
|
+
if (!(other instanceof _SemVer)) {
|
|
315
|
+
other = new _SemVer(other, this.options);
|
|
316
|
+
}
|
|
317
|
+
let i = 0;
|
|
318
|
+
do {
|
|
319
|
+
const a = this.build[i];
|
|
320
|
+
const b = other.build[i];
|
|
321
|
+
debug("build compare", i, a, b);
|
|
322
|
+
if (a === void 0 && b === void 0) {
|
|
323
|
+
return 0;
|
|
324
|
+
} else if (b === void 0) {
|
|
325
|
+
return 1;
|
|
326
|
+
} else if (a === void 0) {
|
|
327
|
+
return -1;
|
|
328
|
+
} else if (a === b) {
|
|
329
|
+
continue;
|
|
330
|
+
} else {
|
|
331
|
+
return compareIdentifiers(a, b);
|
|
332
|
+
}
|
|
333
|
+
} while (++i);
|
|
334
|
+
}
|
|
335
|
+
// preminor will bump the version up to the next minor release, and immediately
|
|
336
|
+
// down to pre-release. premajor and prepatch work the same way.
|
|
337
|
+
inc(release, identifier, identifierBase) {
|
|
338
|
+
if (release.startsWith("pre")) {
|
|
339
|
+
if (!identifier && identifierBase === false) {
|
|
340
|
+
throw new Error("invalid increment argument: identifier is empty");
|
|
341
|
+
}
|
|
342
|
+
if (identifier) {
|
|
343
|
+
const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
|
|
344
|
+
if (!match || match[1] !== identifier) {
|
|
345
|
+
throw new Error(`invalid identifier: ${identifier}`);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
switch (release) {
|
|
350
|
+
case "premajor":
|
|
351
|
+
this.prerelease.length = 0;
|
|
352
|
+
this.patch = 0;
|
|
353
|
+
this.minor = 0;
|
|
354
|
+
this.major++;
|
|
355
|
+
this.inc("pre", identifier, identifierBase);
|
|
356
|
+
break;
|
|
357
|
+
case "preminor":
|
|
358
|
+
this.prerelease.length = 0;
|
|
359
|
+
this.patch = 0;
|
|
360
|
+
this.minor++;
|
|
361
|
+
this.inc("pre", identifier, identifierBase);
|
|
362
|
+
break;
|
|
363
|
+
case "prepatch":
|
|
364
|
+
this.prerelease.length = 0;
|
|
365
|
+
this.inc("patch", identifier, identifierBase);
|
|
366
|
+
this.inc("pre", identifier, identifierBase);
|
|
367
|
+
break;
|
|
368
|
+
// If the input is a non-prerelease version, this acts the same as
|
|
369
|
+
// prepatch.
|
|
370
|
+
case "prerelease":
|
|
371
|
+
if (this.prerelease.length === 0) {
|
|
372
|
+
this.inc("patch", identifier, identifierBase);
|
|
373
|
+
}
|
|
374
|
+
this.inc("pre", identifier, identifierBase);
|
|
375
|
+
break;
|
|
376
|
+
case "release":
|
|
377
|
+
if (this.prerelease.length === 0) {
|
|
378
|
+
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
379
|
+
}
|
|
380
|
+
this.prerelease.length = 0;
|
|
381
|
+
break;
|
|
382
|
+
case "major":
|
|
383
|
+
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
384
|
+
this.major++;
|
|
385
|
+
}
|
|
386
|
+
this.minor = 0;
|
|
387
|
+
this.patch = 0;
|
|
388
|
+
this.prerelease = [];
|
|
389
|
+
break;
|
|
390
|
+
case "minor":
|
|
391
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
392
|
+
this.minor++;
|
|
393
|
+
}
|
|
394
|
+
this.patch = 0;
|
|
395
|
+
this.prerelease = [];
|
|
396
|
+
break;
|
|
397
|
+
case "patch":
|
|
398
|
+
if (this.prerelease.length === 0) {
|
|
399
|
+
this.patch++;
|
|
400
|
+
}
|
|
401
|
+
this.prerelease = [];
|
|
402
|
+
break;
|
|
403
|
+
// This probably shouldn't be used publicly.
|
|
404
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
405
|
+
case "pre": {
|
|
406
|
+
const base = Number(identifierBase) ? 1 : 0;
|
|
407
|
+
if (this.prerelease.length === 0) {
|
|
408
|
+
this.prerelease = [base];
|
|
409
|
+
} else {
|
|
410
|
+
let i = this.prerelease.length;
|
|
411
|
+
while (--i >= 0) {
|
|
412
|
+
if (typeof this.prerelease[i] === "number") {
|
|
413
|
+
this.prerelease[i]++;
|
|
414
|
+
i = -2;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (i === -1) {
|
|
418
|
+
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
419
|
+
throw new Error("invalid increment argument: identifier already exists");
|
|
420
|
+
}
|
|
421
|
+
this.prerelease.push(base);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (identifier) {
|
|
425
|
+
let prerelease = [identifier, base];
|
|
426
|
+
if (identifierBase === false) {
|
|
427
|
+
prerelease = [identifier];
|
|
428
|
+
}
|
|
429
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
430
|
+
if (isNaN(this.prerelease[1])) {
|
|
431
|
+
this.prerelease = prerelease;
|
|
432
|
+
}
|
|
433
|
+
} else {
|
|
434
|
+
this.prerelease = prerelease;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
break;
|
|
438
|
+
}
|
|
439
|
+
default:
|
|
440
|
+
throw new Error(`invalid increment argument: ${release}`);
|
|
441
|
+
}
|
|
442
|
+
this.raw = this.format();
|
|
443
|
+
if (this.build.length) {
|
|
444
|
+
this.raw += `+${this.build.join(".")}`;
|
|
445
|
+
}
|
|
446
|
+
return this;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
module.exports = SemVer;
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// node_modules/semver/functions/parse.js
|
|
454
|
+
var require_parse = __commonJS({
|
|
455
|
+
"node_modules/semver/functions/parse.js"(exports, module) {
|
|
456
|
+
var SemVer = require_semver();
|
|
457
|
+
var parse = (version, options, throwErrors = false) => {
|
|
458
|
+
if (version instanceof SemVer) {
|
|
459
|
+
return version;
|
|
460
|
+
}
|
|
461
|
+
try {
|
|
462
|
+
return new SemVer(version, options);
|
|
463
|
+
} catch (er) {
|
|
464
|
+
if (!throwErrors) {
|
|
465
|
+
return null;
|
|
466
|
+
}
|
|
467
|
+
throw er;
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
module.exports = parse;
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
// node_modules/semver/functions/valid.js
|
|
475
|
+
var require_valid = __commonJS({
|
|
476
|
+
"node_modules/semver/functions/valid.js"(exports, module) {
|
|
477
|
+
var parse = require_parse();
|
|
478
|
+
var valid = (version, options) => {
|
|
479
|
+
const v = parse(version, options);
|
|
480
|
+
return v ? v.version : null;
|
|
481
|
+
};
|
|
482
|
+
module.exports = valid;
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// node_modules/semver/functions/clean.js
|
|
487
|
+
var require_clean = __commonJS({
|
|
488
|
+
"node_modules/semver/functions/clean.js"(exports, module) {
|
|
489
|
+
var parse = require_parse();
|
|
490
|
+
var clean = (version, options) => {
|
|
491
|
+
const s = parse(version.trim().replace(/^[=v]+/, ""), options);
|
|
492
|
+
return s ? s.version : null;
|
|
493
|
+
};
|
|
494
|
+
module.exports = clean;
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
// node_modules/semver/functions/inc.js
|
|
499
|
+
var require_inc = __commonJS({
|
|
500
|
+
"node_modules/semver/functions/inc.js"(exports, module) {
|
|
501
|
+
var SemVer = require_semver();
|
|
502
|
+
var inc = (version, release, options, identifier, identifierBase) => {
|
|
503
|
+
if (typeof options === "string") {
|
|
504
|
+
identifierBase = identifier;
|
|
505
|
+
identifier = options;
|
|
506
|
+
options = void 0;
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
return new SemVer(
|
|
510
|
+
version instanceof SemVer ? version.version : version,
|
|
511
|
+
options
|
|
512
|
+
).inc(release, identifier, identifierBase).version;
|
|
513
|
+
} catch (er) {
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
module.exports = inc;
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
// node_modules/semver/functions/diff.js
|
|
522
|
+
var require_diff = __commonJS({
|
|
523
|
+
"node_modules/semver/functions/diff.js"(exports, module) {
|
|
524
|
+
var parse = require_parse();
|
|
525
|
+
var diff = (version1, version2) => {
|
|
526
|
+
const v1 = parse(version1, null, true);
|
|
527
|
+
const v2 = parse(version2, null, true);
|
|
528
|
+
const comparison = v1.compare(v2);
|
|
529
|
+
if (comparison === 0) {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
const v1Higher = comparison > 0;
|
|
533
|
+
const highVersion = v1Higher ? v1 : v2;
|
|
534
|
+
const lowVersion = v1Higher ? v2 : v1;
|
|
535
|
+
const highHasPre = !!highVersion.prerelease.length;
|
|
536
|
+
const lowHasPre = !!lowVersion.prerelease.length;
|
|
537
|
+
if (lowHasPre && !highHasPre) {
|
|
538
|
+
if (!lowVersion.patch && !lowVersion.minor) {
|
|
539
|
+
return "major";
|
|
540
|
+
}
|
|
541
|
+
if (lowVersion.compareMain(highVersion) === 0) {
|
|
542
|
+
if (lowVersion.minor && !lowVersion.patch) {
|
|
543
|
+
return "minor";
|
|
544
|
+
}
|
|
545
|
+
return "patch";
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
const prefix = highHasPre ? "pre" : "";
|
|
549
|
+
if (v1.major !== v2.major) {
|
|
550
|
+
return prefix + "major";
|
|
551
|
+
}
|
|
552
|
+
if (v1.minor !== v2.minor) {
|
|
553
|
+
return prefix + "minor";
|
|
554
|
+
}
|
|
555
|
+
if (v1.patch !== v2.patch) {
|
|
556
|
+
return prefix + "patch";
|
|
557
|
+
}
|
|
558
|
+
return "prerelease";
|
|
559
|
+
};
|
|
560
|
+
module.exports = diff;
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
// node_modules/semver/functions/major.js
|
|
565
|
+
var require_major = __commonJS({
|
|
566
|
+
"node_modules/semver/functions/major.js"(exports, module) {
|
|
567
|
+
var SemVer = require_semver();
|
|
568
|
+
var major = (a, loose) => new SemVer(a, loose).major;
|
|
569
|
+
module.exports = major;
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// node_modules/semver/functions/minor.js
|
|
574
|
+
var require_minor = __commonJS({
|
|
575
|
+
"node_modules/semver/functions/minor.js"(exports, module) {
|
|
576
|
+
var SemVer = require_semver();
|
|
577
|
+
var minor = (a, loose) => new SemVer(a, loose).minor;
|
|
578
|
+
module.exports = minor;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
// node_modules/semver/functions/patch.js
|
|
583
|
+
var require_patch = __commonJS({
|
|
584
|
+
"node_modules/semver/functions/patch.js"(exports, module) {
|
|
585
|
+
var SemVer = require_semver();
|
|
586
|
+
var patch = (a, loose) => new SemVer(a, loose).patch;
|
|
587
|
+
module.exports = patch;
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
// node_modules/semver/functions/prerelease.js
|
|
592
|
+
var require_prerelease = __commonJS({
|
|
593
|
+
"node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
594
|
+
var parse = require_parse();
|
|
595
|
+
var prerelease = (version, options) => {
|
|
596
|
+
const parsed = parse(version, options);
|
|
597
|
+
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
598
|
+
};
|
|
599
|
+
module.exports = prerelease;
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
// node_modules/semver/functions/compare.js
|
|
604
|
+
var require_compare = __commonJS({
|
|
605
|
+
"node_modules/semver/functions/compare.js"(exports, module) {
|
|
606
|
+
var SemVer = require_semver();
|
|
607
|
+
var compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
608
|
+
module.exports = compare;
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// node_modules/semver/functions/rcompare.js
|
|
613
|
+
var require_rcompare = __commonJS({
|
|
614
|
+
"node_modules/semver/functions/rcompare.js"(exports, module) {
|
|
615
|
+
var compare = require_compare();
|
|
616
|
+
var rcompare = (a, b, loose) => compare(b, a, loose);
|
|
617
|
+
module.exports = rcompare;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// node_modules/semver/functions/compare-loose.js
|
|
622
|
+
var require_compare_loose = __commonJS({
|
|
623
|
+
"node_modules/semver/functions/compare-loose.js"(exports, module) {
|
|
624
|
+
var compare = require_compare();
|
|
625
|
+
var compareLoose = (a, b) => compare(a, b, true);
|
|
626
|
+
module.exports = compareLoose;
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// node_modules/semver/functions/compare-build.js
|
|
631
|
+
var require_compare_build = __commonJS({
|
|
632
|
+
"node_modules/semver/functions/compare-build.js"(exports, module) {
|
|
633
|
+
var SemVer = require_semver();
|
|
634
|
+
var compareBuild = (a, b, loose) => {
|
|
635
|
+
const versionA = new SemVer(a, loose);
|
|
636
|
+
const versionB = new SemVer(b, loose);
|
|
637
|
+
return versionA.compare(versionB) || versionA.compareBuild(versionB);
|
|
638
|
+
};
|
|
639
|
+
module.exports = compareBuild;
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
// node_modules/semver/functions/sort.js
|
|
644
|
+
var require_sort = __commonJS({
|
|
645
|
+
"node_modules/semver/functions/sort.js"(exports, module) {
|
|
646
|
+
var compareBuild = require_compare_build();
|
|
647
|
+
var sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
648
|
+
module.exports = sort;
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
// node_modules/semver/functions/rsort.js
|
|
653
|
+
var require_rsort = __commonJS({
|
|
654
|
+
"node_modules/semver/functions/rsort.js"(exports, module) {
|
|
655
|
+
var compareBuild = require_compare_build();
|
|
656
|
+
var rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
657
|
+
module.exports = rsort;
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
// node_modules/semver/functions/gt.js
|
|
662
|
+
var require_gt = __commonJS({
|
|
663
|
+
"node_modules/semver/functions/gt.js"(exports, module) {
|
|
664
|
+
var compare = require_compare();
|
|
665
|
+
var gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
666
|
+
module.exports = gt;
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
// node_modules/semver/functions/lt.js
|
|
671
|
+
var require_lt = __commonJS({
|
|
672
|
+
"node_modules/semver/functions/lt.js"(exports, module) {
|
|
673
|
+
var compare = require_compare();
|
|
674
|
+
var lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
675
|
+
module.exports = lt;
|
|
676
|
+
}
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
// node_modules/semver/functions/eq.js
|
|
680
|
+
var require_eq = __commonJS({
|
|
681
|
+
"node_modules/semver/functions/eq.js"(exports, module) {
|
|
682
|
+
var compare = require_compare();
|
|
683
|
+
var eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
684
|
+
module.exports = eq;
|
|
685
|
+
}
|
|
686
|
+
});
|
|
687
|
+
|
|
688
|
+
// node_modules/semver/functions/neq.js
|
|
689
|
+
var require_neq = __commonJS({
|
|
690
|
+
"node_modules/semver/functions/neq.js"(exports, module) {
|
|
691
|
+
var compare = require_compare();
|
|
692
|
+
var neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
693
|
+
module.exports = neq;
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
// node_modules/semver/functions/gte.js
|
|
698
|
+
var require_gte = __commonJS({
|
|
699
|
+
"node_modules/semver/functions/gte.js"(exports, module) {
|
|
700
|
+
var compare = require_compare();
|
|
701
|
+
var gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
702
|
+
module.exports = gte;
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
|
|
706
|
+
// node_modules/semver/functions/lte.js
|
|
707
|
+
var require_lte = __commonJS({
|
|
708
|
+
"node_modules/semver/functions/lte.js"(exports, module) {
|
|
709
|
+
var compare = require_compare();
|
|
710
|
+
var lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
711
|
+
module.exports = lte;
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
// node_modules/semver/functions/cmp.js
|
|
716
|
+
var require_cmp = __commonJS({
|
|
717
|
+
"node_modules/semver/functions/cmp.js"(exports, module) {
|
|
718
|
+
var eq = require_eq();
|
|
719
|
+
var neq = require_neq();
|
|
720
|
+
var gt = require_gt();
|
|
721
|
+
var gte = require_gte();
|
|
722
|
+
var lt = require_lt();
|
|
723
|
+
var lte = require_lte();
|
|
724
|
+
var cmp = (a, op, b, loose) => {
|
|
725
|
+
switch (op) {
|
|
726
|
+
case "===":
|
|
727
|
+
if (typeof a === "object") {
|
|
728
|
+
a = a.version;
|
|
729
|
+
}
|
|
730
|
+
if (typeof b === "object") {
|
|
731
|
+
b = b.version;
|
|
732
|
+
}
|
|
733
|
+
return a === b;
|
|
734
|
+
case "!==":
|
|
735
|
+
if (typeof a === "object") {
|
|
736
|
+
a = a.version;
|
|
737
|
+
}
|
|
738
|
+
if (typeof b === "object") {
|
|
739
|
+
b = b.version;
|
|
740
|
+
}
|
|
741
|
+
return a !== b;
|
|
742
|
+
case "":
|
|
743
|
+
case "=":
|
|
744
|
+
case "==":
|
|
745
|
+
return eq(a, b, loose);
|
|
746
|
+
case "!=":
|
|
747
|
+
return neq(a, b, loose);
|
|
748
|
+
case ">":
|
|
749
|
+
return gt(a, b, loose);
|
|
750
|
+
case ">=":
|
|
751
|
+
return gte(a, b, loose);
|
|
752
|
+
case "<":
|
|
753
|
+
return lt(a, b, loose);
|
|
754
|
+
case "<=":
|
|
755
|
+
return lte(a, b, loose);
|
|
756
|
+
default:
|
|
757
|
+
throw new TypeError(`Invalid operator: ${op}`);
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
module.exports = cmp;
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
// node_modules/semver/functions/coerce.js
|
|
765
|
+
var require_coerce = __commonJS({
|
|
766
|
+
"node_modules/semver/functions/coerce.js"(exports, module) {
|
|
767
|
+
var SemVer = require_semver();
|
|
768
|
+
var parse = require_parse();
|
|
769
|
+
var { safeRe: re, t } = require_re();
|
|
770
|
+
var coerce = (version, options) => {
|
|
771
|
+
if (version instanceof SemVer) {
|
|
772
|
+
return version;
|
|
773
|
+
}
|
|
774
|
+
if (typeof version === "number") {
|
|
775
|
+
version = String(version);
|
|
776
|
+
}
|
|
777
|
+
if (typeof version !== "string") {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
options = options || {};
|
|
781
|
+
let match = null;
|
|
782
|
+
if (!options.rtl) {
|
|
783
|
+
match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
|
|
784
|
+
} else {
|
|
785
|
+
const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
|
|
786
|
+
let next;
|
|
787
|
+
while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
|
|
788
|
+
if (!match || next.index + next[0].length !== match.index + match[0].length) {
|
|
789
|
+
match = next;
|
|
790
|
+
}
|
|
791
|
+
coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
|
|
792
|
+
}
|
|
793
|
+
coerceRtlRegex.lastIndex = -1;
|
|
794
|
+
}
|
|
795
|
+
if (match === null) {
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
const major = match[2];
|
|
799
|
+
const minor = match[3] || "0";
|
|
800
|
+
const patch = match[4] || "0";
|
|
801
|
+
const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
|
|
802
|
+
const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
|
|
803
|
+
return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
|
|
804
|
+
};
|
|
805
|
+
module.exports = coerce;
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
// node_modules/semver/internal/lrucache.js
|
|
810
|
+
var require_lrucache = __commonJS({
|
|
811
|
+
"node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
812
|
+
var LRUCache = class {
|
|
813
|
+
constructor() {
|
|
814
|
+
this.max = 1e3;
|
|
815
|
+
this.map = /* @__PURE__ */ new Map();
|
|
816
|
+
}
|
|
817
|
+
get(key) {
|
|
818
|
+
const value = this.map.get(key);
|
|
819
|
+
if (value === void 0) {
|
|
820
|
+
return void 0;
|
|
821
|
+
} else {
|
|
822
|
+
this.map.delete(key);
|
|
823
|
+
this.map.set(key, value);
|
|
824
|
+
return value;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
delete(key) {
|
|
828
|
+
return this.map.delete(key);
|
|
829
|
+
}
|
|
830
|
+
set(key, value) {
|
|
831
|
+
const deleted = this.delete(key);
|
|
832
|
+
if (!deleted && value !== void 0) {
|
|
833
|
+
if (this.map.size >= this.max) {
|
|
834
|
+
const firstKey = this.map.keys().next().value;
|
|
835
|
+
this.delete(firstKey);
|
|
836
|
+
}
|
|
837
|
+
this.map.set(key, value);
|
|
838
|
+
}
|
|
839
|
+
return this;
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
module.exports = LRUCache;
|
|
843
|
+
}
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// node_modules/semver/classes/range.js
|
|
847
|
+
var require_range = __commonJS({
|
|
848
|
+
"node_modules/semver/classes/range.js"(exports, module) {
|
|
849
|
+
var SPACE_CHARACTERS = /\s+/g;
|
|
850
|
+
var Range = class _Range {
|
|
851
|
+
constructor(range, options) {
|
|
852
|
+
options = parseOptions(options);
|
|
853
|
+
if (range instanceof _Range) {
|
|
854
|
+
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
|
|
855
|
+
return range;
|
|
856
|
+
} else {
|
|
857
|
+
return new _Range(range.raw, options);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (range instanceof Comparator) {
|
|
861
|
+
this.raw = range.value;
|
|
862
|
+
this.set = [[range]];
|
|
863
|
+
this.formatted = void 0;
|
|
864
|
+
return this;
|
|
865
|
+
}
|
|
866
|
+
this.options = options;
|
|
867
|
+
this.loose = !!options.loose;
|
|
868
|
+
this.includePrerelease = !!options.includePrerelease;
|
|
869
|
+
this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
|
|
870
|
+
this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
|
|
871
|
+
if (!this.set.length) {
|
|
872
|
+
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
873
|
+
}
|
|
874
|
+
if (this.set.length > 1) {
|
|
875
|
+
const first = this.set[0];
|
|
876
|
+
this.set = this.set.filter((c) => !isNullSet(c[0]));
|
|
877
|
+
if (this.set.length === 0) {
|
|
878
|
+
this.set = [first];
|
|
879
|
+
} else if (this.set.length > 1) {
|
|
880
|
+
for (const c of this.set) {
|
|
881
|
+
if (c.length === 1 && isAny(c[0])) {
|
|
882
|
+
this.set = [c];
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
this.formatted = void 0;
|
|
889
|
+
}
|
|
890
|
+
get range() {
|
|
891
|
+
if (this.formatted === void 0) {
|
|
892
|
+
this.formatted = "";
|
|
893
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
894
|
+
if (i > 0) {
|
|
895
|
+
this.formatted += "||";
|
|
896
|
+
}
|
|
897
|
+
const comps = this.set[i];
|
|
898
|
+
for (let k = 0; k < comps.length; k++) {
|
|
899
|
+
if (k > 0) {
|
|
900
|
+
this.formatted += " ";
|
|
901
|
+
}
|
|
902
|
+
this.formatted += comps[k].toString().trim();
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return this.formatted;
|
|
907
|
+
}
|
|
908
|
+
format() {
|
|
909
|
+
return this.range;
|
|
910
|
+
}
|
|
911
|
+
toString() {
|
|
912
|
+
return this.range;
|
|
913
|
+
}
|
|
914
|
+
parseRange(range) {
|
|
915
|
+
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
|
916
|
+
const memoKey = memoOpts + ":" + range;
|
|
917
|
+
const cached = cache.get(memoKey);
|
|
918
|
+
if (cached) {
|
|
919
|
+
return cached;
|
|
920
|
+
}
|
|
921
|
+
const loose = this.options.loose;
|
|
922
|
+
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
923
|
+
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
924
|
+
debug("hyphen replace", range);
|
|
925
|
+
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
926
|
+
debug("comparator trim", range);
|
|
927
|
+
range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
928
|
+
debug("tilde trim", range);
|
|
929
|
+
range = range.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
930
|
+
debug("caret trim", range);
|
|
931
|
+
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
|
|
932
|
+
if (loose) {
|
|
933
|
+
rangeList = rangeList.filter((comp) => {
|
|
934
|
+
debug("loose invalid filter", comp, this.options);
|
|
935
|
+
return !!comp.match(re[t.COMPARATORLOOSE]);
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
debug("range list", rangeList);
|
|
939
|
+
const rangeMap = /* @__PURE__ */ new Map();
|
|
940
|
+
const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
|
|
941
|
+
for (const comp of comparators) {
|
|
942
|
+
if (isNullSet(comp)) {
|
|
943
|
+
return [comp];
|
|
944
|
+
}
|
|
945
|
+
rangeMap.set(comp.value, comp);
|
|
946
|
+
}
|
|
947
|
+
if (rangeMap.size > 1 && rangeMap.has("")) {
|
|
948
|
+
rangeMap.delete("");
|
|
949
|
+
}
|
|
950
|
+
const result = [...rangeMap.values()];
|
|
951
|
+
cache.set(memoKey, result);
|
|
952
|
+
return result;
|
|
953
|
+
}
|
|
954
|
+
intersects(range, options) {
|
|
955
|
+
if (!(range instanceof _Range)) {
|
|
956
|
+
throw new TypeError("a Range is required");
|
|
957
|
+
}
|
|
958
|
+
return this.set.some((thisComparators) => {
|
|
959
|
+
return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
|
|
960
|
+
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
961
|
+
return rangeComparators.every((rangeComparator) => {
|
|
962
|
+
return thisComparator.intersects(rangeComparator, options);
|
|
963
|
+
});
|
|
964
|
+
});
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
// if ANY of the sets match ALL of its comparators, then pass
|
|
969
|
+
test(version) {
|
|
970
|
+
if (!version) {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
if (typeof version === "string") {
|
|
974
|
+
try {
|
|
975
|
+
version = new SemVer(version, this.options);
|
|
976
|
+
} catch (er) {
|
|
977
|
+
return false;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
981
|
+
if (testSet(this.set[i], version, this.options)) {
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
return false;
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
module.exports = Range;
|
|
989
|
+
var LRU = require_lrucache();
|
|
990
|
+
var cache = new LRU();
|
|
991
|
+
var parseOptions = require_parse_options();
|
|
992
|
+
var Comparator = require_comparator();
|
|
993
|
+
var debug = require_debug();
|
|
994
|
+
var SemVer = require_semver();
|
|
995
|
+
var {
|
|
996
|
+
safeRe: re,
|
|
997
|
+
t,
|
|
998
|
+
comparatorTrimReplace,
|
|
999
|
+
tildeTrimReplace,
|
|
1000
|
+
caretTrimReplace
|
|
1001
|
+
} = require_re();
|
|
1002
|
+
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
|
|
1003
|
+
var isNullSet = (c) => c.value === "<0.0.0-0";
|
|
1004
|
+
var isAny = (c) => c.value === "";
|
|
1005
|
+
var isSatisfiable = (comparators, options) => {
|
|
1006
|
+
let result = true;
|
|
1007
|
+
const remainingComparators = comparators.slice();
|
|
1008
|
+
let testComparator = remainingComparators.pop();
|
|
1009
|
+
while (result && remainingComparators.length) {
|
|
1010
|
+
result = remainingComparators.every((otherComparator) => {
|
|
1011
|
+
return testComparator.intersects(otherComparator, options);
|
|
1012
|
+
});
|
|
1013
|
+
testComparator = remainingComparators.pop();
|
|
1014
|
+
}
|
|
1015
|
+
return result;
|
|
1016
|
+
};
|
|
1017
|
+
var parseComparator = (comp, options) => {
|
|
1018
|
+
comp = comp.replace(re[t.BUILD], "");
|
|
1019
|
+
debug("comp", comp, options);
|
|
1020
|
+
comp = replaceCarets(comp, options);
|
|
1021
|
+
debug("caret", comp);
|
|
1022
|
+
comp = replaceTildes(comp, options);
|
|
1023
|
+
debug("tildes", comp);
|
|
1024
|
+
comp = replaceXRanges(comp, options);
|
|
1025
|
+
debug("xrange", comp);
|
|
1026
|
+
comp = replaceStars(comp, options);
|
|
1027
|
+
debug("stars", comp);
|
|
1028
|
+
return comp;
|
|
1029
|
+
};
|
|
1030
|
+
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
1031
|
+
var replaceTildes = (comp, options) => {
|
|
1032
|
+
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
1033
|
+
};
|
|
1034
|
+
var replaceTilde = (comp, options) => {
|
|
1035
|
+
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
1036
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1037
|
+
debug("tilde", comp, _, M, m, p, pr);
|
|
1038
|
+
let ret;
|
|
1039
|
+
if (isX(M)) {
|
|
1040
|
+
ret = "";
|
|
1041
|
+
} else if (isX(m)) {
|
|
1042
|
+
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
1043
|
+
} else if (isX(p)) {
|
|
1044
|
+
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
1045
|
+
} else if (pr) {
|
|
1046
|
+
debug("replaceTilde pr", pr);
|
|
1047
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1048
|
+
} else {
|
|
1049
|
+
ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
1050
|
+
}
|
|
1051
|
+
debug("tilde return", ret);
|
|
1052
|
+
return ret;
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1055
|
+
var replaceCarets = (comp, options) => {
|
|
1056
|
+
return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
|
|
1057
|
+
};
|
|
1058
|
+
var replaceCaret = (comp, options) => {
|
|
1059
|
+
debug("caret", comp, options);
|
|
1060
|
+
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
|
|
1061
|
+
const z2 = options.includePrerelease ? "-0" : "";
|
|
1062
|
+
return comp.replace(r, (_, M, m, p, pr) => {
|
|
1063
|
+
debug("caret", comp, _, M, m, p, pr);
|
|
1064
|
+
let ret;
|
|
1065
|
+
if (isX(M)) {
|
|
1066
|
+
ret = "";
|
|
1067
|
+
} else if (isX(m)) {
|
|
1068
|
+
ret = `>=${M}.0.0${z2} <${+M + 1}.0.0-0`;
|
|
1069
|
+
} else if (isX(p)) {
|
|
1070
|
+
if (M === "0") {
|
|
1071
|
+
ret = `>=${M}.${m}.0${z2} <${M}.${+m + 1}.0-0`;
|
|
1072
|
+
} else {
|
|
1073
|
+
ret = `>=${M}.${m}.0${z2} <${+M + 1}.0.0-0`;
|
|
1074
|
+
}
|
|
1075
|
+
} else if (pr) {
|
|
1076
|
+
debug("replaceCaret pr", pr);
|
|
1077
|
+
if (M === "0") {
|
|
1078
|
+
if (m === "0") {
|
|
1079
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
|
|
1080
|
+
} else {
|
|
1081
|
+
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1084
|
+
ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
debug("no pr");
|
|
1088
|
+
if (M === "0") {
|
|
1089
|
+
if (m === "0") {
|
|
1090
|
+
ret = `>=${M}.${m}.${p}${z2} <${M}.${m}.${+p + 1}-0`;
|
|
1091
|
+
} else {
|
|
1092
|
+
ret = `>=${M}.${m}.${p}${z2} <${M}.${+m + 1}.0-0`;
|
|
1093
|
+
}
|
|
1094
|
+
} else {
|
|
1095
|
+
ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
debug("caret return", ret);
|
|
1099
|
+
return ret;
|
|
1100
|
+
});
|
|
1101
|
+
};
|
|
1102
|
+
var replaceXRanges = (comp, options) => {
|
|
1103
|
+
debug("replaceXRanges", comp, options);
|
|
1104
|
+
return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
|
|
1105
|
+
};
|
|
1106
|
+
var replaceXRange = (comp, options) => {
|
|
1107
|
+
comp = comp.trim();
|
|
1108
|
+
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
1109
|
+
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
1110
|
+
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
1111
|
+
const xM = isX(M);
|
|
1112
|
+
const xm = xM || isX(m);
|
|
1113
|
+
const xp = xm || isX(p);
|
|
1114
|
+
const anyX = xp;
|
|
1115
|
+
if (gtlt === "=" && anyX) {
|
|
1116
|
+
gtlt = "";
|
|
1117
|
+
}
|
|
1118
|
+
pr = options.includePrerelease ? "-0" : "";
|
|
1119
|
+
if (xM) {
|
|
1120
|
+
if (gtlt === ">" || gtlt === "<") {
|
|
1121
|
+
ret = "<0.0.0-0";
|
|
1122
|
+
} else {
|
|
1123
|
+
ret = "*";
|
|
1124
|
+
}
|
|
1125
|
+
} else if (gtlt && anyX) {
|
|
1126
|
+
if (xm) {
|
|
1127
|
+
m = 0;
|
|
1128
|
+
}
|
|
1129
|
+
p = 0;
|
|
1130
|
+
if (gtlt === ">") {
|
|
1131
|
+
gtlt = ">=";
|
|
1132
|
+
if (xm) {
|
|
1133
|
+
M = +M + 1;
|
|
1134
|
+
m = 0;
|
|
1135
|
+
p = 0;
|
|
1136
|
+
} else {
|
|
1137
|
+
m = +m + 1;
|
|
1138
|
+
p = 0;
|
|
1139
|
+
}
|
|
1140
|
+
} else if (gtlt === "<=") {
|
|
1141
|
+
gtlt = "<";
|
|
1142
|
+
if (xm) {
|
|
1143
|
+
M = +M + 1;
|
|
1144
|
+
} else {
|
|
1145
|
+
m = +m + 1;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (gtlt === "<") {
|
|
1149
|
+
pr = "-0";
|
|
1150
|
+
}
|
|
1151
|
+
ret = `${gtlt + M}.${m}.${p}${pr}`;
|
|
1152
|
+
} else if (xm) {
|
|
1153
|
+
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
|
|
1154
|
+
} else if (xp) {
|
|
1155
|
+
ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
|
|
1156
|
+
}
|
|
1157
|
+
debug("xRange return", ret);
|
|
1158
|
+
return ret;
|
|
1159
|
+
});
|
|
1160
|
+
};
|
|
1161
|
+
var replaceStars = (comp, options) => {
|
|
1162
|
+
debug("replaceStars", comp, options);
|
|
1163
|
+
return comp.trim().replace(re[t.STAR], "");
|
|
1164
|
+
};
|
|
1165
|
+
var replaceGTE0 = (comp, options) => {
|
|
1166
|
+
debug("replaceGTE0", comp, options);
|
|
1167
|
+
return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
|
|
1168
|
+
};
|
|
1169
|
+
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
|
|
1170
|
+
if (isX(fM)) {
|
|
1171
|
+
from = "";
|
|
1172
|
+
} else if (isX(fm)) {
|
|
1173
|
+
from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
|
|
1174
|
+
} else if (isX(fp)) {
|
|
1175
|
+
from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
|
|
1176
|
+
} else if (fpr) {
|
|
1177
|
+
from = `>=${from}`;
|
|
1178
|
+
} else {
|
|
1179
|
+
from = `>=${from}${incPr ? "-0" : ""}`;
|
|
1180
|
+
}
|
|
1181
|
+
if (isX(tM)) {
|
|
1182
|
+
to = "";
|
|
1183
|
+
} else if (isX(tm)) {
|
|
1184
|
+
to = `<${+tM + 1}.0.0-0`;
|
|
1185
|
+
} else if (isX(tp)) {
|
|
1186
|
+
to = `<${tM}.${+tm + 1}.0-0`;
|
|
1187
|
+
} else if (tpr) {
|
|
1188
|
+
to = `<=${tM}.${tm}.${tp}-${tpr}`;
|
|
1189
|
+
} else if (incPr) {
|
|
1190
|
+
to = `<${tM}.${tm}.${+tp + 1}-0`;
|
|
1191
|
+
} else {
|
|
1192
|
+
to = `<=${to}`;
|
|
1193
|
+
}
|
|
1194
|
+
return `${from} ${to}`.trim();
|
|
1195
|
+
};
|
|
1196
|
+
var testSet = (set, version, options) => {
|
|
1197
|
+
for (let i = 0; i < set.length; i++) {
|
|
1198
|
+
if (!set[i].test(version)) {
|
|
1199
|
+
return false;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
if (version.prerelease.length && !options.includePrerelease) {
|
|
1203
|
+
for (let i = 0; i < set.length; i++) {
|
|
1204
|
+
debug(set[i].semver);
|
|
1205
|
+
if (set[i].semver === Comparator.ANY) {
|
|
1206
|
+
continue;
|
|
1207
|
+
}
|
|
1208
|
+
if (set[i].semver.prerelease.length > 0) {
|
|
1209
|
+
const allowed = set[i].semver;
|
|
1210
|
+
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
|
|
1211
|
+
return true;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
return false;
|
|
1216
|
+
}
|
|
1217
|
+
return true;
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
// node_modules/semver/classes/comparator.js
|
|
1223
|
+
var require_comparator = __commonJS({
|
|
1224
|
+
"node_modules/semver/classes/comparator.js"(exports, module) {
|
|
1225
|
+
var ANY = Symbol("SemVer ANY");
|
|
1226
|
+
var Comparator = class _Comparator {
|
|
1227
|
+
static get ANY() {
|
|
1228
|
+
return ANY;
|
|
1229
|
+
}
|
|
1230
|
+
constructor(comp, options) {
|
|
1231
|
+
options = parseOptions(options);
|
|
1232
|
+
if (comp instanceof _Comparator) {
|
|
1233
|
+
if (comp.loose === !!options.loose) {
|
|
1234
|
+
return comp;
|
|
1235
|
+
} else {
|
|
1236
|
+
comp = comp.value;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
comp = comp.trim().split(/\s+/).join(" ");
|
|
1240
|
+
debug("comparator", comp, options);
|
|
1241
|
+
this.options = options;
|
|
1242
|
+
this.loose = !!options.loose;
|
|
1243
|
+
this.parse(comp);
|
|
1244
|
+
if (this.semver === ANY) {
|
|
1245
|
+
this.value = "";
|
|
1246
|
+
} else {
|
|
1247
|
+
this.value = this.operator + this.semver.version;
|
|
1248
|
+
}
|
|
1249
|
+
debug("comp", this);
|
|
1250
|
+
}
|
|
1251
|
+
parse(comp) {
|
|
1252
|
+
const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1253
|
+
const m = comp.match(r);
|
|
1254
|
+
if (!m) {
|
|
1255
|
+
throw new TypeError(`Invalid comparator: ${comp}`);
|
|
1256
|
+
}
|
|
1257
|
+
this.operator = m[1] !== void 0 ? m[1] : "";
|
|
1258
|
+
if (this.operator === "=") {
|
|
1259
|
+
this.operator = "";
|
|
1260
|
+
}
|
|
1261
|
+
if (!m[2]) {
|
|
1262
|
+
this.semver = ANY;
|
|
1263
|
+
} else {
|
|
1264
|
+
this.semver = new SemVer(m[2], this.options.loose);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
toString() {
|
|
1268
|
+
return this.value;
|
|
1269
|
+
}
|
|
1270
|
+
test(version) {
|
|
1271
|
+
debug("Comparator.test", version, this.options.loose);
|
|
1272
|
+
if (this.semver === ANY || version === ANY) {
|
|
1273
|
+
return true;
|
|
1274
|
+
}
|
|
1275
|
+
if (typeof version === "string") {
|
|
1276
|
+
try {
|
|
1277
|
+
version = new SemVer(version, this.options);
|
|
1278
|
+
} catch (er) {
|
|
1279
|
+
return false;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
return cmp(version, this.operator, this.semver, this.options);
|
|
1283
|
+
}
|
|
1284
|
+
intersects(comp, options) {
|
|
1285
|
+
if (!(comp instanceof _Comparator)) {
|
|
1286
|
+
throw new TypeError("a Comparator is required");
|
|
1287
|
+
}
|
|
1288
|
+
if (this.operator === "") {
|
|
1289
|
+
if (this.value === "") {
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
return new Range(comp.value, options).test(this.value);
|
|
1293
|
+
} else if (comp.operator === "") {
|
|
1294
|
+
if (comp.value === "") {
|
|
1295
|
+
return true;
|
|
1296
|
+
}
|
|
1297
|
+
return new Range(this.value, options).test(comp.semver);
|
|
1298
|
+
}
|
|
1299
|
+
options = parseOptions(options);
|
|
1300
|
+
if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
|
|
1301
|
+
return false;
|
|
1302
|
+
}
|
|
1303
|
+
if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) {
|
|
1304
|
+
return false;
|
|
1305
|
+
}
|
|
1306
|
+
if (this.operator.startsWith(">") && comp.operator.startsWith(">")) {
|
|
1307
|
+
return true;
|
|
1308
|
+
}
|
|
1309
|
+
if (this.operator.startsWith("<") && comp.operator.startsWith("<")) {
|
|
1310
|
+
return true;
|
|
1311
|
+
}
|
|
1312
|
+
if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) {
|
|
1313
|
+
return true;
|
|
1314
|
+
}
|
|
1315
|
+
if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) {
|
|
1316
|
+
return true;
|
|
1317
|
+
}
|
|
1318
|
+
if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) {
|
|
1319
|
+
return true;
|
|
1320
|
+
}
|
|
1321
|
+
return false;
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
module.exports = Comparator;
|
|
1325
|
+
var parseOptions = require_parse_options();
|
|
1326
|
+
var { safeRe: re, t } = require_re();
|
|
1327
|
+
var cmp = require_cmp();
|
|
1328
|
+
var debug = require_debug();
|
|
1329
|
+
var SemVer = require_semver();
|
|
1330
|
+
var Range = require_range();
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
// node_modules/semver/functions/satisfies.js
|
|
1335
|
+
var require_satisfies = __commonJS({
|
|
1336
|
+
"node_modules/semver/functions/satisfies.js"(exports, module) {
|
|
1337
|
+
var Range = require_range();
|
|
1338
|
+
var satisfies = (version, range, options) => {
|
|
1339
|
+
try {
|
|
1340
|
+
range = new Range(range, options);
|
|
1341
|
+
} catch (er) {
|
|
1342
|
+
return false;
|
|
1343
|
+
}
|
|
1344
|
+
return range.test(version);
|
|
1345
|
+
};
|
|
1346
|
+
module.exports = satisfies;
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
// node_modules/semver/ranges/to-comparators.js
|
|
1351
|
+
var require_to_comparators = __commonJS({
|
|
1352
|
+
"node_modules/semver/ranges/to-comparators.js"(exports, module) {
|
|
1353
|
+
var Range = require_range();
|
|
1354
|
+
var toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1355
|
+
module.exports = toComparators;
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
// node_modules/semver/ranges/max-satisfying.js
|
|
1360
|
+
var require_max_satisfying = __commonJS({
|
|
1361
|
+
"node_modules/semver/ranges/max-satisfying.js"(exports, module) {
|
|
1362
|
+
var SemVer = require_semver();
|
|
1363
|
+
var Range = require_range();
|
|
1364
|
+
var maxSatisfying = (versions, range, options) => {
|
|
1365
|
+
let max = null;
|
|
1366
|
+
let maxSV = null;
|
|
1367
|
+
let rangeObj = null;
|
|
1368
|
+
try {
|
|
1369
|
+
rangeObj = new Range(range, options);
|
|
1370
|
+
} catch (er) {
|
|
1371
|
+
return null;
|
|
1372
|
+
}
|
|
1373
|
+
versions.forEach((v) => {
|
|
1374
|
+
if (rangeObj.test(v)) {
|
|
1375
|
+
if (!max || maxSV.compare(v) === -1) {
|
|
1376
|
+
max = v;
|
|
1377
|
+
maxSV = new SemVer(max, options);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
return max;
|
|
1382
|
+
};
|
|
1383
|
+
module.exports = maxSatisfying;
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1387
|
+
// node_modules/semver/ranges/min-satisfying.js
|
|
1388
|
+
var require_min_satisfying = __commonJS({
|
|
1389
|
+
"node_modules/semver/ranges/min-satisfying.js"(exports, module) {
|
|
1390
|
+
var SemVer = require_semver();
|
|
1391
|
+
var Range = require_range();
|
|
1392
|
+
var minSatisfying = (versions, range, options) => {
|
|
1393
|
+
let min = null;
|
|
1394
|
+
let minSV = null;
|
|
1395
|
+
let rangeObj = null;
|
|
1396
|
+
try {
|
|
1397
|
+
rangeObj = new Range(range, options);
|
|
1398
|
+
} catch (er) {
|
|
1399
|
+
return null;
|
|
1400
|
+
}
|
|
1401
|
+
versions.forEach((v) => {
|
|
1402
|
+
if (rangeObj.test(v)) {
|
|
1403
|
+
if (!min || minSV.compare(v) === 1) {
|
|
1404
|
+
min = v;
|
|
1405
|
+
minSV = new SemVer(min, options);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
return min;
|
|
1410
|
+
};
|
|
1411
|
+
module.exports = minSatisfying;
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
// node_modules/semver/ranges/min-version.js
|
|
1416
|
+
var require_min_version = __commonJS({
|
|
1417
|
+
"node_modules/semver/ranges/min-version.js"(exports, module) {
|
|
1418
|
+
var SemVer = require_semver();
|
|
1419
|
+
var Range = require_range();
|
|
1420
|
+
var gt = require_gt();
|
|
1421
|
+
var minVersion = (range, loose) => {
|
|
1422
|
+
range = new Range(range, loose);
|
|
1423
|
+
let minver = new SemVer("0.0.0");
|
|
1424
|
+
if (range.test(minver)) {
|
|
1425
|
+
return minver;
|
|
1426
|
+
}
|
|
1427
|
+
minver = new SemVer("0.0.0-0");
|
|
1428
|
+
if (range.test(minver)) {
|
|
1429
|
+
return minver;
|
|
1430
|
+
}
|
|
1431
|
+
minver = null;
|
|
1432
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1433
|
+
const comparators = range.set[i];
|
|
1434
|
+
let setMin = null;
|
|
1435
|
+
comparators.forEach((comparator) => {
|
|
1436
|
+
const compver = new SemVer(comparator.semver.version);
|
|
1437
|
+
switch (comparator.operator) {
|
|
1438
|
+
case ">":
|
|
1439
|
+
if (compver.prerelease.length === 0) {
|
|
1440
|
+
compver.patch++;
|
|
1441
|
+
} else {
|
|
1442
|
+
compver.prerelease.push(0);
|
|
1443
|
+
}
|
|
1444
|
+
compver.raw = compver.format();
|
|
1445
|
+
/* fallthrough */
|
|
1446
|
+
case "":
|
|
1447
|
+
case ">=":
|
|
1448
|
+
if (!setMin || gt(compver, setMin)) {
|
|
1449
|
+
setMin = compver;
|
|
1450
|
+
}
|
|
1451
|
+
break;
|
|
1452
|
+
case "<":
|
|
1453
|
+
case "<=":
|
|
1454
|
+
break;
|
|
1455
|
+
/* istanbul ignore next */
|
|
1456
|
+
default:
|
|
1457
|
+
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
if (setMin && (!minver || gt(minver, setMin))) {
|
|
1461
|
+
minver = setMin;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
if (minver && range.test(minver)) {
|
|
1465
|
+
return minver;
|
|
1466
|
+
}
|
|
1467
|
+
return null;
|
|
1468
|
+
};
|
|
1469
|
+
module.exports = minVersion;
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
// node_modules/semver/ranges/valid.js
|
|
1474
|
+
var require_valid2 = __commonJS({
|
|
1475
|
+
"node_modules/semver/ranges/valid.js"(exports, module) {
|
|
1476
|
+
var Range = require_range();
|
|
1477
|
+
var validRange = (range, options) => {
|
|
1478
|
+
try {
|
|
1479
|
+
return new Range(range, options).range || "*";
|
|
1480
|
+
} catch (er) {
|
|
1481
|
+
return null;
|
|
1482
|
+
}
|
|
1483
|
+
};
|
|
1484
|
+
module.exports = validRange;
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
|
|
1488
|
+
// node_modules/semver/ranges/outside.js
|
|
1489
|
+
var require_outside = __commonJS({
|
|
1490
|
+
"node_modules/semver/ranges/outside.js"(exports, module) {
|
|
1491
|
+
var SemVer = require_semver();
|
|
1492
|
+
var Comparator = require_comparator();
|
|
1493
|
+
var { ANY } = Comparator;
|
|
1494
|
+
var Range = require_range();
|
|
1495
|
+
var satisfies = require_satisfies();
|
|
1496
|
+
var gt = require_gt();
|
|
1497
|
+
var lt = require_lt();
|
|
1498
|
+
var lte = require_lte();
|
|
1499
|
+
var gte = require_gte();
|
|
1500
|
+
var outside = (version, range, hilo, options) => {
|
|
1501
|
+
version = new SemVer(version, options);
|
|
1502
|
+
range = new Range(range, options);
|
|
1503
|
+
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
1504
|
+
switch (hilo) {
|
|
1505
|
+
case ">":
|
|
1506
|
+
gtfn = gt;
|
|
1507
|
+
ltefn = lte;
|
|
1508
|
+
ltfn = lt;
|
|
1509
|
+
comp = ">";
|
|
1510
|
+
ecomp = ">=";
|
|
1511
|
+
break;
|
|
1512
|
+
case "<":
|
|
1513
|
+
gtfn = lt;
|
|
1514
|
+
ltefn = gte;
|
|
1515
|
+
ltfn = gt;
|
|
1516
|
+
comp = "<";
|
|
1517
|
+
ecomp = "<=";
|
|
1518
|
+
break;
|
|
1519
|
+
default:
|
|
1520
|
+
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
1521
|
+
}
|
|
1522
|
+
if (satisfies(version, range, options)) {
|
|
1523
|
+
return false;
|
|
1524
|
+
}
|
|
1525
|
+
for (let i = 0; i < range.set.length; ++i) {
|
|
1526
|
+
const comparators = range.set[i];
|
|
1527
|
+
let high = null;
|
|
1528
|
+
let low = null;
|
|
1529
|
+
comparators.forEach((comparator) => {
|
|
1530
|
+
if (comparator.semver === ANY) {
|
|
1531
|
+
comparator = new Comparator(">=0.0.0");
|
|
1532
|
+
}
|
|
1533
|
+
high = high || comparator;
|
|
1534
|
+
low = low || comparator;
|
|
1535
|
+
if (gtfn(comparator.semver, high.semver, options)) {
|
|
1536
|
+
high = comparator;
|
|
1537
|
+
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
1538
|
+
low = comparator;
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
if (high.operator === comp || high.operator === ecomp) {
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) {
|
|
1545
|
+
return false;
|
|
1546
|
+
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
1547
|
+
return false;
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
return true;
|
|
1551
|
+
};
|
|
1552
|
+
module.exports = outside;
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
// node_modules/semver/ranges/gtr.js
|
|
1557
|
+
var require_gtr = __commonJS({
|
|
1558
|
+
"node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
1559
|
+
var outside = require_outside();
|
|
1560
|
+
var gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1561
|
+
module.exports = gtr;
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
|
|
1565
|
+
// node_modules/semver/ranges/ltr.js
|
|
1566
|
+
var require_ltr = __commonJS({
|
|
1567
|
+
"node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
1568
|
+
var outside = require_outside();
|
|
1569
|
+
var ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1570
|
+
module.exports = ltr;
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
|
|
1574
|
+
// node_modules/semver/ranges/intersects.js
|
|
1575
|
+
var require_intersects = __commonJS({
|
|
1576
|
+
"node_modules/semver/ranges/intersects.js"(exports, module) {
|
|
1577
|
+
var Range = require_range();
|
|
1578
|
+
var intersects = (r1, r2, options) => {
|
|
1579
|
+
r1 = new Range(r1, options);
|
|
1580
|
+
r2 = new Range(r2, options);
|
|
1581
|
+
return r1.intersects(r2, options);
|
|
1582
|
+
};
|
|
1583
|
+
module.exports = intersects;
|
|
1584
|
+
}
|
|
1585
|
+
});
|
|
1586
|
+
|
|
1587
|
+
// node_modules/semver/ranges/simplify.js
|
|
1588
|
+
var require_simplify = __commonJS({
|
|
1589
|
+
"node_modules/semver/ranges/simplify.js"(exports, module) {
|
|
1590
|
+
var satisfies = require_satisfies();
|
|
1591
|
+
var compare = require_compare();
|
|
1592
|
+
module.exports = (versions, range, options) => {
|
|
1593
|
+
const set = [];
|
|
1594
|
+
let first = null;
|
|
1595
|
+
let prev = null;
|
|
1596
|
+
const v = versions.sort((a, b) => compare(a, b, options));
|
|
1597
|
+
for (const version of v) {
|
|
1598
|
+
const included = satisfies(version, range, options);
|
|
1599
|
+
if (included) {
|
|
1600
|
+
prev = version;
|
|
1601
|
+
if (!first) {
|
|
1602
|
+
first = version;
|
|
1603
|
+
}
|
|
1604
|
+
} else {
|
|
1605
|
+
if (prev) {
|
|
1606
|
+
set.push([first, prev]);
|
|
1607
|
+
}
|
|
1608
|
+
prev = null;
|
|
1609
|
+
first = null;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
if (first) {
|
|
1613
|
+
set.push([first, null]);
|
|
1614
|
+
}
|
|
1615
|
+
const ranges = [];
|
|
1616
|
+
for (const [min, max] of set) {
|
|
1617
|
+
if (min === max) {
|
|
1618
|
+
ranges.push(min);
|
|
1619
|
+
} else if (!max && min === v[0]) {
|
|
1620
|
+
ranges.push("*");
|
|
1621
|
+
} else if (!max) {
|
|
1622
|
+
ranges.push(`>=${min}`);
|
|
1623
|
+
} else if (min === v[0]) {
|
|
1624
|
+
ranges.push(`<=${max}`);
|
|
1625
|
+
} else {
|
|
1626
|
+
ranges.push(`${min} - ${max}`);
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
const simplified = ranges.join(" || ");
|
|
1630
|
+
const original = typeof range.raw === "string" ? range.raw : String(range);
|
|
1631
|
+
return simplified.length < original.length ? simplified : range;
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
});
|
|
1635
|
+
|
|
1636
|
+
// node_modules/semver/ranges/subset.js
|
|
1637
|
+
var require_subset = __commonJS({
|
|
1638
|
+
"node_modules/semver/ranges/subset.js"(exports, module) {
|
|
1639
|
+
var Range = require_range();
|
|
1640
|
+
var Comparator = require_comparator();
|
|
1641
|
+
var { ANY } = Comparator;
|
|
1642
|
+
var satisfies = require_satisfies();
|
|
1643
|
+
var compare = require_compare();
|
|
1644
|
+
var subset = (sub, dom, options = {}) => {
|
|
1645
|
+
if (sub === dom) {
|
|
1646
|
+
return true;
|
|
1647
|
+
}
|
|
1648
|
+
sub = new Range(sub, options);
|
|
1649
|
+
dom = new Range(dom, options);
|
|
1650
|
+
let sawNonNull = false;
|
|
1651
|
+
OUTER: for (const simpleSub of sub.set) {
|
|
1652
|
+
for (const simpleDom of dom.set) {
|
|
1653
|
+
const isSub = simpleSubset(simpleSub, simpleDom, options);
|
|
1654
|
+
sawNonNull = sawNonNull || isSub !== null;
|
|
1655
|
+
if (isSub) {
|
|
1656
|
+
continue OUTER;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
if (sawNonNull) {
|
|
1660
|
+
return false;
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
return true;
|
|
1664
|
+
};
|
|
1665
|
+
var minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
|
|
1666
|
+
var minimumVersion = [new Comparator(">=0.0.0")];
|
|
1667
|
+
var simpleSubset = (sub, dom, options) => {
|
|
1668
|
+
if (sub === dom) {
|
|
1669
|
+
return true;
|
|
1670
|
+
}
|
|
1671
|
+
if (sub.length === 1 && sub[0].semver === ANY) {
|
|
1672
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1673
|
+
return true;
|
|
1674
|
+
} else if (options.includePrerelease) {
|
|
1675
|
+
sub = minimumVersionWithPreRelease;
|
|
1676
|
+
} else {
|
|
1677
|
+
sub = minimumVersion;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
if (dom.length === 1 && dom[0].semver === ANY) {
|
|
1681
|
+
if (options.includePrerelease) {
|
|
1682
|
+
return true;
|
|
1683
|
+
} else {
|
|
1684
|
+
dom = minimumVersion;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
const eqSet = /* @__PURE__ */ new Set();
|
|
1688
|
+
let gt, lt;
|
|
1689
|
+
for (const c of sub) {
|
|
1690
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1691
|
+
gt = higherGT(gt, c, options);
|
|
1692
|
+
} else if (c.operator === "<" || c.operator === "<=") {
|
|
1693
|
+
lt = lowerLT(lt, c, options);
|
|
1694
|
+
} else {
|
|
1695
|
+
eqSet.add(c.semver);
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
if (eqSet.size > 1) {
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
let gtltComp;
|
|
1702
|
+
if (gt && lt) {
|
|
1703
|
+
gtltComp = compare(gt.semver, lt.semver, options);
|
|
1704
|
+
if (gtltComp > 0) {
|
|
1705
|
+
return null;
|
|
1706
|
+
} else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) {
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
for (const eq of eqSet) {
|
|
1711
|
+
if (gt && !satisfies(eq, String(gt), options)) {
|
|
1712
|
+
return null;
|
|
1713
|
+
}
|
|
1714
|
+
if (lt && !satisfies(eq, String(lt), options)) {
|
|
1715
|
+
return null;
|
|
1716
|
+
}
|
|
1717
|
+
for (const c of dom) {
|
|
1718
|
+
if (!satisfies(eq, String(c), options)) {
|
|
1719
|
+
return false;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
return true;
|
|
1723
|
+
}
|
|
1724
|
+
let higher, lower;
|
|
1725
|
+
let hasDomLT, hasDomGT;
|
|
1726
|
+
let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
|
|
1727
|
+
let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
|
|
1728
|
+
if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) {
|
|
1729
|
+
needDomLTPre = false;
|
|
1730
|
+
}
|
|
1731
|
+
for (const c of dom) {
|
|
1732
|
+
hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
|
|
1733
|
+
hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
|
|
1734
|
+
if (gt) {
|
|
1735
|
+
if (needDomGTPre) {
|
|
1736
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) {
|
|
1737
|
+
needDomGTPre = false;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
if (c.operator === ">" || c.operator === ">=") {
|
|
1741
|
+
higher = higherGT(gt, c, options);
|
|
1742
|
+
if (higher === c && higher !== gt) {
|
|
1743
|
+
return false;
|
|
1744
|
+
}
|
|
1745
|
+
} else if (gt.operator === ">=" && !satisfies(gt.semver, String(c), options)) {
|
|
1746
|
+
return false;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
if (lt) {
|
|
1750
|
+
if (needDomLTPre) {
|
|
1751
|
+
if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) {
|
|
1752
|
+
needDomLTPre = false;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
if (c.operator === "<" || c.operator === "<=") {
|
|
1756
|
+
lower = lowerLT(lt, c, options);
|
|
1757
|
+
if (lower === c && lower !== lt) {
|
|
1758
|
+
return false;
|
|
1759
|
+
}
|
|
1760
|
+
} else if (lt.operator === "<=" && !satisfies(lt.semver, String(c), options)) {
|
|
1761
|
+
return false;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
if (!c.operator && (lt || gt) && gtltComp !== 0) {
|
|
1765
|
+
return false;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
if (gt && hasDomLT && !lt && gtltComp !== 0) {
|
|
1769
|
+
return false;
|
|
1770
|
+
}
|
|
1771
|
+
if (lt && hasDomGT && !gt && gtltComp !== 0) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
if (needDomGTPre || needDomLTPre) {
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
return true;
|
|
1778
|
+
};
|
|
1779
|
+
var higherGT = (a, b, options) => {
|
|
1780
|
+
if (!a) {
|
|
1781
|
+
return b;
|
|
1782
|
+
}
|
|
1783
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1784
|
+
return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
|
|
1785
|
+
};
|
|
1786
|
+
var lowerLT = (a, b, options) => {
|
|
1787
|
+
if (!a) {
|
|
1788
|
+
return b;
|
|
1789
|
+
}
|
|
1790
|
+
const comp = compare(a.semver, b.semver, options);
|
|
1791
|
+
return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
|
|
1792
|
+
};
|
|
1793
|
+
module.exports = subset;
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
|
|
1797
|
+
// node_modules/semver/index.js
|
|
1798
|
+
var require_semver2 = __commonJS({
|
|
1799
|
+
"node_modules/semver/index.js"(exports, module) {
|
|
1800
|
+
var internalRe = require_re();
|
|
1801
|
+
var constants = require_constants();
|
|
1802
|
+
var SemVer = require_semver();
|
|
1803
|
+
var identifiers = require_identifiers();
|
|
1804
|
+
var parse = require_parse();
|
|
1805
|
+
var valid = require_valid();
|
|
1806
|
+
var clean = require_clean();
|
|
1807
|
+
var inc = require_inc();
|
|
1808
|
+
var diff = require_diff();
|
|
1809
|
+
var major = require_major();
|
|
1810
|
+
var minor = require_minor();
|
|
1811
|
+
var patch = require_patch();
|
|
1812
|
+
var prerelease = require_prerelease();
|
|
1813
|
+
var compare = require_compare();
|
|
1814
|
+
var rcompare = require_rcompare();
|
|
1815
|
+
var compareLoose = require_compare_loose();
|
|
1816
|
+
var compareBuild = require_compare_build();
|
|
1817
|
+
var sort = require_sort();
|
|
1818
|
+
var rsort = require_rsort();
|
|
1819
|
+
var gt = require_gt();
|
|
1820
|
+
var lt = require_lt();
|
|
1821
|
+
var eq = require_eq();
|
|
1822
|
+
var neq = require_neq();
|
|
1823
|
+
var gte = require_gte();
|
|
1824
|
+
var lte = require_lte();
|
|
1825
|
+
var cmp = require_cmp();
|
|
1826
|
+
var coerce = require_coerce();
|
|
1827
|
+
var Comparator = require_comparator();
|
|
1828
|
+
var Range = require_range();
|
|
1829
|
+
var satisfies = require_satisfies();
|
|
1830
|
+
var toComparators = require_to_comparators();
|
|
1831
|
+
var maxSatisfying = require_max_satisfying();
|
|
1832
|
+
var minSatisfying = require_min_satisfying();
|
|
1833
|
+
var minVersion = require_min_version();
|
|
1834
|
+
var validRange = require_valid2();
|
|
1835
|
+
var outside = require_outside();
|
|
1836
|
+
var gtr = require_gtr();
|
|
1837
|
+
var ltr = require_ltr();
|
|
1838
|
+
var intersects = require_intersects();
|
|
1839
|
+
var simplifyRange = require_simplify();
|
|
1840
|
+
var subset = require_subset();
|
|
1841
|
+
module.exports = {
|
|
1842
|
+
parse,
|
|
1843
|
+
valid,
|
|
1844
|
+
clean,
|
|
1845
|
+
inc,
|
|
1846
|
+
diff,
|
|
1847
|
+
major,
|
|
1848
|
+
minor,
|
|
1849
|
+
patch,
|
|
1850
|
+
prerelease,
|
|
1851
|
+
compare,
|
|
1852
|
+
rcompare,
|
|
1853
|
+
compareLoose,
|
|
1854
|
+
compareBuild,
|
|
1855
|
+
sort,
|
|
1856
|
+
rsort,
|
|
1857
|
+
gt,
|
|
1858
|
+
lt,
|
|
1859
|
+
eq,
|
|
1860
|
+
neq,
|
|
1861
|
+
gte,
|
|
1862
|
+
lte,
|
|
1863
|
+
cmp,
|
|
1864
|
+
coerce,
|
|
1865
|
+
Comparator,
|
|
1866
|
+
Range,
|
|
1867
|
+
satisfies,
|
|
1868
|
+
toComparators,
|
|
1869
|
+
maxSatisfying,
|
|
1870
|
+
minSatisfying,
|
|
1871
|
+
minVersion,
|
|
1872
|
+
validRange,
|
|
1873
|
+
outside,
|
|
1874
|
+
gtr,
|
|
1875
|
+
ltr,
|
|
1876
|
+
intersects,
|
|
1877
|
+
simplifyRange,
|
|
1878
|
+
subset,
|
|
1879
|
+
SemVer,
|
|
1880
|
+
re: internalRe.re,
|
|
1881
|
+
src: internalRe.src,
|
|
1882
|
+
tokens: internalRe.t,
|
|
1883
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
1884
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
1885
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
1886
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
|
|
1891
|
+
// src/plugins/hook-system.ts
|
|
1892
|
+
var HookSystemImpl = class {
|
|
1893
|
+
hooks = /* @__PURE__ */ new Map();
|
|
1894
|
+
executing = /* @__PURE__ */ new Set();
|
|
1895
|
+
/**
|
|
1896
|
+
* Register a hook handler
|
|
1897
|
+
*/
|
|
1898
|
+
register(hookName, handler, priority = 10) {
|
|
1899
|
+
if (!this.hooks.has(hookName)) {
|
|
1900
|
+
this.hooks.set(hookName, []);
|
|
1901
|
+
}
|
|
1902
|
+
const hooks = this.hooks.get(hookName);
|
|
1903
|
+
const hook = {
|
|
1904
|
+
name: hookName,
|
|
1905
|
+
handler,
|
|
1906
|
+
priority
|
|
1907
|
+
};
|
|
1908
|
+
const insertIndex = hooks.findIndex((h) => h.priority > priority);
|
|
1909
|
+
if (insertIndex === -1) {
|
|
1910
|
+
hooks.push(hook);
|
|
1911
|
+
} else {
|
|
1912
|
+
hooks.splice(insertIndex, 0, hook);
|
|
1913
|
+
}
|
|
1914
|
+
console.debug(`Hook registered: ${hookName} (priority: ${priority})`);
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Execute all handlers for a hook
|
|
1918
|
+
*/
|
|
1919
|
+
async execute(hookName, data, context) {
|
|
1920
|
+
const hooks = this.hooks.get(hookName);
|
|
1921
|
+
if (!hooks || hooks.length === 0) {
|
|
1922
|
+
return data;
|
|
1923
|
+
}
|
|
1924
|
+
if (this.executing.has(hookName)) {
|
|
1925
|
+
console.warn(`Hook recursion detected for: ${hookName}`);
|
|
1926
|
+
return data;
|
|
1927
|
+
}
|
|
1928
|
+
this.executing.add(hookName);
|
|
1929
|
+
try {
|
|
1930
|
+
let result = data;
|
|
1931
|
+
let cancelled = false;
|
|
1932
|
+
const hookContext = {
|
|
1933
|
+
plugin: "",
|
|
1934
|
+
// Will be set by the plugin manager
|
|
1935
|
+
context: context || {},
|
|
1936
|
+
cancel: () => {
|
|
1937
|
+
cancelled = true;
|
|
1938
|
+
}
|
|
1939
|
+
};
|
|
1940
|
+
for (const hook of hooks) {
|
|
1941
|
+
if (cancelled) {
|
|
1942
|
+
console.debug(`Hook execution cancelled: ${hookName}`);
|
|
1943
|
+
break;
|
|
1944
|
+
}
|
|
1945
|
+
try {
|
|
1946
|
+
console.debug(`Executing hook: ${hookName} (priority: ${hook.priority})`);
|
|
1947
|
+
result = await hook.handler(result, hookContext);
|
|
1948
|
+
} catch (error) {
|
|
1949
|
+
console.error(`Hook execution failed: ${hookName}`, error);
|
|
1950
|
+
if (error instanceof Error && error.message.includes("CRITICAL")) {
|
|
1951
|
+
throw error;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
return result;
|
|
1956
|
+
} finally {
|
|
1957
|
+
this.executing.delete(hookName);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
/**
|
|
1961
|
+
* Remove a hook handler
|
|
1962
|
+
*/
|
|
1963
|
+
unregister(hookName, handler) {
|
|
1964
|
+
const hooks = this.hooks.get(hookName);
|
|
1965
|
+
if (!hooks) return;
|
|
1966
|
+
const index = hooks.findIndex((h) => h.handler === handler);
|
|
1967
|
+
if (index !== -1) {
|
|
1968
|
+
hooks.splice(index, 1);
|
|
1969
|
+
console.debug(`Hook unregistered: ${hookName}`);
|
|
1970
|
+
}
|
|
1971
|
+
if (hooks.length === 0) {
|
|
1972
|
+
this.hooks.delete(hookName);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Get all registered hooks for a name
|
|
1977
|
+
*/
|
|
1978
|
+
getHooks(hookName) {
|
|
1979
|
+
return this.hooks.get(hookName) || [];
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Get all registered hook names
|
|
1983
|
+
*/
|
|
1984
|
+
getHookNames() {
|
|
1985
|
+
return Array.from(this.hooks.keys());
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* Get hook statistics
|
|
1989
|
+
*/
|
|
1990
|
+
getStats() {
|
|
1991
|
+
return Array.from(this.hooks.entries()).map(([hookName, handlers]) => ({
|
|
1992
|
+
hookName,
|
|
1993
|
+
handlerCount: handlers.length
|
|
1994
|
+
}));
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Clear all hooks (useful for testing)
|
|
1998
|
+
*/
|
|
1999
|
+
clear() {
|
|
2000
|
+
this.hooks.clear();
|
|
2001
|
+
this.executing.clear();
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Create a scoped hook system for a plugin
|
|
2005
|
+
*/
|
|
2006
|
+
createScope(_pluginName) {
|
|
2007
|
+
return new ScopedHookSystem(this);
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2010
|
+
var ScopedHookSystem = class {
|
|
2011
|
+
constructor(parent) {
|
|
2012
|
+
this.parent = parent;
|
|
2013
|
+
}
|
|
2014
|
+
registeredHooks = [];
|
|
2015
|
+
/**
|
|
2016
|
+
* Register a hook (scoped to this plugin)
|
|
2017
|
+
*/
|
|
2018
|
+
register(hookName, handler, priority) {
|
|
2019
|
+
this.parent.register(hookName, handler, priority);
|
|
2020
|
+
this.registeredHooks.push({ hookName, handler });
|
|
2021
|
+
}
|
|
2022
|
+
/**
|
|
2023
|
+
* Execute a hook
|
|
2024
|
+
*/
|
|
2025
|
+
async execute(hookName, data, context) {
|
|
2026
|
+
return this.parent.execute(hookName, data, context);
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Unregister a specific hook
|
|
2030
|
+
*/
|
|
2031
|
+
unregister(hookName, handler) {
|
|
2032
|
+
this.parent.unregister(hookName, handler);
|
|
2033
|
+
const index = this.registeredHooks.findIndex(
|
|
2034
|
+
(h) => h.hookName === hookName && h.handler === handler
|
|
2035
|
+
);
|
|
2036
|
+
if (index !== -1) {
|
|
2037
|
+
this.registeredHooks.splice(index, 1);
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Unregister all hooks for this plugin
|
|
2042
|
+
*/
|
|
2043
|
+
unregisterAll() {
|
|
2044
|
+
for (const { hookName, handler } of this.registeredHooks) {
|
|
2045
|
+
this.parent.unregister(hookName, handler);
|
|
2046
|
+
}
|
|
2047
|
+
this.registeredHooks.length = 0;
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Get hooks registered by this plugin
|
|
2051
|
+
*/
|
|
2052
|
+
getRegisteredHooks() {
|
|
2053
|
+
return [...this.registeredHooks];
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
var HookUtils = class {
|
|
2057
|
+
/**
|
|
2058
|
+
* Create a hook name with namespace
|
|
2059
|
+
*/
|
|
2060
|
+
static createHookName(namespace, event) {
|
|
2061
|
+
return `${namespace}:${event}`;
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* Parse a hook name to extract namespace and event
|
|
2065
|
+
*/
|
|
2066
|
+
static parseHookName(hookName) {
|
|
2067
|
+
const parts = hookName.split(":");
|
|
2068
|
+
return {
|
|
2069
|
+
namespace: parts[0] || "",
|
|
2070
|
+
event: parts.slice(1).join(":") || ""
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
/**
|
|
2074
|
+
* Create a middleware that executes hooks
|
|
2075
|
+
*/
|
|
2076
|
+
static createHookMiddleware(hookSystem, beforeHook, afterHook) {
|
|
2077
|
+
return async (c, next) => {
|
|
2078
|
+
if (beforeHook) {
|
|
2079
|
+
const beforeData = { request: c.req, context: c };
|
|
2080
|
+
await hookSystem.execute(beforeHook, beforeData);
|
|
2081
|
+
}
|
|
2082
|
+
await next();
|
|
2083
|
+
if (afterHook) {
|
|
2084
|
+
const afterData = { request: c.req, response: c.res, context: c };
|
|
2085
|
+
await hookSystem.execute(afterHook, afterData);
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
/**
|
|
2090
|
+
* Create a debounced hook handler
|
|
2091
|
+
*/
|
|
2092
|
+
static debounce(handler, delay) {
|
|
2093
|
+
let timeoutId;
|
|
2094
|
+
return async (data, context) => {
|
|
2095
|
+
if (timeoutId) {
|
|
2096
|
+
clearTimeout(timeoutId);
|
|
2097
|
+
}
|
|
2098
|
+
return new Promise((resolve, reject) => {
|
|
2099
|
+
timeoutId = setTimeout(async () => {
|
|
2100
|
+
try {
|
|
2101
|
+
const result = await handler(data, context);
|
|
2102
|
+
resolve(result);
|
|
2103
|
+
} catch (error) {
|
|
2104
|
+
reject(error);
|
|
2105
|
+
}
|
|
2106
|
+
}, delay);
|
|
2107
|
+
});
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
/**
|
|
2111
|
+
* Create a throttled hook handler
|
|
2112
|
+
*/
|
|
2113
|
+
static throttle(handler, limit) {
|
|
2114
|
+
let lastExecution = 0;
|
|
2115
|
+
return async (data, context) => {
|
|
2116
|
+
const now = Date.now();
|
|
2117
|
+
if (now - lastExecution >= limit) {
|
|
2118
|
+
lastExecution = now;
|
|
2119
|
+
return handler(data, context);
|
|
2120
|
+
}
|
|
2121
|
+
return data;
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
|
|
2126
|
+
// src/plugins/plugin-validator.ts
|
|
2127
|
+
var import_semver = __toESM(require_semver2(), 1);
|
|
2128
|
+
var PluginAuthorSchema = z.object({
|
|
2129
|
+
name: z.string().min(1),
|
|
2130
|
+
email: z.string().email().optional(),
|
|
2131
|
+
url: z.string().url().optional()
|
|
2132
|
+
});
|
|
2133
|
+
var PluginRoutesSchema = z.object({
|
|
2134
|
+
path: z.string().min(1),
|
|
2135
|
+
handler: z.any(),
|
|
2136
|
+
// Hono instance
|
|
2137
|
+
description: z.string().optional(),
|
|
2138
|
+
requiresAuth: z.boolean().optional(),
|
|
2139
|
+
roles: z.array(z.string()).optional(),
|
|
2140
|
+
priority: z.number().optional()
|
|
2141
|
+
});
|
|
2142
|
+
var PluginMiddlewareSchema = z.object({
|
|
2143
|
+
name: z.string().min(1),
|
|
2144
|
+
handler: z.function(),
|
|
2145
|
+
description: z.string().optional(),
|
|
2146
|
+
priority: z.number().optional(),
|
|
2147
|
+
routes: z.array(z.string()).optional(),
|
|
2148
|
+
global: z.boolean().optional()
|
|
2149
|
+
});
|
|
2150
|
+
var PluginModelSchema = z.object({
|
|
2151
|
+
name: z.string().min(1),
|
|
2152
|
+
tableName: z.string().min(1),
|
|
2153
|
+
schema: z.any(),
|
|
2154
|
+
// Zod schema
|
|
2155
|
+
migrations: z.array(z.string()),
|
|
2156
|
+
relationships: z.array(z.object({
|
|
2157
|
+
type: z.enum(["oneToOne", "oneToMany", "manyToMany"]),
|
|
2158
|
+
target: z.string(),
|
|
2159
|
+
foreignKey: z.string().optional(),
|
|
2160
|
+
joinTable: z.string().optional()
|
|
2161
|
+
})).optional(),
|
|
2162
|
+
extendsContent: z.boolean().optional()
|
|
2163
|
+
});
|
|
2164
|
+
var PluginServiceSchema = z.object({
|
|
2165
|
+
name: z.string().min(1),
|
|
2166
|
+
implementation: z.any(),
|
|
2167
|
+
description: z.string().optional(),
|
|
2168
|
+
dependencies: z.array(z.string()).optional(),
|
|
2169
|
+
singleton: z.boolean().optional()
|
|
2170
|
+
});
|
|
2171
|
+
var PluginAdminPageSchema = z.object({
|
|
2172
|
+
path: z.string().min(1),
|
|
2173
|
+
title: z.string().min(1),
|
|
2174
|
+
component: z.string().min(1),
|
|
2175
|
+
description: z.string().optional(),
|
|
2176
|
+
permissions: z.array(z.string()).optional(),
|
|
2177
|
+
menuItem: z.object({
|
|
2178
|
+
label: z.string(),
|
|
2179
|
+
path: z.string(),
|
|
2180
|
+
icon: z.string().optional(),
|
|
2181
|
+
order: z.number().optional(),
|
|
2182
|
+
parent: z.string().optional(),
|
|
2183
|
+
permissions: z.array(z.string()).optional(),
|
|
2184
|
+
active: z.boolean().optional()
|
|
2185
|
+
}).optional(),
|
|
2186
|
+
icon: z.string().optional()
|
|
2187
|
+
});
|
|
2188
|
+
var PluginComponentSchema = z.object({
|
|
2189
|
+
name: z.string().min(1),
|
|
2190
|
+
template: z.function(),
|
|
2191
|
+
description: z.string().optional(),
|
|
2192
|
+
propsSchema: z.any().optional()
|
|
2193
|
+
// Zod schema
|
|
2194
|
+
});
|
|
2195
|
+
var PluginHookSchema = z.object({
|
|
2196
|
+
name: z.string().min(1),
|
|
2197
|
+
handler: z.function(),
|
|
2198
|
+
priority: z.number().optional(),
|
|
2199
|
+
description: z.string().optional()
|
|
2200
|
+
});
|
|
2201
|
+
var PluginSchema = z.object({
|
|
2202
|
+
name: z.string().min(1).regex(/^[a-z0-9-]+$/, "Plugin name must be lowercase with hyphens"),
|
|
2203
|
+
version: z.string().refine((v) => import_semver.default.valid(v), "Version must be valid semver"),
|
|
2204
|
+
description: z.string().optional(),
|
|
2205
|
+
author: PluginAuthorSchema.optional(),
|
|
2206
|
+
dependencies: z.array(z.string()).optional(),
|
|
2207
|
+
compatibility: z.string().optional(),
|
|
2208
|
+
license: z.string().optional(),
|
|
2209
|
+
// Extension points
|
|
2210
|
+
routes: z.array(PluginRoutesSchema).optional(),
|
|
2211
|
+
middleware: z.array(PluginMiddlewareSchema).optional(),
|
|
2212
|
+
models: z.array(PluginModelSchema).optional(),
|
|
2213
|
+
services: z.array(PluginServiceSchema).optional(),
|
|
2214
|
+
adminPages: z.array(PluginAdminPageSchema).optional(),
|
|
2215
|
+
adminComponents: z.array(PluginComponentSchema).optional(),
|
|
2216
|
+
menuItems: z.array(z.object({
|
|
2217
|
+
label: z.string(),
|
|
2218
|
+
path: z.string(),
|
|
2219
|
+
icon: z.string().optional(),
|
|
2220
|
+
order: z.number().optional(),
|
|
2221
|
+
parent: z.string().optional(),
|
|
2222
|
+
permissions: z.array(z.string()).optional(),
|
|
2223
|
+
active: z.boolean().optional()
|
|
2224
|
+
})).optional(),
|
|
2225
|
+
hooks: z.array(PluginHookSchema).optional(),
|
|
2226
|
+
// Lifecycle hooks
|
|
2227
|
+
install: z.function().optional(),
|
|
2228
|
+
uninstall: z.function().optional(),
|
|
2229
|
+
activate: z.function().optional(),
|
|
2230
|
+
deactivate: z.function().optional(),
|
|
2231
|
+
configure: z.function().optional()
|
|
2232
|
+
});
|
|
2233
|
+
var PluginValidator = class _PluginValidator {
|
|
2234
|
+
static RESERVED_NAMES = [
|
|
2235
|
+
"core",
|
|
2236
|
+
"system",
|
|
2237
|
+
"admin",
|
|
2238
|
+
"api",
|
|
2239
|
+
"auth",
|
|
2240
|
+
"content",
|
|
2241
|
+
"media",
|
|
2242
|
+
"users",
|
|
2243
|
+
"collections"
|
|
2244
|
+
];
|
|
2245
|
+
static RESERVED_PATHS = [
|
|
2246
|
+
"/admin",
|
|
2247
|
+
"/api",
|
|
2248
|
+
"/auth",
|
|
2249
|
+
"/docs",
|
|
2250
|
+
"/media",
|
|
2251
|
+
"/_assets"
|
|
2252
|
+
];
|
|
2253
|
+
/**
|
|
2254
|
+
* Validate plugin definition
|
|
2255
|
+
*/
|
|
2256
|
+
validate(plugin) {
|
|
2257
|
+
const errors = [];
|
|
2258
|
+
const warnings = [];
|
|
2259
|
+
try {
|
|
2260
|
+
const result = PluginSchema.safeParse(plugin);
|
|
2261
|
+
if (!result.success) {
|
|
2262
|
+
result.error.errors.forEach((err) => {
|
|
2263
|
+
errors.push(`${err.path.join(".")}: ${err.message}`);
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
if (_PluginValidator.RESERVED_NAMES.includes(plugin.name)) {
|
|
2267
|
+
errors.push(`Plugin name "${plugin.name}" is reserved`);
|
|
2268
|
+
}
|
|
2269
|
+
if (plugin.routes) {
|
|
2270
|
+
for (const route of plugin.routes) {
|
|
2271
|
+
if (_PluginValidator.RESERVED_PATHS.some((path) => route.path.startsWith(path))) {
|
|
2272
|
+
errors.push(`Route path "${route.path}" conflicts with reserved system path`);
|
|
2273
|
+
}
|
|
2274
|
+
if (!route.path.startsWith("/")) {
|
|
2275
|
+
errors.push(`Route path "${route.path}" must start with /`);
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
if (plugin.models) {
|
|
2280
|
+
const modelNames = /* @__PURE__ */ new Set();
|
|
2281
|
+
const tableNames = /* @__PURE__ */ new Set();
|
|
2282
|
+
for (const model of plugin.models) {
|
|
2283
|
+
if (modelNames.has(model.name)) {
|
|
2284
|
+
errors.push(`Duplicate model name: ${model.name}`);
|
|
2285
|
+
}
|
|
2286
|
+
modelNames.add(model.name);
|
|
2287
|
+
if (tableNames.has(model.tableName)) {
|
|
2288
|
+
errors.push(`Duplicate table name: ${model.tableName}`);
|
|
2289
|
+
}
|
|
2290
|
+
tableNames.add(model.tableName);
|
|
2291
|
+
if (!/^[a-z][a-z0-9_]*$/.test(model.tableName)) {
|
|
2292
|
+
errors.push(`Invalid table name format: ${model.tableName}`);
|
|
2293
|
+
}
|
|
2294
|
+
const systemTables = ["users", "collections", "content", "content_versions", "media", "api_tokens"];
|
|
2295
|
+
if (systemTables.includes(model.tableName)) {
|
|
2296
|
+
errors.push(`Table name "${model.tableName}" conflicts with system table`);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
if (plugin.services) {
|
|
2301
|
+
const serviceNames = /* @__PURE__ */ new Set();
|
|
2302
|
+
for (const service of plugin.services) {
|
|
2303
|
+
if (serviceNames.has(service.name)) {
|
|
2304
|
+
errors.push(`Duplicate service name: ${service.name}`);
|
|
2305
|
+
}
|
|
2306
|
+
serviceNames.add(service.name);
|
|
2307
|
+
const systemServices = ["auth", "content", "media", "cdn"];
|
|
2308
|
+
if (systemServices.includes(service.name)) {
|
|
2309
|
+
warnings.push(`Service name "${service.name}" conflicts with system service`);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
if (plugin.adminPages) {
|
|
2314
|
+
const pagePaths = /* @__PURE__ */ new Set();
|
|
2315
|
+
for (const page of plugin.adminPages) {
|
|
2316
|
+
if (pagePaths.has(page.path)) {
|
|
2317
|
+
errors.push(`Duplicate admin page path: ${page.path}`);
|
|
2318
|
+
}
|
|
2319
|
+
pagePaths.add(page.path);
|
|
2320
|
+
if (!page.path.startsWith("/")) {
|
|
2321
|
+
errors.push(`Admin page path "${page.path}" must start with /`);
|
|
2322
|
+
}
|
|
2323
|
+
const systemPaths = ["/", "/collections", "/content", "/media", "/users", "/settings"];
|
|
2324
|
+
if (systemPaths.includes(page.path)) {
|
|
2325
|
+
errors.push(`Admin page path "${page.path}" conflicts with system page`);
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
if (plugin.adminComponents) {
|
|
2330
|
+
const componentNames = /* @__PURE__ */ new Set();
|
|
2331
|
+
for (const component of plugin.adminComponents) {
|
|
2332
|
+
if (componentNames.has(component.name)) {
|
|
2333
|
+
errors.push(`Duplicate component name: ${component.name}`);
|
|
2334
|
+
}
|
|
2335
|
+
componentNames.add(component.name);
|
|
2336
|
+
const systemComponents = ["table", "form", "alert", "media-grid", "pagination"];
|
|
2337
|
+
if (systemComponents.includes(component.name)) {
|
|
2338
|
+
warnings.push(`Component name "${component.name}" conflicts with system component`);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
if (plugin.hooks) {
|
|
2343
|
+
for (const hook of plugin.hooks) {
|
|
2344
|
+
if (!hook.name.includes(":")) {
|
|
2345
|
+
warnings.push(`Hook name "${hook.name}" should include namespace (e.g., "plugin:event")`);
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
if (plugin.dependencies?.includes(plugin.name)) {
|
|
2350
|
+
errors.push(`Plugin cannot depend on itself`);
|
|
2351
|
+
}
|
|
2352
|
+
if (plugin.license) {
|
|
2353
|
+
const validLicenses = ["MIT", "Apache-2.0", "GPL-3.0", "BSD-3-Clause", "ISC"];
|
|
2354
|
+
if (!validLicenses.includes(plugin.license)) {
|
|
2355
|
+
warnings.push(`License "${plugin.license}" is not a common SPDX identifier`);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
if (plugin.middleware && plugin.middleware.length > 5) {
|
|
2359
|
+
warnings.push(`Plugin defines ${plugin.middleware.length} middleware functions, consider consolidating`);
|
|
2360
|
+
}
|
|
2361
|
+
if (plugin.hooks && plugin.hooks.length > 10) {
|
|
2362
|
+
warnings.push(`Plugin defines ${plugin.hooks.length} hooks, ensure they are necessary`);
|
|
2363
|
+
}
|
|
2364
|
+
} catch (error) {
|
|
2365
|
+
errors.push(`Validation error: ${error instanceof Error ? error.message : String(error)}`);
|
|
2366
|
+
}
|
|
2367
|
+
return {
|
|
2368
|
+
valid: errors.length === 0,
|
|
2369
|
+
errors,
|
|
2370
|
+
warnings
|
|
2371
|
+
};
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Validate plugin dependencies
|
|
2375
|
+
*/
|
|
2376
|
+
validateDependencies(plugin, registry) {
|
|
2377
|
+
const errors = [];
|
|
2378
|
+
const warnings = [];
|
|
2379
|
+
if (!plugin.dependencies || plugin.dependencies.length === 0) {
|
|
2380
|
+
return { valid: true, errors, warnings };
|
|
2381
|
+
}
|
|
2382
|
+
for (const depName of plugin.dependencies) {
|
|
2383
|
+
if (!registry.has(depName)) {
|
|
2384
|
+
errors.push(`Dependency "${depName}" is not registered`);
|
|
2385
|
+
continue;
|
|
2386
|
+
}
|
|
2387
|
+
const dependency = registry.get(depName);
|
|
2388
|
+
if (dependency.compatibility && plugin.compatibility) {
|
|
2389
|
+
if (!this.isCompatible(dependency.compatibility, plugin.compatibility)) {
|
|
2390
|
+
warnings.push(`Potential compatibility issue with dependency "${depName}"`);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2395
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
2396
|
+
const checkCircular = (name) => {
|
|
2397
|
+
if (visiting.has(name)) return true;
|
|
2398
|
+
if (visited.has(name)) return false;
|
|
2399
|
+
visiting.add(name);
|
|
2400
|
+
const current = registry.get(name);
|
|
2401
|
+
if (current?.dependencies) {
|
|
2402
|
+
for (const depName of current.dependencies) {
|
|
2403
|
+
if (checkCircular(depName)) {
|
|
2404
|
+
errors.push(`Circular dependency detected: ${name} -> ${depName}`);
|
|
2405
|
+
return true;
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
visiting.delete(name);
|
|
2410
|
+
visited.add(name);
|
|
2411
|
+
return false;
|
|
2412
|
+
};
|
|
2413
|
+
checkCircular(plugin.name);
|
|
2414
|
+
return {
|
|
2415
|
+
valid: errors.length === 0,
|
|
2416
|
+
errors,
|
|
2417
|
+
warnings
|
|
2418
|
+
};
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* Validate plugin compatibility with SonicJS version
|
|
2422
|
+
*/
|
|
2423
|
+
validateCompatibility(plugin, sonicVersion) {
|
|
2424
|
+
const errors = [];
|
|
2425
|
+
const warnings = [];
|
|
2426
|
+
if (!plugin.compatibility) {
|
|
2427
|
+
warnings.push("Plugin does not specify compatibility version");
|
|
2428
|
+
return { valid: true, errors, warnings };
|
|
2429
|
+
}
|
|
2430
|
+
try {
|
|
2431
|
+
if (!import_semver.default.satisfies(sonicVersion, plugin.compatibility)) {
|
|
2432
|
+
errors.push(`Plugin requires SonicJS ${plugin.compatibility}, but current version is ${sonicVersion}`);
|
|
2433
|
+
}
|
|
2434
|
+
} catch (error) {
|
|
2435
|
+
errors.push(`Invalid compatibility version format: ${plugin.compatibility}`);
|
|
2436
|
+
}
|
|
2437
|
+
return {
|
|
2438
|
+
valid: errors.length === 0,
|
|
2439
|
+
errors,
|
|
2440
|
+
warnings
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
/**
|
|
2444
|
+
* Check if two version ranges are compatible
|
|
2445
|
+
*/
|
|
2446
|
+
isCompatible(version1, version2) {
|
|
2447
|
+
try {
|
|
2448
|
+
return import_semver.default.intersects(version1, version2);
|
|
2449
|
+
} catch {
|
|
2450
|
+
return false;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Validate plugin security constraints
|
|
2455
|
+
*/
|
|
2456
|
+
validateSecurity(plugin) {
|
|
2457
|
+
const errors = [];
|
|
2458
|
+
const warnings = [];
|
|
2459
|
+
const pluginCode = JSON.stringify(plugin);
|
|
2460
|
+
if (pluginCode.includes("eval(") || pluginCode.includes("Function(")) {
|
|
2461
|
+
errors.push("Plugin contains potentially dangerous code execution patterns");
|
|
2462
|
+
}
|
|
2463
|
+
if (pluginCode.includes("fs.") || pluginCode.includes("require(")) {
|
|
2464
|
+
warnings.push("Plugin may attempt file system access (not available in Cloudflare Workers)");
|
|
2465
|
+
}
|
|
2466
|
+
if (pluginCode.includes("fetch(") || pluginCode.includes("XMLHttpRequest")) {
|
|
2467
|
+
warnings.push("Plugin contains network access code - ensure it follows security guidelines");
|
|
2468
|
+
}
|
|
2469
|
+
const sensitivePatterns = ["password", "secret", "key", "token", "credential"];
|
|
2470
|
+
for (const pattern of sensitivePatterns) {
|
|
2471
|
+
if (pluginCode.toLowerCase().includes(pattern)) {
|
|
2472
|
+
warnings.push(`Plugin code contains "${pattern}" - ensure sensitive data is properly handled`);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
return {
|
|
2476
|
+
valid: errors.length === 0,
|
|
2477
|
+
errors,
|
|
2478
|
+
warnings
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
};
|
|
2482
|
+
|
|
2483
|
+
// src/plugins/plugin-registry.ts
|
|
2484
|
+
var PluginRegistryImpl = class {
|
|
2485
|
+
plugins = /* @__PURE__ */ new Map();
|
|
2486
|
+
configs = /* @__PURE__ */ new Map();
|
|
2487
|
+
statuses = /* @__PURE__ */ new Map();
|
|
2488
|
+
validator;
|
|
2489
|
+
constructor(validator) {
|
|
2490
|
+
this.validator = validator || new PluginValidator();
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Get plugin by name
|
|
2494
|
+
*/
|
|
2495
|
+
get(name) {
|
|
2496
|
+
return this.plugins.get(name);
|
|
2497
|
+
}
|
|
2498
|
+
/**
|
|
2499
|
+
* Get all registered plugins
|
|
2500
|
+
*/
|
|
2501
|
+
getAll() {
|
|
2502
|
+
return Array.from(this.plugins.values());
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Get active plugins
|
|
2506
|
+
*/
|
|
2507
|
+
getActive() {
|
|
2508
|
+
return this.getAll().filter((plugin) => {
|
|
2509
|
+
const status = this.statuses.get(plugin.name);
|
|
2510
|
+
return status?.active === true;
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
/**
|
|
2514
|
+
* Register a plugin
|
|
2515
|
+
*/
|
|
2516
|
+
async register(plugin) {
|
|
2517
|
+
console.info(`Registering plugin: ${plugin.name} v${plugin.version}`);
|
|
2518
|
+
const validation = this.validator.validate(plugin);
|
|
2519
|
+
if (!validation.valid) {
|
|
2520
|
+
throw new Error(`Plugin validation failed for ${plugin.name}: ${validation.errors.join(", ")}`);
|
|
2521
|
+
}
|
|
2522
|
+
if (this.plugins.has(plugin.name)) {
|
|
2523
|
+
const existingPlugin = this.plugins.get(plugin.name);
|
|
2524
|
+
if (existingPlugin.version !== plugin.version) {
|
|
2525
|
+
console.warn(`Plugin ${plugin.name} is already registered with version ${existingPlugin.version}, replacing with ${plugin.version}`);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
const depValidation = this.validator.validateDependencies(plugin, this);
|
|
2529
|
+
if (!depValidation.valid) {
|
|
2530
|
+
throw new Error(`Plugin dependency validation failed for ${plugin.name}: ${depValidation.errors.join(", ")}`);
|
|
2531
|
+
}
|
|
2532
|
+
this.plugins.set(plugin.name, plugin);
|
|
2533
|
+
this.statuses.set(plugin.name, {
|
|
2534
|
+
name: plugin.name,
|
|
2535
|
+
version: plugin.version,
|
|
2536
|
+
active: false,
|
|
2537
|
+
installed: true,
|
|
2538
|
+
hasErrors: false,
|
|
2539
|
+
errors: []
|
|
2540
|
+
});
|
|
2541
|
+
console.info(`Plugin registered successfully: ${plugin.name}`);
|
|
2542
|
+
}
|
|
2543
|
+
/**
|
|
2544
|
+
* Unregister a plugin
|
|
2545
|
+
*/
|
|
2546
|
+
async unregister(name) {
|
|
2547
|
+
console.info(`Unregistering plugin: ${name}`);
|
|
2548
|
+
if (!this.plugins.has(name)) {
|
|
2549
|
+
throw new Error(`Plugin not found: ${name}`);
|
|
2550
|
+
}
|
|
2551
|
+
const dependents = this.getDependents(name);
|
|
2552
|
+
if (dependents.length > 0) {
|
|
2553
|
+
throw new Error(`Cannot unregister ${name}: plugins ${dependents.join(", ")} depend on it`);
|
|
2554
|
+
}
|
|
2555
|
+
this.plugins.delete(name);
|
|
2556
|
+
this.configs.delete(name);
|
|
2557
|
+
this.statuses.delete(name);
|
|
2558
|
+
console.info(`Plugin unregistered: ${name}`);
|
|
2559
|
+
}
|
|
2560
|
+
/**
|
|
2561
|
+
* Check if plugin is registered
|
|
2562
|
+
*/
|
|
2563
|
+
has(name) {
|
|
2564
|
+
return this.plugins.has(name);
|
|
2565
|
+
}
|
|
2566
|
+
/**
|
|
2567
|
+
* Activate a plugin
|
|
2568
|
+
*/
|
|
2569
|
+
async activate(name) {
|
|
2570
|
+
console.info(`Activating plugin: ${name}`);
|
|
2571
|
+
const plugin = this.plugins.get(name);
|
|
2572
|
+
if (!plugin) {
|
|
2573
|
+
throw new Error(`Plugin not found: ${name}`);
|
|
2574
|
+
}
|
|
2575
|
+
const status = this.statuses.get(name);
|
|
2576
|
+
if (status?.active) {
|
|
2577
|
+
console.warn(`Plugin ${name} is already active`);
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
try {
|
|
2581
|
+
if (plugin.dependencies) {
|
|
2582
|
+
for (const depName of plugin.dependencies) {
|
|
2583
|
+
const depStatus = this.statuses.get(depName);
|
|
2584
|
+
if (!depStatus?.active) {
|
|
2585
|
+
await this.activate(depName);
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
this.updateStatus(name, {
|
|
2590
|
+
active: true,
|
|
2591
|
+
hasErrors: false,
|
|
2592
|
+
errors: []
|
|
2593
|
+
});
|
|
2594
|
+
console.info(`Plugin activated: ${name}`);
|
|
2595
|
+
} catch (error) {
|
|
2596
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2597
|
+
this.updateStatus(name, {
|
|
2598
|
+
active: false,
|
|
2599
|
+
hasErrors: true,
|
|
2600
|
+
errors: [errorMessage],
|
|
2601
|
+
lastError: errorMessage
|
|
2602
|
+
});
|
|
2603
|
+
throw new Error(`Failed to activate plugin ${name}: ${errorMessage}`);
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
/**
|
|
2607
|
+
* Deactivate a plugin
|
|
2608
|
+
*/
|
|
2609
|
+
async deactivate(name) {
|
|
2610
|
+
console.info(`Deactivating plugin: ${name}`);
|
|
2611
|
+
const plugin = this.plugins.get(name);
|
|
2612
|
+
if (!plugin) {
|
|
2613
|
+
throw new Error(`Plugin not found: ${name}`);
|
|
2614
|
+
}
|
|
2615
|
+
const status = this.statuses.get(name);
|
|
2616
|
+
if (!status?.active) {
|
|
2617
|
+
console.warn(`Plugin ${name} is not active`);
|
|
2618
|
+
return;
|
|
2619
|
+
}
|
|
2620
|
+
try {
|
|
2621
|
+
const dependents = this.getDependents(name);
|
|
2622
|
+
for (const depName of dependents) {
|
|
2623
|
+
const depStatus = this.statuses.get(depName);
|
|
2624
|
+
if (depStatus?.active) {
|
|
2625
|
+
await this.deactivate(depName);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
this.updateStatus(name, {
|
|
2629
|
+
active: false,
|
|
2630
|
+
hasErrors: false,
|
|
2631
|
+
errors: []
|
|
2632
|
+
});
|
|
2633
|
+
console.info(`Plugin deactivated: ${name}`);
|
|
2634
|
+
} catch (error) {
|
|
2635
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2636
|
+
this.updateStatus(name, {
|
|
2637
|
+
hasErrors: true,
|
|
2638
|
+
errors: [errorMessage],
|
|
2639
|
+
lastError: errorMessage
|
|
2640
|
+
});
|
|
2641
|
+
throw new Error(`Failed to deactivate plugin ${name}: ${errorMessage}`);
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
/**
|
|
2645
|
+
* Get plugin configuration
|
|
2646
|
+
*/
|
|
2647
|
+
getConfig(name) {
|
|
2648
|
+
return this.configs.get(name);
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2651
|
+
* Set plugin configuration
|
|
2652
|
+
*/
|
|
2653
|
+
setConfig(name, config) {
|
|
2654
|
+
this.configs.set(name, {
|
|
2655
|
+
...config,
|
|
2656
|
+
updatedAt: Date.now()
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
/**
|
|
2660
|
+
* Get plugin status
|
|
2661
|
+
*/
|
|
2662
|
+
getStatus(name) {
|
|
2663
|
+
return this.statuses.get(name);
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* Get all plugin statuses
|
|
2667
|
+
*/
|
|
2668
|
+
getAllStatuses() {
|
|
2669
|
+
return new Map(this.statuses);
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Update plugin status
|
|
2673
|
+
*/
|
|
2674
|
+
updateStatus(name, updates) {
|
|
2675
|
+
const current = this.statuses.get(name);
|
|
2676
|
+
if (current) {
|
|
2677
|
+
this.statuses.set(name, { ...current, ...updates });
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
/**
|
|
2681
|
+
* Get plugins that depend on the specified plugin
|
|
2682
|
+
*/
|
|
2683
|
+
getDependents(name) {
|
|
2684
|
+
const dependents = [];
|
|
2685
|
+
for (const [pluginName, plugin] of this.plugins) {
|
|
2686
|
+
if (plugin.dependencies?.includes(name)) {
|
|
2687
|
+
dependents.push(pluginName);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
return dependents;
|
|
2691
|
+
}
|
|
2692
|
+
/**
|
|
2693
|
+
* Get dependency graph
|
|
2694
|
+
*/
|
|
2695
|
+
getDependencyGraph() {
|
|
2696
|
+
const graph = /* @__PURE__ */ new Map();
|
|
2697
|
+
for (const [name, plugin] of this.plugins) {
|
|
2698
|
+
graph.set(name, plugin.dependencies || []);
|
|
2699
|
+
}
|
|
2700
|
+
return graph;
|
|
2701
|
+
}
|
|
2702
|
+
/**
|
|
2703
|
+
* Resolve plugin load order based on dependencies
|
|
2704
|
+
*/
|
|
2705
|
+
resolveLoadOrder() {
|
|
2706
|
+
const graph = this.getDependencyGraph();
|
|
2707
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2708
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
2709
|
+
const result = [];
|
|
2710
|
+
const visit = (name) => {
|
|
2711
|
+
if (visited.has(name)) return;
|
|
2712
|
+
if (visiting.has(name)) {
|
|
2713
|
+
throw new Error(`Circular dependency detected involving plugin: ${name}`);
|
|
2714
|
+
}
|
|
2715
|
+
visiting.add(name);
|
|
2716
|
+
const dependencies = graph.get(name) || [];
|
|
2717
|
+
for (const dep of dependencies) {
|
|
2718
|
+
if (!graph.has(dep)) {
|
|
2719
|
+
throw new Error(`Plugin ${name} depends on ${dep}, but ${dep} is not registered`);
|
|
2720
|
+
}
|
|
2721
|
+
visit(dep);
|
|
2722
|
+
}
|
|
2723
|
+
visiting.delete(name);
|
|
2724
|
+
visited.add(name);
|
|
2725
|
+
result.push(name);
|
|
2726
|
+
};
|
|
2727
|
+
for (const name of graph.keys()) {
|
|
2728
|
+
visit(name);
|
|
2729
|
+
}
|
|
2730
|
+
return result;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* Export plugin configuration
|
|
2734
|
+
*/
|
|
2735
|
+
exportConfig() {
|
|
2736
|
+
const plugins = [];
|
|
2737
|
+
for (const [name, config] of this.configs) {
|
|
2738
|
+
plugins.push({
|
|
2739
|
+
...config,
|
|
2740
|
+
name
|
|
2741
|
+
});
|
|
2742
|
+
}
|
|
2743
|
+
return { plugins };
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* Import plugin configuration
|
|
2747
|
+
*/
|
|
2748
|
+
importConfig(config) {
|
|
2749
|
+
for (const pluginConfig of config.plugins) {
|
|
2750
|
+
if ("name" in pluginConfig) {
|
|
2751
|
+
const { name, ...rest } = pluginConfig;
|
|
2752
|
+
this.setConfig(name, rest);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
/**
|
|
2757
|
+
* Clear all plugins (useful for testing)
|
|
2758
|
+
*/
|
|
2759
|
+
clear() {
|
|
2760
|
+
this.plugins.clear();
|
|
2761
|
+
this.configs.clear();
|
|
2762
|
+
this.statuses.clear();
|
|
2763
|
+
}
|
|
2764
|
+
/**
|
|
2765
|
+
* Get registry statistics
|
|
2766
|
+
*/
|
|
2767
|
+
getStats() {
|
|
2768
|
+
const statuses = Array.from(this.statuses.values());
|
|
2769
|
+
return {
|
|
2770
|
+
total: statuses.length,
|
|
2771
|
+
active: statuses.filter((s) => s.active).length,
|
|
2772
|
+
inactive: statuses.filter((s) => !s.active).length,
|
|
2773
|
+
withErrors: statuses.filter((s) => s.hasErrors).length
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
var PluginManager = class {
|
|
2778
|
+
registry;
|
|
2779
|
+
hooks;
|
|
2780
|
+
validator;
|
|
2781
|
+
context;
|
|
2782
|
+
scopedHooks = /* @__PURE__ */ new Map();
|
|
2783
|
+
pluginRoutes = /* @__PURE__ */ new Map();
|
|
2784
|
+
constructor() {
|
|
2785
|
+
this.validator = new PluginValidator();
|
|
2786
|
+
this.registry = new PluginRegistryImpl(this.validator);
|
|
2787
|
+
this.hooks = new HookSystemImpl();
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Initialize plugin system
|
|
2791
|
+
*/
|
|
2792
|
+
async initialize(context) {
|
|
2793
|
+
console.info("Initializing plugin system...");
|
|
2794
|
+
this.context = context;
|
|
2795
|
+
await this.hooks.execute(HOOKS.APP_INIT, {
|
|
2796
|
+
pluginManager: this,
|
|
2797
|
+
context
|
|
2798
|
+
});
|
|
2799
|
+
console.info("Plugin system initialized");
|
|
2800
|
+
}
|
|
2801
|
+
/**
|
|
2802
|
+
* Load plugins from configuration
|
|
2803
|
+
*/
|
|
2804
|
+
async loadPlugins(configs) {
|
|
2805
|
+
console.info(`Loading ${configs.length} plugins...`);
|
|
2806
|
+
const enabledConfigs = configs.filter((config) => config.enabled);
|
|
2807
|
+
if (enabledConfigs.length === 0) {
|
|
2808
|
+
console.info("No enabled plugins to load");
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2811
|
+
for (const config of enabledConfigs) {
|
|
2812
|
+
try {
|
|
2813
|
+
console.info(`Loading plugin configuration: ${JSON.stringify(config)}`);
|
|
2814
|
+
if ("name" in config) {
|
|
2815
|
+
this.registry.setConfig(config.name, config);
|
|
2816
|
+
}
|
|
2817
|
+
} catch (error) {
|
|
2818
|
+
console.error(`Failed to load plugin configuration:`, error);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
try {
|
|
2822
|
+
const loadOrder = this.registry.resolveLoadOrder();
|
|
2823
|
+
console.info(`Plugin load order: ${loadOrder.join(" -> ")}`);
|
|
2824
|
+
for (const pluginName of loadOrder) {
|
|
2825
|
+
const config = this.registry.getConfig(pluginName);
|
|
2826
|
+
if (config?.enabled) {
|
|
2827
|
+
await this.registry.activate(pluginName);
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
} catch (error) {
|
|
2831
|
+
console.error("Failed to resolve plugin load order:", error);
|
|
2832
|
+
}
|
|
2833
|
+
console.info("Plugin loading completed");
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2836
|
+
* Install a plugin
|
|
2837
|
+
*/
|
|
2838
|
+
async install(plugin, config) {
|
|
2839
|
+
console.info(`Installing plugin: ${plugin.name}`);
|
|
2840
|
+
if (!this.context) {
|
|
2841
|
+
throw new Error("Plugin manager not initialized");
|
|
2842
|
+
}
|
|
2843
|
+
try {
|
|
2844
|
+
const validation = this.validator.validate(plugin);
|
|
2845
|
+
if (!validation.valid) {
|
|
2846
|
+
throw new Error(`Plugin validation failed: ${validation.errors.join(", ")}`);
|
|
2847
|
+
}
|
|
2848
|
+
await this.registry.register(plugin);
|
|
2849
|
+
const pluginConfig = {
|
|
2850
|
+
enabled: true,
|
|
2851
|
+
installedAt: Date.now(),
|
|
2852
|
+
...config
|
|
2853
|
+
};
|
|
2854
|
+
this.registry.setConfig(plugin.name, pluginConfig);
|
|
2855
|
+
const scopedHooks = this.hooks.createScope ? this.hooks.createScope(plugin.name) : this.hooks;
|
|
2856
|
+
this.scopedHooks.set(plugin.name, scopedHooks);
|
|
2857
|
+
const pluginContext = {
|
|
2858
|
+
...this.context,
|
|
2859
|
+
config: pluginConfig,
|
|
2860
|
+
hooks: scopedHooks,
|
|
2861
|
+
logger: this.createLogger(plugin.name)
|
|
2862
|
+
};
|
|
2863
|
+
await this.registerPluginExtensions(plugin, pluginContext);
|
|
2864
|
+
if (plugin.install) {
|
|
2865
|
+
await plugin.install(pluginContext);
|
|
2866
|
+
}
|
|
2867
|
+
await this.hooks.execute(HOOKS.PLUGIN_INSTALL, {
|
|
2868
|
+
plugin: plugin.name,
|
|
2869
|
+
version: plugin.version,
|
|
2870
|
+
context: pluginContext
|
|
2871
|
+
});
|
|
2872
|
+
console.info(`Plugin installed successfully: ${plugin.name}`);
|
|
2873
|
+
} catch (error) {
|
|
2874
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2875
|
+
console.error(`Failed to install plugin ${plugin.name}:`, errorMessage);
|
|
2876
|
+
const status = this.registry.getStatus(plugin.name);
|
|
2877
|
+
if (status) {
|
|
2878
|
+
this.updatePluginStatus(plugin.name, {
|
|
2879
|
+
hasErrors: true,
|
|
2880
|
+
errors: [...status.errors || [], errorMessage],
|
|
2881
|
+
lastError: errorMessage
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
throw error;
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Uninstall a plugin
|
|
2889
|
+
*/
|
|
2890
|
+
async uninstall(name) {
|
|
2891
|
+
console.info(`Uninstalling plugin: ${name}`);
|
|
2892
|
+
const plugin = this.registry.get(name);
|
|
2893
|
+
if (!plugin) {
|
|
2894
|
+
throw new Error(`Plugin not found: ${name}`);
|
|
2895
|
+
}
|
|
2896
|
+
if (!this.context) {
|
|
2897
|
+
throw new Error("Plugin manager not initialized");
|
|
2898
|
+
}
|
|
2899
|
+
try {
|
|
2900
|
+
const status = this.registry.getStatus(name);
|
|
2901
|
+
if (status?.active) {
|
|
2902
|
+
await this.registry.deactivate(name);
|
|
2903
|
+
}
|
|
2904
|
+
const config = this.registry.getConfig(name) || { enabled: false };
|
|
2905
|
+
const pluginContext = {
|
|
2906
|
+
...this.context,
|
|
2907
|
+
config,
|
|
2908
|
+
hooks: this.scopedHooks.get(name) || this.hooks,
|
|
2909
|
+
logger: this.createLogger(name)
|
|
2910
|
+
};
|
|
2911
|
+
if (plugin.uninstall) {
|
|
2912
|
+
await plugin.uninstall(pluginContext);
|
|
2913
|
+
}
|
|
2914
|
+
await this.unregisterPluginExtensions(plugin);
|
|
2915
|
+
const scopedHooks = this.scopedHooks.get(name);
|
|
2916
|
+
if (scopedHooks && "unregisterAll" in scopedHooks) {
|
|
2917
|
+
scopedHooks.unregisterAll();
|
|
2918
|
+
}
|
|
2919
|
+
this.scopedHooks.delete(name);
|
|
2920
|
+
this.pluginRoutes.delete(name);
|
|
2921
|
+
await this.hooks.execute(HOOKS.PLUGIN_UNINSTALL, {
|
|
2922
|
+
plugin: name,
|
|
2923
|
+
context: pluginContext
|
|
2924
|
+
});
|
|
2925
|
+
await this.registry.unregister(name);
|
|
2926
|
+
console.info(`Plugin uninstalled successfully: ${name}`);
|
|
2927
|
+
} catch (error) {
|
|
2928
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
2929
|
+
console.error(`Failed to uninstall plugin ${name}:`, errorMessage);
|
|
2930
|
+
throw error;
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
/**
|
|
2934
|
+
* Get plugin status
|
|
2935
|
+
*/
|
|
2936
|
+
getStatus(name) {
|
|
2937
|
+
const status = this.registry.getStatus(name);
|
|
2938
|
+
if (!status) {
|
|
2939
|
+
return {
|
|
2940
|
+
name,
|
|
2941
|
+
version: "unknown",
|
|
2942
|
+
active: false,
|
|
2943
|
+
installed: false,
|
|
2944
|
+
hasErrors: false
|
|
2945
|
+
};
|
|
2946
|
+
}
|
|
2947
|
+
return status;
|
|
2948
|
+
}
|
|
2949
|
+
/**
|
|
2950
|
+
* Get all plugin statuses
|
|
2951
|
+
*/
|
|
2952
|
+
getAllStatuses() {
|
|
2953
|
+
return Array.from(this.registry.getAllStatuses().values());
|
|
2954
|
+
}
|
|
2955
|
+
/**
|
|
2956
|
+
* Register plugin extensions (routes, middleware, etc.)
|
|
2957
|
+
*/
|
|
2958
|
+
async registerPluginExtensions(plugin, _context) {
|
|
2959
|
+
if (plugin.routes) {
|
|
2960
|
+
const pluginApp = new Hono();
|
|
2961
|
+
for (const route of plugin.routes) {
|
|
2962
|
+
console.debug(`Registering plugin route: ${route.path}`);
|
|
2963
|
+
pluginApp.route(route.path, route.handler);
|
|
2964
|
+
}
|
|
2965
|
+
this.pluginRoutes.set(plugin.name, pluginApp);
|
|
2966
|
+
}
|
|
2967
|
+
if (plugin.middleware) {
|
|
2968
|
+
for (const middleware of plugin.middleware) {
|
|
2969
|
+
console.debug(`Registering plugin middleware: ${middleware.name}`);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
if (plugin.hooks) {
|
|
2973
|
+
const scopedHooks = this.scopedHooks.get(plugin.name);
|
|
2974
|
+
for (const hook of plugin.hooks) {
|
|
2975
|
+
console.debug(`Registering plugin hook: ${hook.name}`);
|
|
2976
|
+
if (scopedHooks) {
|
|
2977
|
+
scopedHooks.register(hook.name, hook.handler, hook.priority);
|
|
2978
|
+
} else {
|
|
2979
|
+
this.hooks.register(hook.name, hook.handler, hook.priority);
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
if (plugin.services) {
|
|
2984
|
+
for (const service of plugin.services) {
|
|
2985
|
+
console.debug(`Registering plugin service: ${service.name}`);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
if (plugin.models) {
|
|
2989
|
+
for (const model of plugin.models) {
|
|
2990
|
+
console.debug(`Registering plugin model: ${model.name}`);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* Unregister plugin extensions
|
|
2996
|
+
*/
|
|
2997
|
+
async unregisterPluginExtensions(plugin) {
|
|
2998
|
+
console.debug(`Unregistering extensions for plugin: ${plugin.name}`);
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Update plugin status
|
|
3002
|
+
*/
|
|
3003
|
+
updatePluginStatus(name, updates) {
|
|
3004
|
+
const current = this.registry.getStatus(name);
|
|
3005
|
+
if (current && "updateStatus" in this.registry) {
|
|
3006
|
+
console.debug(`Updating status for plugin: ${name}`, updates);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Create a logger for a plugin
|
|
3011
|
+
*/
|
|
3012
|
+
createLogger(pluginName) {
|
|
3013
|
+
return {
|
|
3014
|
+
debug: (message, data) => {
|
|
3015
|
+
console.debug(`[Plugin:${pluginName}] ${message}`, data || "");
|
|
3016
|
+
},
|
|
3017
|
+
info: (message, data) => {
|
|
3018
|
+
console.info(`[Plugin:${pluginName}] ${message}`, data || "");
|
|
3019
|
+
},
|
|
3020
|
+
warn: (message, data) => {
|
|
3021
|
+
console.warn(`[Plugin:${pluginName}] ${message}`, data || "");
|
|
3022
|
+
},
|
|
3023
|
+
error: (message, error, data) => {
|
|
3024
|
+
console.error(`[Plugin:${pluginName}] ${message}`, error || "", data || "");
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Get plugin routes for mounting in main app
|
|
3030
|
+
*/
|
|
3031
|
+
getPluginRoutes() {
|
|
3032
|
+
return new Map(this.pluginRoutes);
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* Get plugin middleware for main app
|
|
3036
|
+
*/
|
|
3037
|
+
getPluginMiddleware() {
|
|
3038
|
+
const middleware = [];
|
|
3039
|
+
for (const plugin of this.registry.getActive()) {
|
|
3040
|
+
if (plugin.middleware) {
|
|
3041
|
+
for (const mw of plugin.middleware) {
|
|
3042
|
+
middleware.push({
|
|
3043
|
+
name: `${plugin.name}:${mw.name}`,
|
|
3044
|
+
handler: mw.handler,
|
|
3045
|
+
priority: mw.priority || 10,
|
|
3046
|
+
global: mw.global || false
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
return middleware.sort((a, b) => a.priority - b.priority);
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* Execute shutdown procedures
|
|
3055
|
+
*/
|
|
3056
|
+
async shutdown() {
|
|
3057
|
+
console.info("Shutting down plugin system...");
|
|
3058
|
+
await this.hooks.execute(HOOKS.APP_SHUTDOWN, {
|
|
3059
|
+
pluginManager: this
|
|
3060
|
+
});
|
|
3061
|
+
const activePlugins = this.registry.getActive();
|
|
3062
|
+
for (const plugin of activePlugins.reverse()) {
|
|
3063
|
+
try {
|
|
3064
|
+
await this.registry.deactivate(plugin.name);
|
|
3065
|
+
} catch (error) {
|
|
3066
|
+
console.error(`Error deactivating plugin ${plugin.name}:`, error);
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
console.info("Plugin system shutdown completed");
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Get plugin system statistics
|
|
3073
|
+
*/
|
|
3074
|
+
getStats() {
|
|
3075
|
+
return {
|
|
3076
|
+
registry: this.registry.getStats(),
|
|
3077
|
+
hooks: this.hooks.getStats(),
|
|
3078
|
+
routes: this.pluginRoutes.size,
|
|
3079
|
+
middleware: this.getPluginMiddleware().length
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
|
|
3084
|
+
export { HookSystemImpl, HookUtils, PluginManager, PluginRegistryImpl, PluginValidator, ScopedHookSystem };
|
|
3085
|
+
//# sourceMappingURL=chunk-NRSL6BQI.js.map
|
|
3086
|
+
//# sourceMappingURL=chunk-NRSL6BQI.js.map
|